summaryrefslogtreecommitdiff
path: root/engine/SCons/Scanner/__init__.py
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2017-10-03 06:25:00 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2017-10-03 06:25:00 +0200
commitd4ed069896a9d49eb33966a0f871e39b5c24da8a (patch)
tree1c923e288e1641b8a08a71891e3ee5ea1e4dfde5 /engine/SCons/Scanner/__init__.py
parent3765e33b76c51c81dd7bbbfacab0c4e76a1713cb (diff)
parent13e92f02338ad8d28d58fcd7c9f46d0d5e970e54 (diff)
Merge branch 'release/3.0.0-1'3.0.0-1
Diffstat (limited to 'engine/SCons/Scanner/__init__.py')
-rw-r--r--engine/SCons/Scanner/__init__.py42
1 files changed, 25 insertions, 17 deletions
diff --git a/engine/SCons/Scanner/__init__.py b/engine/SCons/Scanner/__init__.py
index 81617a4..73e8c09 100644
--- a/engine/SCons/Scanner/__init__.py
+++ b/engine/SCons/Scanner/__init__.py
@@ -5,7 +5,7 @@ The Scanner package for the SCons software construction utility.
"""
#
-# Copyright (c) 2001 - 2016 The SCons Foundation
+# Copyright (c) 2001 - 2017 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -27,7 +27,7 @@ The Scanner package for the SCons software construction utility.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Scanner/__init__.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog"
+__revision__ = "src/engine/SCons/Scanner/__init__.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
import re
@@ -62,8 +62,10 @@ def Scanner(function, *args, **kw):
class FindPathDirs(object):
- """A class to bind a specific *PATH variable name to a function that
- will return all of the *path directories."""
+ """
+ A class to bind a specific E{*}PATH variable name to a function that
+ will return all of the E{*}path directories.
+ """
def __init__(self, variable):
self.variable = variable
def __call__(self, env, dir=None, target=None, source=None, argument=None):
@@ -188,12 +190,12 @@ class Base(object):
def path(self, env, dir=None, target=None, source=None):
if not self.path_function:
return ()
- if not self.argument is _null:
+ if self.argument is not _null:
return self.path_function(env, dir, target, source, self.argument)
else:
return self.path_function(env, dir, target, source)
- def __call__(self, node, env, path = ()):
+ def __call__(self, node, env, path=()):
"""
This method scans a single object. 'node' is the node
that will be passed to the scanner function, and 'env' is the
@@ -206,27 +208,27 @@ class Base(object):
self = self.select(node)
if not self.argument is _null:
- list = self.function(node, env, path, self.argument)
+ node_list = self.function(node, env, path, self.argument)
else:
- list = self.function(node, env, path)
+ node_list = self.function(node, env, path)
kw = {}
if hasattr(node, 'dir'):
kw['directory'] = node.dir
node_factory = env.get_factory(self.node_factory)
nodes = []
- for l in list:
+ for l in node_list:
if self.node_class and not isinstance(l, self.node_class):
l = node_factory(l, **kw)
nodes.append(l)
return nodes
- def __cmp__(self, other):
+ def __eq__(self, other):
try:
- return cmp(self.__dict__, other.__dict__)
+ return self.__dict__ == other.__dict__
except AttributeError:
# other probably doesn't have a __dict__
- return cmp(self.__dict__, other)
+ return self.__dict__ == other
def __hash__(self):
return id(self)
@@ -259,7 +261,7 @@ class Base(object):
def _recurse_no_nodes(self, nodes):
return []
- recurse_nodes = _recurse_no_nodes
+ # recurse_nodes = _recurse_no_nodes
def add_scanner(self, skey, scanner):
self.function[skey] = scanner
@@ -283,7 +285,7 @@ class Selector(Base):
self.dict = dict
self.skeys = list(dict.keys())
- def __call__(self, node, env, path = ()):
+ def __call__(self, node, env, path=()):
return self.select(node)(node, env, path)
def select(self, node):
@@ -326,7 +328,7 @@ class Classic(Current):
self.cre = re.compile(regex, re.M)
- def _scan(node, env, path=(), self=self):
+ def _scan(node, _, path=(), self=self):
node = node.rfile()
if not node.exists():
return []
@@ -334,7 +336,12 @@ class Classic(Current):
kw['function'] = _scan
kw['path_function'] = FindPathDirs(path_variable)
- kw['recursive'] = 1
+
+ # Allow recursive to propagate if child class specifies.
+ # In this case resource scanner needs to specify a filter on which files
+ # get recursively processed. Previously was hardcoded to 1 instead of
+ # defaulted to 1.
+ kw['recursive'] = kw.get('recursive', 1)
kw['skeys'] = suffixes
kw['name'] = name
@@ -356,7 +363,7 @@ class Classic(Current):
if node.includes is not None:
includes = node.includes
else:
- includes = self.find_include_names (node)
+ includes = self.find_include_names(node)
# Intern the names of the include files. Saves some memory
# if the same header is included many times.
node.includes = list(map(SCons.Util.silent_intern, includes))
@@ -393,6 +400,7 @@ class ClassicCPP(Classic):
the contained filename in group 1.
"""
def find_include(self, include, source_dir, path):
+ include = list(map(SCons.Util.to_str, include))
if include[0] == '"':
paths = (source_dir,) + tuple(path)
else: