summaryrefslogtreecommitdiff
path: root/utils/migrate-0.8.py
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2010-06-29 11:02:42 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2010-06-29 11:02:42 +0200
commitcdaebccd5f7a5a0e23a9be7989b64850fabafed1 (patch)
tree52d3bd94c02ae9be75fb11bfd423043ef10838cc /utils/migrate-0.8.py
parent57624b5df523c0b3a3ebc1741680f283ee1fbbcd (diff)
parent340f6a3d54f5705801267f365fb08b5d20228fe6 (diff)
downloadpython-apt-cdaebccd5f7a5a0e23a9be7989b64850fabafed1.tar.gz
merged from debian-sid
Diffstat (limited to 'utils/migrate-0.8.py')
-rwxr-xr-xutils/migrate-0.8.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/utils/migrate-0.8.py b/utils/migrate-0.8.py
index d0d8e9a1..9f7790f7 100755
--- a/utils/migrate-0.8.py
+++ b/utils/migrate-0.8.py
@@ -123,7 +123,7 @@ deprecated_cpp_stuff = set([
'SelStateHold', 'SelStateInstall', 'SelStatePurge', 'SelStateUnknown',
'SizeToStr', 'StrToTime', 'StringToBool', 'Time', 'TimeRFC1123',
'TimeToStr', 'URItoFileName', 'UpstreamVersion', 'VersionCompare',
- 'newConfiguration'])
+ 'newConfiguration', '.has_key'])
def do_color(string, words):
"""Colorize (red) the given words in the given string."""
@@ -193,11 +193,19 @@ def find_deprecated_py():
def find_occurences(all_old, files):
"""Find all ocurrences in the given Python files."""
for fname in files:
- if fname.endswith('setup3.py') or not fname.endswith('.py'):
+ if not os.path.exists(fname):
+ continue
+ if not (fname in sys.argv or fname.endswith('.py') or
+ re.match('^#.*python.*', open(fname).readline())):
continue
words = defaultdict(lambda: set())
- for i in ast.walk(ast.parse(open(fname).read())):
+ try:
+ node = ast.parse(open(fname, "rU").read(), fname)
+ except Exception, e:
+ print >> sys.stderr, "Ignoring %s: %s" % (fname, e)
+ continue
+ for i in ast.walk(node):
if isinstance(i, _ast.ImportFrom):
for alias in i.names:
if alias.name in all_old: