src/eric7/Utilities/ClassBrowsers/idlclbr.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
--- a/src/eric7/Utilities/ClassBrowsers/idlclbr.py	Wed Jul 13 11:16:20 2022 +0200
+++ b/src/eric7/Utilities/ClassBrowsers/idlclbr.py	Wed Jul 13 14:55:47 2022 +0200
@@ -21,7 +21,7 @@
 from . import ClbrBaseClasses
 
 SUPPORTED_TYPES = [ClassBrowsers.IDL_SOURCE]
-    
+
 _getnext = re.compile(
     r"""
     (?P<String>
@@ -83,20 +83,22 @@
 |   (?P<End>
         [ \t]* } [ \t]* ;
     )""",
-    re.VERBOSE | re.DOTALL | re.MULTILINE).search
+    re.VERBOSE | re.DOTALL | re.MULTILINE,
+).search
 
 # function to replace comments
 _commentsub = re.compile(r"""//[^\n]*\n|//[^\n]*$""").sub
 # function to normalize whitespace
 _normalize = re.compile(r"""[ \t]{2,}""").sub
 
-_modules = {}                           # cache of modules we've seen
+_modules = {}  # cache of modules we've seen
 
 
 class VisibilityMixin(ClbrBaseClasses.ClbrVisibilityMixinBase):
     """
     Mixin class implementing the notion of visibility.
     """
+
     def __init__(self):
         """
         Constructor
@@ -108,10 +110,11 @@
     """
     Class to represent a CORBA IDL module.
     """
+
     def __init__(self, module, name, file, lineno):
         """
         Constructor
-        
+
         @param module name of the module containing this module
         @type str
         @param name name of this module
@@ -129,10 +132,11 @@
     """
     Class to represent a CORBA IDL interface.
     """
+
     def __init__(self, module, name, superClasses, file, lineno):
         """
         Constructor
-        
+
         @param module name of the module containing this interface
         @type str
         @param name name of this interface
@@ -145,8 +149,7 @@
         @param lineno line number of the interface definition
         @type int
         """
-        ClbrBaseClasses.Class.__init__(self, module, name, superClasses, file,
-                                       lineno)
+        ClbrBaseClasses.Class.__init__(self, module, name, superClasses, file, lineno)
         VisibilityMixin.__init__(self)
 
 
@@ -154,11 +157,11 @@
     """
     Class to represent a CORBA IDL function.
     """
-    def __init__(self, module, name, file, lineno, signature='',
-                 separator=','):
+
+    def __init__(self, module, name, file, lineno, signature="", separator=","):
         """
         Constructor
-        
+
         @param module name of the module containing this function
         @type str
         @param name name of this function
@@ -172,8 +175,9 @@
         @param separator string separating the parameters
         @type str
         """
-        ClbrBaseClasses.Function.__init__(self, module, name, file, lineno,
-                                          signature, separator)
+        ClbrBaseClasses.Function.__init__(
+            self, module, name, file, lineno, signature, separator
+        )
         VisibilityMixin.__init__(self)
 
 
@@ -181,10 +185,11 @@
     """
     Class to represent a CORBA IDL attribute.
     """
+
     def __init__(self, module, name, file, lineno):
         """
         Constructor
-        
+
         @param module name of the module containing this attribute
         @type str
         @param name name of this attribute
@@ -211,7 +216,7 @@
     @rtype dict
     """
     global _modules
-    
+
     if module in _modules:
         # we've seen this file before...
         return _modules[module]
@@ -233,7 +238,7 @@
         # can't do anything with this module
         _modules[module] = {}
         return {}
-    
+
     _modules[module] = scan(src, file, module)
     return _modules[module]
 
@@ -241,7 +246,7 @@
 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
@@ -251,10 +256,11 @@
     @return dictionary containing the extracted data
     @rtype dict
     """
+
     def calculateEndline(lineno, lines):
         """
         Function to calculate the end line.
-        
+
         @param lineno line number to start at (one based)
         @type int
         @param lines list of source lines
@@ -278,11 +284,11 @@
         else:
             # nothing found
             return -1
