#!/usr/bin/env python
# -*- coding: utf-8 -*-

#
# Generated Tue Feb  4 18:15:01 2020 by generateDS.py version 2.35.11.
# Python 3.6.9 (default, Nov  7 2019, 10:44:02)  [GCC 8.3.0]
#
# Command line options:
#   ('-o', 'datafile.py')
#
# Command line arguments:
#   datafile/datafile.xsd
#
# Command line:
#   /home/andre/.local/bin/generateDS -o "datafile.py" datafile/datafile.xsd
#
# Current working directory (os.getcwd()):
#   1g1r-romset-generator
#

import base64
import datetime as datetime_
import decimal as decimal_
import os
import re as re_
import sys

from itertools import zip_longest

try:
    from lxml import etree as etree_
except ImportError:
    from xml.etree import ElementTree as etree_


Validate_simpletypes_ = True
SaveElementTreeNode = True


def parsexml_(infile, 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()
    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

def get_(node, attribute, default=None):
    try:
        return node.__dict__[attribute]
    except AttributeError:
        return default

#
# Namespace prefix definition table (and other attributes, too)
#
# The module generatedsnamespaces, if it is importable, must contain
# a dictionary named GeneratedsNamespaceDefs.  This Python dictionary
# should map element type names (strings) to XML schema namespace prefix
# definitions.  The export method for any class for which there is
# a namespace prefix definition, will export that definition in the
# XML representation of that element.  See the export method of
# any generated element type class for an example of the use of this
# table.
# A sample table is:
#
#     # File: generatedsnamespaces.py
#
#     GenerateDSNamespaceDefs = {
#         "ElementtypeA": "http://www.xxx.com/namespaceA",
#         "ElementtypeB": "http://www.xxx.com/namespaceB",
#     }
#
# Additionally, the generatedsnamespaces module can contain a python
# dictionary named GenerateDSNamespaceTypePrefixes that associates element
# types with the namespace prefixes that are to be added to the
# "xsi:type" attribute value.  See the exportAttributes method of
# any generated element type and the generation of "xsi:type" for an
# example of the use of this table.
# An example table:
#
#     # File: generatedsnamespaces.py
#
#     GenerateDSNamespaceTypePrefixes = {
#         "ElementtypeC": "aaa:",
#         "ElementtypeD": "bbb:",
#     }
#

try:
    from generatedsnamespaces import GenerateDSNamespaceDefs as GenerateDSNamespaceDefs_
except ImportError:
    GenerateDSNamespaceDefs_ = {}
try:
    from generatedsnamespaces import GenerateDSNamespaceTypePrefixes as GenerateDSNamespaceTypePrefixes_
except ImportError:
    GenerateDSNamespaceTypePrefixes_ = {}

#
# You can replace the following class definition by defining an
# importable module named "generatedscollector" containing a class
# named "GdsCollector".  See the default class definition below for
# clues about the possible content of that class.
#
try:
    from generatedscollector import GdsCollector as GdsCollector_
except ImportError:

    class GdsCollector_(object):

        def __init__(self, messages=None):
            if messages is None:
                self.messages = []
            else:
                self.messages = messages

        def add_message(self, msg):
            self.messages.append(msg)

        def get_messages(self):
            return self.messages

        def clear_messages(self):
            self.messages = []

        def print_messages(self):
            for msg in self.messages:
                print("Warning: {}".format(msg))

        def write_messages(self, outstream):
            for msg in self.messages:
                outstream.write("Warning: {}\n".format(msg))


#
# The super-class for enum types
#

try:
    from enum import Enum
except ImportError:
    Enum = object

#
# The root super-class for element type classes
#
# Calls to the methods in these classes are generated by generateDS.py.
# You can replace these methods by re-implementing the following class
#   in a module named generatedssuper.py.

try:
    from generatedssuper import GeneratedsSuper
except ImportError as exp:
    
    class GeneratedsSuper(object):
        __hash__ = object.__hash__
        tzoff_pattern = re_.compile(r'(\+|-)((0\d|1[0-3]):[0-5]\d|14:00)$')
        class _FixedOffsetTZ(datetime_.tzinfo):
            def __init__(self, offset, name):
                self.__offset = datetime_.timedelta(minutes=offset)
                self.__name = name
            def utcoffset(self, dt):
                return self.__offset
            def tzname(self, dt):
                return self.__name
            def dst(self, dt):
                return None
        def gds_format_string(self, input_data, input_name=''):
            return input_data
        def gds_parse_string(self, input_data, node=None, input_name=''):
            return input_data
        def gds_validate_string(self, input_data, node=None, input_name=''):
            if not input_data:
                return ''
            else:
                return input_data
        def gds_format_base64(self, input_data, input_name=''):
            return base64.b64encode(input_data)
        def gds_validate_base64(self, input_data, node=None, input_name=''):
            return input_data
        def gds_format_integer(self, input_data, input_name=''):
            return '%d' % input_data
        def gds_parse_integer(self, input_data, node=None, input_name=''):
            try:
                ival = int(input_data)
            except (TypeError, ValueError) as exp:
                raise_parse_error(node, 'Requires integer value: %s' % exp)
            return ival
        def gds_validate_integer(self, input_data, node=None, input_name=''):
            try:
                value = int(input_data)
            except (TypeError, ValueError):
                raise_parse_error(node, 'Requires integer value')
            return value
        def gds_format_integer_list(self, input_data, input_name=''):
            return '%s' % ' '.join(input_data)
        def gds_validate_integer_list(
                self, input_data, node=None, input_name=''):
            values = input_data.split()
            for value in values:
                try:
                    int(value)
                except (TypeError, ValueError):
                    raise_parse_error(node, 'Requires sequence of integer valuess')
            return values
        def gds_format_float(self, input_data, input_name=''):
            return ('%.15f' % input_data).rstrip('0')
        def gds_parse_float(self, input_data, node=None, input_name=''):
            try:
                fval_ = float(input_data)
            except (TypeError, ValueError) as exp:
                raise_parse_error(node, 'Requires float or double value: %s' % exp)
            return fval_
        def gds_validate_float(self, input_data, node=None, input_name=''):
            try:
                value = float(input_data)
            except (TypeError, ValueError):
                raise_parse_error(node, 'Requires float value')
            return value
        def gds_format_float_list(self, input_data, input_name=''):
            return '%s' % ' '.join(input_data)
        def gds_validate_float_list(
                self, input_data, node=None, input_name=''):
            values = input_data.split()
            for value in values:
                try:
                    float(value)
                except (TypeError, ValueError):
                    raise_parse_error(node, 'Requires sequence of float values')
            return values
        def gds_format_decimal(self, input_data, input_name=''):
            return ('%0.10f' % input_data).rstrip('0')
        def gds_parse_decimal(self, input_data, node=None, input_name=''):
            try:
                decimal_value = decimal_.Decimal(input_data)
            except (TypeError, ValueError):
                raise_parse_error(node, 'Requires decimal value')
            return decimal_value
        def gds_validate_decimal(self, input_data, node=None, input_name=''):
            try:
                value = decimal_.Decimal(input_data)
            except (TypeError, ValueError):
                raise_parse_error(node, 'Requires decimal value')
            return value
        def gds_format_decimal_list(self, input_data, input_name=''):
            return '%s' % ' '.join(input_data)
        def gds_validate_decimal_list(
                self, input_data, node=None, input_name=''):
            values = input_data.split()
            for value in values:
                try:
                    decimal_.Decimal(value)
                except (TypeError, ValueError):
                    raise_parse_error(node, 'Requires sequence of decimal values')
            return values
        def gds_format_double(self, input_data, input_name=''):
            return '%e' % input_data
        def gds_parse_double(self, input_data, node=None, input_name=''):
            try:
                fval_ = float(input_data)
            except (TypeError, ValueError) as exp:
                raise_parse_error(node, 'Requires double or float value: %s' % exp)
            return fval_
        def gds_validate_double(self, input_data, node=None, input_name=''):
            try:
                value = float(input_data)
            except (TypeError, ValueError):
                raise_parse_error(node, 'Requires double or float value')
            return value
        def gds_format_double_list(self, input_data, input_name=''):
            return '%s' % ' '.join(input_data)
        def gds_validate_double_list(
                self, input_data, node=None, input_name=''):
            values = input_data.split()
            for value in values:
                try:
                    float(value)
                except (TypeError, ValueError):
                    raise_parse_error(
                        node, 'Requires sequence of double or float values')
            return values
        def gds_format_boolean(self, input_data, input_name=''):
            return ('%s' % input_data).lower()
        def gds_parse_boolean(self, input_data, node=None, input_name=''):
            if input_data in ('true', '1'):
                bval = True
            elif input_data in ('false', '0'):
                bval = False
            else:
                raise_parse_error(node, 'Requires boolean value')
            return bval
        def gds_validate_boolean(self, input_data, node=None, input_name=''):
            if input_data not in (True, 1, False, 0, ):
                raise_parse_error(
                    node,
                    'Requires boolean value '
                    '(one of True, 1, False, 0)')
            return input_data
        def gds_format_boolean_list(self, input_data, input_name=''):
            return '%s' % ' '.join(input_data)
        def gds_validate_boolean_list(
                self, input_data, node=None, input_name=''):
            values = input_data.split()
            for value in values:
                if value not in (True, 1, False, 0, ):
                    raise_parse_error(
                        node,
                        'Requires sequence of boolean values '
                        '(one of True, 1, False, 0)')
            return values
        def gds_validate_datetime(self, input_data, node=None, input_name=''):
            return input_data
        def gds_format_datetime(self, input_data, input_name=''):
            if input_data.microsecond == 0:
                _svalue = '%04d-%02d-%02dT%02d:%02d:%02d' % (
                    input_data.year,
                    input_data.month,
                    input_data.day,
                    input_data.hour,
                    input_data.minute,
                    input_data.second,
                )
            else:
                _svalue = '%04d-%02d-%02dT%02d:%02d:%02d.%s' % (
                    input_data.year,
                    input_data.month,
                    input_data.day,
                    input_data.hour,
                    input_data.minute,
                    input_data.second,
                    ('%f' % (float(input_data.microsecond) / 1000000))[2:],
                )
            if input_data.tzinfo is not None:
                tzoff = input_data.tzinfo.utcoffset(input_data)
                if tzoff is not None:
                    total_seconds = tzoff.seconds + (86400 * tzoff.days)
                    if total_seconds == 0:
                        _svalue += 'Z'
                    else:
                        if total_seconds < 0:
                            _svalue += '-'
                            total_seconds *= -1
                        else:
                            _svalue += '+'
                        hours = total_seconds // 3600
                        minutes = (total_seconds - (hours * 3600)) // 60
                        _svalue += '{0:02d}:{1:02d}'.format(hours, minutes)
            return _svalue
        @classmethod
        def gds_parse_datetime(cls, input_data):
            tz = None
            if input_data[-1] == 'Z':
                tz = GeneratedsSuper._FixedOffsetTZ(0, 'UTC')
                input_data = input_data[:-1]
            else:
                results = GeneratedsSuper.tzoff_pattern.search(input_data)
                if results is not None:
                    tzoff_parts = results.group(2).split(':')
                    tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1])
                    if results.group(1) == '-':
                        tzoff *= -1
                    tz = GeneratedsSuper._FixedOffsetTZ(
                        tzoff, results.group(0))
                    input_data = input_data[:-6]
            time_parts = input_data.split('.')
            if len(time_parts) > 1:
                micro_seconds = int(float('0.' + time_parts[1]) * 1000000)
                input_data = '%s.%s' % (
                    time_parts[0], "{}".format(micro_seconds).rjust(6, "0"), )
                dt = datetime_.datetime.strptime(
                    input_data, '%Y-%m-%dT%H:%M:%S.%f')
            else:
                dt = datetime_.datetime.strptime(
                    input_data, '%Y-%m-%dT%H:%M:%S')
            dt = dt.replace(tzinfo=tz)
            return dt
        def gds_validate_date(self, input_data, node=None, input_name=''):
            return input_data
        def gds_format_date(self, input_data, input_name=''):
            _svalue = '%04d-%02d-%02d' % (
                input_data.year,
                input_data.month,
                input_data.day,
            )
            try:
                if input_data.tzinfo is not None:
                    tzoff = input_data.tzinfo.utcoffset(input_data)
                    if tzoff is not None:
                        total_seconds = tzoff.seconds + (86400 * tzoff.days)
                        if total_seconds == 0:
                            _svalue += 'Z'
                        else:
                            if total_seconds < 0:
                                _svalue += '-'
                                total_seconds *= -1
                            else:
                                _svalue += '+'
                            hours = total_seconds // 3600
                            minutes = (total_seconds - (hours * 3600)) // 60
                            _svalue += '{0:02d}:{1:02d}'.format(
                                hours, minutes)
            except AttributeError:
                pass
            return _svalue
        @classmethod
        def gds_parse_date(cls, input_data):
            tz = None
            if input_data[-1] == 'Z':
                tz = GeneratedsSuper._FixedOffsetTZ(0, 'UTC')
                input_data = input_data[:-1]
            else:
                results = GeneratedsSuper.tzoff_pattern.search(input_data)
                if results is not None:
                    tzoff_parts = results.group(2).split(':')
                    tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1])
                    if results.group(1) == '-':
                        tzoff *= -1
                    tz = GeneratedsSuper._FixedOffsetTZ(
                        tzoff, results.group(0))
                    input_data = input_data[:-6]
            dt = datetime_.datetime.strptime(input_data, '%Y-%m-%d')
            dt = dt.replace(tzinfo=tz)
            return dt.date()
        def gds_validate_time(self, input_data, node=None, input_name=''):
            return input_data
        def gds_format_time(self, input_data, input_name=''):
            if input_data.microsecond == 0:
                _svalue = '%02d:%02d:%02d' % (
                    input_data.hour,
                    input_data.minute,
                    input_data.second,
                )
            else:
                _svalue = '%02d:%02d:%02d.%s' % (
                    input_data.hour,
                    input_data.minute,
                    input_data.second,
                    ('%f' % (float(input_data.microsecond) / 1000000))[2:],
                )
            if input_data.tzinfo is not None:
                tzoff = input_data.tzinfo.utcoffset(input_data)
                if tzoff is not None:
                    total_seconds = tzoff.seconds + (86400 * tzoff.days)
                    if total_seconds == 0:
                        _svalue += 'Z'
                    else:
                        if total_seconds < 0:
                            _svalue += '-'
                            total_seconds *= -1
                        else:
                            _svalue += '+'
                        hours = total_seconds // 3600
                        minutes = (total_seconds - (hours * 3600)) // 60
                        _svalue += '{0:02d}:{1:02d}'.format(hours, minutes)
            return _svalue
        def gds_validate_simple_patterns(self, patterns, target):
            # pat is a list of lists of strings/patterns.
            # The target value must match at least one of the patterns
            # in order for the test to succeed.
            found1 = True
            for patterns1 in patterns:
                found2 = False
                for patterns2 in patterns1:
                    mo = re_.search(patterns2, target)
                    if mo is not None and len(mo.group(0)) == len(target):
                        found2 = True
                        break
                if not found2:
                    found1 = False
                    break
            return found1
        @classmethod
        def gds_parse_time(cls, input_data):
            tz = None
            if input_data[-1] == 'Z':
                tz = GeneratedsSuper._FixedOffsetTZ(0, 'UTC')
                input_data = input_data[:-1]
            else:
                results = GeneratedsSuper.tzoff_pattern.search(input_data)
                if results is not None:
                    tzoff_parts = results.group(2).split(':')
                    tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1])
                    if results.group(1) == '-':
                        tzoff *= -1
                    tz = GeneratedsSuper._FixedOffsetTZ(
                        tzoff, results.group(0))
                    input_data = input_data[:-6]
            if len(input_data.split('.')) > 1:
                dt = datetime_.datetime.strptime(input_data, '%H:%M:%S.%f')
            else:
                dt = datetime_.datetime.strptime(input_data, '%H:%M:%S')
            dt = dt.replace(tzinfo=tz)
            return dt.time()
        def gds_check_cardinality_(
                self, value, input_name,
                min_occurs=0, max_occurs=1, required=None):
            if value is None:
                length = 0
            elif isinstance(value, list):
                length = len(value)
            else:
                length = 1
            if required is not None :
                if required and length < 1:
                    self.gds_collector_.add_message(
                        "Required value {}{} is missing".format(
                            input_name, self.gds_get_node_lineno_()))
            if length < min_occurs:
                self.gds_collector_.add_message(
                    "Number of values for {}{} is below "
                    "the minimum allowed, "
                    "expected at least {}, found {}".format(
                        input_name, self.gds_get_node_lineno_(),
                        min_occurs, length))
            elif length > max_occurs:
                self.gds_collector_.add_message(
                    "Number of values for {}{} is above "
                    "the maximum allowed, "
                    "expected at most {}, found {}".format(
                        input_name, self.gds_get_node_lineno_(),
                        max_occurs, length))
        def gds_validate_builtin_ST_(
                self, validator, value, input_name,
                min_occurs=None, max_occurs=None, required=None):
            if value is not None:
                try:
                    validator(value, input_name=input_name)
                except GDSParseError as parse_error:
                    self.gds_collector_.add_message(str(parse_error))
        def gds_validate_defined_ST_(
                self, validator, value, input_name,
                min_occurs=None, max_occurs=None, required=None):
            if value is not None:
                try:
                    validator(value)
                except GDSParseError as parse_error:
                    self.gds_collector_.add_message(str(parse_error))
        def gds_str_lower(self, instring):
            return instring.lower()
        def get_path_(self, node):
            path_list = []
            self.get_path_list_(node, path_list)
            path_list.reverse()
            path = '/'.join(path_list)
            return path
        Tag_strip_pattern_ = re_.compile(r'\{.*\}')
        def get_path_list_(self, node, path_list):
            if node is None:
                return
            tag = GeneratedsSuper.Tag_strip_pattern_.sub('', node.tag)
            if tag:
                path_list.append(tag)
            self.get_path_list_(node.getparent(), path_list)
        def get_class_obj_(self, node, default_class=None):
            class_obj1 = default_class
            if 'xsi' in node.nsmap:
                classname = node.get('{%s}type' % node.nsmap['xsi'])
                if classname is not None:
                    names = classname.split(':')
                    if len(names) == 2:
                        classname = names[1]
                    class_obj2 = globals().get(classname)
                    if class_obj2 is not None:
                        class_obj1 = class_obj2
            return class_obj1
        def gds_build_any(self, node, type_name=None):
            # provide default value in case option --disable-xml is used.
            content = ""
            content = etree_.tostring(node, encoding="unicode")
            return content
        @classmethod
        def gds_reverse_node_mapping(cls, mapping):
            return dict(((v, k) for k, v in mapping.items()))
        @staticmethod
        def gds_encode(instring):
            return instring
        @staticmethod
        def convert_unicode(instring):
            if isinstance(instring, str):
                result = quote_xml(instring)
            else:
                result = GeneratedsSuper.gds_encode(str(instring))
            return result
        def __eq__(self, other):
            def excl_select_objs_(obj):
                return (obj[0] != 'parent_object_' and
                        obj[0] != 'gds_collector_')
            if type(self) != type(other):
                return False
            return all(x == y for x, y in zip_longest(
                filter(excl_select_objs_, self.__dict__.items()),
                filter(excl_select_objs_, other.__dict__.items())))
        def __ne__(self, other):
            return not self.__eq__(other)
        # Django ETL transform hooks.
        def gds_djo_etl_transform(self):
            pass
        def gds_djo_etl_transform_db_obj(self, dbobj):
            pass
        # SQLAlchemy ETL transform hooks.
        def gds_sqa_etl_transform(self):
            return 0, None
        def gds_sqa_etl_transform_db_obj(self, dbobj):
            pass
        def gds_get_node_lineno_(self):
            if (hasattr(self, "gds_elementtree_node_") and
                    self.gds_elementtree_node_ is not None):
                return ' near line {}'.format(
                    self.gds_elementtree_node_.sourceline)
            else:
                return ""
    
    
    def getSubclassFromModule_(module, class_):
        '''Get the subclass of a class from a specific module.'''
        name = class_.__name__ + 'Sub'
        if hasattr(module, name):
            return getattr(module, name)
        else:
            return None


