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

#
# Generated Wed Nov 14 13:02:18 2012 by generateDS.py version 2.7c.
#

import sys
import getopt
import re as re_

import cybox.bindings.cybox_core_1_0 as cybox_core_binding
import cybox.bindings.cybox_common_types_1_0 as cybox_common_binding
import stix.bindings.stix_common_0_2 as stix_common_binding
import stix.bindings.stix_campaign_0_5_1 as stix_campaign_binding
import stix.bindings.stix_ttp_0_6 as stix_ttp_binding
#import stix.bindings.stix_incident_0_3_1 as stix_incident_binding
#import stix.bindings.stix_indicator_1_1 as stix_indicator_binding
#import stix.bindings.stix_exploit_target_0_3_1 as stix_exploit_target_binding
#import stix.bindings.capec.ap_schema_2_5 as ap_binding
import stix.bindings.data_marking_0_5 as data_marking_binding

etree_ = None
Verbose_import_ = False
(   XMLParser_import_none, XMLParser_import_lxml,
    XMLParser_import_elementtree
    ) = range(3)
XMLParser_import_library = None
try:
    # lxml
    from lxml import etree as etree_
    XMLParser_import_library = XMLParser_import_lxml
    if Verbose_import_:
        print("running with lxml.etree")
except ImportError:
    try:
        # cElementTree from Python 2.5+
        import xml.etree.cElementTree as etree_
        XMLParser_import_library = XMLParser_import_elementtree
        if Verbose_import_:
            print("running with cElementTree on Python 2.5+")
    except ImportError:
        try:
            # ElementTree from Python 2.5+
            import xml.etree.ElementTree as etree_
            XMLParser_import_library = XMLParser_import_elementtree
            if Verbose_import_:
                print("running with ElementTree on Python 2.5+")
        except ImportError:
            try:
                # normal cElementTree install
                import cElementTree as etree_
                XMLParser_import_library = XMLParser_import_elementtree
                if Verbose_import_:
                    print("running with cElementTree")
            except ImportError:
                try:
                    # normal ElementTree install
                    import elementtree.ElementTree as etree_
                    XMLParser_import_library = XMLParser_import_elementtree
                    if Verbose_import_:
                        print("running with ElementTree")
                except ImportError:
                    raise ImportError("Failed to import ElementTree from any known place")

def parsexml_(*args, **kwargs):
    if (XMLParser_import_library == XMLParser_import_lxml and
        'parser' not in kwargs):
        # Use the lxml ElementTree compatible parser so that, e.g.,
        #   we ignore comments.
        kwargs['parser'] = etree_.ETCompatXMLParser()
    doc = etree_.parse(*args, **kwargs)
    return doc

#
# User methods
#
# Calls to the methods in these classes are generated by generateDS.py.
# You can replace these methods by re-implementing the following class
#   in a module named generatedssuper.py.

try:
    from generatedssuper import GeneratedsSuper
except ImportError, exp:

    class GeneratedsSuper(object):
        def gds_format_string(self, input_data, input_name=''):
            return input_data
        def gds_validate_string(self, input_data, node, input_name=''):
            return input_data
        def gds_format_integer(self, input_data, input_name=''):
            return '%d' % input_data
        def gds_validate_integer(self, input_data, node, input_name=''):
            return input_data
        def gds_format_integer_list(self, input_data, input_name=''):
            return '%s' % input_data
        def gds_validate_integer_list(self, input_data, node, input_name=''):
            values = input_data.split()
            for value in values:
                try:
                    fvalue = float(value)
                except (TypeError, ValueError), exp:
                    raise_parse_error(node, 'Requires sequence of integers')
            return input_data
        def gds_format_float(self, input_data, input_name=''):
            return '%f' % input_data
        def gds_validate_float(self, input_data, node, input_name=''):
            return input_data
        def gds_format_float_list(self, input_data, input_name=''):
            return '%s' % input_data
        def gds_validate_float_list(self, input_data, node, input_name=''):
            values = input_data.split()
            for value in values:
                try:
                    fvalue = float(value)
                except (TypeError, ValueError), exp:
                    raise_parse_error(node, 'Requires sequence of floats')
            return input_data
        def gds_format_double(self, input_data, input_name=''):
            return '%e' % input_data
        def gds_validate_double(self, input_data, node, input_name=''):
            return input_data
        def gds_format_double_list(self, input_data, input_name=''):
            return '%s' % input_data
        def gds_validate_double_list(self, input_data, node, input_name=''):
            values = input_data.split()
            for value in values:
                try:
                    fvalue = float(value)
                except (TypeError, ValueError), exp:
                    raise_parse_error(node, 'Requires sequence of doubles')
            return input_data
        def gds_format_boolean(self, input_data, input_name=''):
            return '%s' % input_data
        def gds_validate_boolean(self, input_data, node, input_name=''):
            return input_data
        def gds_format_boolean_list(self, input_data, input_name=''):
            return '%s' % input_data
        def gds_validate_boolean_list(self, input_data, node, input_name=''):
            values = input_data.split()
            for value in values:
                if value not in ('true', '1', 'false', '0', ):
                    raise_parse_error(node, 'Requires sequence of booleans ("true", "1", "false", "0")')
            return input_data
        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):
            return None


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

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

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

#
# Globals
#

ExternalEncoding = 'ascii'
Tag_pattern_ = re_.compile(r'({.*})?(.*)')
String_cleanup_pat_ = re_.compile(r"[\n\r\s]+")
Namespace_extract_pat_ = re_.compile(r'{(.*)}(.*)')

#
# Support/utility functions.
#

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

def quote_xml(inStr):
    if not inStr:
        return ''
    s1 = (isinstance(inStr, basestring) and inStr or
          '%s' % inStr)
    s1 = s1.replace('&', '&amp;')
    s1 = s1.replace('<', '&lt;')
    s1 = s1.replace('>', '&gt;')
    return s1

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

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

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

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


class GDSParseError(Exception):
    pass

def raise_parse_error(node, msg):
    if XMLParser_import_library == XMLParser_import_lxml:
        msg = '%s (element %s/line %d)' % (msg, node.tag, node.sourceline, )
    else:
        msg = '%s (element %s)' % (msg, node.tag, )
    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
    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, pretty_print)
    def exportSimple(self, outfile, level, name):
        if self.content_type == MixedContainer.TypeString:
            outfile.write('<%s>%s</%s>' % (self.name, self.value, self.name))
        elif self.content_type == MixedContainer.TypeInteger or \
                self.content_type == MixedContainer.TypeBoolean:
            outfile.write('<%s>%d</%s>' % (self.name, self.value, self.name))
        elif self.content_type == MixedContainer.TypeFloat or \
                self.content_type == MixedContainer.TypeDecimal:
            outfile.write('<%s>%f</%s>' % (self.name, self.value, self.name))
        elif self.content_type == MixedContainer.TypeDouble:
            outfile.write('<%s>%g</%s>' % (self.name, self.value, self.name))
    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):
        self.name = name
        self.data_type = data_type
        self.container = container
    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 _cast(typ, value):
    if typ is None or value is None:
        return value
    return typ(value)

#
# Data representation classes.
#


