Utilities/ModuleParser.py

branch
maintenance
changeset 6826
c6dda2cbe081
parent 6815
b1b833693a38
equal deleted inserted replaced
6764:d14ddbfbbd36 6826:c6dda2cbe081
57 return -1 57 return -1
58 58
59 59
60 _py_getnext = re.compile( 60 _py_getnext = re.compile(
61 r""" 61 r"""
62 (?P<String> 62 (?P<Comment>
63 \""" (?P<StringContents1> 63 \# .*? $ # ignore everything in comments
64 )
65
66 | (?P<String>
67 \""" (?P<StringContents1>
64 [^"\\]* (?: 68 [^"\\]* (?:
65 (?: \\. | "(?!"") ) 69 (?: \\. | "(?!"") )
66 [^"\\]* 70 [^"\\]*
67 )* 71 )*
68 ) 72 )
69 \""" 73 \"""
70 74
71 | ''' (?P<StringContents2> 75 | ''' (?P<StringContents2>
72 [^'\\]* (?: 76 [^'\\]* (?:
73 (?: \\. | '(?!'') ) 77 (?: \\. | '(?!'') )
74 [^'\\]* 78 [^'\\]*
526 conditionalsstack = [] # stack of indents of conditional defines 530 conditionalsstack = [] # stack of indents of conditional defines
527 deltastack = [] 531 deltastack = []
528 deltaindent = 0 532 deltaindent = 0
529 deltaindentcalculated = 0 533 deltaindentcalculated = 0
530 i = 0 534 i = 0
531 modulelevel = 1 535 modulelevel = True
532 cur_obj = self 536 cur_obj = self
533 modifierType = Function.General 537 modifierType = Function.General
534 modifierIndent = -1 538 modifierIndent = -1
535 while True: 539 while True:
536 m = self._getnext(src, i) 540 m = self._getnext(src, i)
644 contents = m.group("DocstringContents3") 648 contents = m.group("DocstringContents3")
645 if contents is not None: 649 if contents is not None:
646 contents = _hashsub(r"\1", contents) 650 contents = _hashsub(r"\1", contents)
647 else: 651 else:
648 if self.file.lower().endswith('.ptl'): 652 if self.file.lower().endswith('.ptl'):
649 contents = "" 653 contents = ""
650 else: 654 else:
651 contents = 1 and m.group("DocstringContents1") \ 655 contents = m.group("DocstringContents1") \
652 or m.group("DocstringContents2") 656 or m.group("DocstringContents2")
653 if cur_obj: 657 if cur_obj:
654 cur_obj.addDescription(contents) 658 cur_obj.addDescription(contents)
655 659
656 elif m.start("String") >= 0: 660 elif m.start("String") >= 0:
663 contents = _hashsub(r"\1", contents) 667 contents = _hashsub(r"\1", contents)
664 else: 668 else:
665 if self.file.lower().endswith('.ptl'): 669 if self.file.lower().endswith('.ptl'):
666 contents = "" 670 contents = ""
667 else: 671 else:
668 contents = 1 and m.group("StringContents1") \ 672 contents = m.group("StringContents1") \
669 or m.group("StringContents2") 673 or m.group("StringContents2")
670 if cur_obj: 674 if cur_obj:
671 cur_obj.addDescription(contents) 675 cur_obj.addDescription(contents)
672 676
673 elif m.start("Class") >= 0: 677 elif m.start("Class") >= 0:
811 if deltastack: 815 if deltastack:
812 del deltastack[-1] 816 del deltastack[-1]
813 conditionalsstack.append(thisindent) 817 conditionalsstack.append(thisindent)
814 deltaindentcalculated = 0 818 deltaindentcalculated = 0
815 819
820 elif m.start("Comment") >= 0:
821 if modulelevel:
822 continue
823
816 else: 824 else:
817 assert 0, "regexp _getnext found something unexpected" 825 assert 0, "regexp _getnext found something unexpected"
818 826
819 modulelevel = 0 827 modulelevel = False
820 828
821 def __rb_scan(self, src): 829 def __rb_scan(self, src):
822 """ 830 """
823 Private method to scan the source text of a Python module and retrieve 831 Private method to scan the source text of a Python module and retrieve
824 the relevant information. 832 the relevant information.

eric ide

mercurial