55A class which defines a composite object which can store
66hieararchical dictionaries with names.
77
8- This class is same as a hiearchical dictionary, but it provides methods
9- to add/access/modify children by name, like a Composite.
8+ This class is same as a hiearchical dictionary, but it
9+ provides methods to add/access/modify children by name,
10+ like a Composite.
1011
11- Created Anand B Pillai <abpillai@gmail.com>
12+ Created Anand B Pillai <abpillai@gmail.com>
1213
1314"""
1415__author__ = "Anand B Pillai"
1718
1819
1920def normalize (val ):
20- """Normalize a string so that it can be used as an attribute to a Python
21-
22- object
23- """
21+ """ Normalize a string so that it can be used as an attribute
22+ to a Python object """
2423
2524 if val .find ('-' ) != - 1 :
2625 val = val .replace ('-' , '_' )
@@ -39,7 +38,8 @@ def denormalize(val):
3938
4039class SpecialDict (dict ):
4140
42- """A dictionary type which allows direct attribute access to its keys """
41+ """ A dictionary type which allows direct attribute
42+ access to its keys """
4343
4444 def __getattr__ (self , name ):
4545
@@ -127,13 +127,11 @@ def isLeaf(self):
127127 return not self ._children
128128
129129 def getName (self ):
130-
131130 """ Return the name of this ConfigInfo object """
132131
133132 return self ._name
134133
135134 def getIndex (self , child ):
136-
137135 """ Return the index of the child ConfigInfo object 'child' """
138136
139137 if child in self ._children :
@@ -147,31 +145,29 @@ def getDict(self):
147145 return self [self ._name ]
148146
149147 def getProperty (self , child , key ):
150-
151- """Return the value for the property for child 'child' with key 'key' """
148+ """ Return the value for the property for child
149+ 'child' with key 'key' """
152150
153151 # First get the child's dictionary
154152 childDict = self .getInfoDict (child )
155153 if childDict :
156154 return childDict .get (key , None )
157155
158- def setProperty (self , child , key , value ):
159-
160- """Set the value for the property 'key' for the child 'child' to 'value' """
156+ def setProperty (self , child , key , value ):
157+ """ Set the value for the property 'key' for
158+ the child 'child' to 'value' """
161159
162160 # First get the child's dictionary
163161 childDict = self .getInfoDict (child )
164162 if childDict :
165163 childDict [key ] = value
166164
167165 def getChildren (self ):
168-
169166 """ Return the list of immediate children of this object """
170167
171168 return self ._children
172169
173170 def getAllChildren (self ):
174-
175171 """ Return the list of all children of this object """
176172
177173 l = []
@@ -182,15 +178,13 @@ def getAllChildren(self):
182178 return l
183179
184180 def getChild (self , name ):
185-
186181 """ Return the immediate child object with the given name """
187182
188183 for child in self ._children :
189184 if child .getName () == name :
190185 return child
191186
192187 def findChild (self , name ):
193-
194188 """ Return the child with the given name from the tree """
195189
196190 # Note - this returns the first child of the given name
@@ -202,7 +196,6 @@ def findChild(self, name):
202196 return child
203197
204198 def findChildren (self , name ):
205-
206199 """ Return a list of children with the given name from the tree """
207200
208201 # Note: this returns a list of all the children of a given
@@ -217,7 +210,6 @@ def findChildren(self, name):
217210 return children
218211
219212 def getPropertyDict (self ):
220-
221213 """ Return the property dictionary """
222214
223215 d = self .getChild ('__properties' )
@@ -227,7 +219,6 @@ def getPropertyDict(self):
227219 return {}
228220
229221 def getParent (self ):
230-
231222 """ Return the person who created me """
232223
233224 return self ._father
0 commit comments