mirror of https://gitlab.com/ita1024/waf.git
Cleanup unused global statements
This commit is contained in:
parent
5d4cd9e13c
commit
b5408091b3
|
@ -81,7 +81,6 @@ def create_context(cmd_name, *k, **kw):
|
||||||
:return: Context object
|
:return: Context object
|
||||||
:rtype: :py:class:`waflib.Context.Context`
|
:rtype: :py:class:`waflib.Context.Context`
|
||||||
"""
|
"""
|
||||||
global classes
|
|
||||||
for x in classes:
|
for x in classes:
|
||||||
if x.cmd == cmd_name:
|
if x.cmd == cmd_name:
|
||||||
return x(*k, **kw)
|
return x(*k, **kw)
|
||||||
|
@ -110,7 +109,6 @@ class store_context(type):
|
||||||
if not getattr(cls, 'fun', None):
|
if not getattr(cls, 'fun', None):
|
||||||
cls.fun = cls.cmd
|
cls.fun = cls.cmd
|
||||||
|
|
||||||
global classes
|
|
||||||
classes.insert(0, cls)
|
classes.insert(0, cls)
|
||||||
|
|
||||||
ctx = store_context('ctx', (object,), {})
|
ctx = store_context('ctx', (object,), {})
|
||||||
|
@ -150,7 +148,6 @@ class Context(ctx):
|
||||||
try:
|
try:
|
||||||
rd = kw['run_dir']
|
rd = kw['run_dir']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
global run_dir
|
|
||||||
rd = run_dir
|
rd = run_dir
|
||||||
|
|
||||||
# binds the context to the nodes in use to avoid a context singleton
|
# binds the context to the nodes in use to avoid a context singleton
|
||||||
|
@ -201,7 +198,6 @@ class Context(ctx):
|
||||||
Here, it calls the function name in the top-level wscript file. Most subclasses
|
Here, it calls the function name in the top-level wscript file. Most subclasses
|
||||||
redefine this method to provide additional functionality.
|
redefine this method to provide additional functionality.
|
||||||
"""
|
"""
|
||||||
global g_module
|
|
||||||
self.recurse([os.path.dirname(g_module.root_path)])
|
self.recurse([os.path.dirname(g_module.root_path)])
|
||||||
|
|
||||||
def pre_recurse(self, node):
|
def pre_recurse(self, node):
|
||||||
|
@ -624,7 +620,6 @@ class Context(ctx):
|
||||||
:param ban: list of exact file names to exclude
|
:param ban: list of exact file names to exclude
|
||||||
:type ban: list of string
|
:type ban: list of string
|
||||||
"""
|
"""
|
||||||
global waf_dir
|
|
||||||
if os.path.isdir(waf_dir):
|
if os.path.isdir(waf_dir):
|
||||||
lst = self.root.find_node(waf_dir).find_node('waflib/extras').ant_glob(var)
|
lst = self.root.find_node(waf_dir).find_node('waflib/extras').ant_glob(var)
|
||||||
for x in lst:
|
for x in lst:
|
||||||
|
|
|
@ -139,7 +139,6 @@ class log_filter(logging.Filter):
|
||||||
|
|
||||||
:param rec: log entry
|
:param rec: log entry
|
||||||
"""
|
"""
|
||||||
global verbose
|
|
||||||
rec.zone = rec.module
|
rec.zone = rec.module
|
||||||
if rec.levelno >= logging.INFO:
|
if rec.levelno >= logging.INFO:
|
||||||
return True
|
return True
|
||||||
|
@ -253,18 +252,15 @@ def debug(*k, **kw):
|
||||||
"""
|
"""
|
||||||
Wraps logging.debug and discards messages if the verbosity level :py:attr:`waflib.Logs.verbose` ≤ 0
|
Wraps logging.debug and discards messages if the verbosity level :py:attr:`waflib.Logs.verbose` ≤ 0
|
||||||
"""
|
"""
|
||||||
global verbose
|
|
||||||
if verbose:
|
if verbose:
|
||||||
k = list(k)
|
k = list(k)
|
||||||
k[0] = k[0].replace('\n', ' ')
|
k[0] = k[0].replace('\n', ' ')
|
||||||
global log
|
|
||||||
log.debug(*k, **kw)
|
log.debug(*k, **kw)
|
||||||
|
|
||||||
def error(*k, **kw):
|
def error(*k, **kw):
|
||||||
"""
|
"""
|
||||||
Wrap logging.errors, adds the stack trace when the verbosity level :py:attr:`waflib.Logs.verbose` ≥ 2
|
Wrap logging.errors, adds the stack trace when the verbosity level :py:attr:`waflib.Logs.verbose` ≥ 2
|
||||||
"""
|
"""
|
||||||
global log, verbose
|
|
||||||
log.error(*k, **kw)
|
log.error(*k, **kw)
|
||||||
if verbose > 2:
|
if verbose > 2:
|
||||||
st = traceback.extract_stack()
|
st = traceback.extract_stack()
|
||||||
|
@ -282,14 +278,12 @@ def warn(*k, **kw):
|
||||||
"""
|
"""
|
||||||
Wraps logging.warn
|
Wraps logging.warn
|
||||||
"""
|
"""
|
||||||
global log
|
|
||||||
log.warn(*k, **kw)
|
log.warn(*k, **kw)
|
||||||
|
|
||||||
def info(*k, **kw):
|
def info(*k, **kw):
|
||||||
"""
|
"""
|
||||||
Wraps logging.info
|
Wraps logging.info
|
||||||
"""
|
"""
|
||||||
global log
|
|
||||||
log.info(*k, **kw)
|
log.info(*k, **kw)
|
||||||
|
|
||||||
def init_log():
|
def init_log():
|
||||||
|
@ -381,6 +375,5 @@ def pprint(col, msg, label='', sep='\n'):
|
||||||
:param sep: a string to append at the end (line separator)
|
:param sep: a string to append at the end (line separator)
|
||||||
:type sep: string
|
:type sep: string
|
||||||
"""
|
"""
|
||||||
global info
|
|
||||||
info('%s%s%s %s', colors(col), msg, colors.NORMAL, label, extra={'terminator':sep})
|
info('%s%s%s %s', colors(col), msg, colors.NORMAL, label, extra={'terminator':sep})
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,6 @@ class store_task_type(type):
|
||||||
name = cls.__name__
|
name = cls.__name__
|
||||||
|
|
||||||
if name != 'evil' and name != 'Task':
|
if name != 'evil' and name != 'Task':
|
||||||
global classes
|
|
||||||
if getattr(cls, 'run_str', None):
|
if getattr(cls, 'run_str', None):
|
||||||
# if a string is provided, convert it to a method
|
# if a string is provided, convert it to a method
|
||||||
(f, dvars) = compile_fun(cls.run_str, cls.shell)
|
(f, dvars) = compile_fun(cls.run_str, cls.shell)
|
||||||
|
@ -1219,7 +1218,6 @@ def task_factory(name, func=None, vars=None, color='GREEN', ext_in=[], ext_out=[
|
||||||
params['run'] = func
|
params['run'] = func
|
||||||
|
|
||||||
cls = type(Task)(name, (Task,), params)
|
cls = type(Task)(name, (Task,), params)
|
||||||
global classes
|
|
||||||
classes[name] = cls
|
classes[name] = cls
|
||||||
|
|
||||||
if ext_in:
|
if ext_in:
|
||||||
|
|
|
@ -753,7 +753,6 @@ class subst_pc(Task.Task):
|
||||||
lst.append(g(1))
|
lst.append(g(1))
|
||||||
return "%%(%s)s" % g(1)
|
return "%%(%s)s" % g(1)
|
||||||
return ''
|
return ''
|
||||||
global re_m4
|
|
||||||
code = getattr(self.generator, 're_m4', re_m4).sub(repl, code)
|
code = getattr(self.generator, 're_m4', re_m4).sub(repl, code)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -845,7 +845,6 @@ class c_parser(object):
|
||||||
try:
|
try:
|
||||||
cache = node.ctx.preproc_cache_node
|
cache = node.ctx.preproc_cache_node
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
global FILE_CACHE_SIZE
|
|
||||||
cache = node.ctx.preproc_cache_node = Utils.lru_cache(FILE_CACHE_SIZE)
|
cache = node.ctx.preproc_cache_node = Utils.lru_cache(FILE_CACHE_SIZE)
|
||||||
|
|
||||||
key = (node, filename)
|
key = (node, filename)
|
||||||
|
@ -924,7 +923,6 @@ class c_parser(object):
|
||||||
try:
|
try:
|
||||||
cache = node.ctx.preproc_cache_lines
|
cache = node.ctx.preproc_cache_lines
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
global LINE_CACHE_SIZE
|
|
||||||
cache = node.ctx.preproc_cache_lines = Utils.lru_cache(LINE_CACHE_SIZE)
|
cache = node.ctx.preproc_cache_lines = Utils.lru_cache(LINE_CACHE_SIZE)
|
||||||
try:
|
try:
|
||||||
return cache[node]
|
return cache[node]
|
||||||
|
@ -1072,9 +1070,6 @@ def scan(task):
|
||||||
|
|
||||||
This function is bound as a task method on :py:class:`waflib.Tools.c.c` and :py:class:`waflib.Tools.cxx.cxx` for example
|
This function is bound as a task method on :py:class:`waflib.Tools.c.c` and :py:class:`waflib.Tools.cxx.cxx` for example
|
||||||
"""
|
"""
|
||||||
|
|
||||||
global go_absolute
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
incn = task.generator.includes_nodes
|
incn = task.generator.includes_nodes
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
|
|
@ -240,7 +240,6 @@ class jar_create(JTask):
|
||||||
if not t.hasrun:
|
if not t.hasrun:
|
||||||
return Task.ASK_LATER
|
return Task.ASK_LATER
|
||||||
if not self.inputs:
|
if not self.inputs:
|
||||||
global JAR_RE
|
|
||||||
try:
|
try:
|
||||||
self.inputs = [x for x in self.basedir.ant_glob(JAR_RE, remove=False) if id(x) != id(self.outputs[0])]
|
self.inputs = [x for x in self.basedir.ant_glob(JAR_RE, remove=False) if id(x) != id(self.outputs[0])]
|
||||||
except Exception:
|
except Exception:
|
||||||
|
@ -273,7 +272,6 @@ class javac(JTask):
|
||||||
return Task.ASK_LATER
|
return Task.ASK_LATER
|
||||||
|
|
||||||
if not self.inputs:
|
if not self.inputs:
|
||||||
global SOURCE_RE
|
|
||||||
self.inputs = []
|
self.inputs = []
|
||||||
for x in self.srcdir:
|
for x in self.srcdir:
|
||||||
self.inputs.extend(x.ant_glob(SOURCE_RE, remove=False))
|
self.inputs.extend(x.ant_glob(SOURCE_RE, remove=False))
|
||||||
|
|
|
@ -25,7 +25,6 @@ def h_file(self):
|
||||||
if filename in cache and cache[filename][0] == st.st_mtime:
|
if filename in cache and cache[filename][0] == st.st_mtime:
|
||||||
return cache[filename][1]
|
return cache[filename][1]
|
||||||
|
|
||||||
global STRONGEST
|
|
||||||
if STRONGEST:
|
if STRONGEST:
|
||||||
ret = Utils.h_file(filename)
|
ret = Utils.h_file(filename)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -167,7 +167,6 @@ class tex(Task.Task):
|
||||||
return
|
return
|
||||||
seen.append(node)
|
seen.append(node)
|
||||||
code = node.read()
|
code = node.read()
|
||||||
global re_tex
|
|
||||||
for match in re_tex.finditer(code):
|
for match in re_tex.finditer(code):
|
||||||
|
|
||||||
multibib = match.group('type')
|
multibib = match.group('type')
|
||||||
|
|
|
@ -162,7 +162,6 @@ class utest(Task.Task):
|
||||||
def exec_command(self, cmd, **kw):
|
def exec_command(self, cmd, **kw):
|
||||||
Logs.debug('runner: %r', cmd)
|
Logs.debug('runner: %r', cmd)
|
||||||
if getattr(Options.options, 'dump_test_scripts', False):
|
if getattr(Options.options, 'dump_test_scripts', False):
|
||||||
global SCRIPT_TEMPLATE
|
|
||||||
script_code = SCRIPT_TEMPLATE % {
|
script_code = SCRIPT_TEMPLATE % {
|
||||||
'python': sys.executable,
|
'python': sys.executable,
|
||||||
'env': self.get_test_env(),
|
'env': self.get_test_env(),
|
||||||
|
|
Loading…
Reference in New Issue