Edgewall Software

Changes between Version 3 and Version 4 of GenshiRecipes/RecursiveIncludeScanner


Ignore:
Timestamp:
Feb 4, 2008, 7:07:58 PM (16 years ago)
Author:
anonymous
Comment:

Fixed the code to work with current Genshi

Legend:

Unmodified
Added
Removed
Modified
  • GenshiRecipes/RecursiveIncludeScanner

    v3 v4  
    2020
    2121This solution was kindly provided by Christopher Lenz <cmlenz@gmx.de>
     22Updated 2008-02-04 to work with changes to Genshi by Stephan Sokolow <http://www.ssokolow.com/ContactMe>
    2223"""
    2324
    24 import os,sys
     25import os, sys
    2526from genshi.core import START
    26 from genshi.filters import IncludeFilter
    2727from genshi.input import XMLParser
    28  
    29 def scan_xincludes(filename):
    30     basedir, filename = os.path.split(filename)
    31     namespace = IncludeFilter.NAMESPACE
     28
     29def scan_xincludes(filepath):
     30    basedir, filename = os.path.split(filepath)
    3231    includes = set([filename])
    3332    notfound = set()
    3433    visited = set()
    35  
     34
    3635    def collect(filename):
    3736        try:
     
    4140                    if kind is START:
    4241                        tag, attrib = data
    43                         if tag in namespace and tag.localname == 'include':
     42                        if tag.namespace == 'http://www.w3.org/2001/XInclude' and tag.localname == 'include':
    4443                            includes.add(attrib.get('href'))
    4544            finally:
     
    5049            notfound.add(filename)
    5150
    52  
    5351    while len(includes) > len(visited):
    5452        for filename in includes - visited:
    5553            collect(filename)
    56  
     54
    5755    return includes,notfound
    5856