#
# If you have installed IPython you can uncomment and use the following.
# IPython is available from http://ipython.scipy.org/.
#

## from IPython.Shell import IPShellEmbed
## args = ''
## ipshell = IPShellEmbed(args,
##     banner = 'Dropping into IPython',
##     exit_msg = 'Leaving Interpreter, back to program.')

# Then use the following line where and when you want to drop into the
# IPython shell:
#    ipshell('<some message> -- Entering ipshell.\nHit Ctrl-D to exit')

#
# Globals
#

ExternalEncoding = ''
# Set this to false in order to deactivate during export, the use of
# name space prefixes captured from the input document.
UseCapturedNS_ = True
CapturedNsmap_ = {}
Tag_pattern_ = re_.compile(r'({.*})?(.*)')
String_cleanup_pat_ = re_.compile(r"[\n\r\s]+")
Namespace_extract_pat_ = re_.compile(r'{(.*)}(.*)')
CDATA_pattern_ = re_.compile(r"<!\[CDATA\[.*?\]\]>", re_.DOTALL)

# Change this to redirect the generated superclass module to use a
# specific subclass module.
CurrentSubclassModule_ = None

#
# Support/utility functions.
#


def showIndent(outfile, level, pretty_print=True):
    if pretty_print:
        for idx in range(level):
            outfile.write('    ')


def quote_xml(inStr):
    "Escape markup chars, but do not modify CDATA sections."
    if not inStr:
        return ''
    s1 = (isinstance(inStr, str) and inStr or '%s' % inStr)
    s2 = ''
    pos = 0
    matchobjects = CDATA_pattern_.finditer(s1)
    for mo in matchobjects:
        s3 = s1[pos:mo.start()]
        s2 += quote_xml_aux(s3)
        s2 += s1[mo.start():mo.end()]
        pos = mo.end()
    s3 = s1[pos:]
    s2 += quote_xml_aux(s3)
    return s2


def quote_xml_aux(inStr):
    s1 = inStr.replace('&', '&amp;')
    s1 = s1.replace('<', '&lt;')
    s1 = s1.replace('>', '&gt;')
    return s1


def quote_attrib(inStr):
    s1 = (isinstance(inStr, str) and inStr or '%s' % inStr)
    s1 = s1.replace('&', '&amp;')
    s1 = s1.replace('<', '&lt;')
    s1 = s1.replace('>', '&gt;')
    if '"' in s1:
        if "'" in s1:
            s1 = '"%s"' % s1.replace('"', "&quot;")
        else:
            s1 = "'%s'" % s1
    else:
        s1 = '"%s"' % s1
    return s1


def quote_python(inStr):
    s1 = inStr
    if s1.find("'") == -1:
        if s1.find('\n') == -1:
            return "'%s'" % s1
        else:
            return "'''%s'''" % s1
    else:
        if s1.find('"') != -1:
            s1 = s1.replace('"', '\\"')
        if s1.find('\n') == -1:
            return '"%s"' % s1
        else:
            return '"""%s"""' % s1


def get_all_text_(node):
    if node.text is not None:
        text = node.text
    else:
        text = ''
    for child in node:
        if child.tail is not None:
            text += child.tail
    return text


def find_attr_value_(attr_name, node):
    attrs = node.attrib
    attr_parts = attr_name.split(':')
    value = None
    if len(attr_parts) == 1:
        value = attrs.get(attr_name)
    elif len(attr_parts) == 2:
        prefix, name = attr_parts
        namespace = node.nsmap.get(prefix)
        if namespace is not None:
            value = attrs.get('{%s}%s' % (namespace, name, ))
    return value


def encode_str_2_3(instr):
    return instr


class GDSParseError(Exception):
    pass


def raise_parse_error(node, msg):
    if node is not None:
        msg = '%s (element %s/line %d)' % (msg, node.tag, node.sourceline, )
    raise GDSParseError(msg)