class ThreatActorType(GeneratedsSuper):
    """Specifies a globally unique identifier for this ThreatActor.
    Specifies a globally unique identifier of a ThreatActor
    specified elsewhere.Specifies the relevant STIX-ThreatActor
    schema version for this content."""
    subclass = None
    superclass = None
    def __init__(self, idref=None, id=None, version=None, Identity=None, Intent=None, ObservedTTPs=None, HistoricalCampaigns=None, AssociatedActors=None, Handling=None, Confidence=None, InformationSource=None):
        self.idref = _cast(None, idref)
        self.id = _cast(None, id)
        self.version = _cast(None, version)
        self.Identity = Identity
        if Intent is None:
            self.Intent = []
        else:
            self.Intent = Intent
        self.ObservedTTPs = ObservedTTPs
        self.HistoricalCampaigns = HistoricalCampaigns
        self.AssociatedActors = AssociatedActors
        self.Handling = Handling
        self.Confidence = Confidence
        self.InformationSource = InformationSource
    def factory(*args_, **kwargs_):
        if ThreatActorType.subclass:
            return ThreatActorType.subclass(*args_, **kwargs_)
        else:
            return ThreatActorType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_Identity(self): return self.Identity
    def set_Identity(self, Identity): self.Identity = Identity
    def get_Intent(self): return self.Intent
    def set_Intent(self, Intent): self.Intent = Intent
    def add_Intent(self, value): self.Intent.append(value)
    def insert_Intent(self, index, value): self.Intent[index] = value
    def get_ObservedTTPs(self): return self.ObservedTTPs
    def set_ObservedTTPs(self, ObservedTTPs): self.ObservedTTPs = ObservedTTPs
    def get_HistoricalCampaigns(self): return self.HistoricalCampaigns
    def set_HistoricalCampaigns(self, HistoricalCampaigns): self.HistoricalCampaigns = HistoricalCampaigns
    def get_AssociatedActors(self): return self.AssociatedActors
    def set_AssociatedActors(self, AssociatedActors): self.AssociatedActors = AssociatedActors
    def get_Handling(self): return self.Handling
    def set_Handling(self, Handling): self.Handling = Handling
    def get_Confidence(self): return self.Confidence
    def set_Confidence(self, Confidence): self.Confidence = Confidence
    def get_InformationSource(self): return self.InformationSource
    def set_InformationSource(self, InformationSource): self.InformationSource = InformationSource
    def get_idref(self): return self.idref
    def set_idref(self, idref): self.idref = idref
    def get_id(self): return self.id
    def set_id(self, id): self.id = id
    def get_version(self): return self.version
    def set_version(self, version): self.version = version
    def export(self, outfile, level, namespace_='TA:', name_='ThreatActorType', namespacedef_='', pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='ThreatActorType')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespace_, name_, pretty_print=pretty_print)
            showIndent(outfile, level, pretty_print)
            outfile.write('</%s%s>%s' % (namespace_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespace_='TA:', name_='ThreatActorType'):
        if self.idref is not None and 'idref' not in already_processed:
            already_processed.append('idref')
            outfile.write(' idref=%s' % (quote_attrib(self.idref), ))
        if self.id is not None and 'id' not in already_processed:
            already_processed.append('id')
            outfile.write(' id=%s' % (quote_attrib(self.id), ))
        if self.version is not None and 'version' not in already_processed:
            already_processed.append('version')
            outfile.write(' version=%s' % (self.gds_format_string(quote_attrib(self.version).encode(ExternalEncoding), input_name='version'), ))
    def exportChildren(self, outfile, level, namespace_='TA:', name_='ThreatActorType', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.Identity is not None:
            self.Identity.export(outfile, level, 'TA:', name_='Identity', pretty_print=pretty_print)
        for Intent_ in self.Intent:
            Intent_.export(outfile, level, 'TA:', name_='Intent', pretty_print=pretty_print)
        if self.ObservedTTPs is not None:
            self.ObservedTTPs.export(outfile, level, 'TA:', name_='ObservedTTPs', pretty_print=pretty_print)
        if self.HistoricalCampaigns is not None:
            self.HistoricalCampaigns.export(outfile, level, 'TA:', name_='HistoricalCampaigns', pretty_print=pretty_print)
        if self.AssociatedActors is not None:
            self.AssociatedActors.export(outfile, level, 'TA:', name_='AssociatedActors', pretty_print=pretty_print)
        if self.Handling is not None:
            self.Handling.export(outfile, level, 'TA:', name_='Handling', pretty_print=pretty_print)
        if self.Confidence is not None:
            self.Confidence.export(outfile, level, 'TA:', name_='Confidence', pretty_print=pretty_print)
        if self.InformationSource is not None:
            self.InformationSource.export(outfile, level, 'TA:', name_='InformationSource', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.Identity is not None or
            self.Intent or
            self.ObservedTTPs is not None or
            self.HistoricalCampaigns is not None or
            self.AssociatedActors is not None or
            self.Handling is not None or
            self.Confidence is not None or
            self.InformationSource is not None
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='ThreatActorType'):
        level += 1
        self.exportLiteralAttributes(outfile, level, [], name_)
        if self.hasContent_():
            self.exportLiteralChildren(outfile, level, name_)
    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
        if self.idref is not None and 'idref' not in already_processed:
            already_processed.append('idref')
            showIndent(outfile, level)
            outfile.write('idref = %s,\n' % (self.idref,))
        if self.id is not None and 'id' not in already_processed:
            already_processed.append('id')
            showIndent(outfile, level)
            outfile.write('id = %s,\n' % (self.id,))
        if self.version is not None and 'version' not in already_processed:
            already_processed.append('version')
            showIndent(outfile, level)
            outfile.write('version = "%s",\n' % (self.version,))
    def exportLiteralChildren(self, outfile, level, name_):
        if self.Identity is not None:
            showIndent(outfile, level)
            outfile.write('Identity=model_.stix_common_binding.IdentityType(\n')
            self.Identity.exportLiteral(outfile, level, name_='Identity')
            showIndent(outfile, level)
            outfile.write('),\n')
        showIndent(outfile, level)
        outfile.write('Intent=[\n')
        level += 1
        for Intent_ in self.Intent:
            showIndent(outfile, level)
            outfile.write('model_.stix_common_binding.IntentType(\n')
            Intent_.exportLiteral(outfile, level, name_='stix_common_binding.IntentType')
            showIndent(outfile, level)
            outfile.write('),\n')
        level -= 1
        showIndent(outfile, level)
        outfile.write('],\n')
        if self.ObservedTTPs is not None:
            showIndent(outfile, level)
            outfile.write('ObservedTTPs=model_.ObservedTTPsType(\n')
            self.ObservedTTPs.exportLiteral(outfile, level, name_='ObservedTTPs')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.HistoricalCampaigns is not None:
            showIndent(outfile, level)
            outfile.write('HistoricalCampaigns=model_.HistoricalCampaignsType(\n')
            self.HistoricalCampaigns.exportLiteral(outfile, level, name_='HistoricalCampaigns')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.AssociatedActors is not None:
            showIndent(outfile, level)
            outfile.write('AssociatedActors=model_.AssociatedActorsType(\n')
            self.AssociatedActors.exportLiteral(outfile, level, name_='AssociatedActors')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.Handling is not None:
            showIndent(outfile, level)
            outfile.write('Handling=model_.data_marking_binding.MarkingType(\n')
            self.Handling.exportLiteral(outfile, level, name_='Handling')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.Confidence is not None:
            showIndent(outfile, level)
            outfile.write('Confidence=model_.stix_common_binding.ConfidenceType(\n')
            self.Confidence.exportLiteral(outfile, level, name_='Confidence')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.InformationSource is not None:
            showIndent(outfile, level)
            outfile.write('InformationSource=model_.stix_common_binding.InformationSourceType(\n')
            self.InformationSource.exportLiteral(outfile, level, name_='InformationSource')
            showIndent(outfile, level)
            outfile.write('),\n')
    def build(self, node):
        self.buildAttributes(node, node.attrib, [])
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_)
    def buildAttributes(self, node, attrs, already_processed):
        value = find_attr_value_('idref', node)
        if value is not None and 'idref' not in already_processed:
            already_processed.append('idref')
            self.idref = value
        value = find_attr_value_('id', node)
        if value is not None and 'id' not in already_processed:
            already_processed.append('id')
            self.id = value
        value = find_attr_value_('version', node)
        if value is not None and 'version' not in already_processed:
            already_processed.append('version')
            self.version = value
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'Identity':
            obj_ = stix_common_binding.IdentityType.factory()
            obj_.build(child_)
            self.set_Identity(obj_)
        elif nodeName_ == 'Intent':
            obj_ = stix_common_binding.IntentType.factory()
            obj_.build(child_)
            self.Intent.append(obj_)
        elif nodeName_ == 'ObservedTTPs':
            obj_ = ObservedTTPsType.factory()
            obj_.build(child_)
            self.set_ObservedTTPs(obj_)
        elif nodeName_ == 'HistoricalCampaigns':
            obj_ = HistoricalCampaignsType.factory()
            obj_.build(child_)
            self.set_HistoricalCampaigns(obj_)
        elif nodeName_ == 'AssociatedActors':
            obj_ = AssociatedActorsType.factory()
            obj_.build(child_)
            self.set_AssociatedActors(obj_)
        elif nodeName_ == 'Handling':
            obj_ = data_marking_binding.MarkingType.factory()
            obj_.build(child_)
            self.set_Handling(obj_)
        elif nodeName_ == 'Confidence':
            obj_ = stix_common_binding.ConfidenceType.factory()
            obj_.build(child_)
            self.set_Confidence(obj_)
        elif nodeName_ == 'InformationSource':
            obj_ = stix_common_binding.InformationSourceType.factory()
            obj_.build(child_)
            self.set_InformationSource(obj_)
# end class ThreatActorType




class TTPType(GeneratedsSuper):
    """TTPType characterizes an individual adversary TTP.Specifies a
    globally unique identifier for this TTP item. Specifies a
    globally unique identifier of a TTP item specified
    elsewhere.Specifies the relevant STIX-TTP schema version for
    this content."""
    subclass = None
    superclass = None
    def __init__(self, idref=None, id=None, version=None, Behavior_AttackPatterns=None, Behavior_Malware=None, Behavior_Exploits=None, Resource_Tools=None, Resource_Infrastructure=None, VictimTargeting=None, ExploitTargets=None, Intent=None, RelatedTTPs=None, KillChainPhases=None, InformationSource=None, KillChains=None):
        self.idref = _cast(None, idref)
        self.id = _cast(None, id)
        self.version = _cast(None, version)
        self.Behavior_AttackPatterns = Behavior_AttackPatterns
        self.Behavior_Malware = Behavior_Malware
        self.Behavior_Exploits = Behavior_Exploits
        self.Resource_Tools = Resource_Tools
        self.Resource_Infrastructure = Resource_Infrastructure
        self.VictimTargeting = VictimTargeting
        self.ExploitTargets = ExploitTargets
        self.Intent = Intent
        self.RelatedTTPs = RelatedTTPs
        self.KillChainPhases = KillChainPhases
        self.InformationSource = InformationSource
        self.KillChains = KillChains
    def factory(*args_, **kwargs_):
        if TTPType.subclass:
            return TTPType.subclass(*args_, **kwargs_)
        else:
            return TTPType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_Behavior_AttackPatterns(self): return self.Behavior_AttackPatterns
    def set_Behavior_AttackPatterns(self, Behavior_AttackPatterns): self.Behavior_AttackPatterns = Behavior_AttackPatterns
    def get_Behavior_Malware(self): return self.Behavior_Malware
    def set_Behavior_Malware(self, Behavior_Malware): self.Behavior_Malware = Behavior_Malware
    def get_Behavior_Exploits(self): return self.Behavior_Exploits
    def set_Behavior_Exploits(self, Behavior_Exploits): self.Behavior_Exploits = Behavior_Exploits
    def get_Resource_Tools(self): return self.Resource_Tools
    def set_Resource_Tools(self, Resource_Tools): self.Resource_Tools = Resource_Tools
    def get_Resource_Infrastructure(self): return self.Resource_Infrastructure
    def set_Resource_Infrastructure(self, Resource_Infrastructure): self.Resource_Infrastructure = Resource_Infrastructure
    def get_VictimTargeting(self): return self.VictimTargeting
    def set_VictimTargeting(self, VictimTargeting): self.VictimTargeting = VictimTargeting
    def get_ExploitTargets(self): return self.ExploitTargets
    def set_ExploitTargets(self, ExploitTargets): self.ExploitTargets = ExploitTargets
    def get_Intent(self): return self.Intent
    def set_Intent(self, Intent): self.Intent = Intent
    def get_RelatedTTPs(self): return self.RelatedTTPs
    def set_RelatedTTPs(self, RelatedTTPs): self.RelatedTTPs = RelatedTTPs
    def get_KillChainPhases(self): return self.KillChainPhases
    def set_KillChainPhases(self, KillChainPhases): self.KillChainPhases = KillChainPhases
    def get_InformationSource(self): return self.InformationSource
    def set_InformationSource(self, InformationSource): self.InformationSource = InformationSource
    def get_KillChains(self): return self.KillChains
    def set_KillChains(self, KillChains): self.KillChains = KillChains
    def get_idref(self): return self.idref
    def set_idref(self, idref): self.idref = idref
    def get_id(self): return self.id
    def set_id(self, id): self.id = id
    def get_version(self): return self.version
    def set_version(self, version): self.version = version
    def export(self, outfile, level, namespace_='TTP:', name_='TTPType', namespacedef_='', pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='TTPType')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespace_, name_, pretty_print=pretty_print)
            showIndent(outfile, level, pretty_print)
            outfile.write('</%s%s>%s' % (namespace_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespace_='TTP:', name_='TTPType'):
        if self.idref is not None and 'idref' not in already_processed:
            already_processed.append('idref')
            outfile.write(' idref=%s' % (quote_attrib(self.idref), ))
        if self.id is not None and 'id' not in already_processed:
            already_processed.append('id')
            outfile.write(' id=%s' % (quote_attrib(self.id), ))
        if self.version is not None and 'version' not in already_processed:
            already_processed.append('version')
            outfile.write(' version=%s' % (self.gds_format_string(quote_attrib(self.version).encode(ExternalEncoding), input_name='version'), ))
    def exportChildren(self, outfile, level, namespace_='TTP:', name_='TTPType', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.Behavior_AttackPatterns is not None:
            self.Behavior_AttackPatterns.export(outfile, level, 'TTP:', name_='Behavior-AttackPatterns', pretty_print=pretty_print)
        if self.Behavior_Malware is not None:
            self.Behavior_Malware.export(outfile, level, 'TTP:', name_='Behavior-Malware', pretty_print=pretty_print)
        if self.Behavior_Exploits is not None:
            self.Behavior_Exploits.export(outfile, level, 'TTP:', name_='Behavior-Exploits', pretty_print=pretty_print)
        if self.Resource_Tools is not None:
            self.Resource_Tools.export(outfile, level, 'TTP:', name_='Resource-Tools', pretty_print=pretty_print)
        if self.Resource_Infrastructure is not None:
            self.Resource_Infrastructure.export(outfile, level, 'TTP:', name_='Resource-Infrastructure', pretty_print=pretty_print)
        if self.VictimTargeting is not None:
            self.VictimTargeting.export(outfile, level, 'TTP:', name_='VictimTargeting', pretty_print=pretty_print)
        if self.ExploitTargets is not None:
            self.ExploitTargets.export(outfile, level, 'TTP:', name_='ExploitTargets', pretty_print=pretty_print)
        if self.Intent is not None:
            self.Intent.export(outfile, level, 'TTP:', name_='Intent', pretty_print=pretty_print)
        if self.RelatedTTPs is not None:
            self.RelatedTTPs.export(outfile, level, 'TTP:', name_='RelatedTTPs', pretty_print=pretty_print)
        if self.KillChainPhases is not None:
            self.KillChainPhases.export(outfile, level, 'TTP:', name_='KillChainPhases', pretty_print=pretty_print)
        if self.InformationSource is not None:
            self.InformationSource.export(outfile, level, 'TTP:', name_='InformationSource', pretty_print=pretty_print)
        if self.KillChains is not None:
            self.KillChains.export(outfile, level, 'TTP:', name_='KillChains', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.Behavior_AttackPatterns is not None or
            self.Behavior_Malware is not None or
            self.Behavior_Exploits is not None or
            self.Resource_Tools is not None or
            self.Resource_Infrastructure is not None or
            self.VictimTargeting is not None or
            self.ExploitTargets is not None or
            self.Intent is not None or
            self.RelatedTTPs is not None or
            self.KillChainPhases is not None or
            self.InformationSource is not None or
            self.KillChains is not None
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='TTPType'):
        level += 1
        self.exportLiteralAttributes(outfile, level, [], name_)
        if self.hasContent_():
            self.exportLiteralChildren(outfile, level, name_)
    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
        if self.idref is not None and 'idref' not in already_processed:
            already_processed.append('idref')
            showIndent(outfile, level)
            outfile.write('idref = %s,\n' % (self.idref,))
        if self.id is not None and 'id' not in already_processed:
            already_processed.append('id')
            showIndent(outfile, level)
            outfile.write('id = %s,\n' % (self.id,))
        if self.version is not None and 'version' not in already_processed:
            already_processed.append('version')
            showIndent(outfile, level)
            outfile.write('version = "%s",\n' % (self.version,))
    def exportLiteralChildren(self, outfile, level, name_):
        if self.Behavior_AttackPatterns is not None:
            showIndent(outfile, level)
            outfile.write('Behavior_AttackPatterns=model_.Behavior_AttackPatternsType(\n')
            self.Behavior_AttackPatterns.exportLiteral(outfile, level, name_='Behavior_AttackPatterns')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.Behavior_Malware is not None:
            showIndent(outfile, level)
            outfile.write('Behavior_Malware=model_.Behavior_MalwareType(\n')
            self.Behavior_Malware.exportLiteral(outfile, level, name_='Behavior_Malware')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.Behavior_Exploits is not None:
            showIndent(outfile, level)
            outfile.write('Behavior_Exploits=model_.Behavior_ExploitsType(\n')
            self.Behavior_Exploits.exportLiteral(outfile, level, name_='Behavior_Exploits')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.Resource_Tools is not None:
            showIndent(outfile, level)
            outfile.write('Resource_Tools=model_.Resource_ToolsType(\n')
            self.Resource_Tools.exportLiteral(outfile, level, name_='Resource_Tools')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.Resource_Infrastructure is not None:
            showIndent(outfile, level)
            outfile.write('Resource_Infrastructure=model_.Resource_InfrastructureType(\n')
            self.Resource_Infrastructure.exportLiteral(outfile, level, name_='Resource_Infrastructure')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.VictimTargeting is not None:
            showIndent(outfile, level)
            outfile.write('VictimTargeting=model_.stix_common_binding.IdentityType(\n')
            self.VictimTargeting.exportLiteral(outfile, level, name_='VictimTargeting')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.ExploitTargets is not None:
            showIndent(outfile, level)
            outfile.write('ExploitTargets=model_.ExploitTargetsType(\n')
            self.ExploitTargets.exportLiteral(outfile, level, name_='ExploitTargets')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.Intent is not None:
            showIndent(outfile, level)
            outfile.write('Intent=model_.stix_common_binding.IntentType(\n')
            self.Intent.exportLiteral(outfile, level, name_='Intent')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.RelatedTTPs is not None:
            showIndent(outfile, level)
            outfile.write('RelatedTTPs=model_.RelatedTTPsType(\n')
            self.RelatedTTPs.exportLiteral(outfile, level, name_='RelatedTTPs')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.KillChainPhases is not None:
            showIndent(outfile, level)
            outfile.write('KillChainPhases=model_.KillChainPhasesType(\n')
            self.KillChainPhases.exportLiteral(outfile, level, name_='KillChainPhases')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.InformationSource is not None:
            showIndent(outfile, level)
            outfile.write('InformationSource=model_.stix_common_binding.InformationSourceType(\n')
            self.InformationSource.exportLiteral(outfile, level, name_='InformationSource')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.KillChains is not None:
            showIndent(outfile, level)
            outfile.write('KillChains=model_.KillChainsType(\n')
            self.KillChains.exportLiteral(outfile, level, name_='KillChains')
            showIndent(outfile, level)
            outfile.write('),\n')
    def build(self, node):
        self.buildAttributes(node, node.attrib, [])
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_)
    def buildAttributes(self, node, attrs, already_processed):
        value = find_attr_value_('idref', node)
        if value is not None and 'idref' not in already_processed:
            already_processed.append('idref')
            self.idref = value
        value = find_attr_value_('id', node)
        if value is not None and 'id' not in already_processed:
            already_processed.append('id')
            self.id = value
        value = find_attr_value_('version', node)
        if value is not None and 'version' not in already_processed:
            already_processed.append('version')
            self.version = value
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'Behavior-AttackPatterns':
            obj_ = stix_ttp_binding.Behavior_AttackPatternsType.factory()
            obj_.build(child_)
            self.set_Behavior_AttackPatterns(obj_)
        elif nodeName_ == 'Behavior-Malware':
            obj_ = stix_ttp_binding.Behavior_MalwareType.factory()
            obj_.build(child_)
            self.set_Behavior_Malware(obj_)
        elif nodeName_ == 'Behavior-Exploits':
            obj_ = stix_ttp_binding.Behavior_ExploitsType.factory()
            obj_.build(child_)
            self.set_Behavior_Exploits(obj_)
        elif nodeName_ == 'Resource-Tools':
            obj_ = stix_ttp_binding.Resource_ToolsType.factory()
            obj_.build(child_)
            self.set_Resource_Tools(obj_)
        elif nodeName_ == 'Resource-Infrastructure':
            obj_ = stix_ttp_binding.Resource_InfrastructureType.factory()
            obj_.build(child_)
            self.set_Resource_Infrastructure(obj_)
        elif nodeName_ == 'VictimTargeting':
            obj_ = stix_common_binding.IdentityType.factory()
            obj_.build(child_)
            self.set_VictimTargeting(obj_)
        elif nodeName_ == 'ExploitTargets':
            obj_ = stix_ttp_binding.ExploitTargetsType.factory()
            obj_.build(child_)
            self.set_ExploitTargets(obj_)
        elif nodeName_ == 'Intent':
            obj_ = stix_common_binding.IntentType.factory()
            obj_.build(child_)
            self.set_Intent(obj_)
        elif nodeName_ == 'RelatedTTPs':
            obj_ = stix_ttp_binding.RelatedTTPsType.factory()
            obj_.build(child_)
            self.set_RelatedTTPs(obj_)
        elif nodeName_ == 'KillChainPhases':
            obj_ = stix_ttp_binding.KillChainPhasesType.factory()
            obj_.build(child_)
            self.set_KillChainPhases(obj_)
        elif nodeName_ == 'InformationSource':
            obj_ = stix_common_binding.InformationSourceType.factory()
            obj_.build(child_)
            self.set_InformationSource(obj_)
        elif nodeName_ == 'KillChains':
            obj_ = stix_ttp_binding.KillChainsType.factory()
            obj_.build(child_)
            self.set_KillChains(obj_)
# end class TTPType




class CampaignType(GeneratedsSuper):
    """The CampaignType characterizes a single cyber threat
    Campaign.Specifies a globally unique identifier for this cyber
    threat Campaign.Specifies a globally unique identifier for a
    cyber threat Campaign specified elsewhere.Specifies the relevant
    STIX-Campaign schema version for this content."""
    subclass = None
    superclass = None
    def __init__(self, idref=None, id=None, version=None, Names=None, Intent=None, RelatedTTPs=None, RelatedIncidents=None, RelatedIndicators=None, Attribution=None, AssociatedCampaigns=None, Confidence=None, Activity=None, InformationSource=None):
        self.idref = _cast(None, idref)
        self.id = _cast(None, id)
        self.version = _cast(None, version)
        self.Names = Names
        self.Intent = Intent
        self.RelatedTTPs = RelatedTTPs
        self.RelatedIncidents = RelatedIncidents
        self.RelatedIndicators = RelatedIndicators
        if Attribution is None:
            self.Attribution = []
        else:
            self.Attribution = Attribution
        self.AssociatedCampaigns = AssociatedCampaigns
        self.Confidence = Confidence
        if Activity is None:
            self.Activity = []
        else:
            self.Activity = Activity
        self.InformationSource = InformationSource
    def factory(*args_, **kwargs_):
        if CampaignType.subclass:
            return CampaignType.subclass(*args_, **kwargs_)
        else:
            return CampaignType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_Names(self): return self.Names
    def set_Names(self, Names): self.Names = Names
    def get_Intent(self): return self.Intent
    def set_Intent(self, Intent): self.Intent = Intent
    def get_RelatedTTPs(self): return self.RelatedTTPs
    def set_RelatedTTPs(self, RelatedTTPs): self.RelatedTTPs = RelatedTTPs
    def get_RelatedIncidents(self): return self.RelatedIncidents
    def set_RelatedIncidents(self, RelatedIncidents): self.RelatedIncidents = RelatedIncidents
    def get_RelatedIndicators(self): return self.RelatedIndicators
    def set_RelatedIndicators(self, RelatedIndicators): self.RelatedIndicators = RelatedIndicators
    def get_Attribution(self): return self.Attribution
    def set_Attribution(self, Attribution): self.Attribution = Attribution
    def add_Attribution(self, value): self.Attribution.append(value)
    def insert_Attribution(self, index, value): self.Attribution[index] = value
    def get_AssociatedCampaigns(self): return self.AssociatedCampaigns
    def set_AssociatedCampaigns(self, AssociatedCampaigns): self.AssociatedCampaigns = AssociatedCampaigns
    def get_Confidence(self): return self.Confidence
    def set_Confidence(self, Confidence): self.Confidence = Confidence
    def get_Activity(self): return self.Activity
    def set_Activity(self, Activity): self.Activity = Activity
    def add_Activity(self, value): self.Activity.append(value)
    def insert_Activity(self, index, value): self.Activity[index] = value
    def get_InformationSource(self): return self.InformationSource
    def set_InformationSource(self, InformationSource): self.InformationSource = InformationSource
    def get_idref(self): return self.idref
    def set_idref(self, idref): self.idref = idref
    def get_id(self): return self.id
    def set_id(self, id): self.id = id
    def get_version(self): return self.version
    def set_version(self, version): self.version = version
    def export(self, outfile, level, namespace_='campaign:', name_='CampaignType', namespacedef_='', pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='CampaignType')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespace_, name_, pretty_print=pretty_print)
            showIndent(outfile, level, pretty_print)
            outfile.write('</%s%s>%s' % (namespace_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespace_='campaign:', name_='CampaignType'):
        if self.idref is not None and 'idref' not in already_processed:
            already_processed.append('idref')
            outfile.write(' idref=%s' % (quote_attrib(self.idref), ))
        if self.id is not None and 'id' not in already_processed:
            already_processed.append('id')
            outfile.write(' id=%s' % (quote_attrib(self.id), ))
        if self.version is not None and 'version' not in already_processed:
            already_processed.append('version')
            outfile.write(' version=%s' % (self.gds_format_string(quote_attrib(self.version).encode(ExternalEncoding), input_name='version'), ))
    def exportChildren(self, outfile, level, namespace_='campaign:', name_='CampaignType', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.Names is not None:
            self.Names.export(outfile, level, 'campaign:', name_='Names', pretty_print=pretty_print)
        if self.Intent is not None:
            self.Intent.export(outfile, level, 'campaign:', name_='Intent', pretty_print=pretty_print)
        if self.RelatedTTPs is not None:
            self.RelatedTTPs.export(outfile, level, 'campaign:', name_='RelatedTTPs', pretty_print=pretty_print)
        if self.RelatedIncidents is not None:
            self.RelatedIncidents.export(outfile, level, 'campaign:', name_='RelatedIncidents', pretty_print=pretty_print)
        if self.RelatedIndicators is not None:
            self.RelatedIndicators.export(outfile, level, 'campaign:', name_='RelatedIndicators', pretty_print=pretty_print)
        for Attribution_ in self.Attribution:
            Attribution_.export(outfile, level, 'campaign:', name_='Attribution', pretty_print=pretty_print)
        if self.AssociatedCampaigns is not None:
            self.AssociatedCampaigns.export(outfile, level, 'campaign:', name_='AssociatedCampaigns', pretty_print=pretty_print)
        if self.Confidence is not None:
            self.Confidence.export(outfile, level, 'campaign:', name_='Confidence', pretty_print=pretty_print)
        for Activity_ in self.get_Activity():
            Activity_.export(outfile, level, 'campaign:', name_='Activity', pretty_print=pretty_print)
        if self.InformationSource is not None:
            self.InformationSource.export(outfile, level, 'campaign:', name_='InformationSource', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.Names is not None or
            self.Intent is not None or
            self.RelatedTTPs is not None or
            self.RelatedIncidents is not None or
            self.RelatedIndicators is not None or
            self.Attribution or
            self.AssociatedCampaigns is not None or
            self.Confidence is not None or
            self.Activity or
            self.InformationSource is not None
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='CampaignType'):
        level += 1
        self.exportLiteralAttributes(outfile, level, [], name_)
        if self.hasContent_():
            self.exportLiteralChildren(outfile, level, name_)
    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
        if self.idref is not None and 'idref' not in already_processed:
            already_processed.append('idref')
            showIndent(outfile, level)
            outfile.write('idref = %s,\n' % (self.idref,))
        if self.id is not None and 'id' not in already_processed:
            already_processed.append('id')
            showIndent(outfile, level)
            outfile.write('id = %s,\n' % (self.id,))
        if self.version is not None and 'version' not in already_processed:
            already_processed.append('version')
            showIndent(outfile, level)
            outfile.write('version = "%s",\n' % (self.version,))
    def exportLiteralChildren(self, outfile, level, name_):
        if self.Names is not None:
            showIndent(outfile, level)
            outfile.write('Names=model_.NamesType(\n')
            self.Names.exportLiteral(outfile, level, name_='Names')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.Intent is not None:
            showIndent(outfile, level)
            outfile.write('Intent=model_.stix_common_binding.IntentType(\n')
            self.Intent.exportLiteral(outfile, level, name_='Intent')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.RelatedTTPs is not None:
            showIndent(outfile, level)
            outfile.write('RelatedTTPs=model_.RelatedTTPsType(\n')
            self.RelatedTTPs.exportLiteral(outfile, level, name_='RelatedTTPs')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.RelatedIncidents is not None:
            showIndent(outfile, level)
            outfile.write('RelatedIncidents=model_.RelatedIncidentsType(\n')
            self.RelatedIncidents.exportLiteral(outfile, level, name_='RelatedIncidents')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.RelatedIndicators is not None:
            showIndent(outfile, level)
            outfile.write('RelatedIndicators=model_.RelatedIndicatorsType(\n')
            self.RelatedIndicators.exportLiteral(outfile, level, name_='RelatedIndicators')
            showIndent(outfile, level)
            outfile.write('),\n')
        showIndent(outfile, level)
        outfile.write('Attribution=[\n')
        level += 1
        for Attribution_ in self.Attribution:
            showIndent(outfile, level)
            outfile.write('model_.AttributionType(\n')
            Attribution_.exportLiteral(outfile, level, name_='AttributionType')
            showIndent(outfile, level)
            outfile.write('),\n')
        level -= 1
        showIndent(outfile, level)
        outfile.write('],\n')
        if self.AssociatedCampaigns is not None:
            showIndent(outfile, level)
            outfile.write('AssociatedCampaigns=model_.AssociatedCampaignsType(\n')
            self.AssociatedCampaigns.exportLiteral(outfile, level, name_='AssociatedCampaigns')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.Confidence is not None:
            showIndent(outfile, level)
            outfile.write('Confidence=model_.stix_common_binding.ConfidenceType(\n')
            self.Confidence.exportLiteral(outfile, level, name_='Confidence')
            showIndent(outfile, level)
            outfile.write('),\n')
        showIndent(outfile, level)
        outfile.write('Activity=[\n')
        level += 1
        for Activity_ in self.Activity:
            showIndent(outfile, level)
            outfile.write('model_.stix_common_binding.ActivityType(\n')
            Activity_.exportLiteral(outfile, level, name_='stix_common_binding.ActivityType')
            showIndent(outfile, level)
            outfile.write('),\n')
        level -= 1
        showIndent(outfile, level)
        outfile.write('],\n')
        if self.InformationSource is not None:
            showIndent(outfile, level)
            outfile.write('InformationSource=model_.stix_common_binding.InformationSourceType(\n')
            self.InformationSource.exportLiteral(outfile, level, name_='InformationSource')
            showIndent(outfile, level)
            outfile.write('),\n')
    def build(self, node):
        self.buildAttributes(node, node.attrib, [])
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_)
    def buildAttributes(self, node, attrs, already_processed):
        value = find_attr_value_('idref', node)
        if value is not None and 'idref' not in already_processed:
            already_processed.append('idref')
            self.idref = value
        value = find_attr_value_('id', node)
        if value is not None and 'id' not in already_processed:
            already_processed.append('id')
            self.id = value
        value = find_attr_value_('version', node)
        if value is not None and 'version' not in already_processed:
            already_processed.append('version')
            self.version = value
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'Names':
            obj_ = stix_campaign_binding.NamesType.factory()
            obj_.build(child_)
            self.set_Names(obj_)
        elif nodeName_ == 'Intent':
            obj_ = stix_common_binding.IntentType.factory()
            obj_.build(child_)
            self.set_Intent(obj_)
        elif nodeName_ == 'RelatedTTPs':
            obj_ = stix_campaign_binding.RelatedTTPsType.factory()
            obj_.build(child_)
            self.set_RelatedTTPs(obj_)
        elif nodeName_ == 'RelatedIncidents':
            obj_ = stix_campaign_binding.RelatedIncidentsType.factory()
            obj_.build(child_)
            self.set_RelatedIncidents(obj_)
        elif nodeName_ == 'RelatedIndicators':
            obj_ = stix_campaign_binding.RelatedIndicatorsType.factory()
            obj_.build(child_)
            self.set_RelatedIndicators(obj_)
        elif nodeName_ == 'Attribution':
            obj_ = stix_campaign_binding.AttributionType.factory()
            obj_.build(child_)
            self.Attribution.append(obj_)
        elif nodeName_ == 'AssociatedCampaigns':
            obj_ = stix_campaign_binding.AssociatedCampaignsType.factory()
            obj_.build(child_)
            self.set_AssociatedCampaigns(obj_)
        elif nodeName_ == 'Confidence':
            obj_ = stix_common_binding.ConfidenceType.factory()
            obj_.build(child_)
            self.set_Confidence(obj_)
        elif nodeName_ == 'Activity':
            type_name_ = child_.attrib.get('{http://www.w3.org/2001/XMLSchema-instance}type')
            if type_name_ is None:
                type_name_ = child_.attrib.get('type')
            if type_name_ is not None:
                type_names_ = type_name_.split(':')
                if len(type_names_) == 1:
                    type_name_ = type_names_[0]
                else:
                    type_name_ = type_names_[1]
                class_ = globals()[type_name_]
                obj_ = class_.factory()
                obj_.build(child_)
            else:
                raise NotImplementedError(
                    'Class not implemented for <Activity> element')
            self.Activity.append(obj_)
        elif nodeName_ == 'InformationSource':
            obj_ = stix_common_binding.InformationSourceType.factory()
            obj_.build(child_)
            self.set_InformationSource(obj_)
# end class CampaignType






class AssociatedActorType(ThreatActorType):
    """Specifies the type of association between the two ThreatActors."""
    subclass = None
    superclass = ThreatActorType
    def __init__(self, idref=None, id=None, version=None, Identity=None, Intent=None, ObservedTTPs=None, HistoricalCampaigns=None, AssociatedActors=None, Handling=None, Confidence=None, InformationSource=None, associationType=None, AssociatedActorConfidence=None):
        super(AssociatedActorType, self).__init__(idref, id, version, Identity, Intent, ObservedTTPs, HistoricalCampaigns, AssociatedActors, Handling, Confidence, InformationSource, )
        self.associationType = _cast(None, associationType)
        self.AssociatedActorConfidence = AssociatedActorConfidence
    def factory(*args_, **kwargs_):
        if AssociatedActorType.subclass:
            return AssociatedActorType.subclass(*args_, **kwargs_)
        else:
            return AssociatedActorType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_AssociatedActorConfidence(self): return self.AssociatedActorConfidence
    def set_AssociatedActorConfidence(self, AssociatedActorConfidence): self.AssociatedActorConfidence = AssociatedActorConfidence
    def get_associationType(self): return self.associationType
    def set_associationType(self, associationType): self.associationType = associationType
    def export(self, outfile, level, namespace_='TA:', name_='AssociatedActorType', namespacedef_='', pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='AssociatedActorType')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespace_, name_, pretty_print=pretty_print)
            showIndent(outfile, level, pretty_print)
            outfile.write('</%s%s>%s' % (namespace_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespace_='TA:', name_='AssociatedActorType'):
        super(AssociatedActorType, self).exportAttributes(outfile, level, already_processed, namespace_, name_='AssociatedActorType')
        if self.associationType is not None and 'associationType' not in already_processed:
            already_processed.append('associationType')
            outfile.write(' associationType=%s' % (self.gds_format_string(quote_attrib(self.associationType).encode(ExternalEncoding), input_name='associationType'), ))
    def exportChildren(self, outfile, level, namespace_='TA:', name_='AssociatedActorType', fromsubclass_=False, pretty_print=True):
        super(AssociatedActorType, self).exportChildren(outfile, level, 'TA:', name_, True, pretty_print=pretty_print)
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.AssociatedActorConfidence is not None:
            self.AssociatedActorConfidence.export(outfile, level, 'TA:', name_='AssociatedActorConfidence', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.AssociatedActorConfidence is not None or
            super(AssociatedActorType, self).hasContent_()
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='AssociatedActorType'):
        level += 1
        self.exportLiteralAttributes(outfile, level, [], name_)
        if self.hasContent_():
            self.exportLiteralChildren(outfile, level, name_)
    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
        if self.associationType is not None and 'associationType' not in already_processed:
            already_processed.append('associationType')
            showIndent(outfile, level)
            outfile.write('associationType = "%s",\n' % (self.associationType,))
        super(AssociatedActorType, self).exportLiteralAttributes(outfile, level, already_processed, name_)
    def exportLiteralChildren(self, outfile, level, name_):
        super(AssociatedActorType, self).exportLiteralChildren(outfile, level, name_)
        if self.AssociatedActorConfidence is not None:
            showIndent(outfile, level)
            outfile.write('AssociatedActorConfidence=model_.stix_common_binding.ConfidenceType(\n')
            self.AssociatedActorConfidence.exportLiteral(outfile, level, name_='AssociatedActorConfidence')
            showIndent(outfile, level)
            outfile.write('),\n')
    def build(self, node):
        self.buildAttributes(node, node.attrib, [])
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_)
    def buildAttributes(self, node, attrs, already_processed):
        value = find_attr_value_('associationType', node)
        if value is not None and 'associationType' not in already_processed:
            already_processed.append('associationType')
            self.associationType = value
        super(AssociatedActorType, self).buildAttributes(node, attrs, already_processed)
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'AssociatedActorConfidence':
            obj_ = stix_common_binding.ConfidenceType.factory()
            obj_.build(child_)
            self.set_AssociatedActorConfidence(obj_)
        super(AssociatedActorType, self).buildChildren(child_, node, nodeName_, True)
