Utilities/ModuleParser.py

changeset 766
0940de08fa75
parent 444
6f3b2099858e
child 791
9ec2ac20e54e
equal deleted inserted replaced
765:e5cbb3f273eb 766:0940de08fa75
129 129
130 | (?P<Variable> 130 | (?P<Variable>
131 ^ 131 ^
132 (?P<VariableIndent> [ \t]* ) 132 (?P<VariableIndent> [ \t]* )
133 (?P<VariableName> \w+ ) 133 (?P<VariableName> \w+ )
134 [ \t]* = 134 [ \t]* = [ \t]* (?P<VariableSignal> (?:pyqtSignal)? )
135 ) 135 )
136 136
137 | (?P<Import> 137 | (?P<Import>
138 ^ (?: import | from [ \t]+ \. [ \t]+ import ) [ \t]+ 138 ^ (?: import | from [ \t]+ \. [ \t]+ import ) [ \t]+
139 (?P<ImportList> [^#;\n]+ ) 139 (?P<ImportList> [^#;\n]+ )
649 index -= 1 649 index -= 1
650 650
651 elif m.start("Variable") >= 0: 651 elif m.start("Variable") >= 0:
652 thisindent = _indent(m.group("VariableIndent")) 652 thisindent = _indent(m.group("VariableIndent"))
653 variable_name = m.group("VariableName") 653 variable_name = m.group("VariableName")
654 isSignal = m.group("VariableSignal") != ""
654 lineno = lineno + src.count('\n', last_lineno_pos, start) 655 lineno = lineno + src.count('\n', last_lineno_pos, start)
655 last_lineno_pos = start 656 last_lineno_pos = start
656 if thisindent == 0: 657 if thisindent == 0:
657 # global variable 658 # global variable
658 attr = Attribute(self.name, variable_name, self.file, lineno) 659 attr = Attribute(self.name, variable_name, self.file, lineno,
660 isSignal = isSignal)
659 self.__py_setVisibility(attr) 661 self.__py_setVisibility(attr)
660 self.addGlobal(variable_name, attr) 662 self.addGlobal(variable_name, attr)
661 else: 663 else:
662 index = -1 664 index = -1
663 while index >= -len(classstack): 665 while index >= -len(classstack):
664 if classstack[index][1] >= thisindent: 666 if classstack[index][1] >= thisindent:
665 index -= 1 667 index -= 1
666 else: 668 else:
667 if classstack[index][0] is not None and \ 669 if classstack[index][0] is not None and \
668 isinstance(classstack[index][0], Class): 670 isinstance(classstack[index][0], Class):
669 attr = Attribute(self.name, variable_name, self.file, lineno) 671 attr = Attribute(self.name, variable_name, self.file,
672 lineno, isSignal = isSignal)
670 self.__py_setVisibility(attr) 673 self.__py_setVisibility(attr)
671 classstack[index][0].addGlobal(variable_name, attr) 674 classstack[index][0].addGlobal(variable_name, attr)
672 break 675 break
673 676
674 elif m.start("Import") >= 0: 677 elif m.start("Import") >= 0:
1234 1237
1235 class Attribute(VisibilityBase): 1238 class Attribute(VisibilityBase):
1236 ''' 1239 '''
1237 Class to represent a Python function or method. 1240 Class to represent a Python function or method.
1238 ''' 1241 '''
1239 def __init__(self, module, name, file, lineno): 1242 def __init__(self, module, name, file, lineno, isSignal = False):
1240 """ 1243 """
1241 Constructor 1244 Constructor
1242 1245
1243 @param module name of module containing this function (string) 1246 @param module name of module containing this function (string)
1244 @param name name of the function (string) 1247 @param name name of the function (string)
1245 @param file name of file containing this function (string) 1248 @param file name of file containing this function (string)
1246 @param lineno linenumber of the function definition (integer) 1249 @param lineno linenumber of the function definition (integer)
1250 @keyparam isSignal flag indicating a signal definition (boolean)
1247 """ 1251 """
1248 self.module = module 1252 self.module = module
1249 self.name = name 1253 self.name = name
1250 self.file = file 1254 self.file = file
1251 self.lineno = lineno 1255 self.lineno = lineno
1256 self.isSignal = isSignal
1252 self.setPublic() 1257 self.setPublic()
1253 1258
1254 def readModule(module, path = [], inpackage = False, basename = "", 1259 def readModule(module, path = [], inpackage = False, basename = "",
1255 extensions = None, caching = True): 1260 extensions = None, caching = True):
1256 ''' 1261 '''

eric ide

mercurial