13.5. Source Code for xFS

 CD-ROM reference=13016.txt """ Convert the information about a filesystem or partial filesystem to XML conforming to the xFS DTD. XML Processing with Python Sean Mc Grath http://www.digitome.com """ import os,sys,glob,stat,time,copy import string def escape (s): """ Convert XML special characters to their entity reference representations. """ s = string.join (string.split (s,"<"),"&amp;lt;") s = string.join (string.split (s,"&"),"&amp;amp;") return s def xFS (spec,indent=1): """ Given a directory specification, generate XML from file information. Recursively process subdirectories. """ for f in glob.glob (spec): # Pick up information about the file. o = os.stat(f) # The mode value can be used to determine if this # ...

Get XML Processing with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.