# end class AssociatedActorType






class ObservedTTPType(TTPType):
    subclass = None
    superclass = TTPType
    def __init__(self, idref=None, id=None, version=None, Behavior_AttackPatterns=None, Behavior_Malware=None, Behavior_Exploits=None, Resource_Tools=None, Resource_Infrastructure=None, VictimTargeting=None, ExploitTargets=None, Intent=None, RelatedTTPs=None, KillChainPhases=None, InformationSource=None, KillChains=None, ObservedTTPConfidence=None):
        super(ObservedTTPType, self).__init__(idref, id, version, Behavior_AttackPatterns, Behavior_Malware, Behavior_Exploits, Resource_Tools, Resource_Infrastructure, VictimTargeting, ExploitTargets, Intent, RelatedTTPs, KillChainPhases, InformationSource, KillChains, )
        self.ObservedTTPConfidence = ObservedTTPConfidence
    def factory(*args_, **kwargs_):
        if ObservedTTPType.subclass:
            return ObservedTTPType.subclass(*args_, **kwargs_)
        else:
            return ObservedTTPType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_ObservedTTPConfidence(self): return self.ObservedTTPConfidence
    def set_ObservedTTPConfidence(self, ObservedTTPConfidence): self.ObservedTTPConfidence = ObservedTTPConfidence
    def export(self, outfile, level, namespace_='TA:', name_='ObservedTTPType', namespacedef_='', pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='ObservedTTPType')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespace_, name_, pretty_print=pretty_print)
            showIndent(outfile, level, pretty_print)
            outfile.write('</%s%s>%s' % (namespace_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespace_='TA:', name_='ObservedTTPType'):
        super(ObservedTTPType, self).exportAttributes(outfile, level, already_processed, namespace_, name_='ObservedTTPType')
    def exportChildren(self, outfile, level, namespace_='TA:', name_='ObservedTTPType', fromsubclass_=False, pretty_print=True):
        super(ObservedTTPType, self).exportChildren(outfile, level, 'TA:', name_, True, pretty_print=pretty_print)
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.ObservedTTPConfidence is not None:
            self.ObservedTTPConfidence.export(outfile, level, 'TA:', name_='ObservedTTPConfidence', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.ObservedTTPConfidence is not None or
            super(ObservedTTPType, self).hasContent_()
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='ObservedTTPType'):
        level += 1
        self.exportLiteralAttributes(outfile, level, [], name_)
        if self.hasContent_():
            self.exportLiteralChildren(outfile, level, name_)
    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
        super(ObservedTTPType, self).exportLiteralAttributes(outfile, level, already_processed, name_)
    def exportLiteralChildren(self, outfile, level, name_):
        super(ObservedTTPType, self).exportLiteralChildren(outfile, level, name_)
        if self.ObservedTTPConfidence is not None:
            showIndent(outfile, level)
            outfile.write('ObservedTTPConfidence=model_.stix_common_binding.ConfidenceType(\n')
            self.ObservedTTPConfidence.exportLiteral(outfile, level, name_='ObservedTTPConfidence')
            showIndent(outfile, level)
            outfile.write('),\n')
    def build(self, node):
        self.buildAttributes(node, node.attrib, [])
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_)
    def buildAttributes(self, node, attrs, already_processed):
        super(ObservedTTPType, self).buildAttributes(node, attrs, already_processed)
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'ObservedTTPConfidence':
            obj_ = stix_common_binding.ConfidenceType.factory()
            obj_.build(child_)
            self.set_ObservedTTPConfidence(obj_)
        super(ObservedTTPType, self).buildChildren(child_, node, nodeName_, True)
