summaryrefslogtreecommitdiff
path: root/engine/SCons/Scanner
diff options
context:
space:
mode:
authorLuca Falavigna <dktrkranz@debian.org>2010-06-15 09:21:32 +0000
committerLuca Falavigna <dktrkranz@debian.org>2010-06-15 09:21:32 +0000
commit07fc59e19636a4fc97a18b2038f3fe1c72a94000 (patch)
tree79d4a6239d81b2ccb4752d4f5ca25e0a7d3b4d4b /engine/SCons/Scanner
parent7f642861f3946d4241cbd668de258293ba92767a (diff)
parent340d57481935334465037d97c0db1555b70c0eb1 (diff)
Merge commit 'upstream/2.0.0'
Diffstat (limited to 'engine/SCons/Scanner')
-rw-r--r--engine/SCons/Scanner/C.py6
-rw-r--r--engine/SCons/Scanner/D.py5
-rw-r--r--engine/SCons/Scanner/Dir.py16
-rw-r--r--engine/SCons/Scanner/Fortran.py14
-rw-r--r--engine/SCons/Scanner/IDL.py2
-rw-r--r--engine/SCons/Scanner/LaTeX.py56
-rw-r--r--engine/SCons/Scanner/Prog.py8
-rw-r--r--engine/SCons/Scanner/RC.py2
-rw-r--r--engine/SCons/Scanner/__init__.py36
9 files changed, 58 insertions, 87 deletions
diff --git a/engine/SCons/Scanner/C.py b/engine/SCons/Scanner/C.py
index a8f4be9..598d3b1 100644
--- a/engine/SCons/Scanner/C.py
+++ b/engine/SCons/Scanner/C.py
@@ -27,7 +27,7 @@ This module implements the depenency scanner for C/C++ code.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Scanner/C.py 4720 2010/03/24 03:14:11 jars"
+__revision__ = "src/engine/SCons/Scanner/C.py 5023 2010/06/14 22:05:46 scons"
import SCons.Node.FS
import SCons.Scanner
@@ -44,7 +44,7 @@ class SConsCPPScanner(SCons.cpp.PreProcessor):
missing.
"""
def __init__(self, *args, **kw):
- apply(SCons.cpp.PreProcessor.__init__, (self,)+args, kw)
+ SCons.cpp.PreProcessor.__init__(self, *args, **kw)
self.missing = []
def initialize_result(self, fname):
self.result = SCons.Util.UniqueList([fname])
@@ -81,7 +81,7 @@ def dictify_CPPDEFINES(env):
return {cppdefines : None}
return cppdefines
-class SConsCPPScannerWrapper:
+class SConsCPPScannerWrapper(object):
"""
The SCons wrapper around a cpp.py scanner.
diff --git a/engine/SCons/Scanner/D.py b/engine/SCons/Scanner/D.py
index f657eeb..04bb5a7 100644
--- a/engine/SCons/Scanner/D.py
+++ b/engine/SCons/Scanner/D.py
@@ -30,10 +30,9 @@ Coded by Andy Friesen
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Scanner/D.py 4720 2010/03/24 03:14:11 jars"
+__revision__ = "src/engine/SCons/Scanner/D.py 5023 2010/06/14 22:05:46 scons"
import re
-import string
import SCons.Scanner
@@ -54,7 +53,7 @@ class D(SCons.Scanner.Classic):
def find_include(self, include, source_dir, path):
# translate dots (package separators) to slashes
- inc = string.replace(include, '.', '/')
+ inc = include.replace('.', '/')
i = SCons.Node.FS.find_file(inc + '.d', (source_dir,) + path)
if i is None:
diff --git a/engine/SCons/Scanner/Dir.py b/engine/SCons/Scanner/Dir.py
index bb25324..172aa62 100644
--- a/engine/SCons/Scanner/Dir.py
+++ b/engine/SCons/Scanner/Dir.py
@@ -19,30 +19,29 @@
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-__revision__ = "src/engine/SCons/Scanner/Dir.py 4720 2010/03/24 03:14:11 jars"
+__revision__ = "src/engine/SCons/Scanner/Dir.py 5023 2010/06/14 22:05:46 scons"
import SCons.Node.FS
import SCons.Scanner
def only_dirs(nodes):
is_Dir = lambda n: isinstance(n.disambiguate(), SCons.Node.FS.Dir)
- return filter(is_Dir, nodes)
+ return list(filter(is_Dir, nodes))
def DirScanner(**kw):
"""Return a prototype Scanner instance for scanning
directories for on-disk files"""
kw['node_factory'] = SCons.Node.FS.Entry
kw['recursive'] = only_dirs
- return apply(SCons.Scanner.Base, (scan_on_disk, "DirScanner"), kw)
+ return SCons.Scanner.Base(scan_on_disk, "DirScanner", **kw)
def DirEntryScanner(**kw):
"""Return a prototype Scanner instance for "scanning"
directory Nodes for their in-memory entries"""
kw['node_factory'] = SCons.Node.FS.Entry
kw['recursive'] = None
- return apply(SCons.Scanner.Base, (scan_in_memory, "DirEntryScanner"), kw)
+ return SCons.Scanner.Base(scan_in_memory, "DirEntryScanner", **kw)
skip_entry = {}
@@ -67,7 +66,7 @@ for skip in skip_entry_list:
skip_entry[skip] = 1
skip_entry[SCons.Node.FS._my_normcase(skip)] = 1
-do_not_scan = lambda k: not skip_entry.has_key(k)
+do_not_scan = lambda k: k not in skip_entry
def scan_on_disk(node, env, path=()):
"""
@@ -100,9 +99,8 @@ def scan_in_memory(node, env, path=()):
# mixed Node types (Dirs and Files, for example) has a Dir as
# the first entry.
return []
- entry_list = filter(do_not_scan, entries.keys())
- entry_list.sort()
- return map(lambda n, e=entries: e[n], entry_list)
+ entry_list = sorted(filter(do_not_scan, list(entries.keys())))
+ return [entries[n] for n in entry_list]
# Local Variables:
# tab-width:4
diff --git a/engine/SCons/Scanner/Fortran.py b/engine/SCons/Scanner/Fortran.py
index 1587368..8d023e7 100644
--- a/engine/SCons/Scanner/Fortran.py
+++ b/engine/SCons/Scanner/Fortran.py
@@ -25,12 +25,10 @@ This module implements the dependency scanner for Fortran code.
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-__revision__ = "src/engine/SCons/Scanner/Fortran.py 4720 2010/03/24 03:14:11 jars"
+__revision__ = "src/engine/SCons/Scanner/Fortran.py 5023 2010/06/14 22:05:46 scons"
import re
-import string
import SCons.Node
import SCons.Node.FS
@@ -75,7 +73,7 @@ class F90Scanner(SCons.Scanner.Classic):
kw['skeys'] = suffixes
kw['name'] = name
- apply(SCons.Scanner.Current.__init__, (self,) + args, kw)
+ SCons.Scanner.Current.__init__(self, *args, **kw)
def scan(self, node, env, path=()):
@@ -94,12 +92,12 @@ class F90Scanner(SCons.Scanner.Classic):
d = {}
for m in defmodules:
d[m] = 1
- modules = filter(lambda m, d=d: not d.has_key(m), modules)
+ modules = [m for m in modules if m not in d]
#modules = self.undefinedModules(modules, defmodules)
# Convert module name to a .mod filename
suffix = env.subst('$FORTRANMODSUFFIX')
- modules = map(lambda x, s=suffix: string.lower(x) + s, modules)
+ modules = [x.lower() + suffix for x in modules]
# Remove unique items from the list
mods_and_includes = SCons.Util.unique(includes+modules)
node.includes = mods_and_includes
@@ -123,9 +121,7 @@ class F90Scanner(SCons.Scanner.Classic):
sortkey = self.sort_key(dep)
nodes.append((sortkey, n))
- nodes.sort()
- nodes = map(lambda pair: pair[1], nodes)
- return nodes
+ return [pair[1] for pair in sorted(nodes)]
def FortranScan(path_variable="FORTRANPATH"):
"""Return a prototype Scanner instance for scanning source files
diff --git a/engine/SCons/Scanner/IDL.py b/engine/SCons/Scanner/IDL.py
index f2169f8..507b9e1 100644
--- a/engine/SCons/Scanner/IDL.py
+++ b/engine/SCons/Scanner/IDL.py
@@ -28,7 +28,7 @@ Definition Language) files.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Scanner/IDL.py 4720 2010/03/24 03:14:11 jars"
+__revision__ = "src/engine/SCons/Scanner/IDL.py 5023 2010/06/14 22:05:46 scons"
import SCons.Node.FS
import SCons.Scanner
diff --git a/engine/SCons/Scanner/LaTeX.py b/engine/SCons/Scanner/LaTeX.py
index 01755f4..77be34c 100644
--- a/engine/SCons/Scanner/LaTeX.py
+++ b/engine/SCons/Scanner/LaTeX.py
@@ -27,10 +27,9 @@ This module implements the dependency scanner for LaTeX code.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Scanner/LaTeX.py 4720 2010/03/24 03:14:11 jars"
+__revision__ = "src/engine/SCons/Scanner/LaTeX.py 5023 2010/06/14 22:05:46 scons"
import os.path
-import string
import re
import SCons.Scanner
@@ -41,7 +40,7 @@ TexGraphics = ['.eps', '.ps']
LatexGraphics = ['.pdf', '.png', '.jpg', '.gif', '.tif']
# Used as a return value of modify_env_var if the variable is not set.
-class _Null:
+class _Null(object):
pass
_null = _Null
@@ -58,13 +57,10 @@ def modify_env_var(env, var, abspath):
env.PrependENVPath(var, abspath)
try:
if SCons.Util.is_List(env[var]):
- #TODO(1.5)
- #env.PrependENVPath(var, [os.path.abspath(str(p)) for p in env[var]])
- env.PrependENVPath(var, map(lambda p: os.path.abspath(str(p)), env[var]))
+ env.PrependENVPath(var, [os.path.abspath(str(p)) for p in env[var]])
else:
# Split at os.pathsep to convert into absolute path
- #TODO(1.5) env.PrependENVPath(var, [os.path.abspath(p) for p in str(env[var]).split(os.pathsep)])
- env.PrependENVPath(var, map(lambda p: os.path.abspath(p), string.split(str(env[var]), os.pathsep)))
+ env.PrependENVPath(var, [os.path.abspath(p) for p in str(env[var]).split(os.pathsep)])
except KeyError:
pass
@@ -73,15 +69,13 @@ def modify_env_var(env, var, abspath):
# does not work, refuses to append ":" (os.pathsep).
if SCons.Util.is_List(env['ENV'][var]):
- # TODO(1.5)
- #env['ENV'][var] = os.pathsep.join(env['ENV'][var])
- env['ENV'][var] = string.join(env['ENV'][var], os.pathsep)
+ env['ENV'][var] = os.pathsep.join(env['ENV'][var])
# Append the trailing os.pathsep character here to catch the case with no env[var]
env['ENV'][var] = env['ENV'][var] + os.pathsep
return save
-class FindENVPathDirs:
+class FindENVPathDirs(object):
"""A class to bind a specific *PATH variable name to a function that
will return all of the *path directories."""
def __init__(self, variable):
@@ -165,7 +159,7 @@ class LaTeX(SCons.Scanner.Base):
'bibliographystyle': 'BSTINPUTS',
'usepackage': 'TEXINPUTS',
'lstinputlisting': 'TEXINPUTS'}
- env_variables = SCons.Util.unique(keyword_paths.values())
+ env_variables = SCons.Util.unique(list(keyword_paths.values()))
def __init__(self, name, suffixes, graphics_extensions, *args, **kw):
@@ -184,7 +178,7 @@ class LaTeX(SCons.Scanner.Base):
return []
return self.scan_recurse(node, path)
- class FindMultiPathDirs:
+ class FindMultiPathDirs(object):
"""The stock FindPathDirs function has the wrong granularity:
it is called once per target, while we need the path that depends
on what kind of included files is being searched. This wrapper
@@ -212,7 +206,7 @@ class LaTeX(SCons.Scanner.Base):
# To prevent "dict is not hashable error"
return tuple(di.items())
- class LaTeXScanCheck:
+ class LaTeXScanCheck(object):
"""Skip all but LaTeX source files, i.e., do not scan *.eps,
*.pdf, *.jpg, etc.
"""
@@ -231,7 +225,7 @@ class LaTeX(SCons.Scanner.Base):
kw['scan_check'] = LaTeXScanCheck(suffixes)
kw['name'] = name
- apply(SCons.Scanner.Base.__init__, (self,) + args, kw)
+ SCons.Scanner.Base.__init__(self, *args, **kw)
def _latex_names(self, include):
filename = include[1]
@@ -252,11 +246,12 @@ class LaTeX(SCons.Scanner.Base):
if include[0] == 'includegraphics':
base, ext = os.path.splitext( filename )
if ext == "":
- #TODO(1.5) return [filename + e for e in self.graphics_extensions]
- #return map(lambda e, f=filename: f+e, self.graphics_extensions + TexGraphics)
- # use the line above to find dependency for PDF builder when only .eps figure is present
- # Since it will be found if the user tell scons how to make the pdf figure leave it out for now.
- return map(lambda e, f=filename: f+e, self.graphics_extensions)
+ #return [filename+e for e in self.graphics_extensions + TexGraphics]
+ # use the line above to find dependencies for the PDF builder
+ # when only an .eps figure is present. Since it will be found
+ # if the user tells scons how to make the pdf figure, leave
+ # it out for now.
+ return [filename+e for e in self.graphics_extensions]
return [filename]
def sort_key(self, include):
@@ -303,7 +298,7 @@ class LaTeX(SCons.Scanner.Base):
split_includes = []
for include in includes:
inc_type = noopt_cre.sub('', include[0])
- inc_list = string.split(include[1],',')
+ inc_list = include[1].split(',')
for j in range(len(inc_list)):
split_includes.append( (inc_type, inc_list[j]) )
#
@@ -336,19 +331,11 @@ class LaTeX(SCons.Scanner.Base):
while queue:
include = queue.pop()
- # TODO(1.5): more compact:
- #try:
- # if seen[include[1]] == 1:
- # continue
- #except KeyError:
- # seen[include[1]] = 1
try:
- already_seen = seen[include[1]]
+ if seen[include[1]] == 1:
+ continue
except KeyError:
seen[include[1]] = 1
- already_seen = False
- if already_seen:
- continue
#
# Handle multiple filenames in include[1]
@@ -366,10 +353,7 @@ class LaTeX(SCons.Scanner.Base):
# recurse down
queue.extend( self.scan(n) )
- #
- nodes.sort()
- nodes = map(lambda pair: pair[1], nodes)
- return nodes
+ return [pair[1] for pair in sorted(nodes)]
# Local Variables:
# tab-width:4
diff --git a/engine/SCons/Scanner/Prog.py b/engine/SCons/Scanner/Prog.py
index 395d39f..97f25b3 100644
--- a/engine/SCons/Scanner/Prog.py
+++ b/engine/SCons/Scanner/Prog.py
@@ -21,9 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Scanner/Prog.py 4720 2010/03/24 03:14:11 jars"
-
-import string
+__revision__ = "src/engine/SCons/Scanner/Prog.py 5023 2010/06/14 22:05:46 scons"
import SCons.Node
import SCons.Node.FS
@@ -37,7 +35,7 @@ def ProgramScanner(**kw):
"""Return a prototype Scanner instance for scanning executable
files for static-lib dependencies"""
kw['path_function'] = SCons.Scanner.FindPathDirs('LIBPATH')
- ps = apply(SCons.Scanner.Base, [scan, "ProgramScanner"], kw)
+ ps = SCons.Scanner.Base(scan, "ProgramScanner", **kw)
return ps
def scan(node, env, libpath = ()):
@@ -53,7 +51,7 @@ def scan(node, env, libpath = ()):
# There are no LIBS in this environment, so just return a null list:
return []
if SCons.Util.is_String(libs):
- libs = string.split(libs)
+ libs = libs.split()
else:
libs = SCons.Util.flatten(libs)
diff --git a/engine/SCons/Scanner/RC.py b/engine/SCons/Scanner/RC.py
index 23de58b..de7744b 100644
--- a/engine/SCons/Scanner/RC.py
+++ b/engine/SCons/Scanner/RC.py
@@ -28,7 +28,7 @@ Definition Language) files.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Scanner/RC.py 4720 2010/03/24 03:14:11 jars"
+__revision__ = "src/engine/SCons/Scanner/RC.py 5023 2010/06/14 22:05:46 scons"
import SCons.Node.FS
import SCons.Scanner
diff --git a/engine/SCons/Scanner/__init__.py b/engine/SCons/Scanner/__init__.py
index 987df51..2a6f299 100644
--- a/engine/SCons/Scanner/__init__.py
+++ b/engine/SCons/Scanner/__init__.py
@@ -27,16 +27,15 @@ 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 4720 2010/03/24 03:14:11 jars"
+__revision__ = "src/engine/SCons/Scanner/__init__.py 5023 2010/06/14 22:05:46 scons"
import re
-import string
import SCons.Node.FS
import SCons.Util
-class _Null:
+class _Null(object):
pass
# This is used instead of None as a default argument value so None can be
@@ -56,13 +55,13 @@ def Scanner(function, *args, **kw):
patterned on SCons code.
"""
if SCons.Util.is_Dict(function):
- return apply(Selector, (function,) + args, kw)
+ return Selector(function, *args, **kw)
else:
- return apply(Base, (function,) + args, kw)
+ return Base(function, *args, **kw)
-class FindPathDirs:
+class FindPathDirs(object):
"""A class to bind a specific *PATH variable name to a function that
will return all of the *path directories."""
def __init__(self, variable):
@@ -80,7 +79,7 @@ class FindPathDirs:
-class Base:
+class Base(object):
"""
The base class for dependency scanners. This implements
straightforward, single-pass scanning of a single file.
@@ -171,7 +170,7 @@ class Base:
if skeys is _null:
if SCons.Util.is_Dict(function):
- skeys = function.keys()
+ skeys = list(function.keys())
else:
skeys = []
self.skeys = skeys
@@ -218,7 +217,7 @@ class Base:
nodes = []
for l in list:
if self.node_class and not isinstance(l, self.node_class):
- l = apply(node_factory, (l,), kw)
+ l = node_factory(l, **kw)
nodes.append(l)
return nodes
@@ -280,9 +279,9 @@ class Selector(Base):
for custom modules that may be out there.)
"""
def __init__(self, dict, *args, **kw):
- apply(Base.__init__, (self, None,)+args, kw)
+ Base.__init__(self, None, *args, **kw)
self.dict = dict
- self.skeys = dict.keys()
+ self.skeys = list(dict.keys())
def __call__(self, node, env, path = ()):
return self.select(node)(node, env, path)
@@ -309,7 +308,7 @@ class Current(Base):
def current_check(node, env):
return not node.has_builder() or node.is_up_to_date()
kw['scan_check'] = current_check
- apply(Base.__init__, (self,) + args, kw)
+ Base.__init__(self, *args, **kw)
class Classic(Current):
"""
@@ -339,7 +338,7 @@ class Classic(Current):
kw['skeys'] = suffixes
kw['name'] = name
- apply(Current.__init__, (self,) + args, kw)
+ Current.__init__(self, *args, **kw)
def find_include(self, include, source_dir, path):
n = SCons.Node.FS.find_file(include, (source_dir,) + tuple(path))
@@ -360,7 +359,7 @@ class Classic(Current):
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 = map(SCons.Util.silent_intern, includes)
+ node.includes = list(map(SCons.Util.silent_intern, includes))
# This is a hand-coded DSU (decorate-sort-undecorate, or
# Schwartzian transform) pattern. The sort key is the raw name
@@ -379,12 +378,9 @@ class Classic(Current):
SCons.Warnings.warn(SCons.Warnings.DependencyWarning,
"No dependency generated for file: %s (included from: %s) -- file not found" % (i, node))
else:
- sortkey = self.sort_key(include)
- nodes.append((sortkey, n))
+ nodes.append((self.sort_key(include), n))
- nodes.sort()
- nodes = map(lambda pair: pair[1], nodes)
- return nodes
+ return [pair[1] for pair in sorted(nodes)]
class ClassicCPP(Classic):
"""
@@ -408,7 +404,7 @@ class ClassicCPP(Classic):
return n, i
def sort_key(self, include):
- return SCons.Node.FS._my_normcase(string.join(include))
+ return SCons.Node.FS._my_normcase(' '.join(include))
# Local Variables:
# tab-width:4