#!/usr/bin/env python

#
# Generated Thu Feb 29 18:07:09 2024 by generateDS.py version 2.43.3.
# Python 3.11.3 (main, Apr 19 2023, 18:49:55) [Clang 14.0.6 ]
#
# Command line options:
#   ('-f', '')
#   ('-o', 'schema/partner_lib.py')
#   ('-s', 'schema/partner.py')
#
# Command line arguments:
#   definitions/PARTNER_SHOP_.xsd
#
# Command line:
#   /Users/daniilossinkin/anaconda3/bin/generateDS -f -o "schema/partner_lib.py" -s "schema/partner.py" definitions/PARTNER_SHOP_.xsd
#
# Current working directory (os.getcwd()):
#   imports
#

import os
import sys
from lxml import etree as etree_

import src.data.imports.schema.partner_lib as supermod

def parsexml_(infile, parser=None, **kwargs):
    if parser is None:
        # Use the lxml ElementTree compatible parser so that, e.g.,
        #   we ignore comments.
        parser = etree_.ETCompatXMLParser()
    try:
        if isinstance(infile, os.PathLike):
            infile = os.path.join(infile)
    except AttributeError:
        pass
    doc = etree_.parse(infile, parser=parser, **kwargs)
    return doc

def parsexmlstring_(instring, parser=None, **kwargs):
    if parser is None:
        # Use the lxml ElementTree compatible parser so that, e.g.,
        #   we ignore comments.
        try:
            parser = etree_.ETCompatXMLParser()
        except AttributeError:
            # fallback to xml.etree
            parser = etree_.XMLParser()
    element = etree_.fromstring(instring, parser=parser, **kwargs)
    return element

#
# Globals
#

ExternalEncoding = ''
SaveElementTreeNode = True

#
# Data representation classes
#


class semiramisSub(supermod.semiramis):
    def __init__(self, created=None, locale=None, nlsMode='SINGLE_LANGUAGE', dateTimeMode='COMPACT', Partner=None, **kwargs_):
        super(semiramisSub, self).__init__(created, locale, nlsMode, dateTimeMode, Partner,  **kwargs_)
supermod.semiramis.subclass = semiramisSub
# end class semiramisSub


class PartnerTypeSub(supermod.PartnerType):
    def __init__(self, mark=None, mode=None, invalid=None, number=None, searchString=None, name=None, person=None, organizationalUnit=None, customerStatus=None, addressData=None, Customer=None, PartnerAccountingData=None, CommunicationData=None, **kwargs_):
        super(PartnerTypeSub, self).__init__(mark, mode, invalid, number, searchString, name, person, organizationalUnit, customerStatus, addressData, Customer, PartnerAccountingData, CommunicationData,  **kwargs_)
supermod.PartnerType.subclass = PartnerTypeSub
# end class PartnerTypeSub


class personTypeSub(supermod.personType):
    def __init__(self, mark=None, mode=None, invalid=None, givenName=None, surname=None, fullName=None, gender=None, Salutation=None, Title=None, **kwargs_):
        super(personTypeSub, self).__init__(mark, mode, invalid, givenName, surname, fullName, gender, Salutation, Title,  **kwargs_)
supermod.personType.subclass = personTypeSub
# end class personTypeSub


class SalutationTypeSub(supermod.SalutationType):
    def __init__(self, mark=None, mode=None, invalid=None, name=None, **kwargs_):
        super(SalutationTypeSub, self).__init__(mark, mode, invalid, name,  **kwargs_)
supermod.SalutationType.subclass = SalutationTypeSub
# end class SalutationTypeSub


class TitleTypeSub(supermod.TitleType):
    def __init__(self, mark=None, mode=None, invalid=None, name=None, **kwargs_):
        super(TitleTypeSub, self).__init__(mark, mode, invalid, name,  **kwargs_)
supermod.TitleType.subclass = TitleTypeSub
# end class TitleTypeSub


class organizationalUnitTypeSub(supermod.organizationalUnitType):
    def __init__(self, mark=None, mode=None, invalid=None, ilnNumber=None, **kwargs_):
        super(organizationalUnitTypeSub, self).__init__(mark, mode, invalid, ilnNumber,  **kwargs_)
supermod.organizationalUnitType.subclass = organizationalUnitTypeSub
# end class organizationalUnitTypeSub


class addressDataTypeSub(supermod.addressDataType):
    def __init__(self, mark=None, mode=None, invalid=None, street=None, city=None, postalCode=None, Country=None, **kwargs_):
        super(addressDataTypeSub, self).__init__(mark, mode, invalid, street, city, postalCode, Country,  **kwargs_)
supermod.addressDataType.subclass = addressDataTypeSub
# end class addressDataTypeSub


class CountryTypeSub(supermod.CountryType):
    def __init__(self, mark=None, mode=None, invalid=None, isoCode=None, description=None, **kwargs_):
        super(CountryTypeSub, self).__init__(mark, mode, invalid, isoCode, description,  **kwargs_)
supermod.CountryType.subclass = CountryTypeSub
# end class CountryTypeSub


