764 elif m.start("Import") >= 0: |
767 elif m.start("Import") >= 0: |
765 # import module |
768 # import module |
766 names = [n.strip() for n in |
769 names = [n.strip() for n in |
767 "".join(m.group("ImportList").splitlines()) |
770 "".join(m.group("ImportList").splitlines()) |
768 .replace("\\", "").split(',')] |
771 .replace("\\", "").split(',')] |
769 for name in names: |
772 self.imports.extend( |
770 if name not in self.imports: |
773 [name for name in names |
771 self.imports.append(name) |
774 if name not in self.imports]) |
772 |
775 |
773 elif m.start("ImportFrom") >= 0: |
776 elif m.start("ImportFrom") >= 0: |
774 # from module import stuff |
777 # from module import stuff |
775 mod = m.group("ImportFromPath") |
778 mod = m.group("ImportFromPath") |
|
779 namesLines = (m.group("ImportFromList") |
|
780 .replace("(", "").replace(")", "") |
|
781 .replace("\\", "") |
|
782 .strip().splitlines()) |
|
783 namesLines = [line.split("#")[0].strip() |
|
784 for line in namesLines] |
776 names = [n.strip() for n in |
785 names = [n.strip() for n in |
777 "".join(m.group("ImportFromList").splitlines()) |
786 "".join(namesLines) |
778 .replace("\\", "").split(',')] |
787 .split(',')] |
779 if mod not in self.from_imports: |
788 if mod not in self.from_imports: |
780 self.from_imports[mod] = [] |
789 self.from_imports[mod] = [] |
781 self.from_imports[mod].extend(names) |
790 self.from_imports[mod].extend( |
|
791 [name for name in names |
|
792 if name not in self.from_imports[mod]]) |
782 |
793 |
783 elif m.start("ConditionalDefine") >= 0: |
794 elif m.start("ConditionalDefine") >= 0: |
784 # a conditional function/method definition |
795 # a conditional function/method definition |
785 thisindent = _indent(m.group("ConditionalDefineIndent")) |
796 thisindent = _indent(m.group("ConditionalDefineIndent")) |
786 while conditionalsstack and \ |
797 while conditionalsstack and \ |