Passed
Push — master ( f1e3b2...b13a8b )
by Peter
01:02
created

ore.models.xml_configurations   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 365
Duplicated Lines 61.64 %

Importance

Changes 0
Metric Value
wmc 9
eloc 209
dl 225
loc 365
rs 10
c 0
b 0
f 0

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
# ore/models/xml_configurations.py
2
# -*- coding: utf-8 -*-
3
# PyXB bindings for NM:380e5bfe768ca2a493a558a9fe7b1795196a7c97
4
# Generated 2019-01-09 14:06:28.482992 by PyXB version 1.2.6 using Python 2.7.15.candidate.1
5
# Namespace http://www.fuzzed.org/configurations [xmlns:configurations]
6
7
from __future__ import unicode_literals
8
import pyxb
9
import pyxb.binding
10
import pyxb.binding.saxer
11
import io
12
import pyxb.utils.utility
13
import pyxb.utils.domutils
14
import sys
15
import pyxb.utils.six as _six
16
# Unique identifier for bindings created at the same time
17
_GenerationUID = pyxb.utils.utility.UniqueIdentifier('urn:uuid:c1f84e9a-1417-11e9-9981-0242c0a83004')
18
19
# Version of PyXB used to generate the bindings
20
_PyXBVersion = '1.2.6'
21
# Generated bindings are not compatible across PyXB versions
22
if pyxb.__version__ != _PyXBVersion:
23
    raise pyxb.PyXBVersionError(_PyXBVersion)
24
25
# A holder for module-level binding classes so we can access them from
26
# inside class definitions where property names may conflict.
27
_module_typeBindings = pyxb.utils.utility.Object()
28
29
# Import bindings for namespaces imported into schema
30
import pyxb.binding.datatypes
31
32
# NOTE: All namespace declarations are reserved within the binding
33
Namespace = pyxb.namespace.NamespaceForURI('http://www.fuzzed.org/configurations', create_if_missing=True)
34
Namespace.configureCategories(['typeBinding', 'elementBinding'])
35
36
def CreateFromDocument (xml_text, default_namespace=None, location_base=None):
37
    """Parse the given XML and use the document element to create a
38
    Python instance.
39
40
    @param xml_text An XML document.  This should be data (Python 2
41
    str or Python 3 bytes), or a text (Python 2 unicode or Python 3
42
    str) in the L{pyxb._InputEncoding} encoding.
43
44
    @keyword default_namespace The L{pyxb.Namespace} instance to use as the
45
    default namespace where there is no default namespace in scope.
46
    If unspecified or C{None}, the namespace of the module containing
47
    this function will be used.
48
49
    @keyword location_base: An object to be recorded as the base of all
50
    L{pyxb.utils.utility.Location} instances associated with events and
51
    objects handled by the parser.  You might pass the URI from which
52
    the document was obtained.
53
    """
54
55
    if pyxb.XMLStyle_saxer != pyxb._XMLStyle:
56
        dom = pyxb.utils.domutils.StringToDOM(xml_text)
57
        return CreateFromDOM(dom.documentElement, default_namespace=default_namespace)
58
    if default_namespace is None:
59
        default_namespace = Namespace.fallbackNamespace()
60
    saxer = pyxb.binding.saxer.make_parser(fallback_namespace=default_namespace, location_base=location_base)
61
    handler = saxer.getContentHandler()
62
    xmld = xml_text
63
    if isinstance(xmld, _six.text_type):
64
        xmld = xmld.encode(pyxb._InputEncoding)
65
    saxer.parse(io.BytesIO(xmld))
66
    instance = handler.rootObject()
67
    return instance
68
69
def CreateFromDOM (node, default_namespace=None):
70
    """Create a Python instance from the given DOM node.
71
    The node tag must correspond to an element declaration in this module.
72
73
    @deprecated: Forcing use of DOM interface is unnecessary; use L{CreateFromDocument}."""
74
    if default_namespace is None:
75
        default_namespace = Namespace.fallbackNamespace()
76
    return pyxb.binding.basis.element.AnyCreateFromDOM(node, default_namespace)
77
78
79
# Complex type {http://www.fuzzed.org/configurations}Choice with content type EMPTY
80
class Choice (pyxb.binding.basis.complexTypeDefinition):
81
    """Complex type {http://www.fuzzed.org/configurations}Choice with content type EMPTY"""
