#!/usr/bin/python import sys, os.path, re reg = re.compile(r'^\*include ([^;\s]*?)\s*$', re.MULTILINE) def printdeps(filename): """Expects a filename relative to script's working directory.""" if(filename[-4:]!='.svx'): filename += ".svx" print filename t = file(filename).read() for m in re.findall(reg, t): newfname = m if(newfname[-4:]!='.svx'): newfname += '.svx' newfname = os.path.normpath(os.path.dirname(filename) + '/' + newfname) if(os.path.exists(newfname)): printdeps(newfname) else: # imitate cavern case-sensitivity workaround newfname = m.lower() newfname = os.path.normpath(os.path.dirname(filename) + '/' + newfname) printdeps(newfname) if(len(sys.argv) != 2): print >>sys.stderr, "Usage: %s SVXFILE" % sys.argv[0] sys.exit(1) printdeps(sys.argv[1])