class MixedContainer:
    # Constants for category:
    CategoryNone = 0
    CategoryText = 1
    CategorySimple = 2
    CategoryComplex = 3
    # Constants for content_type:
    TypeNone = 0
    TypeText = 1
    TypeString = 2
    TypeInteger = 3
    TypeFloat = 4
    TypeDecimal = 5
    TypeDouble = 6
    TypeBoolean = 7
    TypeBase64 = 8
    def __init__(self, category, content_type, name, value):
        self.category = category
        self.content_type = content_type
        self.name = name
        self.value = value
    def getCategory(self):
        return self.category
    def getContenttype(self, content_type):
        return self.content_type
    def getValue(self):
        return self.value
    def getName(self):
        return self.name
    def export(self, outfile, level, name, namespace,
               pretty_print=True):
        if self.category == MixedContainer.CategoryText:
            # Prevent exporting empty content as empty lines.
            if self.value.strip():
                outfile.write(self.value)
        elif self.category == MixedContainer.CategorySimple:
            self.exportSimple(outfile, level, name)
        else:    # category == MixedContainer.CategoryComplex
            self.value.export(
                outfile, level, namespace, name_=name,
                pretty_print=pretty_print)
    def exportSimple(self, outfile, level, name):
        if self.content_type == MixedContainer.TypeString:
            outfile.write('<%s>%s</%s>' % (
                self.name, self.value, self.name))
        elif self.content_type == MixedContainer.TypeInteger or \
                self.content_type == MixedContainer.TypeBoolean:
            outfile.write('<%s>%d</%s>' % (
                self.name, self.value, self.name))
        elif self.content_type == MixedContainer.TypeFloat or \
                self.content_type == MixedContainer.TypeDecimal:
            outfile.write('<%s>%f</%s>' % (
                self.name, self.value, self.name))
        elif self.content_type == MixedContainer.TypeDouble:
            outfile.write('<%s>%g</%s>' % (
                self.name, self.value, self.name))
        elif self.content_type == MixedContainer.TypeBase64:
            outfile.write('<%s>%s</%s>' % (
                self.name,
                base64.b64encode(self.value),
                self.name))
    def to_etree(self, element):
        if self.category == MixedContainer.CategoryText:
            # Prevent exporting empty content as empty lines.
            if self.value.strip():
                if len(element) > 0:
                    if element[-1].tail is None:
                        element[-1].tail = self.value
                    else:
                        element[-1].tail += self.value
                else:
                    if element.text is None:
                        element.text = self.value
                    else:
                        element.text += self.value
        elif self.category == MixedContainer.CategorySimple:
            subelement = etree_.SubElement(
                element, '%s' % self.name)
            subelement.text = self.to_etree_simple()
        else:    # category == MixedContainer.CategoryComplex
            self.value.to_etree(element)
    def to_etree_simple(self):
        if self.content_type == MixedContainer.TypeString:
            text = self.value
        elif (self.content_type == MixedContainer.TypeInteger or
                self.content_type == MixedContainer.TypeBoolean):
            text = '%d' % self.value
        elif (self.content_type == MixedContainer.TypeFloat or
                self.content_type == MixedContainer.TypeDecimal):
            text = '%f' % self.value
        elif self.content_type == MixedContainer.TypeDouble:
            text = '%g' % self.value
        elif self.content_type == MixedContainer.TypeBase64:
            text = '%s' % base64.b64encode(self.value)
        return text
    def exportLiteral(self, outfile, level, name):
        if self.category == MixedContainer.CategoryText:
            showIndent(outfile, level)
            outfile.write(
                'model_.MixedContainer(%d, %d, "%s", "%s"),\n' % (
                    self.category, self.content_type,
                    self.name, self.value))
        elif self.category == MixedContainer.CategorySimple:
            showIndent(outfile, level)
            outfile.write(
                'model_.MixedContainer(%d, %d, "%s", "%s"),\n' % (
                    self.category, self.content_type,
                    self.name, self.value))
        else:    # category == MixedContainer.CategoryComplex
            showIndent(outfile, level)
            outfile.write(
                'model_.MixedContainer(%d, %d, "%s",\n' % (
                    self.category, self.content_type, self.name,))
            self.value.exportLiteral(outfile, level + 1)
            showIndent(outfile, level)
            outfile.write(')\n')


class MemberSpec_(object):
    def __init__(self, name='', data_type='', container=0,
            optional=0, child_attrs=None, choice=None):
        self.name = name
        self.data_type = data_type
        self.container = container
        self.child_attrs = child_attrs
        self.choice = choice
        self.optional = optional
    def set_name(self, name): self.name = name
    def get_name(self): return self.name
    def set_data_type(self, data_type): self.data_type = data_type
    def get_data_type_chain(self): return self.data_type
    def get_data_type(self):
        if isinstance(self.data_type, list):
            if len(self.data_type) > 0:
                return self.data_type[-1]
            else:
                return 'xs:string'
        else:
            return self.data_type
    def set_container(self, container): self.container = container
    def get_container(self): return self.container
    def set_child_attrs(self, child_attrs): self.child_attrs = child_attrs
    def get_child_attrs(self): return self.child_attrs
    def set_choice(self, choice): self.choice = choice
    def get_choice(self): return self.choice
    def set_optional(self, optional): self.optional = optional
    def get_optional(self): return self.optional


def _cast(typ, value):
    if typ is None or value is None:
        return value
    return typ(value)

#
# Data representation classes.
#