82
    _TypeDefinition = None
83
    _ContentTypeTag = pyxb.binding.basis.complexTypeDefinition._CT_EMPTY
84
    _Abstract = True
85
    _ExpandedName = pyxb.namespace.ExpandedName(Namespace, 'Choice')
86
    _XSDLocation = pyxb.utils.utility.Location('/ore-common/xsd/configurations.xsd', 7, 2)
87
    _ElementMap = {}
88
    _AttributeMap = {}
89
    # Base type is pyxb.binding.datatypes.anyType
90
    _ElementMap.update({
91
        
92
    })
93
    _AttributeMap.update({
94
        
95
    })
96
_module_typeBindings.Choice = Choice
97
Namespace.addCategoryObject('typeBinding', 'Choice', Choice)
98
99
100
# Complex type {http://www.fuzzed.org/configurations}IntegerToChoiceMap with content type ELEMENT_ONLY
101
class IntegerToChoiceMap (pyxb.binding.basis.complexTypeDefinition):
102
    """Complex type {http://www.fuzzed.org/configurations}IntegerToChoiceMap with content type ELEMENT_ONLY"""
103
    _TypeDefinition = None
104
    _ContentTypeTag = pyxb.binding.basis.complexTypeDefinition._CT_ELEMENT_ONLY
105
    _Abstract = False
106
    _ExpandedName = pyxb.namespace.ExpandedName(Namespace, 'IntegerToChoiceMap')
107
    _XSDLocation = pyxb.utils.utility.Location('/ore-common/xsd/configurations.xsd', 9, 2)
108
    _ElementMap = {}
109
    _AttributeMap = {}
110
    # Base type is pyxb.binding.datatypes.anyType
111
    
112
    # Element value uses Python identifier value_
113
    __value = pyxb.binding.content.ElementDeclaration(pyxb.namespace.ExpandedName(None, 'value'), 'value_', '__httpwww_fuzzed_orgconfigurations_IntegerToChoiceMap_value', False, pyxb.utils.utility.Location('/ore-common/xsd/configurations.xsd', 11, 6), )
114
115
    
116
    value_ = property(__value.value, __value.set, None, None)
117
118
    
119
    # Attribute key uses Python identifier key
120
    __key = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'key'), 'key', '__httpwww_fuzzed_orgconfigurations_IntegerToChoiceMap_key', pyxb.binding.datatypes.string, required=True)
121
    __key._DeclarationLocation = pyxb.utils.utility.Location('/ore-common/xsd/configurations.xsd', 13, 4)
122
    __key._UseLocation = pyxb.utils.utility.Location('/ore-common/xsd/configurations.xsd', 13, 4)
123
    
124
    key = property(__key.value, __key.set, None, None)
125
126
    _ElementMap.update({
127
        __value.name() : __value
128
    })
129
    _AttributeMap.update({
130
        __key.name() : __key
131
    })
132
_module_typeBindings.IntegerToChoiceMap = IntegerToChoiceMap
133
Namespace.addCategoryObject('typeBinding', 'IntegerToChoiceMap', IntegerToChoiceMap)
134
135
136
# Complex type {http://www.fuzzed.org/configurations}Configuration with content type ELEMENT_ONLY
137
class Configuration (pyxb.binding.basis.complexTypeDefinition):
138
    """Complex type {http://www.fuzzed.org/configurations}Configuration with content type ELEMENT_ONLY"""
139
    _TypeDefinition = None
140
    _ContentTypeTag = pyxb.binding.basis.complexTypeDefinition._CT_ELEMENT_ONLY
141
    _Abstract = False
142
    _ExpandedName = pyxb.namespace.ExpandedName(Namespace, 'Configuration')
143
    _XSDLocation = pyxb.utils.utility.Location('/ore-common/xsd/configurations.xsd', 16, 2)
144
    _ElementMap = {}
145
    _AttributeMap = {}
146
    # Base type is pyxb.binding.datatypes.anyType
147
    
148
    # Element choice uses Python identifier choice