-    
+
     def calculateMethodEndline(lineno, lines):
         """
         Function to calculate the end line.
-        
+
         @param lineno line number to start at (one based)
         @type int
         @param lines list of source lines
@@ -299,7 +305,7 @@
             return lineno + 1
         else:
             return -1
-    
+
     # convert eol markers the Python style
     src = src.replace("\r\n", "\n").replace("\r", "\n")
     srcLines = src.splitlines()
@@ -309,7 +315,7 @@
 
     classstack = []  # stack of (class, indent) pairs
     indent = 0
-    
+
     lineno, last_lineno_pos = 1, 0
     i = 0
     while True:
@@ -323,10 +329,10 @@
             thisindent = indent
             meth_name = m.group("MethodName")
             meth_sig = m.group("MethodSignature")
-            meth_sig = meth_sig and meth_sig.replace('\\\n', '') or ''
-            meth_sig = _commentsub('', meth_sig)
-            meth_sig = _normalize(' ', meth_sig)
-            lineno += src.count('\n', last_lineno_pos, start)
+            meth_sig = meth_sig and meth_sig.replace("\\\n", "") or ""
+            meth_sig = _commentsub("", meth_sig)
+            meth_sig = _normalize(" ", meth_sig)
+            lineno += src.count("\n", last_lineno_pos, start)
             last_lineno_pos = start
             # close all interfaces/modules indented at least as much
             while classstack and classstack[-1][1] >= thisindent:
@@ -336,20 +342,17 @@
                 cur_class = classstack[-1][0]
                 if isinstance(cur_class, (Interface, Module)):
                     # it's a method
-                    f = Function(None, meth_name,
-                                 file, lineno, meth_sig)
+                    f = Function(None, meth_name, file, lineno, meth_sig)
                     cur_class._addmethod(meth_name, f)
                 # else it's a nested def
                 else:
                     f = None
             else:
                 # it's a function
-                f = Function(module, meth_name,
-                             file, lineno, meth_sig)
+                f = Function(module, meth_name, file, lineno, meth_sig)
                 if meth_name in dict_counts:
                     dict_counts[meth_name] += 1
-                    meth_name = "{0}_{1:d}".format(
-                        meth_name, dict_counts[meth_name])
+                    meth_name = "{0}_{1:d}".format(meth_name, dict_counts[meth_name])
                 else:
                     dict_counts[meth_name] = 0
                 dictionary[meth_name] = f
@@ -368,17 +371,16 @@
             # close all interfaces/modules indented at least as much
             while classstack and classstack[-1][1] >= thisindent:
                 del classstack[-1]
-            lineno += src.count('\n', last_lineno_pos, start)
+            lineno += src.count("\n", last_lineno_pos, start)
             last_lineno_pos = start
             class_name = m.group("InterfaceName")
             inherit = m.group("InterfaceSupers")
             if inherit:
                 # the interface inherits from other interfaces
                 inherit = inherit[1:].strip()
-                inherit = [_commentsub('', inherit)]
+                inherit = [_commentsub("", inherit)]
             # remember this interface
-            cur_class = Interface(module, class_name, inherit,
-                                  file, lineno)
+            cur_class = Interface(module, class_name, inherit, file, lineno)
             endline = calculateEndline(lineno, srcLines)
             cur_class.setEndLine(endline)
             if not classstack:
@@ -395,7 +397,7 @@
             # close all interfaces/modules indented at least as much
             while classstack and classstack[-1][1] >= thisindent:
                 del classstack[-1]
-            lineno += src.count('\n', last_lineno_pos, start)
+            lineno += src.count("\n", last_lineno_pos, start)
             last_lineno_pos = start
             module_name = m.group("ModuleName")
             # remember this module
@@ -407,16 +409,16 @@
             classstack.append((cur_class, thisindent))
 
         elif m.start("Attribute") >= 0:
-            lineno += src.count('\n', last_lineno_pos, start)
+            lineno += src.count("\n", last_lineno_pos, start)
             last_lineno_pos = start
             index = -1
             while index >= -len(classstack):
                 if (
-                    classstack[index][0] is not None and
-                    not isinstance(classstack[index][0], Function) and
-                    classstack[index][1] < indent
+                    classstack[index][0] is not None
+                    and not isinstance(classstack[index][0], Function)
+                    and classstack[index][1] < indent
                 ):
-                    attributes = m.group("AttributeNames").split(',')
+                    attributes = m.group("AttributeNames").split(",")
                     ro = m.group("AttributeReadonly")
                     for attribute in attributes:
                         attr = Attribute(module, attribute, file, lineno)

eric ide

mercurial