Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
message = 'bad invocation of demandload; should be demandload(globals(), *targets)'
def __init__(self, filename, lineno, target=None):
_messages.Message.__init__(self, filename, lineno)
if target is not None:
self.message = self.message + ': exception %r will occur'
self.message_args = (target,)
class BadDemandloadRegexCall(BadDemandloadCall):
message = 'bad invocation of demand_compile_regexp; should be demand_compile_regexp(globals(), name, *args)'
class UnBindingDemandload(_messages.Message):
message = 'demandloaded target %s was deleted; pointless demandload then'
def __init__(self, filename, lineno, target):
_messages.Message.__init__(self, filename, lineno)
self.message_args = (target,)
class DemandloadImportation(_checker.Importation):
pass
class DemandloadChecker(_Checker):
def addBinding(self, lineno, value, reportRedef=True):
class RedefinedWhileUnused(Message):
message = 'redefinition of unused %r from line %r'
def __init__(self, filename, loc, name, orig_loc):
Message.__init__(self, filename, loc)
self.message_args = (name, orig_loc.lineno)
class ImportShadowedByLoopVar(Message):
message = 'import %r from line %r shadowed by loop variable'
def __init__(self, filename, loc, name, orig_loc):
Message.__init__(self, filename, loc)
self.message_args = (name, orig_loc.lineno)
class ImportStarUsed(Message):
message = "'from %s import *' used; unable to detect undefined names"
def __init__(self, filename, loc, modname):
Message.__init__(self, filename, loc)
self.message_args = (modname,)
class UndefinedName(Message):
message = 'undefined name %r'
def __init__(self, filename, loc, name):
Message.__init__(self, filename, loc)
self.message_args = (name,)
class UndefinedExport(Message):
message = 'undefined name %r in __all__'
def __init__(self, filename, lineno, target):
_messages.Message.__init__(self, filename, lineno)
self.message_args = (target,)
message = 'undefined name %r'
def __init__(self, filename, loc, name):
Message.__init__(self, filename, loc)
self.message_args = (name,)
class UndefinedExport(Message):
message = 'undefined name %r in __all__'
def __init__(self, filename, loc, name):
Message.__init__(self, filename, loc)
self.message_args = (name,)
class UndefinedLocal(Message):
message = "local variable %r (defined in enclosing scope on line %r) referenced before assignment"
def __init__(self, filename, loc, name, orig_loc):
Message.__init__(self, filename, loc)
self.message_args = (name, orig_loc.lineno)
class DuplicateArgument(Message):
message = 'duplicate argument %r in function definition'
def __init__(self, filename, loc, name):
Message.__init__(self, filename, loc)
self.message_args = (name,)
class RedefinedFunction(Message):
message = 'redefinition of function %r from line %r'
def __init__(self, filename, loc, name, orig_loc):
import sublime, sublime_plugin
import os, sys, compiler, re
import traceback
from pyflakes import checker, messages
drawType = 4 | 32
class OffsetError(messages.Message):
message = '%r at offset %r'
def __init__(self, filename, lineno, text, offset):
messages.Message.__init__(self, filename, lineno)
self.offset = offset
self.message_args = (text, offset)
class PythonError(messages.Message):
message = '%r'
def __init__(self, filename, lineno, text):
messages.Message.__init__(self, filename, lineno)
self.message_args = (text,)
def check(codeString, filename):
codeString = codeString.rstrip()
try:
try:
compile(codeString, filename, "exec")
except MemoryError:
# Python 2.4 will raise MemoryError if the source can't be
# decoded.
if sys.version_info[:2] == (2, 4):
raise SyntaxError(None)
raise
message = messageClass(self.filename, *args, **kwargs)
if self.filename not in IGNORE_FILES:
self.my_error_dict.setdefault(str(messageClass), []).append(message.to_list())
def reset_lists():
GLOBAL_CHECKER.my_error_dict = {}
GLOBAL_REPORTER.indent_error = []
modReporter.Reporter.syntaxError = my_exception
GLOBAL_REPORTER = modReporter._makeDefaultReporter()
GLOBAL_CHECKER = Checker
GLOBAL_CHECKER.report = my_report
GLOBAL_CHECKER.my_error_dict = {}
pym.Message.to_list = my_to_list
USED_FOLDER_EMAN2 = ('libpyEM/qtgui', )
EMAN2_GUI_DICT = {}
def get_file_dict():
file_dict = {}
for folder_name in USED_FOLDER:
#files_dir = os.path.join(CURRENT_DIR, NO_USED, folder_name, '*.py')
#file_dict.setdefault('no_used', {})[folder_name] = sorted(glob.glob(files_dir))
files_dir = os.path.join(CURRENT_DIR, NO_UNUSED, folder_name, '*.py')
file_dict.setdefault('no_unused', {})[folder_name] = sorted(glob.glob(files_dir))
for folder_name in USED_FOLDER_EMAN2:
files_dir = os.path.join(CURRENT_DIR, '../..', folder_name, '*.py')
for file_path in glob.glob(files_dir):
mod_name = os.path.splitext(os.path.basename(file_path))[0]
EMAN2_GUI_DICT[mod_name] = 'eman2_gui.{0}'.format(mod_name)
if encoding:
codeString = codeString.encode(encoding)
tree = compile(codeString, filename, "exec", _ast.PyCF_ONLY_AST)
except SyntaxError as value:
msg = value.args[0]
# If there's an encoding problem with the file, the text is None.
if value.text is None:
# Avoid using msg, since for the only known case, it contains a
# bogus message that claims the encoding the file declared was
# unknown.
msg = i18n("Problem decoding source")
value.lineno = 1
if not is_old_pyflake_version():
error = Message(filename, value)
else:
error = Message(filename, value.lineno)
error.message = msg + "%s"
error.message_args = ""
return [error]
else:
# Okay, it's syntactically valid. Now check it.
w = Checker(tree, filename)
return w.messages
def __init__(self, filename, lineno, text):
messages.Message.__init__(self, filename, lineno)
self.message_args = (text,)
class UnusedImport(Message):
message = '%r imported but unused'
def __init__(self, filename, loc, name):
Message.__init__(self, filename, loc, use_column=False)
self.message_args = (name,)
class RedefinedWhileUnused(Message):
message = 'redefinition of unused %r from line %r'
def __init__(self, filename, loc, name, orig_loc):
Message.__init__(self, filename, loc)
self.message_args = (name, orig_loc.lineno)
class ImportShadowedByLoopVar(Message):
message = 'import %r from line %r shadowed by loop variable'
def __init__(self, filename, loc, name, orig_loc):
Message.__init__(self, filename, loc)
self.message_args = (name, orig_loc.lineno)
class ImportStarUsed(Message):
message = "'from %s import *' used; unable to detect undefined names"
def __init__(self, filename, loc, modname):
Message.__init__(self, filename, loc)
self.message_args = (modname,)
class UndefinedName(Message):
message = 'undefined name %r'
def __init__(self, filename, loc, name):
if encoding_match:
encoding = encoding_match.groupdict().get('encoding', None)
if encoding:
codeString = codeString.encode(encoding)
tree = compile(codeString, filename, "exec", _ast.PyCF_ONLY_AST)
except SyntaxError as value:
msg = value.args[0]
# If there's an encoding problem with the file, the text is None.
if value.text is None:
# Avoid using msg, since for the only known case, it contains a
# bogus message that claims the encoding the file declared was
# unknown.
msg = i18n("Problem decoding source")
value.lineno = 1
if not is_old_pyflake_version():
error = Message(filename, value)
else:
error = Message(filename, value.lineno)
error.message = msg + "%s"
error.message_args = ""
return [error]
else:
# Okay, it's syntactically valid. Now check it.
w = Checker(tree, filename)
return w.messages