149
    __choice = pyxb.binding.content.ElementDeclaration(pyxb.namespace.ExpandedName(None, 'choice'), 'choice', '__httpwww_fuzzed_orgconfigurations_Configuration_choice', True, pyxb.utils.utility.Location('/ore-common/xsd/configurations.xsd', 18, 6), )
150
151
    
152
    choice = property(__choice.value, __choice.set, None, None)
153
154
    
155
    # Attribute id uses Python identifier id
156
    __id = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'id'), 'id', '__httpwww_fuzzed_orgconfigurations_Configuration_id', pyxb.binding.datatypes.string, required=True)
157
    __id._DeclarationLocation = pyxb.utils.utility.Location('/ore-common/xsd/configurations.xsd', 20, 4)
158
    __id._UseLocation = pyxb.utils.utility.Location('/ore-common/xsd/configurations.xsd', 20, 4)
159
    
160
    id = property(__id.value, __id.set, None, None)
161
162
    
163
    # Attribute costs uses Python identifier costs
164
    __costs = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'costs'), 'costs', '__httpwww_fuzzed_orgconfigurations_Configuration_costs', pyxb.binding.datatypes.int, required=True)
165
    __costs._DeclarationLocation = pyxb.utils.utility.Location('/ore-common/xsd/configurations.xsd', 21, 4)
166
    __costs._UseLocation = pyxb.utils.utility.Location('/ore-common/xsd/configurations.xsd', 21, 4)
167
    
168
    costs = property(__costs.value, __costs.set, None, None)
169
170
    _ElementMap.update({
171
        __choice.name() : __choice
172
    })
173
    _AttributeMap.update({
174
        __id.name() : __id,
175
        __costs.name() : __costs
176
    })
177
_module_typeBindings.Configuration = Configuration
178
Namespace.addCategoryObject('typeBinding', 'Configuration', Configuration)
179
180
181
# Complex type {http://www.fuzzed.org/configurations}InclusionChoice with content type EMPTY
182
class InclusionChoice (Choice):
183
    """Complex type {http://www.fuzzed.org/configurations}InclusionChoice with content type EMPTY"""
184
    _TypeDefinition = None
185
    _ContentTypeTag = pyxb.binding.basis.complexTypeDefinition._CT_EMPTY
186
    _Abstract = False
187
    _ExpandedName = pyxb.namespace.ExpandedName(Namespace, 'InclusionChoice')
188
    _XSDLocation = pyxb.utils.utility.Location('/ore-common/xsd/configurations.xsd', 24, 2)
189
    _ElementMap = Choice._ElementMap.copy()
190
    _AttributeMap = Choice._AttributeMap.copy()
191
    # Base type is Choice
192
    
193
    # Attribute included uses Python identifier included
194
    __included = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'included'), 'included', '__httpwww_fuzzed_orgconfigurations_InclusionChoice_included', pyxb.binding.datatypes.boolean, required=True)
195
    __included._DeclarationLocation = pyxb.utils.utility.Location('/ore-common/xsd/configurations.xsd', 27, 8)
196
    __included._UseLocation = pyxb.utils.utility.Location('/ore-common/xsd/configurations.xsd', 27, 8)
197
    
198
    included = property(__included.value, __included.set, None, None)
199
200
    _ElementMap.update({
201
        
202
    })
203
    _AttributeMap.update({
204
        __included.name() : __included
205
    })
206
_module_typeBindings.InclusionChoice = InclusionChoice
207
Namespace.addCategoryObject('typeBinding', 'InclusionChoice', InclusionChoice)
208
209
210
# Complex type {http://www.fuzzed.org/configurations}RedundancyChoice with content type EMPTY
211
class RedundancyChoice (Choice):
212
    """Complex type {http://www.fuzzed.org/configurations}RedundancyChoice with content type EMPTY"""
213
    _TypeDefinition = None
214
    _ContentTypeTag = pyxb.binding.basis.complexTypeDefinition._CT_EMPTY
215
    _Abstract = False
216
    _ExpandedName = pyxb.namespace.ExpandedName(Namespace, 'RedundancyChoice')
217
    _XSDLocation = pyxb.utils.utility.Location('/ore-common/xsd/configurations.xsd', 32, 2)
218
    _ElementMap = Choice._ElementMap.copy()
219
    _AttributeMap = Choice._AttributeMap.copy()
220
    # Base type is Choice
