diff options
| author | Julian Andres Klode <jak@debian.org> | 2009-04-20 19:50:53 +0200 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2009-04-20 19:50:53 +0200 |
| commit | 3c833358446a42f1b0e2f81bf23489f539c4b70f (patch) | |
| tree | e7d136145ad37f2c5ea946059c37d746188a4eeb | |
| parent | bd47802c98f30f67b323b0796ff5d79a5e308c08 (diff) | |
| download | python-apt-3c833358446a42f1b0e2f81bf23489f539c4b70f.tar.gz | |
* utils/migrate-0.8.py: Handle attributes specially, reduces false positives.
We now prefix attributes with ., so we do not match global variable names when
checking. This should reduce the number of false positives in some applications.
| -rwxr-xr-x | utils/migrate-0.8.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/utils/migrate-0.8.py b/utils/migrate-0.8.py index b3f143b0..32fc58a3 100755 --- a/utils/migrate-0.8.py +++ b/utils/migrate-0.8.py @@ -61,6 +61,7 @@ def do_color(string, words): if not color: return string for word in words: + word = re.escape(word) string = re.sub('([^_]*)(%s)([^_]*)' % word, "\\1\033[31m\033[1m" + r"\2" + "\033[0m\\3", string) return string @@ -86,7 +87,10 @@ def find_deprecated_cpp(): if lines: line = lines.pop(0) while lines and not '#endif' in line: - all_old.add(line.split(",")[0].strip().strip('{"')) + name = line.split(",")[0].strip().strip('{"') + if 'module' in fname: + name = '.' + name + all_old.add(name) line = lines.pop(0) return all_old @@ -119,7 +123,7 @@ def find_deprecated_py(): if not isinstance(cls, types.TypeType): new.add(clsname) continue - new.update(dir(cls)) + new.update('.' + name for name in dir(cls)) # Attributes/Methods for mname in sys.modules.keys(): if not mname in empty: @@ -134,7 +138,7 @@ def find_deprecated_py(): if not isinstance(cls, types.TypeType): deprecated.add(clsname) continue - deprecated.update(dir(cls)) + deprecated.update('.' + name for name in dir(cls)) # Attributes/Methods for mname in sys.modules.keys(): @@ -160,7 +164,7 @@ def find_occurences(all_old, files): if isinstance(i, _ast.Name) and i.id in all_old: words[i.lineno].add(i.id) - if isinstance(i, _ast.Attribute) and i.attr in all_old: + if isinstance(i, _ast.Attribute) and ('.' + i.attr in all_old): words[i.lineno].add(i.attr) for lineno in sorted(words): @@ -180,6 +184,7 @@ if color: all_old = find_deprecated_cpp() | find_deprecated_py() + files = set() for path in sys.argv[1:]: if not os.path.exists(path): |
