#!/usr/bin/env python
#
# $Source: /home/blais/repos/cvsroot/arubomu/old/bin/remove-user,v $
# $Id: remove-user,v 1.1 2004/02/07 01:17:06 blais Exp $
#

"""remove-user [<options>] <file>

Removes the user part of a jbalb and replaces it with the album within.

"""

__version__ = "$Revision: 1.1 $"
__author__ = "Martin Blais <blais@furius.ca>"


import sys, os
from elementtree import ElementTree


def main():
    import optparse
    parser = optparse.OptionParser(__doc__.strip(), version=__version__)
    opts, args = parser.parse_args()

    if len(args) != 1:
        raise parser.error("Please specify a single input file.")
    fn = args[0]

    try:
        tree = ElementTree.parse(fn)
        root = tree.getroot()
    except IOError, e:
        raise SystemExit("Error: couldn't read file (%s):" % fn + str(e))

    assert root.tag == 'jbalb'
    albumlist = root.findall('album')
    assert len(albumlist) == 1
    album = albumlist[0]
    
    ElementTree.ElementTree(album).write(sys.stdout, encoding='iso-8859-1')
    print

if __name__ == '__main__':
    main()

