From da323672b7164ae01c88b1b3b6ca038b9572c3b7 Mon Sep 17 00:00:00 2001 From: Cara Salter Date: Wed, 5 May 2021 09:42:39 -0400 Subject: [PATCH] Add challenge parser --- data/.gitkeep | 0 fllscoring/challenges.py | 5269 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 5269 insertions(+) create mode 100644 data/.gitkeep create mode 100644 fllscoring/challenges.py diff --git a/data/.gitkeep b/data/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/fllscoring/challenges.py b/fllscoring/challenges.py new file mode 100644 index 0000000..009704b --- /dev/null +++ b/fllscoring/challenges.py @@ -0,0 +1,5269 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# +# Generated Wed May 5 09:34:42 2021 by generateDS.py version 2.38.6. +# Python 3.7.3 (default, Jan 22 2021, 20:04:44) [GCC 8.3.0] +# +# Command line options: +# ('-o', 'fllscoring/challenges.py') +# +# Command line arguments: +# data/challenge.xsd +# +# Command line: +# /home/csalter/.local/bin/generateDS -o "fllscoring/challenges.py" data/challenge.xsd +# +# Current working directory (os.getcwd()): +# comortas +# + +import sys + +try: + ModulenotfoundExp_ = ModuleNotFoundError +except NameError: + ModulenotfoundExp_ = ImportError +from six.moves import zip_longest +import os +import re as re_ +import base64 +import datetime as datetime_ +import decimal as decimal_ + +try: + from lxml import etree as etree_ +except ModulenotfoundExp_: + from xml.etree import ElementTree as etree_ + + +Validate_simpletypes_ = True +SaveElementTreeNode = True +if sys.version_info.major == 2: + BaseStrType_ = basestring +else: + BaseStrType_ = str + + +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 + + +# +# 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 ModulenotfoundExp_: + GenerateDSNamespaceDefs_ = {} +try: + from generatedsnamespaces import ( + GenerateDSNamespaceTypePrefixes as GenerateDSNamespaceTypePrefixes_, + ) +except ModulenotfoundExp_: + 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 ModulenotfoundExp_: + + 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 ModulenotfoundExp_: + 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 ModulenotfoundExp_ 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=""): + if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): + input_data = [str(s) for s in input_data] + 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 values") + 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=""): + if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): + input_data = [str(s) for s in input_data] + 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_value = "%s" % input_data + if "." in return_value: + return_value = return_value.rstrip("0") + if return_value.endswith("."): + return_value = return_value.rstrip(".") + return return_value + + 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=""): + if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): + input_data = [str(s) for s in input_data] + return " ".join([self.gds_format_decimal(item) for item in 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 "%s" % 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=""): + if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): + input_data = [str(s) for s in input_data] + 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=""): + if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): + input_data = [str(s) for s in input_data] + 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: + value = self.gds_parse_boolean(value, node, input_name) + 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): + if sys.version_info.major == 2: + if ExternalEncoding: + encoding = ExternalEncoding + else: + encoding = "utf-8" + return instring.encode(encoding) + else: + return instring + + @staticmethod + def convert_unicode(instring): + if isinstance(instring, str): + result = quote_xml(instring) + elif sys.version_info.major == 2 and isinstance(instring, unicode): + result = quote_xml(instring).encode("utf8") + 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(' -- 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"", 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, BaseStrType_) 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("&", "&") + s1 = s1.replace("<", "<") + s1 = s1.replace(">", ">") + return s1 + + +def quote_attrib(inStr): + s1 = isinstance(inStr, BaseStrType_) and inStr or "%s" % inStr + s1 = s1.replace("&", "&") + s1 = s1.replace("<", "<") + s1 = s1.replace(">", ">") + if '"' in s1: + if "'" in s1: + s1 = '"%s"' % s1.replace('"', """) + 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 + if prefix == "xml": + namespace = "http://www.w3.org/XML/1998/namespace" + else: + 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" % (self.name, self.value, self.name)) + elif ( + self.content_type == MixedContainer.TypeInteger + or self.content_type == MixedContainer.TypeBoolean + ): + outfile.write("<%s>%d" % (self.name, self.value, self.name)) + elif ( + self.content_type == MixedContainer.TypeFloat + or self.content_type == MixedContainer.TypeDecimal + ): + outfile.write("<%s>%f" % (self.name, self.value, self.name)) + elif self.content_type == MixedContainer.TypeDouble: + outfile.write("<%s>%g" % (self.name, self.value, self.name)) + elif self.content_type == MixedContainer.TypeBase64: + outfile.write( + "<%s>%s" % (self.name, base64.b64encode(self.value), self.name) + ) + + def to_etree(self, element, mapping_=None, nsmap_=None): + 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, mapping_=None, nsmap_=None): + 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 defaultType(str, Enum): + YES = "yes" + NO = "no" + + +class challenge(GeneratedsSuper): + __hash__ = GeneratedsSuper.__hash__ + subclass = None + superclass = None + + def __init__( + self, + year=None, + version=None, + name=None, + strings=None, + mission=None, + resources=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.year = _cast(int, year) + self.year_nsprefix_ = None + self.version = _cast(int, version) + self.version_nsprefix_ = None + self.name = _cast(None, name) + self.name_nsprefix_ = None + if strings is None: + self.strings = [] + else: + self.strings = strings + self.strings_nsprefix_ = None + if mission is None: + self.mission = [] + else: + self.mission = mission + self.mission_nsprefix_ = None + self.resources = resources + self.resources_nsprefix_ = None + + def factory(*args_, **kwargs_): + if CurrentSubclassModule_ is not None: + subclass = getSubclassFromModule_(CurrentSubclassModule_, challenge) + if subclass is not None: + return subclass(*args_, **kwargs_) + if challenge.subclass: + return challenge.subclass(*args_, **kwargs_) + else: + return challenge(*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_strings(self): + return self.strings + + def set_strings(self, strings): + self.strings = strings + + def add_strings(self, value): + self.strings.append(value) + + def insert_strings_at(self, index, value): + self.strings.insert(index, value) + + def replace_strings_at(self, index, value): + self.strings[index] = value + + def get_mission(self): + return self.mission + + def set_mission(self, mission): + self.mission = mission + + def add_mission(self, value): + self.mission.append(value) + + def insert_mission_at(self, index, value): + self.mission.insert(index, value) + + def replace_mission_at(self, index, value): + self.mission[index] = value + + def get_resources(self): + return self.resources + + def set_resources(self, resources): + self.resources = resources + + def get_year(self): + return self.year + + def set_year(self, year): + self.year = year + + def get_version(self): + return self.version + + def set_version(self, version): + self.version = version + + def get_name(self): + return self.name + + def set_name(self, name): + self.name = name + + def hasContent_(self): + if self.strings or self.mission or self.resources is not None: + return True + else: + return False + + def export( + self, + outfile, + level, + namespaceprefix_="", + namespacedef_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + name_="challenge", + pretty_print=True, + ): + imported_ns_def_ = GenerateDSNamespaceDefs_.get("challenge") + 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 and name_ == "challenge": + 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_="challenge" + ) + if self.hasContent_(): + outfile.write(">%s" % (eol_,)) + self.exportChildren( + outfile, + level + 1, + namespaceprefix_, + namespacedef_, + name_="challenge", + pretty_print=pretty_print, + ) + showIndent(outfile, level, pretty_print) + outfile.write("%s" % (namespaceprefix_, name_, eol_)) + else: + outfile.write("/>%s" % (eol_,)) + + def exportAttributes( + self, outfile, level, already_processed, namespaceprefix_="", name_="challenge" + ): + if self.year is not None and "year" not in already_processed: + already_processed.add("year") + outfile.write( + ' year="%s"' % self.gds_format_integer(self.year, input_name="year") + ) + if self.version is not None and "version" not in already_processed: + already_processed.add("version") + outfile.write( + ' version="%s"' + % self.gds_format_integer(self.version, input_name="version") + ) + 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_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + name_="challenge", + fromsubclass_=False, + pretty_print=True, + ): + if pretty_print: + eol_ = "\n" + else: + eol_ = "" + for strings_ in self.strings: + namespaceprefix_ = ( + self.strings_nsprefix_ + ":" + if (UseCapturedNS_ and self.strings_nsprefix_) + else "" + ) + strings_.export( + outfile, + level, + namespaceprefix_, + namespacedef_="", + name_="strings", + pretty_print=pretty_print, + ) + for mission_ in self.mission: + namespaceprefix_ = ( + self.mission_nsprefix_ + ":" + if (UseCapturedNS_ and self.mission_nsprefix_) + else "" + ) + mission_.export( + outfile, + level, + namespaceprefix_, + namespacedef_="", + name_="mission", + pretty_print=pretty_print, + ) + if self.resources is not None: + namespaceprefix_ = ( + self.resources_nsprefix_ + ":" + if (UseCapturedNS_ and self.resources_nsprefix_) + else "" + ) + self.resources.export( + outfile, + level, + namespaceprefix_, + namespacedef_="", + name_="resources", + 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_ = 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_("year", node) + if value is not None and "year" not in already_processed: + already_processed.add("year") + self.year = self.gds_parse_integer(value, node, "year") + value = find_attr_value_("version", node) + if value is not None and "version" not in already_processed: + already_processed.add("version") + self.version = self.gds_parse_integer(value, node, "version") + 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 + ): + if nodeName_ == "strings": + obj_ = strings.factory(parent_object_=self) + obj_.build(child_, gds_collector_=gds_collector_) + self.strings.append(obj_) + obj_.original_tagname_ = "strings" + elif nodeName_ == "mission": + obj_ = mission.factory(parent_object_=self) + obj_.build(child_, gds_collector_=gds_collector_) + self.mission.append(obj_) + obj_.original_tagname_ = "mission" + elif nodeName_ == "resources": + obj_ = resources.factory(parent_object_=self) + obj_.build(child_, gds_collector_=gds_collector_) + self.resources = obj_ + obj_.original_tagname_ = "resources" + + +# end class challenge + + +class strings(GeneratedsSuper): + __hash__ = GeneratedsSuper.__hash__ + subclass = None + superclass = None + + def __init__(self, language=None, string=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.language = _cast(None, language) + self.language_nsprefix_ = None + if string is None: + self.string = [] + else: + self.string = string + self.string_nsprefix_ = None + + def factory(*args_, **kwargs_): + if CurrentSubclassModule_ is not None: + subclass = getSubclassFromModule_(CurrentSubclassModule_, strings) + if subclass is not None: + return subclass(*args_, **kwargs_) + if strings.subclass: + return strings.subclass(*args_, **kwargs_) + else: + return strings(*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_string(self): + return self.string + + def set_string(self, string): + self.string = string + + def add_string(self, value): + self.string.append(value) + + def insert_string_at(self, index, value): + self.string.insert(index, value) + + def replace_string_at(self, index, value): + self.string[index] = value + + def get_language(self): + return self.language + + def set_language(self, language): + self.language = language + + def validate_languageType(self, value): + # Validate type languageType, a restriction on xs:string. + if ( + value is not None + and Validate_simpletypes_ + and self.gds_collector_ is not None + ): + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message( + 'Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' + % { + "value": value, + "lineno": lineno, + } + ) + return False + if not self.gds_validate_simple_patterns( + self.validate_languageType_patterns_, value + ): + self.gds_collector_.add_message( + 'Value "%s" does not match xsd pattern restrictions: %s' + % ( + encode_str_2_3(value), + self.validate_languageType_patterns_, + ) + ) + + validate_languageType_patterns_ = [["^([a-z]{2}-[A-Z]{2})$"]] + + def hasContent_(self): + if self.string: + return True + else: + return False + + def export( + self, + outfile, + level, + namespaceprefix_="", + namespacedef_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + name_="strings", + pretty_print=True, + ): + imported_ns_def_ = GenerateDSNamespaceDefs_.get("strings") + 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 and name_ == "strings": + 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_="strings" + ) + if self.hasContent_(): + outfile.write(">%s" % (eol_,)) + self.exportChildren( + outfile, + level + 1, + namespaceprefix_, + namespacedef_, + name_="strings", + pretty_print=pretty_print, + ) + showIndent(outfile, level, pretty_print) + outfile.write("%s" % (namespaceprefix_, name_, eol_)) + else: + outfile.write("/>%s" % (eol_,)) + + def exportAttributes( + self, outfile, level, already_processed, namespaceprefix_="", name_="strings" + ): + 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" + ) + ), + ) + ) + + def exportChildren( + self, + outfile, + level, + namespaceprefix_="", + namespacedef_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + name_="strings", + fromsubclass_=False, + pretty_print=True, + ): + if pretty_print: + eol_ = "\n" + else: + eol_ = "" + for string_ in self.string: + namespaceprefix_ = ( + self.string_nsprefix_ + ":" + if (UseCapturedNS_ and self.string_nsprefix_) + else "" + ) + string_.export( + outfile, + level, + namespaceprefix_, + namespacedef_="", + name_="string", + 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_ = 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_("language", node) + if value is not None and "language" not in already_processed: + already_processed.add("language") + self.language = value + self.validate_languageType(self.language) # validate type languageType + + def buildChildren( + self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None + ): + if nodeName_ == "string": + obj_ = string.factory(parent_object_=self) + obj_.build(child_, gds_collector_=gds_collector_) + self.string.append(obj_) + obj_.original_tagname_ = "string" + + +# end class strings + + +class string(GeneratedsSuper): + __hash__ = GeneratedsSuper.__hash__ + subclass = None + superclass = None + + def __init__(self, id=None, valueOf_=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.id = _cast(None, id) + self.id_nsprefix_ = None + self.valueOf_ = valueOf_ + + def factory(*args_, **kwargs_): + if CurrentSubclassModule_ is not None: + subclass = getSubclassFromModule_(CurrentSubclassModule_, string) + if subclass is not None: + return subclass(*args_, **kwargs_) + if string.subclass: + return string.subclass(*args_, **kwargs_) + else: + return string(*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_id(self): + return self.id + + def set_id(self, id): + self.id = id + + def get_valueOf_(self): + return self.valueOf_ + + def set_valueOf_(self, valueOf_): + self.valueOf_ = valueOf_ + + def hasContent_(self): + if 1 if type(self.valueOf_) in [int, float] else self.valueOf_: + return True + else: + return False + + def export( + self, + outfile, + level, + namespaceprefix_="", + namespacedef_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + name_="string", + pretty_print=True, + ): + imported_ns_def_ = GenerateDSNamespaceDefs_.get("string") + 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 and name_ == "string": + 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_="string" + ) + if self.hasContent_(): + outfile.write(">") + outfile.write(self.convert_unicode(self.valueOf_)) + self.exportChildren( + outfile, + level + 1, + namespaceprefix_, + namespacedef_, + name_="string", + pretty_print=pretty_print, + ) + outfile.write("%s" % (namespaceprefix_, name_, eol_)) + else: + outfile.write("/>%s" % (eol_,)) + + def exportAttributes( + self, outfile, level, already_processed, namespaceprefix_="", name_="string" + ): + if self.id is not None and "id" not in already_processed: + already_processed.add("id") + outfile.write( + " id=%s" + % ( + self.gds_encode( + self.gds_format_string(quote_attrib(self.id), input_name="id") + ), + ) + ) + + def exportChildren( + self, + outfile, + level, + namespaceprefix_="", + namespacedef_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + name_="string", + 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_ = node.prefix + self.buildAttributes(node, node.attrib, already_processed) + self.valueOf_ = get_all_text_(node) + 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_("id", node) + if value is not None and "id" not in already_processed: + already_processed.add("id") + self.id = value + + def buildChildren( + self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None + ): + pass + + +# end class string + + +class mission(GeneratedsSuper): + __hash__ = GeneratedsSuper.__hash__ + subclass = None + superclass = None + + def __init__( + self, + name=None, + description=None, + objective_yesno=None, + objective_number=None, + objective_enum=None, + score=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.description = _cast(None, description) + self.description_nsprefix_ = None + if objective_yesno is None: + self.objective_yesno = [] + else: + self.objective_yesno = objective_yesno + self.objective_yesno_nsprefix_ = None + if objective_number is None: + self.objective_number = [] + else: + self.objective_number = objective_number + self.objective_number_nsprefix_ = None + if objective_enum is None: + self.objective_enum = [] + else: + self.objective_enum = objective_enum + self.objective_enum_nsprefix_ = None + if score is None: + self.score = [] + else: + self.score = score + self.score_nsprefix_ = None + + def factory(*args_, **kwargs_): + if CurrentSubclassModule_ is not None: + subclass = getSubclassFromModule_(CurrentSubclassModule_, mission) + if subclass is not None: + return subclass(*args_, **kwargs_) + if mission.subclass: + return mission.subclass(*args_, **kwargs_) + else: + return mission(*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_objective_yesno(self): + return self.objective_yesno + + def set_objective_yesno(self, objective_yesno): + self.objective_yesno = objective_yesno + + def add_objective_yesno(self, value): + self.objective_yesno.append(value) + + def insert_objective_yesno_at(self, index, value): + self.objective_yesno.insert(index, value) + + def replace_objective_yesno_at(self, index, value): + self.objective_yesno[index] = value + + def get_objective_number(self): + return self.objective_number + + def set_objective_number(self, objective_number): + self.objective_number = objective_number + + def add_objective_number(self, value): + self.objective_number.append(value) + + def insert_objective_number_at(self, index, value): + self.objective_number.insert(index, value) + + def replace_objective_number_at(self, index, value): + self.objective_number[index] = value + + def get_objective_enum(self): + return self.objective_enum + + def set_objective_enum(self, objective_enum): + self.objective_enum = objective_enum + + def add_objective_enum(self, value): + self.objective_enum.append(value) + + def insert_objective_enum_at(self, index, value): + self.objective_enum.insert(index, value) + + def replace_objective_enum_at(self, index, value): + self.objective_enum[index] = value + + def get_score(self): + return self.score + + def set_score(self, score): + self.score = score + + def add_score(self, value): + self.score.append(value) + + def insert_score_at(self, index, value): + self.score.insert(index, value) + + def replace_score_at(self, index, value): + self.score[index] = value + + 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 hasContent_(self): + if ( + self.objective_yesno + or self.objective_number + or self.objective_enum + or self.score + ): + return True + else: + return False + + def export( + self, + outfile, + level, + namespaceprefix_="", + namespacedef_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + name_="mission", + pretty_print=True, + ): + imported_ns_def_ = GenerateDSNamespaceDefs_.get("mission") + 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 and name_ == "mission": + 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_="mission" + ) + if self.hasContent_(): + outfile.write(">%s" % (eol_,)) + self.exportChildren( + outfile, + level + 1, + namespaceprefix_, + namespacedef_, + name_="mission", + pretty_print=pretty_print, + ) + showIndent(outfile, level, pretty_print) + outfile.write("%s" % (namespaceprefix_, name_, eol_)) + else: + outfile.write("/>%s" % (eol_,)) + + def exportAttributes( + self, outfile, level, already_processed, namespaceprefix_="", name_="mission" + ): + 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" + ) + ), + ) + ) + + def exportChildren( + self, + outfile, + level, + namespaceprefix_="", + namespacedef_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + name_="mission", + fromsubclass_=False, + pretty_print=True, + ): + if pretty_print: + eol_ = "\n" + else: + eol_ = "" + for objective_yesno_ in self.objective_yesno: + namespaceprefix_ = ( + self.objective_yesno_nsprefix_ + ":" + if (UseCapturedNS_ and self.objective_yesno_nsprefix_) + else "" + ) + objective_yesno_.export( + outfile, + level, + namespaceprefix_, + namespacedef_="", + name_="objective-yesno", + pretty_print=pretty_print, + ) + for objective_number_ in self.objective_number: + namespaceprefix_ = ( + self.objective_number_nsprefix_ + ":" + if (UseCapturedNS_ and self.objective_number_nsprefix_) + else "" + ) + objective_number_.export( + outfile, + level, + namespaceprefix_, + namespacedef_="", + name_="objective-number", + pretty_print=pretty_print, + ) + for objective_enum_ in self.objective_enum: + namespaceprefix_ = ( + self.objective_enum_nsprefix_ + ":" + if (UseCapturedNS_ and self.objective_enum_nsprefix_) + else "" + ) + objective_enum_.export( + outfile, + level, + namespaceprefix_, + namespacedef_="", + name_="objective-enum", + pretty_print=pretty_print, + ) + for score_ in self.score: + namespaceprefix_ = ( + self.score_nsprefix_ + ":" + if (UseCapturedNS_ and self.score_nsprefix_) + else "" + ) + score_.export( + outfile, + level, + namespaceprefix_, + namespacedef_="", + name_="score", + 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_ = 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 + + def buildChildren( + self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None + ): + if nodeName_ == "objective-yesno": + obj_ = objective_yesno.factory(parent_object_=self) + obj_.build(child_, gds_collector_=gds_collector_) + self.objective_yesno.append(obj_) + obj_.original_tagname_ = "objective-yesno" + elif nodeName_ == "objective-number": + obj_ = objective_number.factory(parent_object_=self) + obj_.build(child_, gds_collector_=gds_collector_) + self.objective_number.append(obj_) + obj_.original_tagname_ = "objective-number" + elif nodeName_ == "objective-enum": + obj_ = objective_enum.factory(parent_object_=self) + obj_.build(child_, gds_collector_=gds_collector_) + self.objective_enum.append(obj_) + obj_.original_tagname_ = "objective-enum" + elif nodeName_ == "score": + obj_ = score.factory(parent_object_=self) + obj_.build(child_, gds_collector_=gds_collector_) + self.score.append(obj_) + obj_.original_tagname_ = "score" + + +# end class mission + + +class objective_yesno(GeneratedsSuper): + __hash__ = GeneratedsSuper.__hash__ + subclass = None + superclass = None + + def __init__( + self, + id=None, + description=None, + default=None, + resource=None, + resource_use=1, + 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.id = _cast(None, id) + self.id_nsprefix_ = None + self.description = _cast(None, description) + self.description_nsprefix_ = None + self.default = _cast(None, default) + self.default_nsprefix_ = None + self.resource = _cast(None, resource) + self.resource_nsprefix_ = None + self.resource_use = _cast(int, resource_use) + self.resource_use_nsprefix_ = None + + def factory(*args_, **kwargs_): + if CurrentSubclassModule_ is not None: + subclass = getSubclassFromModule_(CurrentSubclassModule_, objective_yesno) + if subclass is not None: + return subclass(*args_, **kwargs_) + if objective_yesno.subclass: + return objective_yesno.subclass(*args_, **kwargs_) + else: + return objective_yesno(*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_id(self): + return self.id + + def set_id(self, id): + self.id = id + + 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 get_resource(self): + return self.resource + + def set_resource(self, resource): + self.resource = resource + + def get_resource_use(self): + return self.resource_use + + def set_resource_use(self, resource_use): + self.resource_use = resource_use + + def validate_defaultType(self, value): + # Validate type defaultType, a restriction on xs:string. + if ( + value is not None + and Validate_simpletypes_ + and self.gds_collector_ is not None + ): + if not isinstance(value, str): + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message( + 'Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' + % { + "value": value, + "lineno": lineno, + } + ) + return False + value = value + enumerations = ["yes", "no"] + if value not in enumerations: + lineno = self.gds_get_node_lineno_() + self.gds_collector_.add_message( + 'Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on defaultType' + % {"value": encode_str_2_3(value), "lineno": lineno} + ) + result = False + + def hasContent_(self): + if (): + return True + else: + return False + + def export( + self, + outfile, + level, + namespaceprefix_="", + namespacedef_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + name_="objective-yesno", + pretty_print=True, + ): + imported_ns_def_ = GenerateDSNamespaceDefs_.get("objective-yesno") + 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 and name_ == "objective-yesno": + 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_="objective-yesno" + ) + if self.hasContent_(): + outfile.write(">%s" % (eol_,)) + self.exportChildren( + outfile, + level + 1, + namespaceprefix_, + namespacedef_, + name_="objective-yesno", + pretty_print=pretty_print, + ) + outfile.write("%s" % (namespaceprefix_, name_, eol_)) + else: + outfile.write("/>%s" % (eol_,)) + + def exportAttributes( + self, + outfile, + level, + already_processed, + namespaceprefix_="", + name_="objective-yesno", + ): + if self.id is not None and "id" not in already_processed: + already_processed.add("id") + outfile.write( + " id=%s" + % ( + self.gds_encode( + self.gds_format_string(quote_attrib(self.id), input_name="id") + ), + ) + ) + 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 is not None 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" + ) + ), + ) + ) + if self.resource is not None and "resource" not in already_processed: + already_processed.add("resource") + outfile.write( + " resource=%s" + % ( + self.gds_encode( + self.gds_format_string( + quote_attrib(self.resource), input_name="resource" + ) + ), + ) + ) + if self.resource_use != 1 and "resource_use" not in already_processed: + already_processed.add("resource_use") + outfile.write( + ' resource-use="%s"' + % self.gds_format_integer(self.resource_use, input_name="resource-use") + ) + + def exportChildren( + self, + outfile, + level, + namespaceprefix_="", + namespacedef_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + name_="objective-yesno", + 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_ = 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_("id", node) + if value is not None and "id" not in already_processed: + already_processed.add("id") + self.id = 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 + self.validate_defaultType(self.default) # validate type defaultType + value = find_attr_value_("resource", node) + if value is not None and "resource" not in already_processed: + already_processed.add("resource") + self.resource = value + value = find_attr_value_("resource-use", node) + if value is not None and "resource-use" not in already_processed: + already_processed.add("resource-use") + self.resource_use = self.gds_parse_integer(value, node, "resource-use") + if self.resource_use <= 0: + raise_parse_error(node, "Invalid PositiveInteger") + + def buildChildren( + self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None + ): + pass + + +# end class objective_yesno + + +class objective_number(GeneratedsSuper): + __hash__ = GeneratedsSuper.__hash__ + subclass = None + superclass = None + + def __init__( + self, + id=None, + description=None, + min=None, + max=None, + default=None, + resource=None, + resource_use=1, + 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.id = _cast(None, id) + self.id_nsprefix_ = None + self.description = _cast(None, description) + self.description_nsprefix_ = None + self.min = _cast(int, min) + self.min_nsprefix_ = None + self.max = _cast(int, max) + self.max_nsprefix_ = None + self.default = _cast(int, default) + self.default_nsprefix_ = None + self.resource = _cast(None, resource) + self.resource_nsprefix_ = None + self.resource_use = _cast(int, resource_use) + self.resource_use_nsprefix_ = None + + def factory(*args_, **kwargs_): + if CurrentSubclassModule_ is not None: + subclass = getSubclassFromModule_(CurrentSubclassModule_, objective_number) + if subclass is not None: + return subclass(*args_, **kwargs_) + if objective_number.subclass: + return objective_number.subclass(*args_, **kwargs_) + else: + return objective_number(*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_id(self): + return self.id + + def set_id(self, id): + self.id = id + + def get_description(self): + return self.description + + def set_description(self, description): + self.description = description + + def get_min(self): + return self.min + + def set_min(self, min): + self.min = min + + def get_max(self): + return self.max + + def set_max(self, max): + self.max = max + + def get_default(self): + return self.default + + def set_default(self, default): + self.default = default + + def get_resource(self): + return self.resource + + def set_resource(self, resource): + self.resource = resource + + def get_resource_use(self): + return self.resource_use + + def set_resource_use(self, resource_use): + self.resource_use = resource_use + + def hasContent_(self): + if (): + return True + else: + return False + + def export( + self, + outfile, + level, + namespaceprefix_="", + namespacedef_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + name_="objective-number", + pretty_print=True, + ): + imported_ns_def_ = GenerateDSNamespaceDefs_.get("objective-number") + 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 and name_ == "objective-number": + 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_="objective-number", + ) + if self.hasContent_(): + outfile.write(">%s" % (eol_,)) + self.exportChildren( + outfile, + level + 1, + namespaceprefix_, + namespacedef_, + name_="objective-number", + pretty_print=pretty_print, + ) + outfile.write("%s" % (namespaceprefix_, name_, eol_)) + else: + outfile.write("/>%s" % (eol_,)) + + def exportAttributes( + self, + outfile, + level, + already_processed, + namespaceprefix_="", + name_="objective-number", + ): + if self.id is not None and "id" not in already_processed: + already_processed.add("id") + outfile.write( + " id=%s" + % ( + self.gds_encode( + self.gds_format_string(quote_attrib(self.id), input_name="id") + ), + ) + ) + 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.min is not None and "min" not in already_processed: + already_processed.add("min") + outfile.write( + ' min="%s"' % self.gds_format_integer(self.min, input_name="min") + ) + if self.max is not None and "max" not in already_processed: + already_processed.add("max") + outfile.write( + ' max="%s"' % self.gds_format_integer(self.max, input_name="max") + ) + if self.default is not None and "default" not in already_processed: + already_processed.add("default") + outfile.write( + ' default="%s"' + % self.gds_format_integer(self.default, input_name="default") + ) + if self.resource is not None and "resource" not in already_processed: + already_processed.add("resource") + outfile.write( + " resource=%s" + % ( + self.gds_encode( + self.gds_format_string( + quote_attrib(self.resource), input_name="resource" + ) + ), + ) + ) + if self.resource_use != 1 and "resource_use" not in already_processed: + already_processed.add("resource_use") + outfile.write( + ' resource-use="%s"' + % self.gds_format_integer(self.resource_use, input_name="resource-use") + ) + + def exportChildren( + self, + outfile, + level, + namespaceprefix_="", + namespacedef_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + name_="objective-number", + 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_ = 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_("id", node) + if value is not None and "id" not in already_processed: + already_processed.add("id") + self.id = 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_("min", node) + if value is not None and "min" not in already_processed: + already_processed.add("min") + self.min = self.gds_parse_integer(value, node, "min") + value = find_attr_value_("max", node) + if value is not None and "max" not in already_processed: + already_processed.add("max") + self.max = self.gds_parse_integer(value, node, "max") + value = find_attr_value_("default", node) + if value is not None and "default" not in already_processed: + already_processed.add("default") + self.default = self.gds_parse_integer(value, node, "default") + value = find_attr_value_("resource", node) + if value is not None and "resource" not in already_processed: + already_processed.add("resource") + self.resource = value + value = find_attr_value_("resource-use", node) + if value is not None and "resource-use" not in already_processed: + already_processed.add("resource-use") + self.resource_use = self.gds_parse_integer(value, node, "resource-use") + if self.resource_use <= 0: + raise_parse_error(node, "Invalid PositiveInteger") + + def buildChildren( + self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None + ): + pass + + +# end class objective_number + + +class objective_enum(GeneratedsSuper): + __hash__ = GeneratedsSuper.__hash__ + subclass = None + superclass = None + + def __init__( + self, + id=None, + description=None, + default=None, + resource=None, + option=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.id = _cast(None, id) + self.id_nsprefix_ = None + self.description = _cast(None, description) + self.description_nsprefix_ = None + self.default = _cast(None, default) + self.default_nsprefix_ = None + self.resource = _cast(None, resource) + self.resource_nsprefix_ = None + if option is None: + self.option = [] + else: + self.option = option + self.option_nsprefix_ = None + + def factory(*args_, **kwargs_): + if CurrentSubclassModule_ is not None: + subclass = getSubclassFromModule_(CurrentSubclassModule_, objective_enum) + if subclass is not None: + return subclass(*args_, **kwargs_) + if objective_enum.subclass: + return objective_enum.subclass(*args_, **kwargs_) + else: + return objective_enum(*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_option(self): + return self.option + + def set_option(self, option): + self.option = option + + def add_option(self, value): + self.option.append(value) + + def insert_option_at(self, index, value): + self.option.insert(index, value) + + def replace_option_at(self, index, value): + self.option[index] = value + + def get_id(self): + return self.id + + def set_id(self, id): + self.id = id + + 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 get_resource(self): + return self.resource + + def set_resource(self, resource): + self.resource = resource + + def hasContent_(self): + if self.option: + return True + else: + return False + + def export( + self, + outfile, + level, + namespaceprefix_="", + namespacedef_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + name_="objective-enum", + pretty_print=True, + ): + imported_ns_def_ = GenerateDSNamespaceDefs_.get("objective-enum") + 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 and name_ == "objective-enum": + 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_="objective-enum" + ) + if self.hasContent_(): + outfile.write(">%s" % (eol_,)) + self.exportChildren( + outfile, + level + 1, + namespaceprefix_, + namespacedef_, + name_="objective-enum", + pretty_print=pretty_print, + ) + showIndent(outfile, level, pretty_print) + outfile.write("%s" % (namespaceprefix_, name_, eol_)) + else: + outfile.write("/>%s" % (eol_,)) + + def exportAttributes( + self, + outfile, + level, + already_processed, + namespaceprefix_="", + name_="objective-enum", + ): + if self.id is not None and "id" not in already_processed: + already_processed.add("id") + outfile.write( + " id=%s" + % ( + self.gds_encode( + self.gds_format_string(quote_attrib(self.id), input_name="id") + ), + ) + ) + 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 is not None 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" + ) + ), + ) + ) + if self.resource is not None and "resource" not in already_processed: + already_processed.add("resource") + outfile.write( + " resource=%s" + % ( + self.gds_encode( + self.gds_format_string( + quote_attrib(self.resource), input_name="resource" + ) + ), + ) + ) + + def exportChildren( + self, + outfile, + level, + namespaceprefix_="", + namespacedef_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + name_="objective-enum", + fromsubclass_=False, + pretty_print=True, + ): + if pretty_print: + eol_ = "\n" + else: + eol_ = "" + for option_ in self.option: + namespaceprefix_ = ( + self.option_nsprefix_ + ":" + if (UseCapturedNS_ and self.option_nsprefix_) + else "" + ) + option_.export( + outfile, + level, + namespaceprefix_, + namespacedef_="", + name_="option", + 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_ = 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_("id", node) + if value is not None and "id" not in already_processed: + already_processed.add("id") + self.id = 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 + value = find_attr_value_("resource", node) + if value is not None and "resource" not in already_processed: + already_processed.add("resource") + self.resource = value + + def buildChildren( + self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None + ): + if nodeName_ == "option": + obj_ = option.factory(parent_object_=self) + obj_.build(child_, gds_collector_=gds_collector_) + self.option.append(obj_) + obj_.original_tagname_ = "option" + + +# end class objective_enum + + +class option(GeneratedsSuper): + __hash__ = GeneratedsSuper.__hash__ + subclass = None + superclass = None + + def __init__( + self, + name=None, + description=None, + resource_use=0, + 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.resource_use = _cast(int, resource_use) + self.resource_use_nsprefix_ = None + + def factory(*args_, **kwargs_): + if CurrentSubclassModule_ is not None: + subclass = getSubclassFromModule_(CurrentSubclassModule_, option) + if subclass is not None: + return subclass(*args_, **kwargs_) + if option.subclass: + return option.subclass(*args_, **kwargs_) + else: + return option(*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_resource_use(self): + return self.resource_use + + def set_resource_use(self, resource_use): + self.resource_use = resource_use + + def hasContent_(self): + if (): + return True + else: + return False + + def export( + self, + outfile, + level, + namespaceprefix_="", + namespacedef_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + name_="option", + pretty_print=True, + ): + imported_ns_def_ = GenerateDSNamespaceDefs_.get("option") + 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 and name_ == "option": + 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_="option" + ) + if self.hasContent_(): + outfile.write(">%s" % (eol_,)) + self.exportChildren( + outfile, + level + 1, + namespaceprefix_, + namespacedef_, + name_="option", + pretty_print=pretty_print, + ) + outfile.write("%s" % (namespaceprefix_, name_, eol_)) + else: + outfile.write("/>%s" % (eol_,)) + + def exportAttributes( + self, outfile, level, already_processed, namespaceprefix_="", name_="option" + ): + 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.resource_use != 0 and "resource_use" not in already_processed: + already_processed.add("resource_use") + outfile.write( + ' resource-use="%s"' + % self.gds_format_integer(self.resource_use, input_name="resource-use") + ) + + def exportChildren( + self, + outfile, + level, + namespaceprefix_="", + namespacedef_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + name_="option", + 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_ = 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_("resource-use", node) + if value is not None and "resource-use" not in already_processed: + already_processed.add("resource-use") + self.resource_use = self.gds_parse_integer(value, node, "resource-use") + if self.resource_use < 0: + raise_parse_error(node, "Invalid NonNegativeInteger") + + def buildChildren( + self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None + ): + pass + + +# end class option + + +class score(GeneratedsSuper): + __hash__ = GeneratedsSuper.__hash__ + subclass = None + superclass = None + + def __init__(self, indexes=None, cases=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.indexes = indexes + self.indexes_nsprefix_ = None + self.cases = cases + self.cases_nsprefix_ = None + + def factory(*args_, **kwargs_): + if CurrentSubclassModule_ is not None: + subclass = getSubclassFromModule_(CurrentSubclassModule_, score) + if subclass is not None: + return subclass(*args_, **kwargs_) + if score.subclass: + return score.subclass(*args_, **kwargs_) + else: + return score(*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_indexes(self): + return self.indexes + + def set_indexes(self, indexes): + self.indexes = indexes + + def get_cases(self): + return self.cases + + def set_cases(self, cases): + self.cases = cases + + def hasContent_(self): + if self.indexes is not None or self.cases is not None: + return True + else: + return False + + def export( + self, + outfile, + level, + namespaceprefix_="", + namespacedef_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + name_="score", + pretty_print=True, + ): + imported_ns_def_ = GenerateDSNamespaceDefs_.get("score") + 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 and name_ == "score": + 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_="score" + ) + if self.hasContent_(): + outfile.write(">%s" % (eol_,)) + self.exportChildren( + outfile, + level + 1, + namespaceprefix_, + namespacedef_, + name_="score", + pretty_print=pretty_print, + ) + showIndent(outfile, level, pretty_print) + outfile.write("%s" % (namespaceprefix_, name_, eol_)) + else: + outfile.write("/>%s" % (eol_,)) + + def exportAttributes( + self, outfile, level, already_processed, namespaceprefix_="", name_="score" + ): + pass + + def exportChildren( + self, + outfile, + level, + namespaceprefix_="", + namespacedef_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + name_="score", + fromsubclass_=False, + pretty_print=True, + ): + if pretty_print: + eol_ = "\n" + else: + eol_ = "" + if self.indexes is not None: + namespaceprefix_ = ( + self.indexes_nsprefix_ + ":" + if (UseCapturedNS_ and self.indexes_nsprefix_) + else "" + ) + self.indexes.export( + outfile, + level, + namespaceprefix_, + namespacedef_="", + name_="indexes", + pretty_print=pretty_print, + ) + if self.cases is not None: + namespaceprefix_ = ( + self.cases_nsprefix_ + ":" + if (UseCapturedNS_ and self.cases_nsprefix_) + else "" + ) + self.cases.export( + outfile, + level, + namespaceprefix_, + namespacedef_="", + name_="cases", + 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_ = 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_ == "indexes": + obj_ = indexes.factory(parent_object_=self) + obj_.build(child_, gds_collector_=gds_collector_) + self.indexes = obj_ + obj_.original_tagname_ = "indexes" + elif nodeName_ == "cases": + obj_ = cases.factory(parent_object_=self) + obj_.build(child_, gds_collector_=gds_collector_) + self.cases = obj_ + obj_.original_tagname_ = "cases" + + +# end class score + + +class indexes(GeneratedsSuper): + __hash__ = GeneratedsSuper.__hash__ + subclass = None + superclass = None + + def __init__(self, index=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 + if index is None: + self.index = [] + else: + self.index = index + self.index_nsprefix_ = None + + def factory(*args_, **kwargs_): + if CurrentSubclassModule_ is not None: + subclass = getSubclassFromModule_(CurrentSubclassModule_, indexes) + if subclass is not None: + return subclass(*args_, **kwargs_) + if indexes.subclass: + return indexes.subclass(*args_, **kwargs_) + else: + return indexes(*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_index(self): + return self.index + + def set_index(self, index): + self.index = index + + def add_index(self, value): + self.index.append(value) + + def insert_index_at(self, index, value): + self.index.insert(index, value) + + def replace_index_at(self, index, value): + self.index[index] = value + + def hasContent_(self): + if self.index: + return True + else: + return False + + def export( + self, + outfile, + level, + namespaceprefix_="", + namespacedef_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + name_="indexes", + pretty_print=True, + ): + imported_ns_def_ = GenerateDSNamespaceDefs_.get("indexes") + 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 and name_ == "indexes": + 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_="indexes" + ) + if self.hasContent_(): + outfile.write(">%s" % (eol_,)) + self.exportChildren( + outfile, + level + 1, + namespaceprefix_, + namespacedef_, + name_="indexes", + pretty_print=pretty_print, + ) + showIndent(outfile, level, pretty_print) + outfile.write("%s" % (namespaceprefix_, name_, eol_)) + else: + outfile.write("/>%s" % (eol_,)) + + def exportAttributes( + self, outfile, level, already_processed, namespaceprefix_="", name_="indexes" + ): + pass + + def exportChildren( + self, + outfile, + level, + namespaceprefix_="", + namespacedef_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + name_="indexes", + fromsubclass_=False, + pretty_print=True, + ): + if pretty_print: + eol_ = "\n" + else: + eol_ = "" + for index_ in self.index: + namespaceprefix_ = ( + self.index_nsprefix_ + ":" + if (UseCapturedNS_ and self.index_nsprefix_) + else "" + ) + index_.export( + outfile, + level, + namespaceprefix_, + namespacedef_="", + name_="index", + 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_ = 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_ == "index": + obj_ = index.factory(parent_object_=self) + obj_.build(child_, gds_collector_=gds_collector_) + self.index.append(obj_) + obj_.original_tagname_ = "index" + + +# end class indexes + + +class index(GeneratedsSuper): + __hash__ = GeneratedsSuper.__hash__ + subclass = None + superclass = None + + def __init__(self, objective=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.objective = _cast(None, objective) + self.objective_nsprefix_ = None + + def factory(*args_, **kwargs_): + if CurrentSubclassModule_ is not None: + subclass = getSubclassFromModule_(CurrentSubclassModule_, index) + if subclass is not None: + return subclass(*args_, **kwargs_) + if index.subclass: + return index.subclass(*args_, **kwargs_) + else: + return index(*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_objective(self): + return self.objective + + def set_objective(self, objective): + self.objective = objective + + def hasContent_(self): + if (): + return True + else: + return False + + def export( + self, + outfile, + level, + namespaceprefix_="", + namespacedef_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + name_="index", + pretty_print=True, + ): + imported_ns_def_ = GenerateDSNamespaceDefs_.get("index") + 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 and name_ == "index": + 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_="index" + ) + if self.hasContent_(): + outfile.write(">%s" % (eol_,)) + self.exportChildren( + outfile, + level + 1, + namespaceprefix_, + namespacedef_, + name_="index", + pretty_print=pretty_print, + ) + outfile.write("%s" % (namespaceprefix_, name_, eol_)) + else: + outfile.write("/>%s" % (eol_,)) + + def exportAttributes( + self, outfile, level, already_processed, namespaceprefix_="", name_="index" + ): + if self.objective is not None and "objective" not in already_processed: + already_processed.add("objective") + outfile.write( + " objective=%s" + % ( + self.gds_encode( + self.gds_format_string( + quote_attrib(self.objective), input_name="objective" + ) + ), + ) + ) + + def exportChildren( + self, + outfile, + level, + namespaceprefix_="", + namespacedef_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + name_="index", + 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_ = 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_("objective", node) + if value is not None and "objective" not in already_processed: + already_processed.add("objective") + self.objective = value + + def buildChildren( + self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None + ): + pass + + +# end class index + + +class cases(GeneratedsSuper): + __hash__ = GeneratedsSuper.__hash__ + subclass = None + superclass = None + + def __init__(self, case=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 + if case is None: + self.case = [] + else: + self.case = case + self.case_nsprefix_ = None + + def factory(*args_, **kwargs_): + if CurrentSubclassModule_ is not None: + subclass = getSubclassFromModule_(CurrentSubclassModule_, cases) + if subclass is not None: + return subclass(*args_, **kwargs_) + if cases.subclass: + return cases.subclass(*args_, **kwargs_) + else: + return cases(*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_case(self): + return self.case + + def set_case(self, case): + self.case = case + + def add_case(self, value): + self.case.append(value) + + def insert_case_at(self, index, value): + self.case.insert(index, value) + + def replace_case_at(self, index, value): + self.case[index] = value + + def hasContent_(self): + if self.case: + return True + else: + return False + + def export( + self, + outfile, + level, + namespaceprefix_="", + namespacedef_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + name_="cases", + pretty_print=True, + ): + imported_ns_def_ = GenerateDSNamespaceDefs_.get("cases") + 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 and name_ == "cases": + 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_="cases" + ) + if self.hasContent_(): + outfile.write(">%s" % (eol_,)) + self.exportChildren( + outfile, + level + 1, + namespaceprefix_, + namespacedef_, + name_="cases", + pretty_print=pretty_print, + ) + showIndent(outfile, level, pretty_print) + outfile.write("%s" % (namespaceprefix_, name_, eol_)) + else: + outfile.write("/>%s" % (eol_,)) + + def exportAttributes( + self, outfile, level, already_processed, namespaceprefix_="", name_="cases" + ): + pass + + def exportChildren( + self, + outfile, + level, + namespaceprefix_="", + namespacedef_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + name_="cases", + fromsubclass_=False, + pretty_print=True, + ): + if pretty_print: + eol_ = "\n" + else: + eol_ = "" + for case_ in self.case: + namespaceprefix_ = ( + self.case_nsprefix_ + ":" + if (UseCapturedNS_ and self.case_nsprefix_) + else "" + ) + case_.export( + outfile, + level, + namespaceprefix_, + namespacedef_="", + name_="case", + 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_ = 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_ == "case": + obj_ = case.factory(parent_object_=self) + obj_.build(child_, gds_collector_=gds_collector_) + self.case.append(obj_) + obj_.original_tagname_ = "case" + + +# end class cases + + +class case(GeneratedsSuper): + __hash__ = GeneratedsSuper.__hash__ + subclass = None + superclass = None + + def __init__( + self, + index_ref=None, + points=None, + percentage=None, + error=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 + if index_ref is None: + self.index_ref = [] + else: + self.index_ref = index_ref + self.index_ref_nsprefix_ = None + self.points = points + self.points_nsprefix_ = None + self.percentage = percentage + self.percentage_nsprefix_ = None + self.error = error + self.error_nsprefix_ = None + + def factory(*args_, **kwargs_): + if CurrentSubclassModule_ is not None: + subclass = getSubclassFromModule_(CurrentSubclassModule_, case) + if subclass is not None: + return subclass(*args_, **kwargs_) + if case.subclass: + return case.subclass(*args_, **kwargs_) + else: + return case(*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_index_ref(self): + return self.index_ref + + def set_index_ref(self, index_ref): + self.index_ref = index_ref + + def add_index_ref(self, value): + self.index_ref.append(value) + + def insert_index_ref_at(self, index, value): + self.index_ref.insert(index, value) + + def replace_index_ref_at(self, index, value): + self.index_ref[index] = value + + def get_points(self): + return self.points + + def set_points(self, points): + self.points = points + + def get_percentage(self): + return self.percentage + + def set_percentage(self, percentage): + self.percentage = percentage + + def get_error(self): + return self.error + + def set_error(self, error): + self.error = error + + def hasContent_(self): + if ( + self.index_ref + or self.points is not None + or self.percentage is not None + or self.error is not None + ): + return True + else: + return False + + def export( + self, + outfile, + level, + namespaceprefix_="", + namespacedef_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + name_="case", + pretty_print=True, + ): + imported_ns_def_ = GenerateDSNamespaceDefs_.get("case") + 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 and name_ == "case": + 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_="case" + ) + if self.hasContent_(): + outfile.write(">%s" % (eol_,)) + self.exportChildren( + outfile, + level + 1, + namespaceprefix_, + namespacedef_, + name_="case", + pretty_print=pretty_print, + ) + showIndent(outfile, level, pretty_print) + outfile.write("%s" % (namespaceprefix_, name_, eol_)) + else: + outfile.write("/>%s" % (eol_,)) + + def exportAttributes( + self, outfile, level, already_processed, namespaceprefix_="", name_="case" + ): + pass + + def exportChildren( + self, + outfile, + level, + namespaceprefix_="", + namespacedef_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + name_="case", + fromsubclass_=False, + pretty_print=True, + ): + if pretty_print: + eol_ = "\n" + else: + eol_ = "" + for index_ref_ in self.index_ref: + namespaceprefix_ = ( + self.index_ref_nsprefix_ + ":" + if (UseCapturedNS_ and self.index_ref_nsprefix_) + else "" + ) + index_ref_.export( + outfile, + level, + namespaceprefix_, + namespacedef_="", + name_="index-ref", + pretty_print=pretty_print, + ) + if self.points is not None: + namespaceprefix_ = ( + self.points_nsprefix_ + ":" + if (UseCapturedNS_ and self.points_nsprefix_) + else "" + ) + self.points.export( + outfile, + level, + namespaceprefix_, + namespacedef_="", + name_="points", + pretty_print=pretty_print, + ) + if self.percentage is not None: + namespaceprefix_ = ( + self.percentage_nsprefix_ + ":" + if (UseCapturedNS_ and self.percentage_nsprefix_) + else "" + ) + self.percentage.export( + outfile, + level, + namespaceprefix_, + namespacedef_="", + name_="percentage", + pretty_print=pretty_print, + ) + if self.error is not None: + namespaceprefix_ = ( + self.error_nsprefix_ + ":" + if (UseCapturedNS_ and self.error_nsprefix_) + else "" + ) + self.error.export( + outfile, + level, + namespaceprefix_, + namespacedef_="", + name_="error", + 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_ = 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_ == "index-ref": + obj_ = index_ref.factory(parent_object_=self) + obj_.build(child_, gds_collector_=gds_collector_) + self.index_ref.append(obj_) + obj_.original_tagname_ = "index-ref" + elif nodeName_ == "points": + obj_ = points.factory(parent_object_=self) + obj_.build(child_, gds_collector_=gds_collector_) + self.points = obj_ + obj_.original_tagname_ = "points" + elif nodeName_ == "percentage": + obj_ = percentage.factory(parent_object_=self) + obj_.build(child_, gds_collector_=gds_collector_) + self.percentage = obj_ + obj_.original_tagname_ = "percentage" + elif nodeName_ == "error": + obj_ = error.factory(parent_object_=self) + obj_.build(child_, gds_collector_=gds_collector_) + self.error = obj_ + obj_.original_tagname_ = "error" + + +# end class case + + +class index_ref(GeneratedsSuper): + __hash__ = GeneratedsSuper.__hash__ + subclass = None + superclass = None + + def __init__(self, value=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.value = _cast(None, value) + self.value_nsprefix_ = None + + def factory(*args_, **kwargs_): + if CurrentSubclassModule_ is not None: + subclass = getSubclassFromModule_(CurrentSubclassModule_, index_ref) + if subclass is not None: + return subclass(*args_, **kwargs_) + if index_ref.subclass: + return index_ref.subclass(*args_, **kwargs_) + else: + return index_ref(*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_value(self): + return self.value + + def set_value(self, value): + self.value = value + + def hasContent_(self): + if (): + return True + else: + return False + + def export( + self, + outfile, + level, + namespaceprefix_="", + namespacedef_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + name_="index-ref", + pretty_print=True, + ): + imported_ns_def_ = GenerateDSNamespaceDefs_.get("index-ref") + 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 and name_ == "index-ref": + 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_="index-ref" + ) + if self.hasContent_(): + outfile.write(">%s" % (eol_,)) + self.exportChildren( + outfile, + level + 1, + namespaceprefix_, + namespacedef_, + name_="index-ref", + pretty_print=pretty_print, + ) + outfile.write("%s" % (namespaceprefix_, name_, eol_)) + else: + outfile.write("/>%s" % (eol_,)) + + def exportAttributes( + self, outfile, level, already_processed, namespaceprefix_="", name_="index-ref" + ): + if self.value is not None and "value" not in already_processed: + already_processed.add("value") + outfile.write( + " value=%s" + % ( + self.gds_encode( + self.gds_format_string( + quote_attrib(self.value), input_name="value" + ) + ), + ) + ) + + def exportChildren( + self, + outfile, + level, + namespaceprefix_="", + namespacedef_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + name_="index-ref", + 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_ = 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_("value", node) + if value is not None and "value" not in already_processed: + already_processed.add("value") + self.value = value + + def buildChildren( + self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None + ): + pass + + +# end class index_ref + + +class points(GeneratedsSuper): + __hash__ = GeneratedsSuper.__hash__ + subclass = None + superclass = None + + def __init__(self, amount=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.amount = _cast(int, amount) + self.amount_nsprefix_ = None + + def factory(*args_, **kwargs_): + if CurrentSubclassModule_ is not None: + subclass = getSubclassFromModule_(CurrentSubclassModule_, points) + if subclass is not None: + return subclass(*args_, **kwargs_) + if points.subclass: + return points.subclass(*args_, **kwargs_) + else: + return points(*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_amount(self): + return self.amount + + def set_amount(self, amount): + self.amount = amount + + def hasContent_(self): + if (): + return True + else: + return False + + def export( + self, + outfile, + level, + namespaceprefix_="", + namespacedef_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + name_="points", + pretty_print=True, + ): + imported_ns_def_ = GenerateDSNamespaceDefs_.get("points") + 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 and name_ == "points": + 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_="points" + ) + if self.hasContent_(): + outfile.write(">%s" % (eol_,)) + self.exportChildren( + outfile, + level + 1, + namespaceprefix_, + namespacedef_, + name_="points", + pretty_print=pretty_print, + ) + outfile.write("%s" % (namespaceprefix_, name_, eol_)) + else: + outfile.write("/>%s" % (eol_,)) + + def exportAttributes( + self, outfile, level, already_processed, namespaceprefix_="", name_="points" + ): + if self.amount is not None and "amount" not in already_processed: + already_processed.add("amount") + outfile.write( + ' amount="%s"' + % self.gds_format_integer(self.amount, input_name="amount") + ) + + def exportChildren( + self, + outfile, + level, + namespaceprefix_="", + namespacedef_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + name_="points", + 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_ = 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_("amount", node) + if value is not None and "amount" not in already_processed: + already_processed.add("amount") + self.amount = self.gds_parse_integer(value, node, "amount") + + def buildChildren( + self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None + ): + pass + + +# end class points + + +class percentage(GeneratedsSuper): + __hash__ = GeneratedsSuper.__hash__ + subclass = None + superclass = None + + def __init__(self, amount=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.amount = _cast(int, amount) + self.amount_nsprefix_ = None + + def factory(*args_, **kwargs_): + if CurrentSubclassModule_ is not None: + subclass = getSubclassFromModule_(CurrentSubclassModule_, percentage) + if subclass is not None: + return subclass(*args_, **kwargs_) + if percentage.subclass: + return percentage.subclass(*args_, **kwargs_) + else: + return percentage(*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_amount(self): + return self.amount + + def set_amount(self, amount): + self.amount = amount + + def hasContent_(self): + if (): + return True + else: + return False + + def export( + self, + outfile, + level, + namespaceprefix_="", + namespacedef_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + name_="percentage", + pretty_print=True, + ): + imported_ns_def_ = GenerateDSNamespaceDefs_.get("percentage") + 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 and name_ == "percentage": + 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_="percentage" + ) + if self.hasContent_(): + outfile.write(">%s" % (eol_,)) + self.exportChildren( + outfile, + level + 1, + namespaceprefix_, + namespacedef_, + name_="percentage", + pretty_print=pretty_print, + ) + outfile.write("%s" % (namespaceprefix_, name_, eol_)) + else: + outfile.write("/>%s" % (eol_,)) + + def exportAttributes( + self, outfile, level, already_processed, namespaceprefix_="", name_="percentage" + ): + if self.amount is not None and "amount" not in already_processed: + already_processed.add("amount") + outfile.write( + ' amount="%s"' + % self.gds_format_integer(self.amount, input_name="amount") + ) + + def exportChildren( + self, + outfile, + level, + namespaceprefix_="", + namespacedef_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + name_="percentage", + 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_ = 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_("amount", node) + if value is not None and "amount" not in already_processed: + already_processed.add("amount") + self.amount = self.gds_parse_integer(value, node, "amount") + + def buildChildren( + self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None + ): + pass + + +# end class percentage + + +class error(GeneratedsSuper): + __hash__ = GeneratedsSuper.__hash__ + subclass = None + superclass = None + + def __init__(self, message=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.message = _cast(None, message) + self.message_nsprefix_ = None + + def factory(*args_, **kwargs_): + if CurrentSubclassModule_ is not None: + subclass = getSubclassFromModule_(CurrentSubclassModule_, error) + if subclass is not None: + return subclass(*args_, **kwargs_) + if error.subclass: + return error.subclass(*args_, **kwargs_) + else: + return error(*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_message(self): + return self.message + + def set_message(self, message): + self.message = message + + def hasContent_(self): + if (): + return True + else: + return False + + def export( + self, + outfile, + level, + namespaceprefix_="", + namespacedef_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + name_="error", + pretty_print=True, + ): + imported_ns_def_ = GenerateDSNamespaceDefs_.get("error") + 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 and name_ == "error": + 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_="error" + ) + if self.hasContent_(): + outfile.write(">%s" % (eol_,)) + self.exportChildren( + outfile, + level + 1, + namespaceprefix_, + namespacedef_, + name_="error", + pretty_print=pretty_print, + ) + outfile.write("%s" % (namespaceprefix_, name_, eol_)) + else: + outfile.write("/>%s" % (eol_,)) + + def exportAttributes( + self, outfile, level, already_processed, namespaceprefix_="", name_="error" + ): + if self.message is not None and "message" not in already_processed: + already_processed.add("message") + outfile.write( + " message=%s" + % ( + self.gds_encode( + self.gds_format_string( + quote_attrib(self.message), input_name="message" + ) + ), + ) + ) + + def exportChildren( + self, + outfile, + level, + namespaceprefix_="", + namespacedef_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + name_="error", + 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_ = 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_("message", node) + if value is not None and "message" not in already_processed: + already_processed.add("message") + self.message = value + + def buildChildren( + self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None + ): + pass + + +# end class error + + +class resources(GeneratedsSuper): + __hash__ = GeneratedsSuper.__hash__ + subclass = None + superclass = None + + def __init__(self, resource=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 + if resource is None: + self.resource = [] + else: + self.resource = resource + self.resource_nsprefix_ = None + + def factory(*args_, **kwargs_): + if CurrentSubclassModule_ is not None: + subclass = getSubclassFromModule_(CurrentSubclassModule_, resources) + if subclass is not None: + return subclass(*args_, **kwargs_) + if resources.subclass: + return resources.subclass(*args_, **kwargs_) + else: + return resources(*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_resource(self): + return self.resource + + def set_resource(self, resource): + self.resource = resource + + def add_resource(self, value): + self.resource.append(value) + + def insert_resource_at(self, index, value): + self.resource.insert(index, value) + + def replace_resource_at(self, index, value): + self.resource[index] = value + + def hasContent_(self): + if self.resource: + return True + else: + return False + + def export( + self, + outfile, + level, + namespaceprefix_="", + namespacedef_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + name_="resources", + pretty_print=True, + ): + imported_ns_def_ = GenerateDSNamespaceDefs_.get("resources") + 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 and name_ == "resources": + 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_="resources" + ) + if self.hasContent_(): + outfile.write(">%s" % (eol_,)) + self.exportChildren( + outfile, + level + 1, + namespaceprefix_, + namespacedef_, + name_="resources", + pretty_print=pretty_print, + ) + showIndent(outfile, level, pretty_print) + outfile.write("%s" % (namespaceprefix_, name_, eol_)) + else: + outfile.write("/>%s" % (eol_,)) + + def exportAttributes( + self, outfile, level, already_processed, namespaceprefix_="", name_="resources" + ): + pass + + def exportChildren( + self, + outfile, + level, + namespaceprefix_="", + namespacedef_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + name_="resources", + fromsubclass_=False, + pretty_print=True, + ): + if pretty_print: + eol_ = "\n" + else: + eol_ = "" + for resource_ in self.resource: + namespaceprefix_ = ( + self.resource_nsprefix_ + ":" + if (UseCapturedNS_ and self.resource_nsprefix_) + else "" + ) + resource_.export( + outfile, + level, + namespaceprefix_, + namespacedef_="", + name_="resource", + 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_ = 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_ == "resource": + obj_ = resourceType.factory(parent_object_=self) + obj_.build(child_, gds_collector_=gds_collector_) + self.resource.append(obj_) + obj_.original_tagname_ = "resource" + + +# end class resources + + +class resourceType(GeneratedsSuper): + __hash__ = GeneratedsSuper.__hash__ + subclass = None + superclass = None + + def __init__( + self, name=None, quota=None, message=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.quota = _cast(int, quota) + self.quota_nsprefix_ = None + self.message = _cast(None, message) + self.message_nsprefix_ = None + + def factory(*args_, **kwargs_): + if CurrentSubclassModule_ is not None: + subclass = getSubclassFromModule_(CurrentSubclassModule_, resourceType) + if subclass is not None: + return subclass(*args_, **kwargs_) + if resourceType.subclass: + return resourceType.subclass(*args_, **kwargs_) + else: + return resourceType(*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_quota(self): + return self.quota + + def set_quota(self, quota): + self.quota = quota + + def get_message(self): + return self.message + + def set_message(self, message): + self.message = message + + def hasContent_(self): + if (): + return True + else: + return False + + def export( + self, + outfile, + level, + namespaceprefix_="", + namespacedef_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + name_="resourceType", + pretty_print=True, + ): + imported_ns_def_ = GenerateDSNamespaceDefs_.get("resourceType") + 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 and name_ == "resourceType": + 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_="resourceType" + ) + if self.hasContent_(): + outfile.write(">%s" % (eol_,)) + self.exportChildren( + outfile, + level + 1, + namespaceprefix_, + namespacedef_, + name_="resourceType", + pretty_print=pretty_print, + ) + outfile.write("%s" % (namespaceprefix_, name_, eol_)) + else: + outfile.write("/>%s" % (eol_,)) + + def exportAttributes( + self, + outfile, + level, + already_processed, + namespaceprefix_="", + name_="resourceType", + ): + 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.quota is not None and "quota" not in already_processed: + already_processed.add("quota") + outfile.write( + ' quota="%s"' % self.gds_format_integer(self.quota, input_name="quota") + ) + if self.message is not None and "message" not in already_processed: + already_processed.add("message") + outfile.write( + " message=%s" + % ( + self.gds_encode( + self.gds_format_string( + quote_attrib(self.message), input_name="message" + ) + ), + ) + ) + + def exportChildren( + self, + outfile, + level, + namespaceprefix_="", + namespacedef_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + name_="resourceType", + 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_ = 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_("quota", node) + if value is not None and "quota" not in already_processed: + already_processed.add("quota") + self.quota = self.gds_parse_integer(value, node, "quota") + if self.quota <= 0: + raise_parse_error(node, "Invalid PositiveInteger") + value = find_attr_value_("message", node) + if value is not None and "message" not in already_processed: + already_processed.add("message") + self.message = value + + def buildChildren( + self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None + ): + pass + + +# end class resourceType + + +GDSClassesMapping = {} + + +USAGE_TEXT = """ +Usage: python .py [ -s ] +""" + + +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 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 = "challenge" + rootClass = challenge + 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('\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, mapping=None, nsmap=None +): + parser = None + doc = parsexml_(inFileName, parser) + gds_collector = GdsCollector_() + rootNode = doc.getroot() + rootTag, rootClass = get_root_tag(rootNode) + if rootClass is None: + rootTag = "challenge" + rootClass = challenge + rootObj = rootClass.factory() + rootObj.build(rootNode, gds_collector_=gds_collector) + # Enable Python to collect the space used by the DOM. + if mapping is None: + mapping = {} + rootElement = rootObj.to_etree(None, name_=rootTag, mapping_=mapping, nsmap_=nsmap) + 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 = "challenge" + rootClass = challenge + rootObj = rootClass.factory() + rootObj.build(rootNode, gds_collector_=gds_collector) + if not SaveElementTreeNode: + rootNode = None + if not silence: + sys.stdout.write('\n') + rootObj.export( + sys.stdout, + 0, + name_=rootTag, + namespacedef_='xmlns:fll="http://fll-tools.com/applications/scoring/v1/challenge.xsd"', + ) + 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 = "challenge" + rootClass = challenge + 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 challenges import *\n\n") + sys.stdout.write("import challenges 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_ = {} + +# +# Mapping of namespaces to types defined in them +# and the file in which each is defined. +# simpleTypes are marked "ST" and complexTypes "CT". +NamespaceToDefMappings_ = { + "http://fll-tools.com/applications/scoring/v1/challenge.xsd": [ + ("strings", "data/challenge.xsd", "CT"), + ("string", "data/challenge.xsd", "CT"), + ("mission", "data/challenge.xsd", "CT"), + ("objective_yesno", "data/challenge.xsd", "CT"), + ("objective_number", "data/challenge.xsd", "CT"), + ("objective_enum", "data/challenge.xsd", "CT"), + ("option", "data/challenge.xsd", "CT"), + ("score", "data/challenge.xsd", "CT"), + ("indexes", "data/challenge.xsd", "CT"), + ("index", "data/challenge.xsd", "CT"), + ("cases", "data/challenge.xsd", "CT"), + ("case", "data/challenge.xsd", "CT"), + ("index_ref", "data/challenge.xsd", "CT"), + ("points", "data/challenge.xsd", "CT"), + ("percentage", "data/challenge.xsd", "CT"), + ("error", "data/challenge.xsd", "CT"), + ("resources", "data/challenge.xsd", "CT"), + ] +} + +__all__ = [ + "case", + "cases", + "challenge", + "error", + "index", + "index_ref", + "indexes", + "mission", + "objective_enum", + "objective_number", + "objective_yesno", + "option", + "percentage", + "points", + "resourceType", + "resources", + "score", + "string", + "strings", +] -- 2.45.2