
- add Exception.description property support - add a few sanity checks to over.app.Main - added top-level stack frame display to over.app.Main.exception_handler - the command line parser is now usable :)
36 lines
708 B
Cython
36 lines
708 B
Cython
#! /usr/bin/env python3
|
|
# encoding: utf-8
|
|
|
|
from collections import OrderedDict
|
|
|
|
# --------------------------------------------------
|
|
|
|
cdef class ndict(OrderedDict):
|
|
"""
|
|
An OrderedDict subclass whose keys are exposed as attributes.
|
|
|
|
>>> d = ndict()
|
|
>>> d.alpha = 1
|
|
>>> d["alpha"]
|
|
1
|
|
>>> d["beta"] = 42
|
|
>>> d.beta
|
|
42
|
|
>>> d
|
|
{"alpha": 1, "beta": 42}
|
|
"""
|
|
|
|
def __getattr__(self, str name):
|
|
"""
|
|
@while looking up an attribute
|
|
"""
|
|
|
|
if name in self:
|
|
return self[name]
|
|
elif name.replace("_", "-") in self:
|
|
return self[name.replace("_", "-")]
|
|
else:
|
|
raise AttributeError('"ndict" object has no attribute "%s"' %(name))
|
|
|
|
def __setattr__(self, str name, value):
|
|
self[name] = value
|