#!/usr/local/bin/python # This script parses the Master-Index.xml file, using the ifarchivexml # module. (ifarchivexml.py must be in the current directory, or in your # Python path.) # # Two handy ways to use this: # # python -i parse-ifarchive.py Master-Index.xml # # Starts Python in interactive mode, with rootdir set to the root directory, # dirs set to a dictionary of directories, and files set to a dictionary # of files. # # python parse-ifarchive.py Master-Index.xml Master-Index.pik # # Creates a pickle file containing the pickled tuple (rootdir, dirs, files). # This can then be loaded with the Python commands: # import pickle # fl = open('Master-Index.pik', 'r') # (rootdir, dirs, files) = pickle.load(fl) # fl.close() # import sys import cPickle import ifarchivexml if (len(sys.argv) < 2): print 'usage: parse-ifarchive.py file.xml [file.pik]' sys.exit() result = ifarchivexml.parse(sys.argv[1]) (rootdir, dirs, files) = result if (len(sys.argv) > 2): fl = open(sys.argv[2], 'w') cPickle.dump(result, fl) fl.close()