# 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
                    pkgname, with_split[0], errors)
                if mapped_lic is None:
                    mapped_lic = u"UNKNOWN_MAPPING(%s)" % with_split[0]
                if len(with_split) == 2:
                    ands.append(mapped_lic + u" WITH " + with_split[1])
                else:
                    ands.append(mapped_lic)
            ors.append(' AND '.join(ands))

        retval = ' OR '.join(ors)
        return retval

    def map_lic(self, pkgname, licenses, errors):
        if pkgname in self.perpackage_override:
            if self.perpackage_override[pkgname]:
                return self.perpackage_override[pkgname]

        retval = []
        for l in licenses:
            if l is not None:
                retval.append(self.map_license_string(pkgname, l, errors))
            else:
                retval.append('Empty license')

        return retval


def scan_nomos(license_text):
    with NamedTemporaryFile() as f:
        f.write(license_text.encode('utf-8'))

# 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

                    pkgname, with_split[0], errors)
                if mapped_lic is None:
                    mapped_lic = u"UNKNOWN_MAPPING(%s)" % with_split[0]
                if len(with_split) == 2:
                    ands.append(mapped_lic + u" WITH " + with_split[1])
                else:
                    ands.append(mapped_lic)
            ors.append(' AND '.join(ands))

        retval = ' OR '.join(ors)
        return retval

    def map_lic(self, pkgname, licenses, errors):
        if pkgname in self.perpackage_override:
            if self.perpackage_override[pkgname]:
                return self.perpackage_override[pkgname]

        retval = []
        for l in licenses:
            if l is not None:
                retval.append(self.map_license_string(pkgname, l, errors))
            else:
                retval.append('Empty license')

        return retval


def scan_nomos(license_text):
    with NamedTemporaryFile() as f:
        f.write(license_text.encode('utf-8'))

        nomos_out = system_out(