221
    
222
    # Attribute n uses Python identifier n
223
    __n = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'n'), 'n', '__httpwww_fuzzed_orgconfigurations_RedundancyChoice_n', pyxb.binding.datatypes.int, required=True)
224
    __n._DeclarationLocation = pyxb.utils.utility.Location('/ore-common/xsd/configurations.xsd', 35, 8)
225
    __n._UseLocation = pyxb.utils.utility.Location('/ore-common/xsd/configurations.xsd', 35, 8)
226
    
227
    n = property(__n.value, __n.set, None, None)
228
229
    _ElementMap.update({
230
        
231
    })
232
    _AttributeMap.update({
233
        __n.name() : __n
234
    })
235
_module_typeBindings.RedundancyChoice = RedundancyChoice
236
Namespace.addCategoryObject('typeBinding', 'RedundancyChoice', RedundancyChoice)
237
238
239
# Complex type {http://www.fuzzed.org/configurations}FeatureChoice with content type EMPTY
240
class FeatureChoice (Choice):
241
    """Complex type {http://www.fuzzed.org/configurations}FeatureChoice with content type EMPTY"""
242
    _TypeDefinition = None
243
    _ContentTypeTag = pyxb.binding.basis.complexTypeDefinition._CT_EMPTY
244
    _Abstract = False
245
    _ExpandedName = pyxb.namespace.ExpandedName(Namespace, 'FeatureChoice')
246
    _XSDLocation = pyxb.utils.utility.Location('/ore-common/xsd/configurations.xsd', 40, 2)
247
    _ElementMap = Choice._ElementMap.copy()
248
    _AttributeMap = Choice._AttributeMap.copy()
249
    # Base type is Choice
250
    
251
    # Attribute featureId uses Python identifier featureId
252
    __featureId = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'featureId'), 'featureId', '__httpwww_fuzzed_orgconfigurations_FeatureChoice_featureId', pyxb.binding.datatypes.string, required=True)
253
    __featureId._DeclarationLocation = pyxb.utils.utility.Location('/ore-common/xsd/configurations.xsd', 43, 8)
254
    __featureId._UseLocation = pyxb.utils.utility.Location('/ore-common/xsd/configurations.xsd', 43, 8)
255
    
256
    featureId = property(__featureId.value, __featureId.set, None, None)
257
258
    _ElementMap.update({
259
        
260
    })
261
    _AttributeMap.update({
262
        __featureId.name() : __featureId
263
    })
264
_module_typeBindings.FeatureChoice = FeatureChoice
265
Namespace.addCategoryObject('typeBinding', 'FeatureChoice', FeatureChoice)
266
267
268
# Complex type {http://www.fuzzed.org/configurations}TransferInChoice with content type ELEMENT_ONLY
269
class TransferInChoice (Choice):
270
    """Complex type {http://www.fuzzed.org/configurations}TransferInChoice with content type ELEMENT_ONLY"""
271
    _TypeDefinition = None
272
    _ContentTypeTag = pyxb.binding.basis.complexTypeDefinition._CT_ELEMENT_ONLY
273
    _Abstract = False
274
    _ExpandedName = pyxb.namespace.ExpandedName(Namespace, 'TransferInChoice')
275
    _XSDLocation = pyxb.utils.utility.Location('/ore-common/xsd/configurations.xsd', 48, 2)
276
    _ElementMap = Choice._ElementMap.copy()
277
    _AttributeMap = Choice._AttributeMap.copy()
278
    # Base type is Choice
279
    
280
    # Element chosenConfiguration uses Python identifier chosenConfiguration
281
    __chosenConfiguration = pyxb.binding.content.ElementDeclaration(pyxb.namespace.ExpandedName(None, 'chosenConfiguration'), 'chosenConfiguration', '__httpwww_fuzzed_orgconfigurations_TransferInChoice_chosenConfiguration', False, pyxb.utils.utility.Location('/ore-common/xsd/configurations.xsd', 52, 10), )
282
283
    
284
    chosenConfiguration = property(__chosenConfiguration.value, __chosenConfiguration.set, None, None)
285
286
    _ElementMap.update({
287
        __chosenConfiguration.name() : __chosenConfiguration
288
    })
289
    _AttributeMap.update({
290
        
291
    })