class CustomerTypeSub(supermod.CustomerType):
    def __init__(self, mark=None, mode=None, invalid=None, allowOrders=None, deliveryDataInfo=None, classification1=None, classification2=None, classification5=None, PriceListing=None, Imp_SizeSurchargeListing=None, Imp_CustomerPossibleSalesItem=None, Imp_CustomerPossibleOrderTypes=None, **kwargs_):
        super(CustomerTypeSub, self).__init__(mark, mode, invalid, allowOrders, deliveryDataInfo, classification1, classification2, classification5, PriceListing, Imp_SizeSurchargeListing, Imp_CustomerPossibleSalesItem, Imp_CustomerPossibleOrderTypes,  **kwargs_)
supermod.CustomerType.subclass = CustomerTypeSub
# end class CustomerTypeSub


class deliveryDataInfoTypeSub(supermod.deliveryDataInfoType):
    def __init__(self, mark=None, mode=None, invalid=None, ShippingTerms=None, **kwargs_):
        super(deliveryDataInfoTypeSub, self).__init__(mark, mode, invalid, ShippingTerms,  **kwargs_)
supermod.deliveryDataInfoType.subclass = deliveryDataInfoTypeSub
# end class deliveryDataInfoTypeSub


class ShippingTermsTypeSub(supermod.ShippingTermsType):
    def __init__(self, mark=None, mode=None, invalid=None, code=None, description=None, **kwargs_):
        super(ShippingTermsTypeSub, self).__init__(mark, mode, invalid, code, description,  **kwargs_)
supermod.ShippingTermsType.subclass = ShippingTermsTypeSub
# end class ShippingTermsTypeSub


class PriceListingTypeSub(supermod.PriceListingType):
    def __init__(self, mark=None, mode=None, invalid=None, code=None, **kwargs_):
        super(PriceListingTypeSub, self).__init__(mark, mode, invalid, code,  **kwargs_)
supermod.PriceListingType.subclass = PriceListingTypeSub
# end class PriceListingTypeSub


class Imp_SizeSurchargeListingTypeSub(supermod.Imp_SizeSurchargeListingType):
    def __init__(self, mark=None, mode=None, invalid=None, code=None, description=None, **kwargs_):
        super(Imp_SizeSurchargeListingTypeSub, self).__init__(mark, mode, invalid, code, description,  **kwargs_)
supermod.Imp_SizeSurchargeListingType.subclass = Imp_SizeSurchargeListingTypeSub
# end class Imp_SizeSurchargeListingTypeSub


class Imp_CustomerPossibleSalesItemTypeSub(supermod.Imp_CustomerPossibleSalesItemType):
    def __init__(self, mark=None, mode=None, invalid=None, Item=None, **kwargs_):
        super(Imp_CustomerPossibleSalesItemTypeSub, self).__init__(mark, mode, invalid, Item,  **kwargs_)
supermod.Imp_CustomerPossibleSalesItemType.subclass = Imp_CustomerPossibleSalesItemTypeSub
# end class Imp_CustomerPossibleSalesItemTypeSub


class ItemTypeSub(supermod.ItemType):
    def __init__(self, mark=None, mode=None, invalid=None, eans=None, **kwargs_):
        super(ItemTypeSub, self).__init__(mark, mode, invalid, eans,  **kwargs_)
supermod.ItemType.subclass = ItemTypeSub
# end class ItemTypeSub


class eansTypeSub(supermod.eansType):
    def __init__(self, index=None, valueOf_=None, **kwargs_):
        super(eansTypeSub, self).__init__(index, valueOf_,  **kwargs_)
supermod.eansType.subclass = eansTypeSub
# end class eansTypeSub


class Imp_CustomerPossibleOrderTypesTypeSub(supermod.Imp_CustomerPossibleOrderTypesType):
    def __init__(self, mark=None, mode=None, invalid=None, PriceListing=None, **kwargs_):
        super(Imp_CustomerPossibleOrderTypesTypeSub, self).__init__(mark, mode, invalid, PriceListing,  **kwargs_)
supermod.Imp_CustomerPossibleOrderTypesType.subclass = Imp_CustomerPossibleOrderTypesTypeSub
# end class Imp_CustomerPossibleOrderTypesTypeSub


class PriceListingType1Sub(supermod.PriceListingType1):
    def __init__(self, mark=None, mode=None, invalid=None, code=None, **kwargs_):
        super(PriceListingType1Sub, self).__init__(mark, mode, invalid, code,  **kwargs_)
supermod.PriceListingType1.subclass = PriceListingType1Sub
# end class PriceListingType1Sub


class PartnerAccountingDataTypeSub(supermod.PartnerAccountingDataType):
    def __init__(self, mark=None, mode=None, invalid=None, SalesPaymentTerms=None, **kwargs_):
        super(PartnerAccountingDataTypeSub, self).__init__(mark, mode, invalid, SalesPaymentTerms,  **kwargs_)
supermod.PartnerAccountingDataType.subclass = PartnerAccountingDataTypeSub
# end class PartnerAccountingDataTypeSub