class datafile(GeneratedsSuper):
    __hash__ = GeneratedsSuper.__hash__
    subclass = None
    superclass = None
    def __init__(self, build_=None, debug='no', header=None, game=None, gds_collector_=None, **kwargs_):
        self.gds_collector_ = gds_collector_
        self.gds_elementtree_node_ = None
        self.original_tagname_ = None
        self.parent_object_ = kwargs_.get('parent_object_')
        self.ns_prefix_ = None
        self.build_ = _cast(None, build_)
        self.build__nsprefix_ = None
        self.debug = _cast(None, debug)
        self.debug_nsprefix_ = None
        self.header = header
        self.header_nsprefix_ = None
        if game is None:
            self.game = []
        else:
            self.game = game
        self.game_nsprefix_ = None
    def factory(*args_, **kwargs_):
        if CurrentSubclassModule_ is not None:
            subclass = getSubclassFromModule_(
                CurrentSubclassModule_, datafile)
            if subclass is not None:
                return subclass(*args_, **kwargs_)
        if datafile.subclass:
            return datafile.subclass(*args_, **kwargs_)
        else:
            return datafile(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_ns_prefix_(self):
        return self.ns_prefix_
    def set_ns_prefix_(self, ns_prefix):
        self.ns_prefix_ = ns_prefix
    def get_header(self):
        return self.header
    def set_header(self, header):
        self.header = header
    def get_game(self):
        return self.game
    def set_game(self, game):
        self.game = game
    def add_game(self, value):
        self.game.append(value)
    def insert_game_at(self, index, value):
        self.game.insert(index, value)
    def replace_game_at(self, index, value):
        self.game[index] = value
    def get_build(self):
        return self.build_
    def set_build(self, build_):
        self.build_ = build_
    def get_debug(self):
        return self.debug
    def set_debug(self, debug):
        self.debug = debug
    def hasContent_(self):
        if (
            self.header is not None or
            self.game
        ):
            return True
        else:
            return False
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='datafile', pretty_print=True):
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('datafile')
        if imported_ns_def_ is not None:
            namespacedef_ = imported_ns_def_
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.original_tagname_ is not None:
            name_ = self.original_tagname_
        if UseCapturedNS_ and self.ns_prefix_:
            namespaceprefix_ = self.ns_prefix_ + ':'
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = set()
        self.exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='datafile')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='datafile', pretty_print=pretty_print)
            showIndent(outfile, level, pretty_print)
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='datafile'):
        if self.build_ is not None and 'build_' not in already_processed:
            already_processed.add('build_')
            outfile.write(' build=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.build_), input_name='build')), ))
        if self.debug != "no" and 'debug' not in already_processed:
            already_processed.add('debug')
            outfile.write(' debug=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.debug), input_name='debug')), ))
    def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='datafile', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.header is not None:
            namespaceprefix_ = self.header_nsprefix_ + ':' if (UseCapturedNS_ and self.header_nsprefix_) else ''
            self.header.export(outfile, level, namespaceprefix_, namespacedef_='', name_='header', pretty_print=pretty_print)
        for game_ in self.game:
            namespaceprefix_ = self.game_nsprefix_ + ':' if (UseCapturedNS_ and self.game_nsprefix_) else ''
            game_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='game', pretty_print=pretty_print)
    def build(self, node, gds_collector_=None):
        self.gds_collector_ = gds_collector_
        if SaveElementTreeNode:
            self.gds_elementtree_node_ = node
        already_processed = set()
        self.ns_prefix_ = get_(node, 'prefix')
        self.buildAttributes(node, node.attrib, already_processed)
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
        return self
    def buildAttributes(self, node, attrs, already_processed):
        value = find_attr_value_('build', node)
        if value is not None and 'build' not in already_processed:
            already_processed.add('build')
            self.build_ = value
        value = find_attr_value_('debug', node)
        if value is not None and 'debug' not in already_processed:
            already_processed.add('debug')
            self.debug = value
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
        if nodeName_ == 'header':
            obj_ = header.factory(parent_object_=self)
            obj_.build(child_, gds_collector_=gds_collector_)
            self.header = obj_
            obj_.original_tagname_ = 'header'
        elif nodeName_ == 'game':
            obj_ = game.factory(parent_object_=self)
            obj_.build(child_, gds_collector_=gds_collector_)
            self.game.append(obj_)
            obj_.original_tagname_ = 'game'
# end class datafile


class header(GeneratedsSuper):
    __hash__ = GeneratedsSuper.__hash__
    subclass = None
    superclass = None
    def __init__(self, name=None, description=None, category=None, version=None, date=None, author=None, email=None, homepage=None, url=None, comment=None, clrmamepro=None, romcenter=None, gds_collector_=None, **kwargs_):
        self.gds_collector_ = gds_collector_
        self.gds_elementtree_node_ = None
        self.original_tagname_ = None
        self.parent_object_ = kwargs_.get('parent_object_')
        self.ns_prefix_ = None
        self.name = name
        self.name_nsprefix_ = None
        self.description = description
        self.description_nsprefix_ = None
        self.category = category
        self.category_nsprefix_ = None
        self.version = version
        self.version_nsprefix_ = None
        self.date = date
        self.date_nsprefix_ = None
        self.author = author
        self.author_nsprefix_ = None
        self.email = email
        self.email_nsprefix_ = None
        self.homepage = homepage
        self.homepage_nsprefix_ = None
        self.url = url
        self.url_nsprefix_ = None
        self.comment = comment
        self.comment_nsprefix_ = None
        self.clrmamepro = clrmamepro
        self.clrmamepro_nsprefix_ = None
        self.romcenter = romcenter
        self.romcenter_nsprefix_ = None
    def factory(*args_, **kwargs_):
        if CurrentSubclassModule_ is not None:
            subclass = getSubclassFromModule_(
                CurrentSubclassModule_, header)
            if subclass is not None:
                return subclass(*args_, **kwargs_)
        if header.subclass:
            return header.subclass(*args_, **kwargs_)
        else:
            return header(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_ns_prefix_(self):
        return self.ns_prefix_
    def set_ns_prefix_(self, ns_prefix):
        self.ns_prefix_ = ns_prefix
    def get_name(self):
        return self.name
    def set_name(self, name):
        self.name = name
    def get_description(self):
        return self.description
    def set_description(self, description):
        self.description = description
    def get_category(self):
        return self.category
    def set_category(self, category):
        self.category = category
    def get_version(self):
        return self.version
    def set_version(self, version):
        self.version = version
    def get_date(self):
        return self.date
    def set_date(self, date):
        self.date = date
    def get_author(self):
        return self.author
    def set_author(self, author):
        self.author = author
    def get_email(self):
        return self.email
    def set_email(self, email):
        self.email = email
    def get_homepage(self):
        return self.homepage
    def set_homepage(self, homepage):
        self.homepage = homepage
    def get_url(self):
        return self.url
    def set_url(self, url):
        self.url = url
    def get_comment(self):
        return self.comment
    def set_comment(self, comment):
        self.comment = comment
    def get_clrmamepro(self):
        return self.clrmamepro
    def set_clrmamepro(self, clrmamepro):
        self.clrmamepro = clrmamepro
    def get_romcenter(self):
        return self.romcenter
    def set_romcenter(self, romcenter):
        self.romcenter = romcenter
    def hasContent_(self):
        if (
            self.name is not None or
            self.description is not None or
            self.category is not None or
            self.version is not None or
            self.date is not None or
            self.author is not None or
            self.email is not None or
            self.homepage is not None or
            self.url is not None or
            self.comment is not None or
            self.clrmamepro is not None or
            self.romcenter is not None
        ):
            return True
        else:
            return False
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='header', pretty_print=True):
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('header')
        if imported_ns_def_ is not None:
            namespacedef_ = imported_ns_def_
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.original_tagname_ is not None:
            name_ = self.original_tagname_
        if UseCapturedNS_ and self.ns_prefix_:
            namespaceprefix_ = self.ns_prefix_ + ':'
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = set()
        self.exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='header')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='header', pretty_print=pretty_print)
            showIndent(outfile, level, pretty_print)
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='header'):
        pass
    def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='header', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.name is not None:
            namespaceprefix_ = self.name_nsprefix_ + ':' if (UseCapturedNS_ and self.name_nsprefix_) else ''
            showIndent(outfile, level, pretty_print)
            outfile.write('<%sname>%s</%sname>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.name), input_name='name')), namespaceprefix_ , eol_))
        if self.description is not None:
            namespaceprefix_ = self.description_nsprefix_ + ':' if (UseCapturedNS_ and self.description_nsprefix_) else ''
            showIndent(outfile, level, pretty_print)
            outfile.write('<%sdescription>%s</%sdescription>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.description), input_name='description')), namespaceprefix_ , eol_))
        if self.category is not None:
            namespaceprefix_ = self.category_nsprefix_ + ':' if (UseCapturedNS_ and self.category_nsprefix_) else ''
            showIndent(outfile, level, pretty_print)
            outfile.write('<%scategory>%s</%scategory>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.category), input_name='category')), namespaceprefix_ , eol_))
        if self.version is not None:
            namespaceprefix_ = self.version_nsprefix_ + ':' if (UseCapturedNS_ and self.version_nsprefix_) else ''
            showIndent(outfile, level, pretty_print)
            outfile.write('<%sversion>%s</%sversion>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.version), input_name='version')), namespaceprefix_ , eol_))
        if self.date is not None:
            namespaceprefix_ = self.date_nsprefix_ + ':' if (UseCapturedNS_ and self.date_nsprefix_) else ''
            showIndent(outfile, level, pretty_print)
            outfile.write('<%sdate>%s</%sdate>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.date), input_name='date')), namespaceprefix_ , eol_))
        if self.author is not None:
            namespaceprefix_ = self.author_nsprefix_ + ':' if (UseCapturedNS_ and self.author_nsprefix_) else ''
            showIndent(outfile, level, pretty_print)
            outfile.write('<%sauthor>%s</%sauthor>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.author), input_name='author')), namespaceprefix_ , eol_))
        if self.email is not None:
            namespaceprefix_ = self.email_nsprefix_ + ':' if (UseCapturedNS_ and self.email_nsprefix_) else ''
            showIndent(outfile, level, pretty_print)
            outfile.write('<%semail>%s</%semail>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.email), input_name='email')), namespaceprefix_ , eol_))
        if self.homepage is not None:
            namespaceprefix_ = self.homepage_nsprefix_ + ':' if (UseCapturedNS_ and self.homepage_nsprefix_) else ''
            showIndent(outfile, level, pretty_print)
            outfile.write('<%shomepage>%s</%shomepage>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.homepage), input_name='homepage')), namespaceprefix_ , eol_))
        if self.url is not None:
            namespaceprefix_ = self.url_nsprefix_ + ':' if (UseCapturedNS_ and self.url_nsprefix_) else ''
            showIndent(outfile, level, pretty_print)
            outfile.write('<%surl>%s</%surl>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.url), input_name='url')), namespaceprefix_ , eol_))
        if self.comment is not None:
            namespaceprefix_ = self.comment_nsprefix_ + ':' if (UseCapturedNS_ and self.comment_nsprefix_) else ''
            showIndent(outfile, level, pretty_print)
            outfile.write('<%scomment>%s</%scomment>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.comment), input_name='comment')), namespaceprefix_ , eol_))
        if self.clrmamepro is not None:
            namespaceprefix_ = self.clrmamepro_nsprefix_ + ':' if (UseCapturedNS_ and self.clrmamepro_nsprefix_) else ''
            self.clrmamepro.export(outfile, level, namespaceprefix_, namespacedef_='', name_='clrmamepro', pretty_print=pretty_print)
        if self.romcenter is not None:
            namespaceprefix_ = self.romcenter_nsprefix_ + ':' if (UseCapturedNS_ and self.romcenter_nsprefix_) else ''
            self.romcenter.export(outfile, level, namespaceprefix_, namespacedef_='', name_='romcenter', pretty_print=pretty_print)
    def build(self, node, gds_collector_=None):
        self.gds_collector_ = gds_collector_
        if SaveElementTreeNode:
            self.gds_elementtree_node_ = node
        already_processed = set()
        self.ns_prefix_ = get_(node, 'prefix')
        self.buildAttributes(node, node.attrib, already_processed)
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
        return self
    def buildAttributes(self, node, attrs, already_processed):
        pass
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
        if nodeName_ == 'name':
            value_ = child_.text
            value_ = self.gds_parse_string(value_, node, 'name')
            value_ = self.gds_validate_string(value_, node, 'name')
            self.name = value_
            self.name_nsprefix_ = get_(child_, 'prefix')
        elif nodeName_ == 'description':
            value_ = child_.text
            value_ = self.gds_parse_string(value_, node, 'description')
            value_ = self.gds_validate_string(value_, node, 'description')
            self.description = value_
            self.description_nsprefix_ = get_(child_, 'prefix')
        elif nodeName_ == 'category':
            value_ = child_.text
            value_ = self.gds_parse_string(value_, node, 'category')
            value_ = self.gds_validate_string(value_, node, 'category')
            self.category = value_
            self.category_nsprefix_ = get_(child_, 'prefix')
        elif nodeName_ == 'version':
            value_ = child_.text
            value_ = self.gds_parse_string(value_, node, 'version')
            value_ = self.gds_validate_string(value_, node, 'version')
            self.version = value_
            self.version_nsprefix_ = get_(child_, 'prefix')
        elif nodeName_ == 'date':
            value_ = child_.text
            value_ = self.gds_parse_string(value_, node, 'date')
            value_ = self.gds_validate_string(value_, node, 'date')
            self.date = value_
            self.date_nsprefix_ = get_(child_, 'prefix')
        elif nodeName_ == 'author':
            value_ = child_.text
            value_ = self.gds_parse_string(value_, node, 'author')
            value_ = self.gds_validate_string(value_, node, 'author')
            self.author = value_
            self.author_nsprefix_ = get_(child_, 'prefix')
        elif nodeName_ == 'email':
            value_ = child_.text
            value_ = self.gds_parse_string(value_, node, 'email')
            value_ = self.gds_validate_string(value_, node, 'email')
            self.email = value_
            self.email_nsprefix_ = get_(child_, 'prefix')
        elif nodeName_ == 'homepage':
            value_ = child_.text
            value_ = self.gds_parse_string(value_, node, 'homepage')
            value_ = self.gds_validate_string(value_, node, 'homepage')
            self.homepage = value_
            self.homepage_nsprefix_ = get_(child_, 'prefix')
        elif nodeName_ == 'url':
            value_ = child_.text
            value_ = self.gds_parse_string(value_, node, 'url')
            value_ = self.gds_validate_string(value_, node, 'url')
            self.url = value_
            self.url_nsprefix_ = get_(child_, 'prefix')
        elif nodeName_ == 'comment':
            value_ = child_.text
            value_ = self.gds_parse_string(value_, node, 'comment')
            value_ = self.gds_validate_string(value_, node, 'comment')
            self.comment = value_
            self.comment_nsprefix_ = get_(child_, 'prefix')
        elif nodeName_ == 'clrmamepro':
            obj_ = clrmamepro.factory(parent_object_=self)
            obj_.build(child_, gds_collector_=gds_collector_)
            self.clrmamepro = obj_
            obj_.original_tagname_ = 'clrmamepro'
        elif nodeName_ == 'romcenter':
            obj_ = romcenter.factory(parent_object_=self)
            obj_.build(child_, gds_collector_=gds_collector_)
            self.romcenter = obj_
            obj_.original_tagname_ = 'romcenter'
# end class header


class clrmamepro(GeneratedsSuper):
    __hash__ = GeneratedsSuper.__hash__
    subclass = None
    superclass = None
    def __init__(self, header=None, forcemerging='split', forcenodump='obsolete', forcepacking='zip', gds_collector_=None, **kwargs_):
        self.gds_collector_ = gds_collector_
        self.gds_elementtree_node_ = None
        self.original_tagname_ = None
        self.parent_object_ = kwargs_.get('parent_object_')
        self.ns_prefix_ = None
        self.header = _cast(None, header)
        self.header_nsprefix_ = None
        self.forcemerging = _cast(None, forcemerging)
        self.forcemerging_nsprefix_ = None
        self.forcenodump = _cast(None, forcenodump)
        self.forcenodump_nsprefix_ = None
        self.forcepacking = _cast(None, forcepacking)
        self.forcepacking_nsprefix_ = None
    def factory(*args_, **kwargs_):
        if CurrentSubclassModule_ is not None:
            subclass = getSubclassFromModule_(
                CurrentSubclassModule_, clrmamepro)
            if subclass is not None:
                return subclass(*args_, **kwargs_)
        if clrmamepro.subclass:
            return clrmamepro.subclass(*args_, **kwargs_)
        else:
            return clrmamepro(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_ns_prefix_(self):
        return self.ns_prefix_
    def set_ns_prefix_(self, ns_prefix):
        self.ns_prefix_ = ns_prefix
    def get_header(self):
        return self.header
    def set_header(self, header):
        self.header = header
    def get_forcemerging(self):
        return self.forcemerging
    def set_forcemerging(self, forcemerging):
        self.forcemerging = forcemerging
    def get_forcenodump(self):
        return self.forcenodump
    def set_forcenodump(self, forcenodump):
        self.forcenodump = forcenodump
    def get_forcepacking(self):
        return self.forcepacking
    def set_forcepacking(self, forcepacking):
        self.forcepacking = forcepacking
    def hasContent_(self):
        if (

        ):
            return True
        else:
            return False
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='clrmamepro', pretty_print=True):
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('clrmamepro')
        if imported_ns_def_ is not None:
            namespacedef_ = imported_ns_def_
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.original_tagname_ is not None:
            name_ = self.original_tagname_
        if UseCapturedNS_ and self.ns_prefix_:
            namespaceprefix_ = self.ns_prefix_ + ':'
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = set()
        self.exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='clrmamepro')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='clrmamepro', pretty_print=pretty_print)
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='clrmamepro'):
        if self.header is not None and 'header' not in already_processed:
            already_processed.add('header')
            outfile.write(' header=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.header), input_name='header')), ))
        if self.forcemerging != "split" and 'forcemerging' not in already_processed:
            already_processed.add('forcemerging')
            outfile.write(' forcemerging=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.forcemerging), input_name='forcemerging')), ))
        if self.forcenodump != "obsolete" and 'forcenodump' not in already_processed:
            already_processed.add('forcenodump')
            outfile.write(' forcenodump=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.forcenodump), input_name='forcenodump')), ))
        if self.forcepacking != "zip" and 'forcepacking' not in already_processed:
            already_processed.add('forcepacking')
            outfile.write(' forcepacking=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.forcepacking), input_name='forcepacking')), ))
    def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='clrmamepro', fromsubclass_=False, pretty_print=True):
        pass
    def build(self, node, gds_collector_=None):
        self.gds_collector_ = gds_collector_
        if SaveElementTreeNode:
            self.gds_elementtree_node_ = node
        already_processed = set()
        self.ns_prefix_ = get_(node, 'prefix')
        self.buildAttributes(node, node.attrib, already_processed)
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
        return self
    def buildAttributes(self, node, attrs, already_processed):
        value = find_attr_value_('header', node)
        if value is not None and 'header' not in already_processed:
            already_processed.add('header')
            self.header = value
        value = find_attr_value_('forcemerging', node)
        if value is not None and 'forcemerging' not in already_processed:
            already_processed.add('forcemerging')
            self.forcemerging = value
        value = find_attr_value_('forcenodump', node)
        if value is not None and 'forcenodump' not in already_processed:
            already_processed.add('forcenodump')
            self.forcenodump = value
        value = find_attr_value_('forcepacking', node)
        if value is not None and 'forcepacking' not in already_processed:
            already_processed.add('forcepacking')
            self.forcepacking = value
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
        pass
# end class clrmamepro


class romcenter(GeneratedsSuper):
    __hash__ = GeneratedsSuper.__hash__
    subclass = None
    superclass = None
    def __init__(self, plugin=None, rommode='split', biosmode='split', samplemode='merged', lockrommode='no', lockbiosmode='no', locksamplemode='no', gds_collector_=None, **kwargs_):
        self.gds_collector_ = gds_collector_
        self.gds_elementtree_node_ = None
        self.original_tagname_ = None
        self.parent_object_ = kwargs_.get('parent_object_')
        self.ns_prefix_ = None
        self.plugin = _cast(None, plugin)
        self.plugin_nsprefix_ = None
        self.rommode = _cast(None, rommode)
        self.rommode_nsprefix_ = None
        self.biosmode = _cast(None, biosmode)
        self.biosmode_nsprefix_ = None
        self.samplemode = _cast(None, samplemode)
        self.samplemode_nsprefix_ = None
        self.lockrommode = _cast(None, lockrommode)
        self.lockrommode_nsprefix_ = None
        self.lockbiosmode = _cast(None, lockbiosmode)
        self.lockbiosmode_nsprefix_ = None
        self.locksamplemode = _cast(None, locksamplemode)
        self.locksamplemode_nsprefix_ = None
    def factory(*args_, **kwargs_):
        if CurrentSubclassModule_ is not None:
            subclass = getSubclassFromModule_(
                CurrentSubclassModule_, romcenter)
            if subclass is not None:
                return subclass(*args_, **kwargs_)
        if romcenter.subclass:
            return romcenter.subclass(*args_, **kwargs_)
        else:
            return romcenter(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_ns_prefix_(self):
        return self.ns_prefix_
    def set_ns_prefix_(self, ns_prefix):
        self.ns_prefix_ = ns_prefix
    def get_plugin(self):
        return self.plugin
    def set_plugin(self, plugin):
        self.plugin = plugin
    def get_rommode(self):
        return self.rommode
    def set_rommode(self, rommode):
        self.rommode = rommode
    def get_biosmode(self):
        return self.biosmode
    def set_biosmode(self, biosmode):
        self.biosmode = biosmode
    def get_samplemode(self):
        return self.samplemode
    def set_samplemode(self, samplemode):
        self.samplemode = samplemode
    def get_lockrommode(self):
        return self.lockrommode
    def set_lockrommode(self, lockrommode):
        self.lockrommode = lockrommode
    def get_lockbiosmode(self):
        return self.lockbiosmode
    def set_lockbiosmode(self, lockbiosmode):
        self.lockbiosmode = lockbiosmode
    def get_locksamplemode(self):
        return self.locksamplemode
    def set_locksamplemode(self, locksamplemode):
        self.locksamplemode = locksamplemode
    def hasContent_(self):
        if (

        ):
            return True
        else:
            return False
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='romcenter', pretty_print=True):
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('romcenter')
        if imported_ns_def_ is not None:
            namespacedef_ = imported_ns_def_
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.original_tagname_ is not None:
            name_ = self.original_tagname_
        if UseCapturedNS_ and self.ns_prefix_:
            namespaceprefix_ = self.ns_prefix_ + ':'
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = set()
        self.exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='romcenter')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='romcenter', pretty_print=pretty_print)
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='romcenter'):
        if self.plugin is not None and 'plugin' not in already_processed:
            already_processed.add('plugin')
            outfile.write(' plugin=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.plugin), input_name='plugin')), ))
        if self.rommode != "split" and 'rommode' not in already_processed:
            already_processed.add('rommode')
            outfile.write(' rommode=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.rommode), input_name='rommode')), ))
        if self.biosmode != "split" and 'biosmode' not in already_processed:
            already_processed.add('biosmode')
            outfile.write(' biosmode=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.biosmode), input_name='biosmode')), ))
        if self.samplemode != "merged" and 'samplemode' not in already_processed:
            already_processed.add('samplemode')
            outfile.write(' samplemode=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.samplemode), input_name='samplemode')), ))
        if self.lockrommode != "no" and 'lockrommode' not in already_processed:
            already_processed.add('lockrommode')
            outfile.write(' lockrommode=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.lockrommode), input_name='lockrommode')), ))
        if self.lockbiosmode != "no" and 'lockbiosmode' not in already_processed:
            already_processed.add('lockbiosmode')
            outfile.write(' lockbiosmode=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.lockbiosmode), input_name='lockbiosmode')), ))
        if self.locksamplemode != "no" and 'locksamplemode' not in already_processed:
            already_processed.add('locksamplemode')
            outfile.write(' locksamplemode=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.locksamplemode), input_name='locksamplemode')), ))
    def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='romcenter', fromsubclass_=False, pretty_print=True):
        pass
    def build(self, node, gds_collector_=None):
        self.gds_collector_ = gds_collector_
        if SaveElementTreeNode:
            self.gds_elementtree_node_ = node
        already_processed = set()
        self.ns_prefix_ = get_(node, 'prefix')
        self.buildAttributes(node, node.attrib, already_processed)
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
        return self
    def buildAttributes(self, node, attrs, already_processed):
        value = find_attr_value_('plugin', node)
        if value is not None and 'plugin' not in already_processed:
            already_processed.add('plugin')
            self.plugin = value
        value = find_attr_value_('rommode', node)
        if value is not None and 'rommode' not in already_processed:
            already_processed.add('rommode')
            self.rommode = value
        value = find_attr_value_('biosmode', node)
        if value is not None and 'biosmode' not in already_processed:
            already_processed.add('biosmode')
            self.biosmode = value
        value = find_attr_value_('samplemode', node)
        if value is not None and 'samplemode' not in already_processed:
            already_processed.add('samplemode')
            self.samplemode = value
        value = find_attr_value_('lockrommode', node)
        if value is not None and 'lockrommode' not in already_processed:
            already_processed.add('lockrommode')
            self.lockrommode = value
        value = find_attr_value_('lockbiosmode', node)
        if value is not None and 'lockbiosmode' not in already_processed:
            already_processed.add('lockbiosmode')
            self.lockbiosmode = value
        value = find_attr_value_('locksamplemode', node)
        if value is not None and 'locksamplemode' not in already_processed:
            already_processed.add('locksamplemode')
            self.locksamplemode = value
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
        pass
# end class romcenter


class game(GeneratedsSuper):
    __hash__ = GeneratedsSuper.__hash__
    subclass = None
    superclass = None
    def __init__(self, name=None, sourcefile=None, isbios='no', cloneof=None, romof=None, sampleof=None, board=None, rebuildto=None, comment=None, description=None, year=None, manufacturer=None, release=None, biosset=None, rom=None, disk=None, sample=None, archive=None, gds_collector_=None, **kwargs_):
        self.gds_collector_ = gds_collector_
        self.gds_elementtree_node_ = None
        self.original_tagname_ = None
        self.parent_object_ = kwargs_.get('parent_object_')
        self.ns_prefix_ = None
        self.name = _cast(None, name)
        self.name_nsprefix_ = None
        self.sourcefile = _cast(None, sourcefile)
        self.sourcefile_nsprefix_ = None
        self.isbios = _cast(None, isbios)
        self.isbios_nsprefix_ = None
        self.cloneof = _cast(None, cloneof)
        self.cloneof_nsprefix_ = None
        self.romof = _cast(None, romof)
        self.romof_nsprefix_ = None
        self.sampleof = _cast(None, sampleof)
        self.sampleof_nsprefix_ = None
        self.board = _cast(None, board)
        self.board_nsprefix_ = None
        self.rebuildto = _cast(None, rebuildto)
        self.rebuildto_nsprefix_ = None
        if comment is None:
            self.comment = []
        else:
            self.comment = comment
        self.comment_nsprefix_ = None
        self.description = description
        self.description_nsprefix_ = None
        self.year = year
        self.year_nsprefix_ = None
        self.manufacturer = manufacturer
        self.manufacturer_nsprefix_ = None
        if release is None:
            self.release = []
        else:
            self.release = release
        self.release_nsprefix_ = None
        if biosset is None:
            self.biosset = []
        else:
            self.biosset = biosset
        self.biosset_nsprefix_ = None
        if rom is None:
            self.rom = []
        else:
            self.rom = rom
        self.rom_nsprefix_ = None
        if disk is None:
            self.disk = []
        else:
            self.disk = disk
        self.disk_nsprefix_ = None
        if sample is None:
            self.sample = []
        else:
            self.sample = sample
        self.sample_nsprefix_ = None
        if archive is None:
            self.archive = []
        else:
            self.archive = archive
        self.archive_nsprefix_ = None
    def factory(*args_, **kwargs_):
        if CurrentSubclassModule_ is not None:
            subclass = getSubclassFromModule_(
                CurrentSubclassModule_, game)
            if subclass is not None:
                return subclass(*args_, **kwargs_)
        if game.subclass:
            return game.subclass(*args_, **kwargs_)
        else:
            return game(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_ns_prefix_(self):
        return self.ns_prefix_
    def set_ns_prefix_(self, ns_prefix):
        self.ns_prefix_ = ns_prefix
    def get_comment(self):
        return self.comment
    def set_comment(self, comment):
        self.comment = comment
    def add_comment(self, value):
        self.comment.append(value)
    def insert_comment_at(self, index, value):
        self.comment.insert(index, value)
    def replace_comment_at(self, index, value):
        self.comment[index] = value
    def get_description(self):
        return self.description
    def set_description(self, description):
        self.description = description
    def get_year(self):
        return self.year
    def set_year(self, year):
        self.year = year
    def get_manufacturer(self):
        return self.manufacturer
    def set_manufacturer(self, manufacturer):
        self.manufacturer = manufacturer
    def get_release(self):
        return self.release
    def set_release(self, release):
        self.release = release
    def add_release(self, value):
        self.release.append(value)
    def insert_release_at(self, index, value):
        self.release.insert(index, value)
    def replace_release_at(self, index, value):
        self.release[index] = value
    def get_biosset(self):
        return self.biosset
    def set_biosset(self, biosset):
        self.biosset = biosset
    def add_biosset(self, value):
        self.biosset.append(value)
    def insert_biosset_at(self, index, value):
        self.biosset.insert(index, value)
    def replace_biosset_at(self, index, value):
        self.biosset[index] = value
    def get_rom(self):
        return self.rom
    def set_rom(self, rom):
        self.rom = rom
    def add_rom(self, value):
        self.rom.append(value)
    def insert_rom_at(self, index, value):
        self.rom.insert(index, value)
    def replace_rom_at(self, index, value):
        self.rom[index] = value
    def get_disk(self):
        return self.disk
    def set_disk(self, disk):
        self.disk = disk
    def add_disk(self, value):
        self.disk.append(value)
    def insert_disk_at(self, index, value):
        self.disk.insert(index, value)
    def replace_disk_at(self, index, value):
        self.disk[index] = value
    def get_sample(self):
        return self.sample
    def set_sample(self, sample):
        self.sample = sample
    def add_sample(self, value):
        self.sample.append(value)
    def insert_sample_at(self, index, value):
        self.sample.insert(index, value)
    def replace_sample_at(self, index, value):
        self.sample[index] = value
    def get_archive(self):
        return self.archive
    def set_archive(self, archive):
        self.archive = archive
    def add_archive(self, value):
        self.archive.append(value)
    def insert_archive_at(self, index, value):
        self.archive.insert(index, value)
    def replace_archive_at(self, index, value):
        self.archive[index] = value
    def get_name(self):
        return self.name
    def set_name(self, name):
        self.name = name
    def get_sourcefile(self):
        return self.sourcefile
    def set_sourcefile(self, sourcefile):
        self.sourcefile = sourcefile
    def get_isbios(self):
        return self.isbios
    def set_isbios(self, isbios):
        self.isbios = isbios
    def get_cloneof(self):
        return self.cloneof
    def set_cloneof(self, cloneof):
        self.cloneof = cloneof
    def get_romof(self):
        return self.romof
    def set_romof(self, romof):
        self.romof = romof
    def get_sampleof(self):
        return self.sampleof
    def set_sampleof(self, sampleof):
        self.sampleof = sampleof
    def get_board(self):
        return self.board
    def set_board(self, board):
        self.board = board
    def get_rebuildto(self):
        return self.rebuildto
    def set_rebuildto(self, rebuildto):
        self.rebuildto = rebuildto
    def hasContent_(self):
        if (
            self.comment or
            self.description is not None or
            self.year is not None or
            self.manufacturer is not None or
            self.release or
            self.biosset or
            self.rom or
            self.disk or
            self.sample or
            self.archive
        ):
            return True
        else:
            return False
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='game', pretty_print=True):
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('game')
        if imported_ns_def_ is not None:
            namespacedef_ = imported_ns_def_
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.original_tagname_ is not None:
            name_ = self.original_tagname_
        if UseCapturedNS_ and self.ns_prefix_:
            namespaceprefix_ = self.ns_prefix_ + ':'
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = set()
        self.exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='game')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='game', pretty_print=pretty_print)
            showIndent(outfile, level, pretty_print)
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='game'):
        if self.name is not None and 'name' not in already_processed:
            already_processed.add('name')
            outfile.write(' name=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.name), input_name='name')), ))
        if self.sourcefile is not None and 'sourcefile' not in already_processed:
            already_processed.add('sourcefile')
            outfile.write(' sourcefile=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.sourcefile), input_name='sourcefile')), ))
        if self.isbios != "no" and 'isbios' not in already_processed:
            already_processed.add('isbios')
            outfile.write(' isbios=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.isbios), input_name='isbios')), ))
        if self.cloneof is not None and 'cloneof' not in already_processed:
            already_processed.add('cloneof')
            outfile.write(' cloneof=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.cloneof), input_name='cloneof')), ))
        if self.romof is not None and 'romof' not in already_processed:
            already_processed.add('romof')
            outfile.write(' romof=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.romof), input_name='romof')), ))
        if self.sampleof is not None and 'sampleof' not in already_processed:
            already_processed.add('sampleof')
            outfile.write(' sampleof=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.sampleof), input_name='sampleof')), ))
        if self.board is not None and 'board' not in already_processed:
            already_processed.add('board')
            outfile.write(' board=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.board), input_name='board')), ))
        if self.rebuildto is not None and 'rebuildto' not in already_processed:
            already_processed.add('rebuildto')
            outfile.write(' rebuildto=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.rebuildto), input_name='rebuildto')), ))
    def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='game', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        for comment_ in self.comment:
            namespaceprefix_ = self.comment_nsprefix_ + ':' if (UseCapturedNS_ and self.comment_nsprefix_) else ''
            showIndent(outfile, level, pretty_print)
            outfile.write('<%scomment>%s</%scomment>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(comment_), input_name='comment')), namespaceprefix_ , eol_))
        if self.description is not None:
            namespaceprefix_ = self.description_nsprefix_ + ':' if (UseCapturedNS_ and self.description_nsprefix_) else ''
            showIndent(outfile, level, pretty_print)
            outfile.write('<%sdescription>%s</%sdescription>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.description), input_name='description')), namespaceprefix_ , eol_))
        if self.year is not None:
            namespaceprefix_ = self.year_nsprefix_ + ':' if (UseCapturedNS_ and self.year_nsprefix_) else ''
            showIndent(outfile, level, pretty_print)
            outfile.write('<%syear>%s</%syear>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.year), input_name='year')), namespaceprefix_ , eol_))
        if self.manufacturer is not None:
            namespaceprefix_ = self.manufacturer_nsprefix_ + ':' if (UseCapturedNS_ and self.manufacturer_nsprefix_) else ''
            showIndent(outfile, level, pretty_print)
            outfile.write('<%smanufacturer>%s</%smanufacturer>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.manufacturer), input_name='manufacturer')), namespaceprefix_ , eol_))
        for release_ in self.release:
            namespaceprefix_ = self.release_nsprefix_ + ':' if (UseCapturedNS_ and self.release_nsprefix_) else ''
            release_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='release', pretty_print=pretty_print)
        for biosset_ in self.biosset:
            namespaceprefix_ = self.biosset_nsprefix_ + ':' if (UseCapturedNS_ and self.biosset_nsprefix_) else ''
            biosset_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='biosset', pretty_print=pretty_print)
        for rom_ in self.rom:
            namespaceprefix_ = self.rom_nsprefix_ + ':' if (UseCapturedNS_ and self.rom_nsprefix_) else ''
            rom_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='rom', pretty_print=pretty_print)
        for disk_ in self.disk:
            namespaceprefix_ = self.disk_nsprefix_ + ':' if (UseCapturedNS_ and self.disk_nsprefix_) else ''
            disk_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='disk', pretty_print=pretty_print)
        for sample_ in self.sample:
            namespaceprefix_ = self.sample_nsprefix_ + ':' if (UseCapturedNS_ and self.sample_nsprefix_) else ''
            sample_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='sample', pretty_print=pretty_print)
        for archive_ in self.archive:
            namespaceprefix_ = self.archive_nsprefix_ + ':' if (UseCapturedNS_ and self.archive_nsprefix_) else ''
            archive_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='archive', pretty_print=pretty_print)
    def build(self, node, gds_collector_=None):
        self.gds_collector_ = gds_collector_
        if SaveElementTreeNode:
            self.gds_elementtree_node_ = node
        already_processed = set()
        self.ns_prefix_ = get_(node, 'prefix')
        self.buildAttributes(node, node.attrib, already_processed)
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
        return self
    def buildAttributes(self, node, attrs, already_processed):
        value = find_attr_value_('name', node)
        if value is not None and 'name' not in already_processed:
            already_processed.add('name')
            self.name = value
        value = find_attr_value_('sourcefile', node)
        if value is not None and 'sourcefile' not in already_processed:
            already_processed.add('sourcefile')
            self.sourcefile = value
        value = find_attr_value_('isbios', node)
        if value is not None and 'isbios' not in already_processed:
            already_processed.add('isbios')
            self.isbios = value
        value = find_attr_value_('cloneof', node)
        if value is not None and 'cloneof' not in already_processed:
            already_processed.add('cloneof')
            self.cloneof = value
        value = find_attr_value_('romof', node)
        if value is not None and 'romof' not in already_processed:
            already_processed.add('romof')
            self.romof = value
        value = find_attr_value_('sampleof', node)
        if value is not None and 'sampleof' not in already_processed:
            already_processed.add('sampleof')
            self.sampleof = value
        value = find_attr_value_('board', node)
        if value is not None and 'board' not in already_processed:
            already_processed.add('board')
            self.board = value
        value = find_attr_value_('rebuildto', node)
        if value is not None and 'rebuildto' not in already_processed:
            already_processed.add('rebuildto')
            self.rebuildto = value
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
        if nodeName_ == 'comment':
            value_ = child_.text
            value_ = self.gds_parse_string(value_, node, 'comment')
            value_ = self.gds_validate_string(value_, node, 'comment')
            self.comment.append(value_)
            self.comment_nsprefix_ = get_(child_, 'prefix')
        elif nodeName_ == 'description':
            value_ = child_.text
            value_ = self.gds_parse_string(value_, node, 'description')
            value_ = self.gds_validate_string(value_, node, 'description')
            self.description = value_
            self.description_nsprefix_ = get_(child_, 'prefix')
        elif nodeName_ == 'year':
            value_ = child_.text
            value_ = self.gds_parse_string(value_, node, 'year')
            value_ = self.gds_validate_string(value_, node, 'year')
            self.year = value_
            self.year_nsprefix_ = get_(child_, 'prefix')
        elif nodeName_ == 'manufacturer':
            value_ = child_.text
            value_ = self.gds_parse_string(value_, node, 'manufacturer')
            value_ = self.gds_validate_string(value_, node, 'manufacturer')
            self.manufacturer = value_
            self.manufacturer_nsprefix_ = get_(child_, 'prefix')
        elif nodeName_ == 'release':
            obj_ = release.factory(parent_object_=self)
            obj_.build(child_, gds_collector_=gds_collector_)
            self.release.append(obj_)
            obj_.original_tagname_ = 'release'
        elif nodeName_ == 'biosset':
            obj_ = biosset.factory(parent_object_=self)
            obj_.build(child_, gds_collector_=gds_collector_)
            self.biosset.append(obj_)
            obj_.original_tagname_ = 'biosset'
        elif nodeName_ == 'rom':
            obj_ = rom.factory(parent_object_=self)
            obj_.build(child_, gds_collector_=gds_collector_)
            self.rom.append(obj_)
            obj_.original_tagname_ = 'rom'
        elif nodeName_ == 'disk':
            obj_ = disk.factory(parent_object_=self)
            obj_.build(child_, gds_collector_=gds_collector_)
            self.disk.append(obj_)
            obj_.original_tagname_ = 'disk'
        elif nodeName_ == 'sample':
            obj_ = sample.factory(parent_object_=self)
            obj_.build(child_, gds_collector_=gds_collector_)
            self.sample.append(obj_)
            obj_.original_tagname_ = 'sample'
        elif nodeName_ == 'archive':
            obj_ = archive.factory(parent_object_=self)
            obj_.build(child_, gds_collector_=gds_collector_)
            self.archive.append(obj_)
            obj_.original_tagname_ = 'archive'
# end class game


class release(GeneratedsSuper):
    __hash__ = GeneratedsSuper.__hash__
    subclass = None
    superclass = None
    def __init__(self, name=None, region=None, language=None, date=None, default='no', gds_collector_=None, **kwargs_):
        self.gds_collector_ = gds_collector_
        self.gds_elementtree_node_ = None
        self.original_tagname_ = None
        self.parent_object_ = kwargs_.get('parent_object_')
        self.ns_prefix_ = None
        self.name = _cast(None, name)
        self.name_nsprefix_ = None
        self.region = _cast(None, region)
        self.region_nsprefix_ = None
        self.language = _cast(None, language)
        self.language_nsprefix_ = None
        self.date = _cast(None, date)
        self.date_nsprefix_ = None
        self.default = _cast(None, default)
        self.default_nsprefix_ = None
    def factory(*args_, **kwargs_):
        if CurrentSubclassModule_ is not None:
            subclass = getSubclassFromModule_(
                CurrentSubclassModule_, release)
            if subclass is not None:
                return subclass(*args_, **kwargs_)
        if release.subclass:
            return release.subclass(*args_, **kwargs_)
        else:
            return release(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_ns_prefix_(self):
        return self.ns_prefix_
    def set_ns_prefix_(self, ns_prefix):
        self.ns_prefix_ = ns_prefix
    def get_name(self):
        return self.name
    def set_name(self, name):
        self.name = name
    def get_region(self):
        return self.region
    def set_region(self, region):
        self.region = region
    def get_language(self):
        return self.language
    def set_language(self, language):
        self.language = language
    def get_date(self):
        return self.date
    def set_date(self, date):
        self.date = date
    def get_default(self):
        return self.default
    def set_default(self, default):
        self.default = default
    def hasContent_(self):
        if (

        ):
            return True
        else:
            return False
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='release', pretty_print=True):
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('release')
        if imported_ns_def_ is not None:
            namespacedef_ = imported_ns_def_
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.original_tagname_ is not None:
            name_ = self.original_tagname_
        if UseCapturedNS_ and self.ns_prefix_:
            namespaceprefix_ = self.ns_prefix_ + ':'
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = set()
        self.exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='release')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='release', pretty_print=pretty_print)
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='release'):
        if self.name is not None and 'name' not in already_processed:
            already_processed.add('name')
            outfile.write(' name=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.name), input_name='name')), ))
        if self.region is not None and 'region' not in already_processed:
            already_processed.add('region')
            outfile.write(' region=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.region), input_name='region')), ))
        if self.language is not None and 'language' not in already_processed:
            already_processed.add('language')
            outfile.write(' language=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.language), input_name='language')), ))
        if self.date is not None and 'date' not in already_processed:
            already_processed.add('date')
            outfile.write(' date=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.date), input_name='date')), ))
        if self.default != "no" and 'default' not in already_processed:
            already_processed.add('default')
            outfile.write(' default=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.default), input_name='default')), ))
    def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='release', fromsubclass_=False, pretty_print=True):
        pass
    def build(self, node, gds_collector_=None):
        self.gds_collector_ = gds_collector_
        if SaveElementTreeNode:
            self.gds_elementtree_node_ = node
        already_processed = set()
        self.ns_prefix_ = get_(node, 'prefix')
        self.buildAttributes(node, node.attrib, already_processed)
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
        return self
    def buildAttributes(self, node, attrs, already_processed):
        value = find_attr_value_('name', node)
        if value is not None and 'name' not in already_processed:
            already_processed.add('name')
            self.name = value
        value = find_attr_value_('region', node)
        if value is not None and 'region' not in already_processed:
            already_processed.add('region')
            self.region = value
        value = find_attr_value_('language', node)
        if value is not None and 'language' not in already_processed:
            already_processed.add('language')
            self.language = value
        value = find_attr_value_('date', node)
        if value is not None and 'date' not in already_processed:
            already_processed.add('date')
            self.date = value
        value = find_attr_value_('default', node)
        if value is not None and 'default' not in already_processed:
            already_processed.add('default')
            self.default = value
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
        pass
# end class release


class biosset(GeneratedsSuper):
    __hash__ = GeneratedsSuper.__hash__
    subclass = None
    superclass = None
    def __init__(self, name=None, description=None, default='no', gds_collector_=None, **kwargs_):
        self.gds_collector_ = gds_collector_
        self.gds_elementtree_node_ = None
        self.original_tagname_ = None
        self.parent_object_ = kwargs_.get('parent_object_')
        self.ns_prefix_ = None
        self.name = _cast(None, name)
        self.name_nsprefix_ = None
        self.description = _cast(None, description)
        self.description_nsprefix_ = None
        self.default = _cast(None, default)
        self.default_nsprefix_ = None
    def factory(*args_, **kwargs_):
        if CurrentSubclassModule_ is not None:
            subclass = getSubclassFromModule_(
                CurrentSubclassModule_, biosset)
            if subclass is not None:
                return subclass(*args_, **kwargs_)
        if biosset.subclass:
            return biosset.subclass(*args_, **kwargs_)
        else:
            return biosset(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_ns_prefix_(self):
        return self.ns_prefix_
    def set_ns_prefix_(self, ns_prefix):
        self.ns_prefix_ = ns_prefix
    def get_name(self):
        return self.name
    def set_name(self, name):
        self.name = name
    def get_description(self):
        return self.description
    def set_description(self, description):
        self.description = description
    def get_default(self):
        return self.default
    def set_default(self, default):
        self.default = default
    def hasContent_(self):
        if (

        ):
            return True
        else:
            return False
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='biosset', pretty_print=True):
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('biosset')
        if imported_ns_def_ is not None:
            namespacedef_ = imported_ns_def_
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.original_tagname_ is not None:
            name_ = self.original_tagname_
        if UseCapturedNS_ and self.ns_prefix_:
            namespaceprefix_ = self.ns_prefix_ + ':'
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = set()
        self.exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='biosset')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='biosset', pretty_print=pretty_print)
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='biosset'):
        if self.name is not None and 'name' not in already_processed:
            already_processed.add('name')
            outfile.write(' name=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.name), input_name='name')), ))
        if self.description is not None and 'description' not in already_processed:
            already_processed.add('description')
            outfile.write(' description=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.description), input_name='description')), ))
        if self.default != "no" and 'default' not in already_processed:
            already_processed.add('default')
            outfile.write(' default=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.default), input_name='default')), ))
    def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='biosset', fromsubclass_=False, pretty_print=True):
        pass
    def build(self, node, gds_collector_=None):
        self.gds_collector_ = gds_collector_
        if SaveElementTreeNode:
            self.gds_elementtree_node_ = node
        already_processed = set()
        self.ns_prefix_ = get_(node, 'prefix')
        self.buildAttributes(node, node.attrib, already_processed)
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
        return self
    def buildAttributes(self, node, attrs, already_processed):
        value = find_attr_value_('name', node)
        if value is not None and 'name' not in already_processed:
            already_processed.add('name')
            self.name = value
        value = find_attr_value_('description', node)
        if value is not None and 'description' not in already_processed:
            already_processed.add('description')
            self.description = value
        value = find_attr_value_('default', node)
        if value is not None and 'default' not in already_processed:
            already_processed.add('default')
            self.default = value
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
        pass
# end class biosset


class rom(GeneratedsSuper):
    __hash__ = GeneratedsSuper.__hash__
    subclass = None
    superclass = None
    def __init__(self, name=None, size=None, crc=None, sha1=None, md5=None, merge=None, status='good', date=None, gds_collector_=None, **kwargs_):
        self.gds_collector_ = gds_collector_
        self.gds_elementtree_node_ = None
        self.original_tagname_ = None
        self.parent_object_ = kwargs_.get('parent_object_')
        self.ns_prefix_ = None
        self.name = _cast(None, name)
        self.name_nsprefix_ = None
        self.size = _cast(None, size)
        self.size_nsprefix_ = None
        self.crc = _cast(None, crc)
        self.crc_nsprefix_ = None
        self.sha1 = _cast(None, sha1)
        self.sha1_nsprefix_ = None
        self.md5 = _cast(None, md5)
        self.md5_nsprefix_ = None
        self.merge = _cast(None, merge)
        self.merge_nsprefix_ = None
        self.status = _cast(None, status)
        self.status_nsprefix_ = None
        self.date = _cast(None, date)
        self.date_nsprefix_ = None
    def factory(*args_, **kwargs_):
        if CurrentSubclassModule_ is not None:
            subclass = getSubclassFromModule_(
                CurrentSubclassModule_, rom)
            if subclass is not None:
                return subclass(*args_, **kwargs_)
        if rom.subclass:
            return rom.subclass(*args_, **kwargs_)
        else:
            return rom(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_ns_prefix_(self):
        return self.ns_prefix_
    def set_ns_prefix_(self, ns_prefix):
        self.ns_prefix_ = ns_prefix
    def get_name(self):
        return self.name
    def set_name(self, name):
        self.name = name
    def get_size(self):
        return self.size
    def set_size(self, size):
        self.size = size
    def get_crc(self):
        return self.crc
    def set_crc(self, crc):
        self.crc = crc
    def get_sha1(self):
        return self.sha1
    def set_sha1(self, sha1):
        self.sha1 = sha1
    def get_md5(self):
        return self.md5
    def set_md5(self, md5):
        self.md5 = md5
    def get_merge(self):
        return self.merge
    def set_merge(self, merge):
        self.merge = merge
    def get_status(self):
        return self.status
    def set_status(self, status):
        self.status = status
    def get_date(self):
        return self.date
    def set_date(self, date):
        self.date = date
    def hasContent_(self):
        if (

        ):
            return True
        else:
            return False
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='rom', pretty_print=True):
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('rom')
        if imported_ns_def_ is not None:
            namespacedef_ = imported_ns_def_
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.original_tagname_ is not None:
            name_ = self.original_tagname_
        if UseCapturedNS_ and self.ns_prefix_:
            namespaceprefix_ = self.ns_prefix_ + ':'
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = set()
        self.exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='rom')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='rom', pretty_print=pretty_print)
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='rom'):
        if self.name is not None and 'name' not in already_processed:
            already_processed.add('name')
            outfile.write(' name=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.name), input_name='name')), ))
        if self.size is not None and 'size' not in already_processed:
            already_processed.add('size')
            outfile.write(' size=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.size), input_name='size')), ))
        if self.crc is not None and 'crc' not in already_processed:
            already_processed.add('crc')
            outfile.write(' crc=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.crc), input_name='crc')), ))
        if self.sha1 is not None and 'sha1' not in already_processed:
            already_processed.add('sha1')
            outfile.write(' sha1=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.sha1), input_name='sha1')), ))
        if self.md5 is not None and 'md5' not in already_processed:
            already_processed.add('md5')
            outfile.write(' md5=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.md5), input_name='md5')), ))
        if self.merge is not None and 'merge' not in already_processed:
            already_processed.add('merge')
            outfile.write(' merge=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.merge), input_name='merge')), ))
        if self.status != "good" and 'status' not in already_processed:
            already_processed.add('status')
            outfile.write(' status=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.status), input_name='status')), ))
        if self.date is not None and 'date' not in already_processed:
            already_processed.add('date')
            outfile.write(' date=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.date), input_name='date')), ))
    def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='rom', fromsubclass_=False, pretty_print=True):
        pass
    def build(self, node, gds_collector_=None):
        self.gds_collector_ = gds_collector_
        if SaveElementTreeNode:
            self.gds_elementtree_node_ = node
        already_processed = set()
        self.ns_prefix_ = get_(node, 'prefix')
        self.buildAttributes(node, node.attrib, already_processed)
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
        return self
    def buildAttributes(self, node, attrs, already_processed):
        value = find_attr_value_('name', node)
        if value is not None and 'name' not in already_processed:
            already_processed.add('name')
            self.name = value
        value = find_attr_value_('size', node)
        if value is not None and 'size' not in already_processed:
            already_processed.add('size')
            self.size = value
        value = find_attr_value_('crc', node)
        if value is not None and 'crc' not in already_processed:
            already_processed.add('crc')
            self.crc = value
        value = find_attr_value_('sha1', node)
        if value is not None and 'sha1' not in already_processed:
            already_processed.add('sha1')
            self.sha1 = value
        value = find_attr_value_('md5', node)
        if value is not None and 'md5' not in already_processed:
            already_processed.add('md5')
            self.md5 = value
        value = find_attr_value_('merge', node)
        if value is not None and 'merge' not in already_processed:
            already_processed.add('merge')
            self.merge = value
        value = find_attr_value_('status', node)
        if value is not None and 'status' not in already_processed:
            already_processed.add('status')
            self.status = value
        value = find_attr_value_('date', node)
        if value is not None and 'date' not in already_processed:
            already_processed.add('date')
            self.date = value
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
        pass
# end class rom


class disk(GeneratedsSuper):
    __hash__ = GeneratedsSuper.__hash__
    subclass = None
    superclass = None
    def __init__(self, name=None, sha1=None, md5=None, merge=None, status='good', gds_collector_=None, **kwargs_):
        self.gds_collector_ = gds_collector_
        self.gds_elementtree_node_ = None
        self.original_tagname_ = None
        self.parent_object_ = kwargs_.get('parent_object_')
        self.ns_prefix_ = None
        self.name = _cast(None, name)
        self.name_nsprefix_ = None
        self.sha1 = _cast(None, sha1)
        self.sha1_nsprefix_ = None
        self.md5 = _cast(None, md5)
        self.md5_nsprefix_ = None
        self.merge = _cast(None, merge)
        self.merge_nsprefix_ = None
        self.status = _cast(None, status)
        self.status_nsprefix_ = None
    def factory(*args_, **kwargs_):
        if CurrentSubclassModule_ is not None:
            subclass = getSubclassFromModule_(
                CurrentSubclassModule_, disk)
            if subclass is not None:
                return subclass(*args_, **kwargs_)
        if disk.subclass:
            return disk.subclass(*args_, **kwargs_)
        else:
            return disk(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_ns_prefix_(self):
        return self.ns_prefix_
    def set_ns_prefix_(self, ns_prefix):
        self.ns_prefix_ = ns_prefix
    def get_name(self):
        return self.name
    def set_name(self, name):
        self.name = name
    def get_sha1(self):
        return self.sha1
    def set_sha1(self, sha1):
        self.sha1 = sha1
    def get_md5(self):
        return self.md5
    def set_md5(self, md5):
        self.md5 = md5
    def get_merge(self):
        return self.merge
    def set_merge(self, merge):
        self.merge = merge
    def get_status(self):
        return self.status
    def set_status(self, status):
        self.status = status
    def hasContent_(self):
        if (

        ):
            return True
        else:
            return False
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='disk', pretty_print=True):
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('disk')
        if imported_ns_def_ is not None:
            namespacedef_ = imported_ns_def_
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.original_tagname_ is not None:
            name_ = self.original_tagname_
        if UseCapturedNS_ and self.ns_prefix_:
            namespaceprefix_ = self.ns_prefix_ + ':'
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = set()
        self.exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='disk')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='disk', pretty_print=pretty_print)
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='disk'):
        if self.name is not None and 'name' not in already_processed:
            already_processed.add('name')
            outfile.write(' name=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.name), input_name='name')), ))
        if self.sha1 is not None and 'sha1' not in already_processed:
            already_processed.add('sha1')
            outfile.write(' sha1=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.sha1), input_name='sha1')), ))
        if self.md5 is not None and 'md5' not in already_processed:
            already_processed.add('md5')
            outfile.write(' md5=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.md5), input_name='md5')), ))
        if self.merge is not None and 'merge' not in already_processed:
            already_processed.add('merge')
            outfile.write(' merge=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.merge), input_name='merge')), ))
        if self.status != "good" and 'status' not in already_processed:
            already_processed.add('status')
            outfile.write(' status=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.status), input_name='status')), ))
    def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='disk', fromsubclass_=False, pretty_print=True):
        pass
    def build(self, node, gds_collector_=None):
        self.gds_collector_ = gds_collector_
        if SaveElementTreeNode:
            self.gds_elementtree_node_ = node
        already_processed = set()
        self.ns_prefix_ = get_(node, 'prefix')
        self.buildAttributes(node, node.attrib, already_processed)
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
        return self
    def buildAttributes(self, node, attrs, already_processed):
        value = find_attr_value_('name', node)
        if value is not None and 'name' not in already_processed:
            already_processed.add('name')
            self.name = value
        value = find_attr_value_('sha1', node)
        if value is not None and 'sha1' not in already_processed:
            already_processed.add('sha1')
            self.sha1 = value
        value = find_attr_value_('md5', node)
        if value is not None and 'md5' not in already_processed:
            already_processed.add('md5')
            self.md5 = value
        value = find_attr_value_('merge', node)
        if value is not None and 'merge' not in already_processed:
            already_processed.add('merge')
            self.merge = value
        value = find_attr_value_('status', node)
        if value is not None and 'status' not in already_processed:
            already_processed.add('status')
            self.status = value
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
        pass
# end class disk


class sample(GeneratedsSuper):
    __hash__ = GeneratedsSuper.__hash__
    subclass = None
    superclass = None
    def __init__(self, name=None, gds_collector_=None, **kwargs_):
        self.gds_collector_ = gds_collector_
        self.gds_elementtree_node_ = None
        self.original_tagname_ = None
        self.parent_object_ = kwargs_.get('parent_object_')
        self.ns_prefix_ = None
        self.name = _cast(None, name)
        self.name_nsprefix_ = None
    def factory(*args_, **kwargs_):
        if CurrentSubclassModule_ is not None:
            subclass = getSubclassFromModule_(
                CurrentSubclassModule_, sample)
            if subclass is not None:
                return subclass(*args_, **kwargs_)
        if sample.subclass:
            return sample.subclass(*args_, **kwargs_)
        else:
            return sample(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_ns_prefix_(self):
        return self.ns_prefix_
    def set_ns_prefix_(self, ns_prefix):
        self.ns_prefix_ = ns_prefix
    def get_name(self):
        return self.name
    def set_name(self, name):
        self.name = name
    def hasContent_(self):
        if (

        ):
            return True
        else:
            return False
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='sample', pretty_print=True):
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('sample')
        if imported_ns_def_ is not None:
            namespacedef_ = imported_ns_def_
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.original_tagname_ is not None:
            name_ = self.original_tagname_
        if UseCapturedNS_ and self.ns_prefix_:
            namespaceprefix_ = self.ns_prefix_ + ':'
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = set()
        self.exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='sample')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='sample', pretty_print=pretty_print)
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='sample'):
        if self.name is not None and 'name' not in already_processed:
            already_processed.add('name')
            outfile.write(' name=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.name), input_name='name')), ))
    def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='sample', fromsubclass_=False, pretty_print=True):
        pass
    def build(self, node, gds_collector_=None):
        self.gds_collector_ = gds_collector_
        if SaveElementTreeNode:
            self.gds_elementtree_node_ = node
        already_processed = set()
        self.ns_prefix_ = get_(node, 'prefix')
        self.buildAttributes(node, node.attrib, already_processed)
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
        return self
    def buildAttributes(self, node, attrs, already_processed):
        value = find_attr_value_('name', node)
        if value is not None and 'name' not in already_processed:
            already_processed.add('name')
            self.name = value
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
        pass
# end class sample


class archive(GeneratedsSuper):
    __hash__ = GeneratedsSuper.__hash__
    subclass = None
    superclass = None
    def __init__(self, name=None, gds_collector_=None, **kwargs_):
        self.gds_collector_ = gds_collector_
        self.gds_elementtree_node_ = None
        self.original_tagname_ = None
        self.parent_object_ = kwargs_.get('parent_object_')
        self.ns_prefix_ = None
        self.name = _cast(None, name)
        self.name_nsprefix_ = None
    def factory(*args_, **kwargs_):
        if CurrentSubclassModule_ is not None:
            subclass = getSubclassFromModule_(
                CurrentSubclassModule_, archive)
            if subclass is not None:
                return subclass(*args_, **kwargs_)
        if archive.subclass:
            return archive.subclass(*args_, **kwargs_)
        else:
            return archive(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_ns_prefix_(self):
        return self.ns_prefix_
    def set_ns_prefix_(self, ns_prefix):
        self.ns_prefix_ = ns_prefix
    def get_name(self):
        return self.name
    def set_name(self, name):
        self.name = name
    def hasContent_(self):
        if (

        ):
            return True
        else:
            return False
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='archive', pretty_print=True):
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('archive')
        if imported_ns_def_ is not None:
            namespacedef_ = imported_ns_def_
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.original_tagname_ is not None:
            name_ = self.original_tagname_
        if UseCapturedNS_ and self.ns_prefix_:
            namespaceprefix_ = self.ns_prefix_ + ':'
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = set()
        self.exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='archive')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='archive', pretty_print=pretty_print)
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='archive'):
        if self.name is not None and 'name' not in already_processed:
            already_processed.add('name')
            outfile.write(' name=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.name), input_name='name')), ))
    def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='archive', fromsubclass_=False, pretty_print=True):
        pass
    def build(self, node, gds_collector_=None):
        self.gds_collector_ = gds_collector_
        if SaveElementTreeNode:
            self.gds_elementtree_node_ = node
        already_processed = set()
        self.ns_prefix_ = get_(node, 'prefix')
        self.buildAttributes(node, node.attrib, already_processed)
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
        return self
    def buildAttributes(self, node, attrs, already_processed):
        value = find_attr_value_('name', node)
        if value is not None and 'name' not in already_processed:
            already_processed.add('name')
            self.name = value
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
        pass
# end class archive


GDSClassesMapping = {
}


USAGE_TEXT = """
Usage: python <Parser>.py [ -s ] <in_xml_file>
"""


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


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


def get_required_ns_prefix_defs(rootNode):
    '''Get all name space prefix definitions required in this XML doc.
    Return a dictionary of definitions and a char string of definitions.
    '''
    nsmap = {
        prefix: uri
        for node in rootNode.iter()
        for (prefix, uri) in get_(node, 'nsmap', {}).items()
        if prefix is not None
    }
    namespacedefs = ' '.join([
        'xmlns:{}="{}"'.format(prefix, uri)
        for prefix, uri in nsmap.items()
    ])
    return nsmap, namespacedefs


def parse(inFileName, silence=False, print_warnings=True):
    global CapturedNsmap_
    gds_collector = GdsCollector_()
    parser = None
    doc = parsexml_(inFileName, parser)
    rootNode = doc.getroot()
    rootTag, rootClass = get_root_tag(rootNode)
    if rootClass is None:
        rootTag = 'datafile'
        rootClass = datafile
    rootObj = rootClass.factory()
    rootObj.build(rootNode, gds_collector_=gds_collector)
    CapturedNsmap_, namespacedefs = get_required_ns_prefix_defs(rootNode)
    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_=namespacedefs,
            pretty_print=True)
    if print_warnings and len(gds_collector.get_messages()) > 0:
        separator = ('-' * 50) + '\n'
        sys.stderr.write(separator)
        sys.stderr.write('----- Warnings -- count: {} -----\n'.format(
            len(gds_collector.get_messages()), ))
        gds_collector.write_messages(sys.stderr)
        sys.stderr.write(separator)
    return rootObj


def parseEtree(inFileName, silence=False, print_warnings=True):
    parser = None
    doc = parsexml_(inFileName, parser)
    gds_collector = GdsCollector_()
    rootNode = doc.getroot()
    rootTag, rootClass = get_root_tag(rootNode)
    if rootClass is None:
        rootTag = 'datafile'
        rootClass = datafile
    rootObj = rootClass.factory()
    rootObj.build(rootNode, gds_collector_=gds_collector)
    # Enable Python to collect the space used by the DOM.
    mapping = {}
    rootElement = rootObj.to_etree(None, name_=rootTag, mapping_=mapping)
    reverse_mapping = rootObj.gds_reverse_node_mapping(mapping)
    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(str(content))
        sys.stdout.write('\n')
    if print_warnings and len(gds_collector.get_messages()) > 0:
        separator = ('-' * 50) + '\n'
        sys.stderr.write(separator)
        sys.stderr.write('----- Warnings -- count: {} -----\n'.format(
            len(gds_collector.get_messages()), ))
        gds_collector.write_messages(sys.stderr)
        sys.stderr.write(separator)
    return rootObj, rootElement, mapping, reverse_mapping


def parseString(inString, silence=False, print_warnings=True):
    '''Parse a string, create the object tree, and export it.

    Arguments:
    - inString -- A string.  This XML fragment should not start
      with an XML declaration containing an encoding.
    - silence -- A boolean.  If False, export the object.
    Returns -- The root object in the tree.
    '''
    parser = None
    rootNode= parsexmlstring_(inString, parser)
    gds_collector = GdsCollector_()
    rootTag, rootClass = get_root_tag(rootNode)
    if rootClass is None:
        rootTag = 'datafile'
        rootClass = datafile
    rootObj = rootClass.factory()
    rootObj.build(rootNode, gds_collector_=gds_collector)
    if not SaveElementTreeNode:
        rootNode = None
    if not silence:
        sys.stdout.write('<?xml version="1.0" ?>\n')
        rootObj.export(
            sys.stdout, 0, name_=rootTag,
            namespacedef_='')
    if print_warnings and len(gds_collector.get_messages()) > 0:
        separator = ('-' * 50) + '\n'
        sys.stderr.write(separator)
        sys.stderr.write('----- Warnings -- count: {} -----\n'.format(
            len(gds_collector.get_messages()), ))
        gds_collector.write_messages(sys.stderr)
        sys.stderr.write(separator)
    return rootObj


def parseLiteral(inFileName, silence=False, print_warnings=True):
    parser = None
    doc = parsexml_(inFileName, parser)
    gds_collector = GdsCollector_()
    rootNode = doc.getroot()
    rootTag, rootClass = get_root_tag(rootNode)
    if rootClass is None:
        rootTag = 'datafile'
        rootClass = datafile
    rootObj = rootClass.factory()
    rootObj.build(rootNode, gds_collector_=gds_collector)
    # Enable Python to collect the space used by the DOM.
    if not SaveElementTreeNode:
        doc = None
        rootNode = None
    if not silence:
        sys.stdout.write('#from datafile import *\n\n')
        sys.stdout.write('import datafile as model_\n\n')
        sys.stdout.write('rootObj = model_.rootClass(\n')
        rootObj.exportLiteral(sys.stdout, 0, name_=rootTag)
        sys.stdout.write(')\n')
    if print_warnings and len(gds_collector.get_messages()) > 0:
        separator = ('-' * 50) + '\n'
        sys.stderr.write(separator)
        sys.stderr.write('----- Warnings -- count: {} -----\n'.format(
            len(gds_collector.get_messages()), ))
        gds_collector.write_messages(sys.stderr)
        sys.stderr.write(separator)
    return rootObj


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


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

RenameMappings_ = {
}

__all__ = [
    "archive",
    "biosset",
    "clrmamepro",
    "datafile",
    "disk",
    "game",
    "header",
    "release",
    "rom",
    "romcenter",
    "sample"
]
