All pastes #250997 Raw Edit

Something

public text v1 · immutable
#250997 ·published 2006-11-17 17:00 UTC
rendered paste body
def collect_pspecs(visitor, dirname=None):
    if not dirname:
        dirname = config.pspec_folder
    # populate the list
    global allSpecs
    if allSpecs:
        for x in allSpecs:
            apply(visitor,x)
        return
    allSpecs = []
    for root, dirs, files in os.walk(dirname):
        if "pspec.xml" in files:
            try:
                sf = pisi.specfile.SpecFile()
                sf.read(os.path.join(root, "pspec.xml"))
                allSpecs.append( (sf, root) )
                visitor(sf, root)
                # found a package, dont go deeper
                for d in dirs:
                    dirs.remove(d)
            except Exception, inst:
                print "Broken package", root
                print inst
        # dont walk into the versioned stuff
        if ".svn" in dirs:
            dirs.remove(".svn")