diff options
author | Guido van Rossum <guido@python.org> | 1992-12-10 00:00:58 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1992-12-10 00:00:58 (GMT) |
commit | 15f27fb6ea2e0c3e0f7bf361cb9fd2db729bb254 (patch) | |
tree | 95deee1c4b15da544698f5bc52d975eb197448d5 /Tools/scripts/pdeps.py | |
parent | 1d9741742ea6604f26c94a3ff4dd126ac097f797 (diff) | |
download | cpython-15f27fb6ea2e0c3e0f7bf361cb9fd2db729bb254.zip cpython-15f27fb6ea2e0c3e0f7bf361cb9fd2db729bb254.tar.gz cpython-15f27fb6ea2e0c3e0f7bf361cb9fd2db729bb254.tar.bz2 |
Adapt to modern times...
Diffstat (limited to 'Tools/scripts/pdeps.py')
-rwxr-xr-x | Tools/scripts/pdeps.py | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/Tools/scripts/pdeps.py b/Tools/scripts/pdeps.py index df20894..8cf573f 100755 --- a/Tools/scripts/pdeps.py +++ b/Tools/scripts/pdeps.py @@ -1,4 +1,4 @@ -#! /usr/local/python +#! /usr/local/bin/python # pdeps # @@ -21,8 +21,8 @@ import sys -import regexp -import path +import regex +import os import string @@ -58,15 +58,15 @@ def main(): # Compiled regular expressions to search for import statements # -m_import = regexp.compile('^[ \t]*from[ \t]+([^ \t]+)[ \t]+') -m_from = regexp.compile('^[ \t]*import[ \t]+([^#]+)') +m_import = regex.compile('^[ \t]*from[ \t]+\([^ \t]+\)[ \t]+') +m_from = regex.compile('^[ \t]*import[ \t]+\([^#]+\)') # Collect data from one file # def process(filename, table): fp = open(filename, 'r') - mod = path.basename(filename) + mod = os.path.basename(filename) if mod[-3:] == '.py': mod = mod[:-3] table[mod] = list = [] @@ -77,17 +77,17 @@ def process(filename, table): nextline = fp.readline() if not nextline: break line = line[:-1] + nextline - result = m_import.exec(line) - if not result: - result = m_from.exec(line) - if result: - (a, b), (a1, b1) = result - words = string.splitfields(line[a1:b1], ',') - # print '#', line, words - for word in words: - word = string.strip(word) - if word not in list: - list.append(word) + if m_import.match(line) >= 0: + (a, b), (a1, b1) = m_import.regs[:2] + elif m_from.match(line) >= 0: + (a, b), (a1, b1) = m_from.regs[:2] + else: continue + words = string.splitfields(line[a1:b1], ',') + # print '#', line, words + for word in words: + word = string.strip(word) + if word not in list: + list.append(word) # Compute closure (this is in fact totally general) |