Changes between Version 3 and Version 4 of GenshiRecipes/RecursiveIncludeScanner
- Timestamp:
- Feb 4, 2008, 7:07:58 PM (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
GenshiRecipes/RecursiveIncludeScanner
v3 v4 20 20 21 21 This solution was kindly provided by Christopher Lenz <cmlenz@gmx.de> 22 Updated 2008-02-04 to work with changes to Genshi by Stephan Sokolow <http://www.ssokolow.com/ContactMe> 22 23 """ 23 24 24 import os, sys25 import os, sys 25 26 from genshi.core import START 26 from genshi.filters import IncludeFilter27 27 from genshi.input import XMLParser 28 29 def scan_xincludes(filename): 30 basedir, filename = os.path.split(filename) 31 namespace = IncludeFilter.NAMESPACE 28 29 def scan_xincludes(filepath): 30 basedir, filename = os.path.split(filepath) 32 31 includes = set([filename]) 33 32 notfound = set() 34 33 visited = set() 35 34 36 35 def collect(filename): 37 36 try: … … 41 40 if kind is START: 42 41 tag, attrib = data 43 if tag in namespaceand tag.localname == 'include':42 if tag.namespace == 'http://www.w3.org/2001/XInclude' and tag.localname == 'include': 44 43 includes.add(attrib.get('href')) 45 44 finally: … … 50 49 notfound.add(filename) 51 50 52 53 51 while len(includes) > len(visited): 54 52 for filename in includes - visited: 55 53 collect(filename) 56 54 57 55 return includes,notfound 58 56