Changes between Version 2 and Version 3 of GenshiRecipes/RecursiveIncludeScanner
- Timestamp:
- Sep 12, 2006, 12:24:23 PM (18 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
GenshiRecipes/RecursiveIncludeScanner
v2 v3 1 = [GenshiRecipes Genshi Recipes]: Recursive Include Scanner = 2 1 3 == Motivation == 2 4 3 This recipe evolved after discussion of another recipe, [wiki: MarkupRecipes/SconsXIncludeScanner Implicit dependencies with scons], on [IrcChannel #markup]. The solution, and the source code used in this recipe, was kindly provided by Christopher Lenz (aka cmlenz).5 This recipe evolved after discussion of another recipe, [wiki:GenshiRecipes/SconsXIncludeScanner Implicit dependencies with scons], on the IrcChannel. The solution, and the source code used in this recipe, was kindly provided by Christopher Lenz (aka cmlenz). 4 6 5 7 When working with a relatively large set of xml sources that make use of XIncludes there is a common question that comes in two forms: … … 8 10 * What files '''were''' included by a particular source ? 9 11 10 This recipe seeks to address the first sense as far as is possible. [wiki: MarkupRecipes/SconsXIncludeScanner Implicit dependencies with scons] could be used as a starting point for answering the second.12 This recipe seeks to address the first sense as far as is possible. [wiki:GenshiRecipes/SconsXIncludeScanner Implicit dependencies with scons] could be used as a starting point for answering the second. 11 13 12 14 == Code == … … 15 17 {{{ 16 18 #!python 17 """Recursive xincludes scanner for Markup19 """Recursive xincludes scanner for Genshi 18 20 19 21 This solution was kindly provided by Christopher Lenz <cmlenz@gmx.de> … … 21 23 22 24 import os,sys 23 from markup.core import START24 from markup.filters import IncludeFilter25 from markup.input import XMLParser25 from genshi.core import START 26 from genshi.filters import IncludeFilter 27 from genshi.input import XMLParser 26 28 27 29 def scan_xincludes(filename): … … 76 78 == Discussion == 77 79 78 Markup syntaxsupports conditional includes and includes whose target file names are dynamic. The latter makes it impossible to know for certain "before the show", which files '''will''' be included. Conditional includes that depend on static state could be determined before the show. This is, however, far from trivial.80 The Genshi XML template language supports conditional includes and includes whose target file names are dynamic. The latter makes it impossible to know for certain "before the show", which files '''will''' be included. Conditional includes that depend on static state could be determined before the show. This is, however, far from trivial. 79 81 80 Integrating Markup, or anything like it, into a build system is a typical scenario that prompts these questions. Typically you will want automatic dependencies, and reliable, but minimal, rebuilds in the event that any of your source files are changed.82 Integrating Genshi, or anything like it, into a build system is a typical scenario that prompts these questions. Typically you will want automatic dependencies, and reliable, but minimal, rebuilds in the event that any of your source files are changed. 81 83 82 84 For build system dependencies the consequence of false positives is often acceptable. The consequence being more sources are rebuilt than strictly necessary. And, answering the latter form of the question, "what files '''were''' included" is usually sufficient for ensuring re-builds are both minimal and correct. 83 85 84 86 ---- 87 See also GenshiRecipes, [wiki:GenshiRecipes/SconsXIncludeScanner]