# end class ObservedTTPType

class HistoricalCampaignType(CampaignType):
    subclass = None
    superclass = CampaignType
    def __init__(self, idref=None, id=None, version=None, Names=None, Intent=None, RelatedTTPs=None, RelatedIncidents=None, RelatedIndicators=None, Attribution=None, AssociatedCampaigns=None, Confidence=None, Activity=None, InformationSource=None, HistoricalCampaignConfidence=None):
        super(HistoricalCampaignType, self).__init__(idref, id, version, Names, Intent, RelatedTTPs, RelatedIncidents, RelatedIndicators, Attribution, AssociatedCampaigns, Confidence, Activity, InformationSource, )
        self.HistoricalCampaignConfidence = HistoricalCampaignConfidence
    def factory(*args_, **kwargs_):
        if HistoricalCampaignType.subclass:
            return HistoricalCampaignType.subclass(*args_, **kwargs_)
        else:
            return HistoricalCampaignType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_HistoricalCampaignConfidence(self): return self.HistoricalCampaignConfidence
    def set_HistoricalCampaignConfidence(self, HistoricalCampaignConfidence): self.HistoricalCampaignConfidence = HistoricalCampaignConfidence
    def export(self, outfile, level, namespace_='TA:', name_='HistoricalCampaignType', namespacedef_='', pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='HistoricalCampaignType')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespace_, name_, pretty_print=pretty_print)
            showIndent(outfile, level, pretty_print)
            outfile.write('</%s%s>%s' % (namespace_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespace_='TA:', name_='HistoricalCampaignType'):
        super(HistoricalCampaignType, self).exportAttributes(outfile, level, already_processed, namespace_, name_='HistoricalCampaignType')
    def exportChildren(self, outfile, level, namespace_='TA:', name_='HistoricalCampaignType', fromsubclass_=False, pretty_print=True):
        super(HistoricalCampaignType, self).exportChildren(outfile, level, 'TA:', name_, True, pretty_print=pretty_print)
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.HistoricalCampaignConfidence is not None:
            self.HistoricalCampaignConfidence.export(outfile, level, 'TA:', name_='HistoricalCampaignConfidence', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.HistoricalCampaignConfidence is not None or
            super(HistoricalCampaignType, self).hasContent_()
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='HistoricalCampaignType'):
        level += 1
        self.exportLiteralAttributes(outfile, level, [], name_)
        if self.hasContent_():
            self.exportLiteralChildren(outfile, level, name_)
    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
        super(HistoricalCampaignType, self).exportLiteralAttributes(outfile, level, already_processed, name_)
    def exportLiteralChildren(self, outfile, level, name_):
        super(HistoricalCampaignType, self).exportLiteralChildren(outfile, level, name_)
        if self.HistoricalCampaignConfidence is not None:
            showIndent(outfile, level)
            outfile.write('HistoricalCampaignConfidence=model_.stix_common_binding.ConfidenceType(\n')
            self.HistoricalCampaignConfidence.exportLiteral(outfile, level, name_='HistoricalCampaignConfidence')
            showIndent(outfile, level)
            outfile.write('),\n')
    def build(self, node):
        self.buildAttributes(node, node.attrib, [])
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_)
    def buildAttributes(self, node, attrs, already_processed):
        super(HistoricalCampaignType, self).buildAttributes(node, attrs, already_processed)
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'HistoricalCampaignConfidence':
            obj_ = stix_common_binding.ConfidenceType.factory()
            obj_.build(child_)
            self.set_HistoricalCampaignConfidence(obj_)
        super(HistoricalCampaignType, self).buildChildren(child_, node, nodeName_, True)
