Reply to comment

xfl - a Python module to create and compare file lists in XML

xfl is a simple Python module to store and compare lists of files and complete directory trees in XML. It uses the ElementTree module to provide a pythonic interface to XML.

xfl manages basic file lists including file and directory names, sizes, modification times and owners. The hierarchical structure of a directory tree is simply reproduced as nested XML tags. Here is a simple example:

<dirtree name="C:\Python25\Tools" time="1187522227.44">
  <dir name="i18n">
    <file name="makelocalealias.py" size="2080" mtime="1130526398.0" owner="BUILTIN\Administrators"/>
    <file name="msgfmt.py" size="5704" mtime="1144404866.0" owner="BUILTIN\Administrators"/>
    <file name="pygettext.py" size="22773" mtime="1130526398.0" owner="BUILTIN\Administrators"/>
  </dir>
  <dir name="pynche">
    <file name="ChipViewer.py" size="5158" mtime="1130526398.0" owner="BUILTIN\Administrators"/>
    <dir name="X">
      <file name="rgb.txt" size="18128" mtime="1130526398.0" owner="BUILTIN\Administrators"/>
      <file name="xlicense.txt" size="1381" mtime="1130526398.0" owner="BUILTIN\Administrators"/>
    </dir>
  </dir>
</dirtree>

Two XML file lists may be compared in order to check which files are identical, have been added, changed or deleted.

Usage:

Just run xfl.py from the command line to get information on its usage as a script.

To create a new XML file list:

xfl.py <root path> <XML file>

To create a new XML file list and compare to a previous state:

xfl.py <root path> <XML file> <previous XML file>

xfl is extensible: it is easy to import it in a custom script in order to store additional information about each file or directory. As an example, the provided script xfl-crc.py stores the CRC32 hash of each file to demonstrate a simple integrity checker. It could be easily extended to add MD5, SHA1 or SHA256 fingerprints.

License:

CeCILL v2, open-source.

Download:

Click on the icon below.

 

AttachmentSize
xfl_0.06.zip4.42 KB

Reply

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <b> <address> <blockquote> <br> <caption> <center> <code> <dd> <del> <div> <dl> <dt> <em> <font> <h2> <h3> <h4> <h5> <h6> <hr> <i> <img> <li> <ol> <p> <pre> <span> <strong> <sub> <sup> <table> <tbody> <td> <tfoot> <th> <thead> <tr> <u> <ul> <tr>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. The supported tag styles are: <foo>, [foo].
  • Use [toc list: ol; title: Table of Contents; minlevel: 2; maxlevel: 3; attachments: yes;] to insert a mediawiki style collapsible table of contents. All the arguments are optional.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.