292
_module_typeBindings.TransferInChoice = TransferInChoice
293
Namespace.addCategoryObject('typeBinding', 'TransferInChoice', TransferInChoice)
294
295
296
297
298
IntegerToChoiceMap._AddElement(pyxb.binding.basis.element(pyxb.namespace.ExpandedName(None, 'value'), Choice, scope=IntegerToChoiceMap, location=pyxb.utils.utility.Location('/ore-common/xsd/configurations.xsd', 11, 6)))
299
300
def _BuildAutomaton ():
301
    # Remove this helper function from the namespace after it is invoked
302
    global _BuildAutomaton
303
    del _BuildAutomaton
304
    import pyxb.utils.fac as fac
305
306
    counters = set()
307
    states = []
308
    final_update = set()
309
    symbol = pyxb.binding.content.ElementUse(IntegerToChoiceMap._UseForTag(pyxb.namespace.ExpandedName(None, 'value')), pyxb.utils.utility.Location('/ore-common/xsd/configurations.xsd', 11, 6))
310
    st_0 = fac.State(symbol, is_initial=True, final_update=final_update, is_unordered_catenation=False)
311
    states.append(st_0)
312
    transitions = []
313
    st_0._set_transitionSet(transitions)
314
    return fac.Automaton(states, counters, False, containing_state=None)
315
IntegerToChoiceMap._Automaton = _BuildAutomaton()
316
317
318
319
320
Configuration._AddElement(pyxb.binding.basis.element(pyxb.namespace.ExpandedName(None, 'choice'), IntegerToChoiceMap, scope=Configuration, location=pyxb.utils.utility.Location('/ore-common/xsd/configurations.xsd', 18, 6)))
321
322
def _BuildAutomaton_ ():
323
    # Remove this helper function from the namespace after it is invoked
324
    global _BuildAutomaton_
325
    del _BuildAutomaton_
326
    import pyxb.utils.fac as fac
327
328
    counters = set()
329
    cc_0 = fac.CounterCondition(min=0, max=None, metadata=pyxb.utils.utility.Location('/ore-common/xsd/configurations.xsd', 18, 6))
330
    counters.add(cc_0)
331
    states = []
332
    final_update = set()
333
    final_update.add(fac.UpdateInstruction(cc_0, False))
334
    symbol = pyxb.binding.content.ElementUse(Configuration._UseForTag(pyxb.namespace.ExpandedName(None, 'choice')), pyxb.utils.utility.Location('/ore-common/xsd/configurations.xsd', 18, 6))
335
    st_0 = fac.State(symbol, is_initial=True, final_update=final_update, is_unordered_catenation=False)
336
    states.append(st_0)
337
    transitions = []
338
    transitions.append(fac.Transition(st_0, [
339
        fac.UpdateInstruction(cc_0, True) ]))
340
    st_0._set_transitionSet(transitions)
341
    return fac.Automaton(states, counters, True, containing_state=None)
342
Configuration._Automaton = _BuildAutomaton_()
343
344
345
346
347
TransferInChoice._AddElement(pyxb.binding.basis.element(pyxb.namespace.ExpandedName(None, 'chosenConfiguration'), Configuration, scope=TransferInChoice, location=pyxb.utils.utility.Location('/ore-common/xsd/configurations.xsd', 52, 10)))
348
349
def _BuildAutomaton_2 ():
350
    # Remove this helper function from the namespace after it is invoked
351
    global _BuildAutomaton_2
352
    del _BuildAutomaton_2
353
    import pyxb.utils.fac as fac
354
355
    counters = set()
356
    states = []
357
    final_update = set()
358
    symbol = pyxb.binding.content.ElementUse(TransferInChoice._UseForTag(pyxb.namespace.ExpandedName(None, 'chosenConfiguration')), pyxb.utils.utility.Location('/ore-common/xsd/configurations.xsd', 52, 10))
359
    st_0 = fac.State(symbol, is_initial=True, final_update=final_update, is_unordered_catenation=False)
360
    states.append(st_0)
361
    transitions = []
362
    st_0._set_transitionSet(transitions)
363
    return fac.Automaton(states, counters, False, containing_state=None)
364
TransferInChoice._Automaton = _BuildAutomaton_2()
365
366