aboutsummaryrefslogtreecommitdiff
path: root/wqflask/utility
diff options
context:
space:
mode:
authorZachary Sloan2013-10-11 14:46:52 -0500
committerZachary Sloan2013-10-11 14:46:52 -0500
commit34c6c908ac072609a2f923946d474504d3fa0331 (patch)
tree8f7635a312115419bf8ce12602fe9c46e048a92c /wqflask/utility
parent51be798ef6311a86ea1ca8c5092277d727b98a5a (diff)
parent38ae30a5fb46753a361e1c7454871430d7097c3b (diff)
downloadgenenetwork2-34c6c908ac072609a2f923946d474504d3fa0331.tar.gz
Merge /home/sam/gene
Diffstat (limited to 'wqflask/utility')
-rwxr-xr-xwqflask/utility/__init__.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/wqflask/utility/__init__.py b/wqflask/utility/__init__.py
index d0e4a3fa..d9856eed 100755
--- a/wqflask/utility/__init__.py
+++ b/wqflask/utility/__init__.py
@@ -1,5 +1,6 @@
from pprint import pformat as pf
+# Todo: Move these out of __init__
class Bunch(object):
"""Like a dictionary but using object notation"""
@@ -10,3 +11,25 @@ class Bunch(object):
return pf(self.__dict__)
+class Struct(object):
+ '''The recursive class for building and representing objects with.
+
+ From http://stackoverflow.com/a/6573827/1175849
+
+ '''
+
+ def __init__(self, obj):
+ for k, v in obj.iteritems():
+ if isinstance(v, dict):
+ setattr(self, k, Struct(v))
+ else:
+ setattr(self, k, v)
+
+ def __getitem__(self, val):
+ return self.__dict__[val]
+
+ def __repr__(self):
+ return '{%s}' % str(', '.join('%s : %s' % (k, repr(v)) for
+ (k, v) in self.__dict__.iteritems()))
+
+