summaryrefslogtreecommitdiff
path: root/engine/SCons/Scanner/LaTeX.py
diff options
context:
space:
mode:
Diffstat (limited to 'engine/SCons/Scanner/LaTeX.py')
-rw-r--r--engine/SCons/Scanner/LaTeX.py56
1 files changed, 20 insertions, 36 deletions
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