relations are now "directives", and code is cleaned up.

This commit is contained in:
Todd Gamblin
2015-03-17 20:59:47 -04:00
parent 8e87b2176a
commit 0944ba120c
5 changed files with 82 additions and 82 deletions

View File

@@ -126,9 +126,9 @@ def caller_locals():
del stack
def get_calling_package_name():
def get_calling_module_name():
"""Make sure that the caller is a class definition, and return the
module's name.
enclosing module's name.
"""
stack = inspect.stack()
try:
@@ -322,6 +322,27 @@ def match(string):
return match
def DictWrapper(dictionary):
"""Returns a class that wraps a dictionary and enables it to be used
like an object."""
class wrapper(object):
def __getattr__(self, name):
return dictionary[name]
def __setattr__(self, name, value):
dictionary[name] = value
return value
def setdefault(self, *args):
return dictionary.setdefault(*args)
def get(self, *args):
return dictionary.get(*args)
return wrapper()
class RequiredAttributeError(ValueError):
def __init__(self, message):
super(RequiredAttributeError, self).__init__(message)