# Path: elbepack/treeutils.py
# class etree(ebase):
#     def __init__(self, fname):
#         if fname is not None:
#             parser = XMLParser(huge_tree=True, remove_comments=False)
#             et = parse(fname, parser=parser)
#         else:
#             et = ElementTree(file=None)
# 
#         ebase.__init__(self, et)
# 
#     def write(self, fname, encoding=None):
#         # Make sure, that we end with a newline
#         self.et.getroot().tail = '\n'
#         self.et.write(fname, encoding=encoding)
# 
#     def tostring(self):
#         return self.et.tostring()
# 
#     def ensure_child(self, tag):
#         retval = self.et.find("./" + tag)
#         if retval is not None:
#             return elem(retval)
#         return elem(SubElement(self.et.getroot(), tag))
# 
#     def set_child_position(self, child, pos):
#         root = self.et.getroot()
#         root.remove(child.et)
#         root.insert(pos, child.et)
# 
#     def setroot(self, tag):
#         retval = elem(Element(tag))
#         # pylint: disable=protected-access
#         self.et._setroot(retval.et)
#         return retval
# 
#     @property
#     def root(self):
#         return elem(self.et.getroot())
# 
# Path: elbepack/version.py

# 
# Path: elbepack/shellhelper.py
# def system_out(cmd, stdin=None, allow_fail=False, env_add=None):
#     """system_out() - Wrapper around command_out().
# 
#     On failure, raises an exception if allow_fail=False, on success,
#     returns the output of cmd.
# 
#     --
# 
#     >>> system_out("false") # doctest: +ELLIPSIS
#     Traceback (most recent call last):
#     ...
#     elbepack.shellhelper.CommandError: ...
# 
#     >>> system_out("false", allow_fail=True)
#     ''
# 
#     """
#     code, out = command_out(cmd, stdin=stdin, env_add=env_add)
# 
#     if code != 0:
#         if not allow_fail:
#             raise CommandError(cmd, code)
# 
#     return out


from optparse import OptionParser
from datetime import datetime
from tempfile import NamedTemporaryFile
from elbepack.treeutils import etree
from elbepack.version import elbe_version
from elbepack.shellhelper import system_out
import sys
import os
import io
    oparser = OptionParser(
        usage="usage: %prog parselicence [options] <licencefile>")
    oparser.add_option("--output", dest="output",
                       help="outputfilename")
    oparser.add_option("--mapping", dest="mapping",
                       help="mapping filename")
    oparser.add_option(
        "--use-nomos",
        action="store_true",
        dest="use_nomos",
        default=False,
        help="Use the external nomos tool on the copyright text, "
             "and record the ouput in out xml")
    oparser.add_option(
        "--errors-only",
        action="store_true",
        dest="only_errors",
        default=False,
        help="Only Output Packages with errors, "
             "needing a fix in the mapping file")
    oparser.add_option("--tvout", dest="tagvalue",
                       help="tag value output filename")

    (opt, args) = oparser.parse_args(argv)

    if len(args) != 1:
        print("wrong number of arguments")
        oparser.print_help()
        sys.exit(20)


# Path: elbepack/treeutils.py
# class etree(ebase):
#     def __init__(self, fname):
#         if fname is not None:
#             parser = XMLParser(huge_tree=True, remove_comments=False)
#             et = parse(fname, parser=parser)
#         else:
#             et = ElementTree(file=None)
# 
#         ebase.__init__(self, et)
# 
#     def write(self, fname, encoding=None):
#         # Make sure, that we end with a newline
#         self.et.getroot().tail = '\n'
#         self.et.write(fname, encoding=encoding)
# 
#     def tostring(self):
#         return self.et.tostring()
# 
#     def ensure_child(self, tag):
#         retval = self.et.find("./" + tag)
#         if retval is not None:
#             return elem(retval)
#         return elem(SubElement(self.et.getroot(), tag))
# 
#     def set_child_position(self, child, pos):
#         root = self.et.getroot()
#         root.remove(child.et)
#         root.insert(pos, child.et)
# 
#     def setroot(self, tag):
#         retval = elem(Element(tag))
#         # pylint: disable=protected-access
#         self.et._setroot(retval.et)
#         return retval
# 
#     @property
#     def root(self):
#         return elem(self.et.getroot())
# 
# Path: elbepack/version.py

# 
# Path: elbepack/shellhelper.py
# def system_out(cmd, stdin=None, allow_fail=False, env_add=None):
#     """system_out() - Wrapper around command_out().
# 
#     On failure, raises an exception if allow_fail=False, on success,
#     returns the output of cmd.
# 
#     --
# 
#     >>> system_out("false") # doctest: +ELLIPSIS
#     Traceback (most recent call last):
#     ...
#     elbepack.shellhelper.CommandError: ...
# 
#     >>> system_out("false", allow_fail=True)
#     ''
# 
#     """
#     code, out = command_out(cmd, stdin=stdin, env_add=env_add)
# 
#     if code != 0:
#         if not allow_fail:
#             raise CommandError(cmd, code)
# 
#     return out


# Path: elbepack/commands/parselicence.py
from optparse import OptionParser
from datetime import datetime
from tempfile import NamedTemporaryFile
from elbepack.treeutils import etree
from elbepack.version import elbe_version
from elbepack.shellhelper import system_out
import sys
import os
import io

    oparser = OptionParser(
        usage="usage: %prog parselicence [options] <licencefile>")
    oparser.add_option("--output", dest="output",
                       help="outputfilename")
    oparser.add_option("--mapping", dest="mapping",
                       help="mapping filename")
    oparser.add_option(
        "--use-nomos",
        action="store_true",
        dest="use_nomos",
        default=False,
        help="Use the external nomos tool on the copyright text, "
             "and record the ouput in out xml")
    oparser.add_option(
        "--errors-only",
        action="store_true",
        dest="only_errors",
        default=False,
        help="Only Output Packages with errors, "
             "needing a fix in the mapping file")
    oparser.add_option("--tvout", dest="tagvalue",
                       help="tag value output filename")

    (opt, args) = oparser.parse_args(argv)

    if len(args) != 1:
        print("wrong number of arguments")
        oparser.print_help()
        sys.exit(20)


    tree = etree(args[0])