# end class HistoricalCampaignType


class ObservedTTPsType(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, ObservedTTP=None):
        if ObservedTTP is None:
            self.ObservedTTP = []
        else:
            self.ObservedTTP = ObservedTTP
    def factory(*args_, **kwargs_):
        if ObservedTTPsType.subclass:
            return ObservedTTPsType.subclass(*args_, **kwargs_)
        else:
            return ObservedTTPsType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_ObservedTTP(self): return self.ObservedTTP
    def set_ObservedTTP(self, ObservedTTP): self.ObservedTTP = ObservedTTP
    def add_ObservedTTP(self, value): self.ObservedTTP.append(value)
    def insert_ObservedTTP(self, index, value): self.ObservedTTP[index] = value
    def export(self, outfile, level, namespace_='TA:', name_='ObservedTTPsType', namespacedef_='', pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='ObservedTTPsType')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespace_, name_, pretty_print=pretty_print)
            showIndent(outfile, level, pretty_print)
            outfile.write('</%s%s>%s' % (namespace_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespace_='TA:', name_='ObservedTTPsType'):
        pass
    def exportChildren(self, outfile, level, namespace_='TA:', name_='ObservedTTPsType', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        for ObservedTTP_ in self.ObservedTTP:
            ObservedTTP_.export(outfile, level, namespace_, name_='ObservedTTP', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.ObservedTTP
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='ObservedTTPsType'):
        level += 1
        self.exportLiteralAttributes(outfile, level, [], name_)
        if self.hasContent_():
            self.exportLiteralChildren(outfile, level, name_)
    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
        pass
    def exportLiteralChildren(self, outfile, level, name_):
        showIndent(outfile, level)
        outfile.write('ObservedTTP=[\n')
        level += 1
        for ObservedTTP_ in self.ObservedTTP:
            showIndent(outfile, level)
            outfile.write('model_.ObservedTTPType(\n')
            ObservedTTP_.exportLiteral(outfile, level, name_='ObservedTTPType')
            showIndent(outfile, level)
            outfile.write('),\n')
        level -= 1
        showIndent(outfile, level)
        outfile.write('],\n')
    def build(self, node):
        self.buildAttributes(node, node.attrib, [])
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_)
    def buildAttributes(self, node, attrs, already_processed):
        pass
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'ObservedTTP':
            obj_ = ObservedTTPType.factory()
            obj_.build(child_)
            self.ObservedTTP.append(obj_)
# end class ObservedTTPsType


class HistoricalCampaignsType(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, HistoricalCampaign=None):
        if HistoricalCampaign is None:
            self.HistoricalCampaign = []
        else:
            self.HistoricalCampaign = HistoricalCampaign
    def factory(*args_, **kwargs_):
        if HistoricalCampaignsType.subclass:
            return HistoricalCampaignsType.subclass(*args_, **kwargs_)
        else:
            return HistoricalCampaignsType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_HistoricalCampaign(self): return self.HistoricalCampaign
    def set_HistoricalCampaign(self, HistoricalCampaign): self.HistoricalCampaign = HistoricalCampaign
    def add_HistoricalCampaign(self, value): self.HistoricalCampaign.append(value)
    def insert_HistoricalCampaign(self, index, value): self.HistoricalCampaign[index] = value
    def export(self, outfile, level, namespace_='TA:', name_='HistoricalCampaignsType', namespacedef_='', pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='HistoricalCampaignsType')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespace_, name_, pretty_print=pretty_print)
            showIndent(outfile, level, pretty_print)
            outfile.write('</%s%s>%s' % (namespace_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespace_='TA:', name_='HistoricalCampaignsType'):
        pass
    def exportChildren(self, outfile, level, namespace_='TA:', name_='HistoricalCampaignsType', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        for HistoricalCampaign_ in self.HistoricalCampaign:
            HistoricalCampaign_.export(outfile, level, namespace_, name_='HistoricalCampaign', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.HistoricalCampaign
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='HistoricalCampaignsType'):
        level += 1
        self.exportLiteralAttributes(outfile, level, [], name_)
        if self.hasContent_():
            self.exportLiteralChildren(outfile, level, name_)
    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
        pass
    def exportLiteralChildren(self, outfile, level, name_):
        showIndent(outfile, level)
        outfile.write('HistoricalCampaign=[\n')
        level += 1
        for HistoricalCampaign_ in self.HistoricalCampaign:
            showIndent(outfile, level)
            outfile.write('model_.HistoricalCampaignType(\n')
            HistoricalCampaign_.exportLiteral(outfile, level, name_='HistoricalCampaignType')
            showIndent(outfile, level)
            outfile.write('),\n')
        level -= 1
        showIndent(outfile, level)
        outfile.write('],\n')
    def build(self, node):
        self.buildAttributes(node, node.attrib, [])
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_)
    def buildAttributes(self, node, attrs, already_processed):
        pass
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'HistoricalCampaign':
            obj_ = HistoricalCampaignType.factory()
            obj_.build(child_)
            self.HistoricalCampaign.append(obj_)
# end class HistoricalCampaignsType


class AssociatedActorsType(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, AssociatedActor=None):
        if AssociatedActor is None:
            self.AssociatedActor = []
        else:
            self.AssociatedActor = AssociatedActor
    def factory(*args_, **kwargs_):
        if AssociatedActorsType.subclass:
            return AssociatedActorsType.subclass(*args_, **kwargs_)
        else:
            return AssociatedActorsType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_AssociatedActor(self): return self.AssociatedActor
    def set_AssociatedActor(self, AssociatedActor): self.AssociatedActor = AssociatedActor
    def add_AssociatedActor(self, value): self.AssociatedActor.append(value)
    def insert_AssociatedActor(self, index, value): self.AssociatedActor[index] = value
    def export(self, outfile, level, namespace_='TA:', name_='AssociatedActorsType', namespacedef_='', pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='AssociatedActorsType')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespace_, name_, pretty_print=pretty_print)
            showIndent(outfile, level, pretty_print)
            outfile.write('</%s%s>%s' % (namespace_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespace_='TA:', name_='AssociatedActorsType'):
        pass
    def exportChildren(self, outfile, level, namespace_='TA:', name_='AssociatedActorsType', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        for AssociatedActor_ in self.AssociatedActor:
            AssociatedActor_.export(outfile, level, namespace_, name_='AssociatedActor', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.AssociatedActor
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='AssociatedActorsType'):
        level += 1
        self.exportLiteralAttributes(outfile, level, [], name_)
        if self.hasContent_():
            self.exportLiteralChildren(outfile, level, name_)
    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
        pass
    def exportLiteralChildren(self, outfile, level, name_):
        showIndent(outfile, level)
        outfile.write('AssociatedActor=[\n')
        level += 1
        for AssociatedActor_ in self.AssociatedActor:
            showIndent(outfile, level)
            outfile.write('model_.AssociatedActorType(\n')
            AssociatedActor_.exportLiteral(outfile, level, name_='AssociatedActorType')
            showIndent(outfile, level)
            outfile.write('),\n')
        level -= 1
        showIndent(outfile, level)
        outfile.write('],\n')
    def build(self, node):
        self.buildAttributes(node, node.attrib, [])
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_)
    def buildAttributes(self, node, attrs, already_processed):
        pass
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'AssociatedActor':
            obj_ = AssociatedActorType.factory()
            obj_.build(child_)
            self.AssociatedActor.append(obj_)
# end class AssociatedActorsType



class AssociatedCampaignsType(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, AssociatedCampaign=None):
        if AssociatedCampaign is None:
            self.AssociatedCampaign = []
        else:
            self.AssociatedCampaign = AssociatedCampaign
    def factory(*args_, **kwargs_):
        if AssociatedCampaignsType.subclass:
            return AssociatedCampaignsType.subclass(*args_, **kwargs_)
        else:
            return AssociatedCampaignsType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_AssociatedCampaign(self): return self.AssociatedCampaign
    def set_AssociatedCampaign(self, AssociatedCampaign): self.AssociatedCampaign = AssociatedCampaign
    def add_AssociatedCampaign(self, value): self.AssociatedCampaign.append(value)
    def insert_AssociatedCampaign(self, index, value): self.AssociatedCampaign[index] = value
    def export(self, outfile, level, namespace_='campaign:', name_='AssociatedCampaignsType', namespacedef_='', pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='AssociatedCampaignsType')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespace_, name_, pretty_print=pretty_print)
            showIndent(outfile, level, pretty_print)
            outfile.write('</%s%s>%s' % (namespace_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespace_='campaign:', name_='AssociatedCampaignsType'):
        pass
    def exportChildren(self, outfile, level, namespace_='campaign:', name_='AssociatedCampaignsType', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        for AssociatedCampaign_ in self.AssociatedCampaign:
            AssociatedCampaign_.export(outfile, level, namespace_, name_='AssociatedCampaign', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.AssociatedCampaign
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='AssociatedCampaignsType'):
        level += 1
        self.exportLiteralAttributes(outfile, level, [], name_)
        if self.hasContent_():
            self.exportLiteralChildren(outfile, level, name_)
    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
        pass
    def exportLiteralChildren(self, outfile, level, name_):
        showIndent(outfile, level)
        outfile.write('AssociatedCampaign=[\n')
        level += 1
        for AssociatedCampaign_ in self.AssociatedCampaign:
            showIndent(outfile, level)
            outfile.write('model_.AssociatedCampaignType(\n')
            AssociatedCampaign_.exportLiteral(outfile, level, name_='AssociatedCampaignType')
            showIndent(outfile, level)
            outfile.write('),\n')
        level -= 1
        showIndent(outfile, level)
        outfile.write('],\n')
    def build(self, node):
        self.buildAttributes(node, node.attrib, [])
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_)
    def buildAttributes(self, node, attrs, already_processed):
        pass
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'AssociatedCampaign':
            obj_ = AssociatedCampaignType.factory()
            obj_.build(child_)
            self.AssociatedCampaign.append(obj_)
# end class AssociatedCampaignsType



class AttributedThreatActorType(ThreatActorType):
    """The AttributedThreatActorType specifies a Threat Actor asserted to
    be attributed for a Campaign."""
    subclass = None
    superclass = ThreatActorType
    def __init__(self, idref=None, id=None, version=None, Identity=None, Intent=None, ObservedTTPs=None, HistoricalCampaigns=None, AssociatedActors=None, Handling=None, Confidence=None, InformationSource=None, AttributedThreatActorConfidence=None):
        super(AttributedThreatActorType, self).__init__(idref, id, version, Identity, Intent, ObservedTTPs, HistoricalCampaigns, AssociatedActors, Handling, Confidence, InformationSource, )
        self.AttributedThreatActorConfidence = AttributedThreatActorConfidence
    def factory(*args_, **kwargs_):
        if AttributedThreatActorType.subclass:
            return AttributedThreatActorType.subclass(*args_, **kwargs_)
        else:
            return AttributedThreatActorType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_AttributedThreatActorConfidence(self): return self.AttributedThreatActorConfidence
    def set_AttributedThreatActorConfidence(self, AttributedThreatActorConfidence): self.AttributedThreatActorConfidence = AttributedThreatActorConfidence
    def export(self, outfile, level, namespace_='campaign:', name_='AttributedThreatActorType', namespacedef_='', pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='AttributedThreatActorType')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespace_, name_, pretty_print=pretty_print)
            showIndent(outfile, level, pretty_print)
            outfile.write('</%s%s>%s' % (namespace_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespace_='campaign:', name_='AttributedThreatActorType'):
        super(AttributedThreatActorType, self).exportAttributes(outfile, level, already_processed, namespace_, name_='AttributedThreatActorType')
    def exportChildren(self, outfile, level, namespace_='campaign:', name_='AttributedThreatActorType', fromsubclass_=False, pretty_print=True):
        super(AttributedThreatActorType, self).exportChildren(outfile, level, 'campaign:', name_, True, pretty_print=pretty_print)
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.AttributedThreatActorConfidence is not None:
            self.AttributedThreatActorConfidence.export(outfile, level, 'campaign:', name_='AttributedThreatActorConfidence', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.AttributedThreatActorConfidence is not None or
            super(AttributedThreatActorType, self).hasContent_()
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='AttributedThreatActorType'):
        level += 1
        self.exportLiteralAttributes(outfile, level, [], name_)
        if self.hasContent_():
            self.exportLiteralChildren(outfile, level, name_)
    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
        super(AttributedThreatActorType, self).exportLiteralAttributes(outfile, level, already_processed, name_)
    def exportLiteralChildren(self, outfile, level, name_):
        super(AttributedThreatActorType, self).exportLiteralChildren(outfile, level, name_)
        if self.AttributedThreatActorConfidence is not None:
            showIndent(outfile, level)
            outfile.write('AttributedThreatActorConfidence=model_.stix_common_binding.ConfidenceType(\n')
            self.AttributedThreatActorConfidence.exportLiteral(outfile, level, name_='AttributedThreatActorConfidence')
            showIndent(outfile, level)
            outfile.write('),\n')
    def build(self, node):
        self.buildAttributes(node, node.attrib, [])
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_)
    def buildAttributes(self, node, attrs, already_processed):
        super(AttributedThreatActorType, self).buildAttributes(node, attrs, already_processed)
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'AttributedThreatActorConfidence':
            obj_ = stix_common_binding.ConfidenceType.factory()
            obj_.build(child_)
            self.set_AttributedThreatActorConfidence(obj_)
        super(AttributedThreatActorType, self).buildChildren(child_, node, nodeName_, True)
