OLD | NEW |
1 """SCons.Scanner.LaTeX | 1 """SCons.Scanner.LaTeX |
2 | 2 |
3 This module implements the dependency scanner for LaTeX code. | 3 This module implements the dependency scanner for LaTeX code. |
4 | 4 |
5 """ | 5 """ |
6 | 6 |
7 # | 7 # |
8 # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 The SCons Foundat
ion | 8 # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The SCons F
oundation |
9 # | 9 # |
10 # Permission is hereby granted, free of charge, to any person obtaining | 10 # Permission is hereby granted, free of charge, to any person obtaining |
11 # a copy of this software and associated documentation files (the | 11 # a copy of this software and associated documentation files (the |
12 # "Software"), to deal in the Software without restriction, including | 12 # "Software"), to deal in the Software without restriction, including |
13 # without limitation the rights to use, copy, modify, merge, publish, | 13 # without limitation the rights to use, copy, modify, merge, publish, |
14 # distribute, sublicense, and/or sell copies of the Software, and to | 14 # distribute, sublicense, and/or sell copies of the Software, and to |
15 # permit persons to whom the Software is furnished to do so, subject to | 15 # permit persons to whom the Software is furnished to do so, subject to |
16 # the following conditions: | 16 # the following conditions: |
17 # | 17 # |
18 # The above copyright notice and this permission notice shall be included | 18 # The above copyright notice and this permission notice shall be included |
19 # in all copies or substantial portions of the Software. | 19 # in all copies or substantial portions of the Software. |
20 # | 20 # |
21 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY | 21 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY |
22 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE | 22 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE |
23 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | 23 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
24 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | 24 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
25 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | 25 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
26 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | 26 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
27 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | 27 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
28 # | 28 # |
29 | 29 |
30 __revision__ = "src/engine/SCons/Scanner/LaTeX.py 3842 2008/12/20 22:59:52 scons
" | 30 __revision__ = "src/engine/SCons/Scanner/LaTeX.py 3897 2009/01/13 06:45:54 scons
" |
31 | 31 |
32 import os.path | 32 import os.path |
33 import string | 33 import string |
34 import re | 34 import re |
35 | 35 |
36 import SCons.Scanner | 36 import SCons.Scanner |
37 import SCons.Util | 37 import SCons.Util |
38 | 38 |
39 # list of graphics file extensions for TeX and LaTeX | 39 # list of graphics file extensions for TeX and LaTeX |
40 TexGraphics = ['.eps', '.ps'] | 40 TexGraphics = ['.eps', '.ps'] |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 if ext == "": | 244 if ext == "": |
245 return [filename + '.bib'] | 245 return [filename + '.bib'] |
246 if include[0] == 'usepackage': | 246 if include[0] == 'usepackage': |
247 base, ext = os.path.splitext( filename ) | 247 base, ext = os.path.splitext( filename ) |
248 if ext == "": | 248 if ext == "": |
249 return [filename + '.sty'] | 249 return [filename + '.sty'] |
250 if include[0] == 'includegraphics': | 250 if include[0] == 'includegraphics': |
251 base, ext = os.path.splitext( filename ) | 251 base, ext = os.path.splitext( filename ) |
252 if ext == "": | 252 if ext == "": |
253 #TODO(1.5) return [filename + e for e in self.graphics_extension
s] | 253 #TODO(1.5) return [filename + e for e in self.graphics_extension
s] |
| 254 #return map(lambda e, f=filename: f+e, self.graphics_extensions
+ TexGraphics) |
| 255 # use the line above to find dependency for PDF builder when onl
y .eps figure is present |
| 256 # Since it will be found if the user tell scons how to make the
pdf figure leave it out for now. |
254 return map(lambda e, f=filename: f+e, self.graphics_extensions) | 257 return map(lambda e, f=filename: f+e, self.graphics_extensions) |
255 return [filename] | 258 return [filename] |
256 | 259 |
257 def sort_key(self, include): | 260 def sort_key(self, include): |
258 return SCons.Node.FS._my_normcase(str(include)) | 261 return SCons.Node.FS._my_normcase(str(include)) |
259 | 262 |
260 def find_include(self, include, source_dir, path): | 263 def find_include(self, include, source_dir, path): |
261 try: | 264 try: |
262 sub_path = path[include[0]] | 265 sub_path = path[include[0]] |
263 except (IndexError, KeyError): | 266 except (IndexError, KeyError): |
(...skipping 14 matching lines...) Expand all Loading... |
278 # Modify the default scan function to allow for the regular | 281 # Modify the default scan function to allow for the regular |
279 # expression to return a comma separated list of file names | 282 # expression to return a comma separated list of file names |
280 # as can be the case with the bibliography keyword. | 283 # as can be the case with the bibliography keyword. |
281 | 284 |
282 # Cache the includes list in node so we only scan it once: | 285 # Cache the includes list in node so we only scan it once: |
283 path_dict = dict(list(path)) | 286 path_dict = dict(list(path)) |
284 noopt_cre = re.compile('\[.*$') | 287 noopt_cre = re.compile('\[.*$') |
285 if node.includes != None: | 288 if node.includes != None: |
286 includes = node.includes | 289 includes = node.includes |
287 else: | 290 else: |
288 includes = self.cre.findall(node.get_contents()) | 291 includes = self.cre.findall(node.get_text_contents()) |
289 # 1. Split comma-separated lines, e.g. | 292 # 1. Split comma-separated lines, e.g. |
290 # ('bibliography', 'phys,comp') | 293 # ('bibliography', 'phys,comp') |
291 # should become two entries | 294 # should become two entries |
292 # ('bibliography', 'phys') | 295 # ('bibliography', 'phys') |
293 # ('bibliography', 'comp') | 296 # ('bibliography', 'comp') |
294 # 2. Remove the options, e.g., such as | 297 # 2. Remove the options, e.g., such as |
295 # ('includegraphics[clip,width=0.7\\linewidth]', 'picture.eps') | 298 # ('includegraphics[clip,width=0.7\\linewidth]', 'picture.eps') |
296 # should become | 299 # should become |
297 # ('includegraphics', 'picture.eps') | 300 # ('includegraphics', 'picture.eps') |
298 split_includes = [] | 301 split_includes = [] |
(...skipping 26 matching lines...) Expand all Loading... |
325 if include[0] != 'usepackage': | 328 if include[0] != 'usepackage': |
326 SCons.Warnings.warn(SCons.Warnings.DependencyWarning, | 329 SCons.Warnings.warn(SCons.Warnings.DependencyWarning, |
327 "No dependency generated for file: %s (i
ncluded from: %s) -- file not found" % (i, node)) | 330 "No dependency generated for file: %s (i
ncluded from: %s) -- file not found" % (i, node)) |
328 else: | 331 else: |
329 sortkey = self.sort_key(n) | 332 sortkey = self.sort_key(n) |
330 nodes.append((sortkey, n)) | 333 nodes.append((sortkey, n)) |
331 # | 334 # |
332 nodes.sort() | 335 nodes.sort() |
333 nodes = map(lambda pair: pair[1], nodes) | 336 nodes = map(lambda pair: pair[1], nodes) |
334 return nodes | 337 return nodes |
OLD | NEW |