/usr/share/pyshared/pychecker2/File.py is in pychecker 0.8.19-12.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | from pychecker2.util import parents
from compiler import ast
class File:
def __init__(self, name):
self.name = name
self.parseTree = None
self.scopes = {}
self.root_scope = None
self.warnings = []
def __cmp__(self, other):
return cmp(self.name, other.name)
def warning(self, line, warn, *args):
lineno = getattr(line, 'lineno', line)
if not lineno and hasattr(line, 'parent'):
for p in parents(line):
if p.lineno:
lineno = p.lineno
break
self.warnings.append( (lineno, warn, args) )
def scope_filter(self, type):
return [x for x in self.scopes.iteritems() if isinstance(x[0], type)]
def function_scopes(self):
return self.scope_filter(ast.Function)
def class_scopes(self):
return self.scope_filter(ast.Class)
def not_class_scopes(self):
result = []
for n, s in self.scopes.iteritems():
if not isinstance(n, ast.Class):
result.append( (n, s) )
return result
|