Utilities/ClassBrowsers/pyclbr.py

changeset 5604
b047181a4a33
parent 5389
9b1c800daff3
child 5651
982465f8389c
--- a/Utilities/ClassBrowsers/pyclbr.py	Sat Mar 11 14:35:22 2017 +0100
+++ b/Utilities/ClassBrowsers/pyclbr.py	Sat Mar 11 18:08:42 2017 +0100
@@ -157,17 +157,18 @@
     """
     Class to represent a Python class.
     """
-    def __init__(self, module, name, super, file, lineno):
+    def __init__(self, module, name, superClasses, file, lineno):
         """
         Constructor
         
         @param module name of the module containing this class
         @param name name of this class
-        @param super list of class names this class is inherited from
+        @param superClasses list of class names this class is inherited from
         @param file filename containing this class
         @param lineno linenumber of the class definition
         """
-        ClbrBaseClasses.Class.__init__(self, module, name, super, file, lineno)
+        ClbrBaseClasses.Class.__init__(self, module, name, superClasses, file,
+                                       lineno)
         VisibilityMixin.__init__(self)
 
 
@@ -340,7 +341,7 @@
     """
     global _modules
     
-    dict = {}
+    dictionary = {}
     dict_counts = {}
 
     if module in _modules:
@@ -348,8 +349,8 @@
         return _modules[module]
     if module in sys.builtin_module_names:
         # this is a built-in module
-        _modules[module] = dict
-        return dict
+        _modules[module] = dictionary
+        return dictionary
 
     # search the path for the module
     f = None
@@ -364,10 +365,10 @@
         f, file, (suff, mode, type) = \
             ClassBrowsers.find_module(module, fullpath, isPyFile)
     if module.endswith(".py") and type == imp.PKG_DIRECTORY:
-        return dict
+        return dictionary
     if type == imp.PKG_DIRECTORY:
-        dict['__path__'] = [file]
-        _modules[module] = dict
+        dictionary['__path__'] = [file]
+        _modules[module] = dictionary
         path = [file] + path
         f, file, (suff, mode, type) = \
             ClassBrowsers.find_module('__init__', [file])
@@ -375,10 +376,10 @@
         f.close()
     if type not in SUPPORTED_TYPES:
         # not Python source, can't do anything with this module
-        _modules[module] = dict
-        return dict
+        _modules[module] = dictionary
+        return dictionary
 
-    _modules[module] = dict
+    _modules[module] = dictionary
     classstack = []  # stack of (class, indent) pairs
     conditionalsstack = []  # stack of indents of conditional defines
     deltastack = []
@@ -388,8 +389,8 @@
         src = Utilities.readEncodedFile(file)[0]
     except (UnicodeError, IOError):
         # can't do anything with this module
-        _modules[module] = dict
-        return dict
+        _modules[module] = dictionary
+        return dictionary
 
     lineno, last_lineno_pos = 1, 0
     lastGlobalEntry = None
@@ -470,7 +471,7 @@
                         meth_name, dict_counts[meth_name])
                 else:
                     dict_counts[meth_name] = 0
-                dict[meth_name] = f
+                dictionary[meth_name] = f
             if not classstack:
                 if lastGlobalEntry:
                     lastGlobalEntry.setEndLine(lineno - 1)
@@ -508,9 +509,9 @@
                 names = []
                 for n in inherit.split(','):
                     n = n.strip()
-                    if n in dict:
+                    if n in dictionary:
                         # we know this super class
-                        n = dict[n]
+                        n = dictionary[n]
                     else:
                         c = n.split('.')
                         if len(c) > 1:
@@ -537,7 +538,7 @@
                         class_name, dict_counts[class_name])
                 else:
                     dict_counts[class_name] = 0
-                dict[class_name] = cur_class
+                dictionary[class_name] = cur_class
             else:
                 classstack[-1][0]._addclass(class_name, cur_class)
             if not classstack:
@@ -567,10 +568,10 @@
             last_lineno_pos = start
             if thisindent == 0:
                 # global variable
-                if "@@Globals@@" not in dict:
-                    dict["@@Globals@@"] = ClbrBaseClasses.ClbrBase(
+                if "@@Globals@@" not in dictionary:
+                    dictionary["@@Globals@@"] = ClbrBaseClasses.ClbrBase(
                         module, "Globals", file, lineno)
-                dict["@@Globals@@"]._addglobal(
+                dictionary["@@Globals@@"]._addglobal(
                     Attribute(module, variable_name, file, lineno))
                 if lastGlobalEntry:
                     lastGlobalEntry.setEndLine(lineno - 1)
@@ -591,7 +592,7 @@
             lineno = lineno + src.count('\n', last_lineno_pos, start)
             last_lineno_pos = start
             pubs = Publics(module, file, lineno, idents)
-            dict['__all__'] = pubs
+            dictionary['__all__'] = pubs
         
         elif m.start("Import") >= 0:
             # import module
@@ -600,10 +601,10 @@
                      .replace("\\", "").split(',')]
             lineno = lineno + src.count('\n', last_lineno_pos, start)
             last_lineno_pos = start
-            if "@@Import@@" not in dict:
-                dict["@@Import@@"] = Imports(module, file)
+            if "@@Import@@" not in dictionary:
+                dictionary["@@Import@@"] = Imports(module, file)
             for name in names:
-                dict["@@Import@@"].addImport(name, [], lineno)
+                dictionary["@@Import@@"].addImport(name, [], lineno)
         
         elif m.start("ImportFrom") >= 0:
             # from module import stuff
@@ -619,9 +620,9 @@
                      .split(',')]
             lineno = lineno + src.count('\n', last_lineno_pos, start)
             last_lineno_pos = start
-            if "@@Import@@" not in dict:
-                dict["@@Import@@"] = Imports(module, file)
-            dict["@@Import@@"].addImport(mod, names, lineno)
+            if "@@Import@@" not in dictionary:
+                dictionary["@@Import@@"] = Imports(module, file)
+            dictionary["@@Import@@"].addImport(mod, names, lineno)
         
         elif m.start("ConditionalDefine") >= 0:
             # a conditional function/method definition
@@ -639,26 +640,26 @@
             coding = m.group("Coding")
             lineno = lineno + src.count('\n', last_lineno_pos, start)
             last_lineno_pos = start
-            if "@@Coding@@" not in dict:
-                dict["@@Coding@@"] = ClbrBaseClasses.Coding(
+            if "@@Coding@@" not in dictionary:
+                dictionary["@@Coding@@"] = ClbrBaseClasses.Coding(
                     module, file, lineno, coding)
         
         else:
             assert 0, "regexp _getnext found something unexpected"
 
-    if '__all__' in dict:
+    if '__all__' in dictionary:
         # set visibility of all top level elements
-        pubs = dict['__all__']
-        for key in list(list(dict.keys())):
+        pubs = dictionary['__all__']
+        for key in dictionary.keys():
             if key == '__all__' or key.startswith("@@"):
                 continue
             if key in pubs.identifiers:
-                dict[key].setPublic()
+                dictionary[key].setPublic()
             else:
-                dict[key].setPrivate()
-        del dict['__all__']
+                dictionary[key].setPrivate()
+        del dictionary['__all__']
     
-    return dict
+    return dictionary
 
 
 def _indent(ws):

eric ide

mercurial