116 elif self.name.startswith('_'): |
117 elif self.name.startswith('_'): |
117 self.setProtected() |
118 self.setProtected() |
118 else: |
119 else: |
119 self.setPublic() |
120 self.setPublic() |
120 |
121 |
|
122 |
121 class Class(ClbrBaseClasses.Class, VisibilityMixin): |
123 class Class(ClbrBaseClasses.Class, VisibilityMixin): |
122 """ |
124 """ |
123 Class to represent a Python class. |
125 Class to represent a Python class. |
124 """ |
126 """ |
125 def __init__(self, module, name, super, file, lineno): |
127 def __init__(self, module, name, super, file, lineno): |
133 @param lineno linenumber of the class definition |
135 @param lineno linenumber of the class definition |
134 """ |
136 """ |
135 ClbrBaseClasses.Class.__init__(self, module, name, super, file, lineno) |
137 ClbrBaseClasses.Class.__init__(self, module, name, super, file, lineno) |
136 VisibilityMixin.__init__(self) |
138 VisibilityMixin.__init__(self) |
137 |
139 |
|
140 |
138 class Function(ClbrBaseClasses.Function, VisibilityMixin): |
141 class Function(ClbrBaseClasses.Function, VisibilityMixin): |
139 """ |
142 """ |
140 Class to represent a Python function. |
143 Class to represent a Python function. |
141 """ |
144 """ |
142 def __init__(self, module, name, file, lineno, signature = '', separator = ','): |
145 def __init__(self, module, name, file, lineno, signature='', separator=','): |
143 """ |
146 """ |
144 Constructor |
147 Constructor |
145 |
148 |
146 @param module name of the module containing this function |
149 @param module name of the module containing this function |
147 @param name name of this function |
150 @param name name of this function |
148 @param file filename containing this class |
151 @param file filename containing this class |
149 @param lineno linenumber of the class definition |
152 @param lineno linenumber of the class definition |
150 @param signature parameterlist of the method |
153 @param signature parameterlist of the method |
151 @param separator string separating the parameters |
154 @param separator string separating the parameters |
152 """ |
155 """ |
153 ClbrBaseClasses.Function.__init__(self, module, name, file, lineno, |
156 ClbrBaseClasses.Function.__init__(self, module, name, file, lineno, |
154 signature, separator) |
157 signature, separator) |
155 VisibilityMixin.__init__(self) |
158 VisibilityMixin.__init__(self) |
|
159 |
156 |
160 |
157 class Attribute(ClbrBaseClasses.Attribute, VisibilityMixin): |
161 class Attribute(ClbrBaseClasses.Attribute, VisibilityMixin): |
158 """ |
162 """ |
159 Class to represent a class attribute. |
163 Class to represent a class attribute. |
160 """ |
164 """ |
168 @param lineno linenumber of the class definition |
172 @param lineno linenumber of the class definition |
169 """ |
173 """ |
170 ClbrBaseClasses.Attribute.__init__(self, module, name, file, lineno) |
174 ClbrBaseClasses.Attribute.__init__(self, module, name, file, lineno) |
171 VisibilityMixin.__init__(self) |
175 VisibilityMixin.__init__(self) |
172 |
176 |
|
177 |
173 class Publics(object): |
178 class Publics(object): |
174 """ |
179 """ |
175 Class to represent the list of public identifiers. |
180 Class to represent the list of public identifiers. |
176 """ |
181 """ |
177 def __init__(self, module, file, lineno, idents): |
182 def __init__(self, module, file, lineno, idents): |
185 """ |
190 """ |
186 self.module = module |
191 self.module = module |
187 self.name = '__all__' |
192 self.name = '__all__' |
188 self.file = file |
193 self.file = file |
189 self.lineno = lineno |
194 self.lineno = lineno |
190 self.identifiers = [e.replace('"','').replace("'","").strip() \ |
195 self.identifiers = [e.replace('"', '').replace("'", "").strip() \ |
191 for e in idents.split(',')] |
196 for e in idents.split(',')] |
192 |
197 |
193 def readmodule_ex(module, path=[], inpackage = False, isPyFile = False): |
198 |
|
199 def readmodule_ex(module, path=[], inpackage=False, isPyFile=False): |
194 ''' |
200 ''' |
195 Read a module file and return a dictionary of classes. |
201 Read a module file and return a dictionary of classes. |
196 |
202 |
197 Search for MODULE in PATH and sys.path, read and parse the |
203 Search for MODULE in PATH and sys.path, read and parse the |
198 module and return a dictionary with one entry for each class |
204 module and return a dictionary with one entry for each class |
242 # not Python source, can't do anything with this module |
248 # not Python source, can't do anything with this module |
243 _modules[module] = dict |
249 _modules[module] = dict |
244 return dict |
250 return dict |
245 |
251 |
246 _modules[module] = dict |
252 _modules[module] = dict |
247 classstack = [] # stack of (class, indent) pairs |
253 classstack = [] # stack of (class, indent) pairs |
248 conditionalsstack = [] # stack of indents of conditional defines |
254 conditionalsstack = [] # stack of indents of conditional defines |
249 deltastack = [] |
255 deltastack = [] |
250 deltaindent = 0 |
256 deltaindent = 0 |
251 deltaindentcalculated = 0 |
257 deltaindentcalculated = 0 |
252 try: |
258 try: |
253 src = Utilities.readEncodedFile(file)[0] |
259 src = Utilities.readEncodedFile(file)[0] |
276 # modify indentation level for conditional defines |
282 # modify indentation level for conditional defines |
277 if conditionalsstack: |
283 if conditionalsstack: |
278 if thisindent > conditionalsstack[-1]: |
284 if thisindent > conditionalsstack[-1]: |
279 if not deltaindentcalculated: |
285 if not deltaindentcalculated: |
280 deltastack.append(thisindent - conditionalsstack[-1]) |
286 deltastack.append(thisindent - conditionalsstack[-1]) |
281 deltaindent = reduce(lambda x,y: x+y, deltastack) |
287 deltaindent = reduce(lambda x, y: x + y, deltastack) |
282 deltaindentcalculated = 1 |
288 deltaindentcalculated = 1 |
283 thisindent -= deltaindent |
289 thisindent -= deltaindent |
284 else: |
290 else: |
285 while conditionalsstack and \ |
291 while conditionalsstack and \ |
286 conditionalsstack[-1] >= thisindent: |
292 conditionalsstack[-1] >= thisindent: |
308 dict_counts[meth_name] += 1 |
314 dict_counts[meth_name] += 1 |
309 meth_name = "{0}_{1:d}".format(meth_name, dict_counts[meth_name]) |
315 meth_name = "{0}_{1:d}".format(meth_name, dict_counts[meth_name]) |
310 else: |
316 else: |
311 dict_counts[meth_name] = 0 |
317 dict_counts[meth_name] = 0 |
312 dict[meth_name] = f |
318 dict[meth_name] = f |
313 classstack.append((f, thisindent)) # Marker for nested fns |
319 classstack.append((f, thisindent)) # Marker for nested fns |
314 |
320 |
315 elif m.start("String") >= 0: |
321 elif m.start("String") >= 0: |
316 pass |
322 pass |
317 |
323 |
318 elif m.start("Class") >= 0: |
324 elif m.start("Class") >= 0: |