eric6/Utilities/ClassBrowsers/protoclbr.py

changeset 7690
a59680062837
parent 7685
0b6e8c0d6403
child 7695
032a0586a349
--- a/eric6/Utilities/ClassBrowsers/protoclbr.py	Fri Sep 04 18:48:52 2020 +0200
+++ b/eric6/Utilities/ClassBrowsers/protoclbr.py	Fri Sep 04 18:50:43 2020 +0200
@@ -190,7 +190,6 @@
         VisibilityMixin.__init__(self)
 
 
-# TODO: extract scan function (see pyclbr)
 def readmodule_ex(module, path=None):
     """
     Read a ProtoBuf protocol file and return a dictionary of messages, enums,
@@ -205,8 +204,6 @@
     """
     global _modules
     
-    dictionary = {}
-
     if module in _modules:
         # we've seen this file before...
         return _modules[module]
@@ -219,21 +216,41 @@
         f.close()
     if type not in SUPPORTED_TYPES:
         # not ProtoBuf protocol source, can't do anything with this module
-        _modules[module] = dictionary
-        return dictionary
+        _modules[module] = {}
+        return {}
 
-    _modules[module] = dictionary
-    classstack = []  # stack of (class, indent) pairs
-    indent = 0
     try:
         src = Utilities.readEncodedFile(file)[0]
     except (UnicodeError, IOError):
         # can't do anything with this module
-        _modules[module] = dictionary
-        return dictionary
+        _modules[module] = {}
+        return {}
+    
+    _modules[module] = scan(src, file, module)
+    return _modules[module]
+
+
+def scan(src, file, module):
+    """
+    Public method to scan the given source text.
+    
+    @param src source text to be scanned
+    @type str
+    @param file file name associated with the source text
+    @type str
+    @param module module name associated with the source text
+    @type str
+    @return dictionary containing the extracted data
+    @rtype dict
+    """
     # convert eol markers the Python style
     src = src.replace("\r\n", "\n").replace("\r", "\n")
 
+    dictionary = {}
+
+    classstack = []  # stack of (class, indent) pairs
+    indent = 0
+
     lineno, last_lineno_pos = 1, 0
     lastGlobalEntry = None
     cur_obj = None

eric ide

mercurial