# end class AttributedThreatActorType





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

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

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

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

def parseString(inString):
    from StringIO import StringIO
    doc = parsexml_(StringIO(inString))
    rootNode = doc.getroot()
    rootTag, rootClass = get_root_tag(rootNode)
    if rootClass is None:
        rootTag = 'ThreatActor'
        rootClass = ThreatActorType
    rootObj = rootClass.factory()
    rootObj.build(rootNode)
    # Enable Python to collect the space used by the DOM.
    doc = None
    sys.stdout.write('<?xml version="1.0" ?>\n')
    rootObj.export(sys.stdout, 0, name_="ThreatActor",
        namespacedef_='')
    return rootObj

def parseLiteral(inFileName):
    doc = parsexml_(inFileName)
    rootNode = doc.getroot()
    rootTag, rootClass = get_root_tag(rootNode)
    if rootClass is None:
        rootTag = 'ThreatActor'
        rootClass = ThreatActorType
    rootObj = rootClass.factory()
    rootObj.build(rootNode)
    # Enable Python to collect the space used by the DOM.
    doc = None
    sys.stdout.write('#from stix_threat_actor_0_5 import *\n\n')
    sys.stdout.write('import stix_threat_actor_0_5 as model_\n\n')
    sys.stdout.write('rootObj = model_.rootTag(\n')
    rootObj.exportLiteral(sys.stdout, 0, name_=rootTag)
    sys.stdout.write(')\n')
    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()

__all__ = [
    "ThreatActorType",
    "ObservedTTPType",
    "HistoricalCampaignType",
    "AssociatedActorType",
    "CampaignType",
    "TTPType"
    ]

