/usr/share/lintian/helpers/python/pyflakes is in lintian4python 0.28.1.
This file is owned by root:root, with mode 0o755.
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | #!/usr/bin/python
# encoding=UTF-8
# Copyright © 2011, 2012, 2013, 2014 Jakub Wilk
#
# This program is free software. It is distributed under the terms of the GNU
# General Public License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, you can find it on the World Wide Web at
# http://www.gnu.org/copyleft/gpl.html, or write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
import re
import sys
if sys.version_info > (3,):
if not sys.flags.dont_write_bytecode:
raise RuntimeError('cowardly refusing to import Python 2.X modules')
# Close your eyes here.
sys.path += ['/usr/share/pyshared']
import pyflakes
del sys.path[-1]
# You can open your eyes now.
import pyflakes.scripts.pyflakes as flakes
import pyflakes.messages
class CompileError(Exception):
pass
original_compile = compile
def my_compile(*args, **kwargs):
# pyflakes itself doesn't catch all exceptions that could be raised by compile().
# See bugs #674796 and #674797.
try:
return original_compile(*args, **kwargs)
except Exception as ex:
raise CompileError(ex)
__builtins__.compile = my_compile
blacklist = {
# these are taken care in code-analysis
'duplicate-argument',
'late-future-import',
'return-with-args-inside-generator',
}
def Message_str(self):
tag = 'pyflakes' + re.sub('[A-Z]', lambda m: '-' + m.group(0).lower(), type(self).__name__)
arg_types = []
tp = str
for s in re.split('(%.)', self.message):
if len(s) == 2:
if s[0] == '%' and s[1] != '%':
arg_types += [tp]
if s.endswith(' line '):
tp = lambda x: 'line ' + str(x)
else:
tp = str
del tp
extra_args = [tp(arg) for arg, tp in zip(self.message_args, arg_types)]
if tag.split('-', 1)[1] in blacklist:
return ''
return '{tag} {line}: {args}'.format(
tag=tag,
line=self.lineno,
args=' '.join(extra_args)
)
pyflakes.messages.Message.__str__ = Message_str
if __name__ == '__main__':
sys.stderr = sys.stdout
for filename in sys.argv[1:]:
print('# {0}'.format(filename.replace('\n', '?')))
try:
flakes.checkPath(filename)
except AttributeError as ex:
if ex.args == ("'ClassScope' object has no attribute 'returnValue'",):
# bug #742995
continue
raise
except CompileError:
pass
# Local Variables:
# indent-tabs-mode: nil
# End:
# vim: syntax=python sw=4 sts=4 sr et
|