Utilities/ModuleParser.py

changeset 6815
b1b833693a38
parent 6813
7f4cfe76b90c
equal deleted inserted replaced
6814:7640753ca46e 6815:b1b833693a38
58 58
59 59
60 _py_getnext = re.compile( 60 _py_getnext = re.compile(
61 r""" 61 r"""
62 (?P<Comment> 62 (?P<Comment>
63 \#[^\n]*$ # Ignore triple quotes in comments 63 \# .*? $ # ignore everything in comments
64 ) 64 )
65 65
66 | (?P<String> 66 | (?P<String>
67 \""" (?P<StringContents1> 67 \""" (?P<StringContents1>
68 [^"\\]* (?: 68 [^"\\]* (?:
530 conditionalsstack = [] # stack of indents of conditional defines 530 conditionalsstack = [] # stack of indents of conditional defines
531 deltastack = [] 531 deltastack = []
532 deltaindent = 0 532 deltaindent = 0
533 deltaindentcalculated = 0 533 deltaindentcalculated = 0
534 i = 0 534 i = 0
535 modulelevel = 1 535 modulelevel = True
536 cur_obj = self 536 cur_obj = self
537 modifierType = Function.General 537 modifierType = Function.General
538 modifierIndent = -1 538 modifierIndent = -1
539 while True: 539 while True:
540 m = self._getnext(src, i) 540 m = self._getnext(src, i)
650 contents = _hashsub(r"\1", contents) 650 contents = _hashsub(r"\1", contents)
651 else: 651 else:
652 if self.file.lower().endswith('.ptl'): 652 if self.file.lower().endswith('.ptl'):
653 contents = "" 653 contents = ""
654 else: 654 else:
655 contents = 1 and m.group("DocstringContents1") \ 655 contents = m.group("DocstringContents1") \
656 or m.group("DocstringContents2") 656 or m.group("DocstringContents2")
657 if cur_obj: 657 if cur_obj:
658 cur_obj.addDescription(contents) 658 cur_obj.addDescription(contents)
659 659
660 elif m.start("String") >= 0: 660 elif m.start("String") >= 0:
667 contents = _hashsub(r"\1", contents) 667 contents = _hashsub(r"\1", contents)
668 else: 668 else:
669 if self.file.lower().endswith('.ptl'): 669 if self.file.lower().endswith('.ptl'):
670 contents = "" 670 contents = ""
671 else: 671 else:
672 contents = 1 and m.group("StringContents1") \ 672 contents = m.group("StringContents1") \
673 or m.group("StringContents2") 673 or m.group("StringContents2")
674 if cur_obj: 674 if cur_obj:
675 cur_obj.addDescription(contents) 675 cur_obj.addDescription(contents)
676 676
677 elif m.start("Class") >= 0: 677 elif m.start("Class") >= 0:
816 del deltastack[-1] 816 del deltastack[-1]
817 conditionalsstack.append(thisindent) 817 conditionalsstack.append(thisindent)
818 deltaindentcalculated = 0 818 deltaindentcalculated = 0
819 819
820 elif m.start("Comment") >= 0: 820 elif m.start("Comment") >= 0:
821 pass 821 if modulelevel:
822 continue
822 823
823 else: 824 else:
824 assert 0, "regexp _getnext found something unexpected" 825 assert 0, "regexp _getnext found something unexpected"
825 826
826 modulelevel = 0 827 modulelevel = False
827 828
828 def __rb_scan(self, src): 829 def __rb_scan(self, src):
829 """ 830 """
830 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
831 the relevant information. 832 the relevant information.

eric ide

mercurial