class SalesPaymentTermsTypeSub(supermod.SalesPaymentTermsType):
    def __init__(self, mark=None, mode=None, invalid=None, code=None, description=None, **kwargs_):
        super(SalesPaymentTermsTypeSub, self).__init__(mark, mode, invalid, code, description,  **kwargs_)
supermod.SalesPaymentTermsType.subclass = SalesPaymentTermsTypeSub
# end class SalesPaymentTermsTypeSub


class CommunicationDataTypeSub(supermod.CommunicationDataType):
    def __init__(self, mark=None, mode=None, invalid=None, commData=None, normalizedCommData=None, Method=None, **kwargs_):
        super(CommunicationDataTypeSub, self).__init__(mark, mode, invalid, commData, normalizedCommData, Method,  **kwargs_)
supermod.CommunicationDataType.subclass = CommunicationDataTypeSub
# end class CommunicationDataTypeSub


class MethodTypeSub(supermod.MethodType):
    def __init__(self, mark=None, mode=None, invalid=None, name=None, description=None, media=None, **kwargs_):
        super(MethodTypeSub, self).__init__(mark, mode, invalid, name, description, media,  **kwargs_)
supermod.MethodType.subclass = MethodTypeSub
# end class MethodTypeSub


def get_root_tag(node):
    tag = supermod.Tag_pattern_.match(node.tag).groups()[-1]
    rootClass = None
    rootClass = supermod.GDSClassesMapping.get(tag)
    if rootClass is None and hasattr(supermod, tag):
        rootClass = getattr(supermod, tag)
    return tag, rootClass


def parse(inFilename, silence=False):
    parser = None
    doc = parsexml_(inFilename, parser)
    rootNode = doc.getroot()
    rootTag, rootClass = get_root_tag(rootNode)
    if rootClass is None:
        rootTag = 'semiramis'
        rootClass = supermod.semiramis
    rootObj = rootClass.factory()
    rootObj.build(rootNode)
    # Enable Python to collect the space used by the DOM.
    if not SaveElementTreeNode:
        doc = None
        rootNode = None
    if not silence:
        sys.stdout.write('<?xml version="1.0" ?>\n')
        rootObj.export(
            sys.stdout, 0, name_=rootTag,
            namespacedef_='',
            pretty_print=True)
    return rootObj


def parseEtree(inFilename, silence=False):
    parser = None
    doc = parsexml_(inFilename, parser)
    rootNode = doc.getroot()
    rootTag, rootClass = get_root_tag(rootNode)
    if rootClass is None:
        rootTag = 'semiramis'
        rootClass = supermod.semiramis
    rootObj = rootClass.factory()
    rootObj.build(rootNode)
    mapping = {}
    rootElement = rootObj.to_etree(None, name_=rootTag, mapping_=mapping)
    reverse_mapping = rootObj.gds_reverse_node_mapping(mapping)
    # Enable Python to collect the space used by the DOM.
    if not SaveElementTreeNode:
        doc = None
        rootNode = None
    if not silence:
        content = etree_.tostring(
            rootElement, pretty_print=True,
            xml_declaration=True, encoding="utf-8")
        sys.stdout.write(content)
        sys.stdout.write('\n')
    return rootObj, rootElement, mapping, reverse_mapping


def parseString(inString, silence=False):
    if sys.version_info.major == 2:
        from StringIO import StringIO
    else:
        from io import BytesIO as StringIO
    parser = None
    rootNode= parsexmlstring_(inString, parser)
    rootTag, rootClass = get_root_tag(rootNode)
    if rootClass is None:
        rootTag = 'semiramis'
        rootClass = supermod.semiramis
    rootObj = rootClass.factory()
    rootObj.build(rootNode)
    # Enable Python to collect the space used by the DOM.
    if not SaveElementTreeNode:
        rootNode = None
    if not silence:
        sys.stdout.write('<?xml version="1.0" ?>\n')
        rootObj.export(
            sys.stdout, 0, name_=rootTag,
            namespacedef_='')
    return rootObj


def parseLiteral(inFilename, silence=False):
    parser = None
    doc = parsexml_(inFilename, parser)
    rootNode = doc.getroot()
    rootTag, rootClass = get_root_tag(rootNode)
    if rootClass is None:
        rootTag = 'semiramis'
        rootClass = supermod.semiramis
    rootObj = rootClass.factory()
    rootObj.build(rootNode)
    # Enable Python to collect the space used by the DOM.
    if not SaveElementTreeNode:
        doc = None
        rootNode = None
    if not silence:
        sys.stdout.write('#from ??? import *\n\n')
        sys.stdout.write('import ??? as model_\n\n')
        sys.stdout.write('rootObj = model_.rootClass(\n')
        rootObj.exportLiteral(sys.stdout, 0, name_=rootTag)
        sys.stdout.write(')\n')
    return rootObj


USAGE_TEXT = """
Usage: python ???.py <infilename>
"""


def usage():
    print(USAGE_TEXT)
    sys.exit(1)


def main():
    args = sys.argv[1:]
    if len(args) != 1:
        usage()
    infilename = args[0]
    parse(infilename)


if __name__ == '__main__':
    #import pdb; pdb.set_trace()
    main()
