Utilities/ClassBrowsers/pyclbr.py

changeset 6552
ea16b851fdab
parent 6048
82ad8ec9548c
child 6645
ad476851d7e0
equal deleted inserted replaced
6551:f4adb9431204 6552:ea16b851fdab
95 | (?P<Variable> 95 | (?P<Variable>
96 ^ 96 ^
97 (?P<VariableIndent> [ \t]* ) 97 (?P<VariableIndent> [ \t]* )
98 (?P<VariableName> \w+ ) 98 (?P<VariableName> \w+ )
99 [ \t]* = 99 [ \t]* =
100 )
101
102 | (?P<Main>
103 ^
104 if \s+ __name__ \s* == \s* [^:]+ : $
100 ) 105 )
101 106
102 | (?P<ConditionalDefine> 107 | (?P<ConditionalDefine>
103 ^ 108 ^
104 (?P<ConditionalDefineIndent> [ \t]* ) 109 (?P<ConditionalDefineIndent> [ \t]* )
560 classstack[index][0]._addattribute(attr) 565 classstack[index][0]._addattribute(attr)
561 break 566 break
562 else: 567 else:
563 index -= 1 568 index -= 1
564 569
570 elif m.start("Main") >= 0:
571 # 'main' part of the script, reset class stack
572 lineno = lineno + src.count('\n', last_lineno_pos, start)
573 last_lineno_pos = start
574 classstack = []
575
565 elif m.start("Variable") >= 0: 576 elif m.start("Variable") >= 0:
566 thisindent = _indent(m.group("VariableIndent")) 577 thisindent = _indent(m.group("VariableIndent"))
567 variable_name = m.group("VariableName") 578 variable_name = m.group("VariableName")
568 lineno = lineno + src.count('\n', last_lineno_pos, start) 579 lineno = lineno + src.count('\n', last_lineno_pos, start)
569 last_lineno_pos = start 580 last_lineno_pos = start
570 if thisindent == 0: 581 if thisindent == 0 or not classstack:
571 # global variable 582 # global variable, reset class stack first
583 classstack = []
584
572 if "@@Globals@@" not in dictionary: 585 if "@@Globals@@" not in dictionary:
573 dictionary["@@Globals@@"] = ClbrBaseClasses.ClbrBase( 586 dictionary["@@Globals@@"] = ClbrBaseClasses.ClbrBase(
574 module, "Globals", file, lineno) 587 module, "Globals", file, lineno)
575 dictionary["@@Globals@@"]._addglobal( 588 dictionary["@@Globals@@"]._addglobal(
576 Attribute(module, variable_name, file, lineno)) 589 Attribute(module, variable_name, file, lineno))

eric ide

mercurial