pywemo 1.4.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pywemo/README.md +69 -0
- pywemo/__init__.py +33 -0
- pywemo/color.py +79 -0
- pywemo/discovery.py +194 -0
- pywemo/exceptions.py +94 -0
- pywemo/ouimeaux_device/LICENSE +12 -0
- pywemo/ouimeaux_device/__init__.py +679 -0
- pywemo/ouimeaux_device/api/__init__.py +1 -0
- pywemo/ouimeaux_device/api/attributes.py +131 -0
- pywemo/ouimeaux_device/api/db_orm.py +197 -0
- pywemo/ouimeaux_device/api/long_press.py +168 -0
- pywemo/ouimeaux_device/api/rules_db.py +467 -0
- pywemo/ouimeaux_device/api/service.py +363 -0
- pywemo/ouimeaux_device/api/wemo_services.py +25 -0
- pywemo/ouimeaux_device/api/wemo_services.pyi +241 -0
- pywemo/ouimeaux_device/api/xsd/__init__.py +1 -0
- pywemo/ouimeaux_device/api/xsd/device.py +3888 -0
- pywemo/ouimeaux_device/api/xsd/device.xsd +95 -0
- pywemo/ouimeaux_device/api/xsd/service.py +3872 -0
- pywemo/ouimeaux_device/api/xsd/service.xsd +93 -0
- pywemo/ouimeaux_device/api/xsd_types.py +222 -0
- pywemo/ouimeaux_device/bridge.py +506 -0
- pywemo/ouimeaux_device/coffeemaker.py +92 -0
- pywemo/ouimeaux_device/crockpot.py +157 -0
- pywemo/ouimeaux_device/dimmer.py +70 -0
- pywemo/ouimeaux_device/humidifier.py +223 -0
- pywemo/ouimeaux_device/insight.py +191 -0
- pywemo/ouimeaux_device/lightswitch.py +11 -0
- pywemo/ouimeaux_device/maker.py +54 -0
- pywemo/ouimeaux_device/motion.py +6 -0
- pywemo/ouimeaux_device/outdoor_plug.py +6 -0
- pywemo/ouimeaux_device/switch.py +32 -0
- pywemo/py.typed +0 -0
- pywemo/ssdp.py +372 -0
- pywemo/subscribe.py +782 -0
- pywemo/util.py +139 -0
- pywemo-1.4.0.dist-info/LICENSE +54 -0
- pywemo-1.4.0.dist-info/METADATA +192 -0
- pywemo-1.4.0.dist-info/RECORD +40 -0
- pywemo-1.4.0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,3888 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
# flake8: noqa
|
|
4
|
+
# isort: skip_file
|
|
5
|
+
# mypy: ignore-errors
|
|
6
|
+
# pylint: skip-file
|
|
7
|
+
|
|
8
|
+
#
|
|
9
|
+
# Generated by generateDS.py version 2.43.3.
|
|
10
|
+
# Python [sys.version]
|
|
11
|
+
#
|
|
12
|
+
# Command line options:
|
|
13
|
+
# ('-f', '')
|
|
14
|
+
# ('--no-dates', '')
|
|
15
|
+
# ('-o', 'device.py')
|
|
16
|
+
#
|
|
17
|
+
# Command line arguments:
|
|
18
|
+
# pywemo/ouimeaux_device/api/xsd/device.xsd
|
|
19
|
+
#
|
|
20
|
+
# Command line:
|
|
21
|
+
# generateDS.py -f --no-dates -o "device.py" pywemo/ouimeaux_device/api/xsd/device.xsd
|
|
22
|
+
#
|
|
23
|
+
# Current working directory (os.getcwd()):
|
|
24
|
+
# pywemo
|
|
25
|
+
#
|
|
26
|
+
|
|
27
|
+
import sys
|
|
28
|
+
|
|
29
|
+
try:
|
|
30
|
+
ModulenotfoundExp_ = ModuleNotFoundError
|
|
31
|
+
except NameError:
|
|
32
|
+
ModulenotfoundExp_ = ImportError
|
|
33
|
+
from itertools import zip_longest
|
|
34
|
+
import os
|
|
35
|
+
import re as re_
|
|
36
|
+
import base64
|
|
37
|
+
import datetime as datetime_
|
|
38
|
+
import decimal as decimal_
|
|
39
|
+
from lxml import etree as etree_
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
Validate_simpletypes_ = True
|
|
43
|
+
SaveElementTreeNode = True
|
|
44
|
+
TagNamePrefix = ""
|
|
45
|
+
if sys.version_info.major == 2:
|
|
46
|
+
BaseStrType_ = basestring
|
|
47
|
+
else:
|
|
48
|
+
BaseStrType_ = str
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def parsexml_(infile, parser=None, **kwargs):
|
|
52
|
+
if parser is None:
|
|
53
|
+
# Use the lxml ElementTree compatible parser so that, e.g.,
|
|
54
|
+
# we ignore comments.
|
|
55
|
+
try:
|
|
56
|
+
parser = etree_.ETCompatXMLParser()
|
|
57
|
+
except AttributeError:
|
|
58
|
+
# fallback to xml.etree
|
|
59
|
+
parser = etree_.XMLParser()
|
|
60
|
+
try:
|
|
61
|
+
if isinstance(infile, os.PathLike):
|
|
62
|
+
infile = os.path.join(infile)
|
|
63
|
+
except AttributeError:
|
|
64
|
+
pass
|
|
65
|
+
doc = etree_.parse(infile, parser=parser, **kwargs)
|
|
66
|
+
return doc
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def parsexmlstring_(instring, parser=None, **kwargs):
|
|
70
|
+
if parser is None:
|
|
71
|
+
# Use the lxml ElementTree compatible parser so that, e.g.,
|
|
72
|
+
# we ignore comments.
|
|
73
|
+
try:
|
|
74
|
+
parser = etree_.ETCompatXMLParser()
|
|
75
|
+
except AttributeError:
|
|
76
|
+
# fallback to xml.etree
|
|
77
|
+
parser = etree_.XMLParser()
|
|
78
|
+
element = etree_.fromstring(instring, parser=parser, **kwargs)
|
|
79
|
+
return element
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
#
|
|
83
|
+
# Namespace prefix definition table (and other attributes, too)
|
|
84
|
+
#
|
|
85
|
+
# The module generatedsnamespaces, if it is importable, must contain
|
|
86
|
+
# a dictionary named GeneratedsNamespaceDefs. This Python dictionary
|
|
87
|
+
# should map element type names (strings) to XML schema namespace prefix
|
|
88
|
+
# definitions. The export method for any class for which there is
|
|
89
|
+
# a namespace prefix definition, will export that definition in the
|
|
90
|
+
# XML representation of that element. See the export method of
|
|
91
|
+
# any generated element type class for an example of the use of this
|
|
92
|
+
# table.
|
|
93
|
+
# A sample table is:
|
|
94
|
+
#
|
|
95
|
+
# # File: generatedsnamespaces.py
|
|
96
|
+
#
|
|
97
|
+
# GenerateDSNamespaceDefs = {
|
|
98
|
+
# "ElementtypeA": "http://www.xxx.com/namespaceA",
|
|
99
|
+
# "ElementtypeB": "http://www.xxx.com/namespaceB",
|
|
100
|
+
# }
|
|
101
|
+
#
|
|
102
|
+
# Additionally, the generatedsnamespaces module can contain a python
|
|
103
|
+
# dictionary named GenerateDSNamespaceTypePrefixes that associates element
|
|
104
|
+
# types with the namespace prefixes that are to be added to the
|
|
105
|
+
# "xsi:type" attribute value. See the _exportAttributes method of
|
|
106
|
+
# any generated element type and the generation of "xsi:type" for an
|
|
107
|
+
# example of the use of this table.
|
|
108
|
+
# An example table:
|
|
109
|
+
#
|
|
110
|
+
# # File: generatedsnamespaces.py
|
|
111
|
+
#
|
|
112
|
+
# GenerateDSNamespaceTypePrefixes = {
|
|
113
|
+
# "ElementtypeC": "aaa:",
|
|
114
|
+
# "ElementtypeD": "bbb:",
|
|
115
|
+
# }
|
|
116
|
+
#
|
|
117
|
+
|
|
118
|
+
try:
|
|
119
|
+
from generatedsnamespaces import (
|
|
120
|
+
GenerateDSNamespaceDefs as GenerateDSNamespaceDefs_,
|
|
121
|
+
)
|
|
122
|
+
except ModulenotfoundExp_:
|
|
123
|
+
GenerateDSNamespaceDefs_ = {}
|
|
124
|
+
try:
|
|
125
|
+
from generatedsnamespaces import (
|
|
126
|
+
GenerateDSNamespaceTypePrefixes as GenerateDSNamespaceTypePrefixes_,
|
|
127
|
+
)
|
|
128
|
+
except ModulenotfoundExp_:
|
|
129
|
+
GenerateDSNamespaceTypePrefixes_ = {}
|
|
130
|
+
|
|
131
|
+
#
|
|
132
|
+
# You can replace the following class definition by defining an
|
|
133
|
+
# importable module named "generatedscollector" containing a class
|
|
134
|
+
# named "GdsCollector". See the default class definition below for
|
|
135
|
+
# clues about the possible content of that class.
|
|
136
|
+
#
|
|
137
|
+
try:
|
|
138
|
+
from generatedscollector import GdsCollector as GdsCollector_
|
|
139
|
+
except ModulenotfoundExp_:
|
|
140
|
+
|
|
141
|
+
class GdsCollector_(object):
|
|
142
|
+
def __init__(self, messages=None):
|
|
143
|
+
if messages is None:
|
|
144
|
+
self.messages = []
|
|
145
|
+
else:
|
|
146
|
+
self.messages = messages
|
|
147
|
+
|
|
148
|
+
def add_message(self, msg):
|
|
149
|
+
self.messages.append(msg)
|
|
150
|
+
|
|
151
|
+
def get_messages(self):
|
|
152
|
+
return self.messages
|
|
153
|
+
|
|
154
|
+
def clear_messages(self):
|
|
155
|
+
self.messages = []
|
|
156
|
+
|
|
157
|
+
def print_messages(self):
|
|
158
|
+
for msg in self.messages:
|
|
159
|
+
print("Warning: {}".format(msg))
|
|
160
|
+
|
|
161
|
+
def write_messages(self, outstream):
|
|
162
|
+
for msg in self.messages:
|
|
163
|
+
outstream.write("Warning: {}\n".format(msg))
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
#
|
|
167
|
+
# The super-class for enum types
|
|
168
|
+
#
|
|
169
|
+
|
|
170
|
+
try:
|
|
171
|
+
from enum import Enum
|
|
172
|
+
except ModulenotfoundExp_:
|
|
173
|
+
Enum = object
|
|
174
|
+
|
|
175
|
+
#
|
|
176
|
+
# The root super-class for element type classes
|
|
177
|
+
#
|
|
178
|
+
# Calls to the methods in these classes are generated by generateDS.py.
|
|
179
|
+
# You can replace these methods by re-implementing the following class
|
|
180
|
+
# in a module named generatedssuper.py.
|
|
181
|
+
|
|
182
|
+
try:
|
|
183
|
+
from generatedssuper import GeneratedsSuper
|
|
184
|
+
except ModulenotfoundExp_ as exp:
|
|
185
|
+
try:
|
|
186
|
+
from generatedssupersuper import GeneratedsSuperSuper
|
|
187
|
+
except ModulenotfoundExp_ as exp:
|
|
188
|
+
|
|
189
|
+
class GeneratedsSuperSuper(object):
|
|
190
|
+
pass
|
|
191
|
+
|
|
192
|
+
class GeneratedsSuper(GeneratedsSuperSuper):
|
|
193
|
+
__hash__ = object.__hash__
|
|
194
|
+
tzoff_pattern = re_.compile(r"(\+|-)((0\d|1[0-3]):[0-5]\d|14:00)$")
|
|
195
|
+
|
|
196
|
+
class _FixedOffsetTZ(datetime_.tzinfo):
|
|
197
|
+
def __init__(self, offset, name):
|
|
198
|
+
self.__offset = datetime_.timedelta(minutes=offset)
|
|
199
|
+
self.__name = name
|
|
200
|
+
|
|
201
|
+
def utcoffset(self, dt):
|
|
202
|
+
return self.__offset
|
|
203
|
+
|
|
204
|
+
def tzname(self, dt):
|
|
205
|
+
return self.__name
|
|
206
|
+
|
|
207
|
+
def dst(self, dt):
|
|
208
|
+
return None
|
|
209
|
+
|
|
210
|
+
def __str__(self):
|
|
211
|
+
settings = {
|
|
212
|
+
"str_pretty_print": True,
|
|
213
|
+
"str_indent_level": 0,
|
|
214
|
+
"str_namespaceprefix": "",
|
|
215
|
+
"str_name": self.__class__.__name__,
|
|
216
|
+
"str_namespacedefs": "",
|
|
217
|
+
}
|
|
218
|
+
for n in settings:
|
|
219
|
+
if hasattr(self, n):
|
|
220
|
+
settings[n] = getattr(self, n)
|
|
221
|
+
if sys.version_info.major == 2:
|
|
222
|
+
from StringIO import StringIO
|
|
223
|
+
else:
|
|
224
|
+
from io import StringIO
|
|
225
|
+
output = StringIO()
|
|
226
|
+
self.export(
|
|
227
|
+
output,
|
|
228
|
+
settings["str_indent_level"],
|
|
229
|
+
pretty_print=settings["str_pretty_print"],
|
|
230
|
+
namespaceprefix_=settings["str_namespaceprefix"],
|
|
231
|
+
name_=settings["str_name"],
|
|
232
|
+
namespacedef_=settings["str_namespacedefs"],
|
|
233
|
+
)
|
|
234
|
+
strval = output.getvalue()
|
|
235
|
+
output.close()
|
|
236
|
+
return strval
|
|
237
|
+
|
|
238
|
+
def gds_format_string(self, input_data, input_name=""):
|
|
239
|
+
return input_data
|
|
240
|
+
|
|
241
|
+
def gds_parse_string(self, input_data, node=None, input_name=""):
|
|
242
|
+
return input_data
|
|
243
|
+
|
|
244
|
+
def gds_validate_string(self, input_data, node=None, input_name=""):
|
|
245
|
+
if not input_data:
|
|
246
|
+
return ""
|
|
247
|
+
else:
|
|
248
|
+
return input_data
|
|
249
|
+
|
|
250
|
+
def gds_format_base64(self, input_data, input_name=""):
|
|
251
|
+
return base64.b64encode(input_data).decode("ascii")
|
|
252
|
+
|
|
253
|
+
def gds_validate_base64(self, input_data, node=None, input_name=""):
|
|
254
|
+
return input_data
|
|
255
|
+
|
|
256
|
+
def gds_format_integer(self, input_data, input_name=""):
|
|
257
|
+
return "%d" % int(input_data)
|
|
258
|
+
|
|
259
|
+
def gds_parse_integer(self, input_data, node=None, input_name=""):
|
|
260
|
+
try:
|
|
261
|
+
ival = int(input_data)
|
|
262
|
+
except (TypeError, ValueError) as exp:
|
|
263
|
+
raise_parse_error(node, "Requires integer value: %s" % exp)
|
|
264
|
+
return ival
|
|
265
|
+
|
|
266
|
+
def gds_validate_integer(self, input_data, node=None, input_name=""):
|
|
267
|
+
try:
|
|
268
|
+
value = int(input_data)
|
|
269
|
+
except (TypeError, ValueError):
|
|
270
|
+
raise_parse_error(node, "Requires integer value")
|
|
271
|
+
return value
|
|
272
|
+
|
|
273
|
+
def gds_format_integer_list(self, input_data, input_name=""):
|
|
274
|
+
if len(input_data) > 0 and not isinstance(
|
|
275
|
+
input_data[0], BaseStrType_
|
|
276
|
+
):
|
|
277
|
+
input_data = [str(s) for s in input_data]
|
|
278
|
+
return "%s" % " ".join(input_data)
|
|
279
|
+
|
|
280
|
+
def gds_validate_integer_list(
|
|
281
|
+
self, input_data, node=None, input_name=""
|
|
282
|
+
):
|
|
283
|
+
values = input_data.split()
|
|
284
|
+
for value in values:
|
|
285
|
+
try:
|
|
286
|
+
int(value)
|
|
287
|
+
except (TypeError, ValueError):
|
|
288
|
+
raise_parse_error(
|
|
289
|
+
node, "Requires sequence of integer values"
|
|
290
|
+
)
|
|
291
|
+
return values
|
|
292
|
+
|
|
293
|
+
def gds_format_float(self, input_data, input_name=""):
|
|
294
|
+
value = ("%.15f" % float(input_data)).rstrip("0")
|
|
295
|
+
if value.endswith("."):
|
|
296
|
+
value += "0"
|
|
297
|
+
return value
|
|
298
|
+
|
|
299
|
+
def gds_parse_float(self, input_data, node=None, input_name=""):
|
|
300
|
+
try:
|
|
301
|
+
fval_ = float(input_data)
|
|
302
|
+
except (TypeError, ValueError) as exp:
|
|
303
|
+
raise_parse_error(
|
|
304
|
+
node, "Requires float or double value: %s" % exp
|
|
305
|
+
)
|
|
306
|
+
return fval_
|
|
307
|
+
|
|
308
|
+
def gds_validate_float(self, input_data, node=None, input_name=""):
|
|
309
|
+
try:
|
|
310
|
+
value = float(input_data)
|
|
311
|
+
except (TypeError, ValueError):
|
|
312
|
+
raise_parse_error(node, "Requires float value")
|
|
313
|
+
return value
|
|
314
|
+
|
|
315
|
+
def gds_format_float_list(self, input_data, input_name=""):
|
|
316
|
+
if len(input_data) > 0 and not isinstance(
|
|
317
|
+
input_data[0], BaseStrType_
|
|
318
|
+
):
|
|
319
|
+
input_data = [str(s) for s in input_data]
|
|
320
|
+
return "%s" % " ".join(input_data)
|
|
321
|
+
|
|
322
|
+
def gds_validate_float_list(
|
|
323
|
+
self, input_data, node=None, input_name=""
|
|
324
|
+
):
|
|
325
|
+
values = input_data.split()
|
|
326
|
+
for value in values:
|
|
327
|
+
try:
|
|
328
|
+
float(value)
|
|
329
|
+
except (TypeError, ValueError):
|
|
330
|
+
raise_parse_error(
|
|
331
|
+
node, "Requires sequence of float values"
|
|
332
|
+
)
|
|
333
|
+
return values
|
|
334
|
+
|
|
335
|
+
def gds_format_decimal(self, input_data, input_name=""):
|
|
336
|
+
return_value = "%s" % input_data
|
|
337
|
+
if "." in return_value:
|
|
338
|
+
return_value = return_value.rstrip("0")
|
|
339
|
+
if return_value.endswith("."):
|
|
340
|
+
return_value = return_value.rstrip(".")
|
|
341
|
+
return return_value
|
|
342
|
+
|
|
343
|
+
def gds_parse_decimal(self, input_data, node=None, input_name=""):
|
|
344
|
+
try:
|
|
345
|
+
decimal_value = decimal_.Decimal(input_data)
|
|
346
|
+
except (TypeError, ValueError):
|
|
347
|
+
raise_parse_error(node, "Requires decimal value")
|
|
348
|
+
return decimal_value
|
|
349
|
+
|
|
350
|
+
def gds_validate_decimal(self, input_data, node=None, input_name=""):
|
|
351
|
+
try:
|
|
352
|
+
value = decimal_.Decimal(input_data)
|
|
353
|
+
except (TypeError, ValueError):
|
|
354
|
+
raise_parse_error(node, "Requires decimal value")
|
|
355
|
+
return value
|
|
356
|
+
|
|
357
|
+
def gds_format_decimal_list(self, input_data, input_name=""):
|
|
358
|
+
if len(input_data) > 0 and not isinstance(
|
|
359
|
+
input_data[0], BaseStrType_
|
|
360
|
+
):
|
|
361
|
+
input_data = [str(s) for s in input_data]
|
|
362
|
+
return " ".join(
|
|
363
|
+
[self.gds_format_decimal(item) for item in input_data]
|
|
364
|
+
)
|
|
365
|
+
|
|
366
|
+
def gds_validate_decimal_list(
|
|
367
|
+
self, input_data, node=None, input_name=""
|
|
368
|
+
):
|
|
369
|
+
values = input_data.split()
|
|
370
|
+
for value in values:
|
|
371
|
+
try:
|
|
372
|
+
decimal_.Decimal(value)
|
|
373
|
+
except (TypeError, ValueError):
|
|
374
|
+
raise_parse_error(
|
|
375
|
+
node, "Requires sequence of decimal values"
|
|
376
|
+
)
|
|
377
|
+
return values
|
|
378
|
+
|
|
379
|
+
def gds_format_double(self, input_data, input_name=""):
|
|
380
|
+
return "%s" % input_data
|
|
381
|
+
|
|
382
|
+
def gds_parse_double(self, input_data, node=None, input_name=""):
|
|
383
|
+
try:
|
|
384
|
+
fval_ = float(input_data)
|
|
385
|
+
except (TypeError, ValueError) as exp:
|
|
386
|
+
raise_parse_error(
|
|
387
|
+
node, "Requires double or float value: %s" % exp
|
|
388
|
+
)
|
|
389
|
+
return fval_
|
|
390
|
+
|
|
391
|
+
def gds_validate_double(self, input_data, node=None, input_name=""):
|
|
392
|
+
try:
|
|
393
|
+
value = float(input_data)
|
|
394
|
+
except (TypeError, ValueError):
|
|
395
|
+
raise_parse_error(node, "Requires double or float value")
|
|
396
|
+
return value
|
|
397
|
+
|
|
398
|
+
def gds_format_double_list(self, input_data, input_name=""):
|
|
399
|
+
if len(input_data) > 0 and not isinstance(
|
|
400
|
+
input_data[0], BaseStrType_
|
|
401
|
+
):
|
|
402
|
+
input_data = [str(s) for s in input_data]
|
|
403
|
+
return "%s" % " ".join(input_data)
|
|
404
|
+
|
|
405
|
+
def gds_validate_double_list(
|
|
406
|
+
self, input_data, node=None, input_name=""
|
|
407
|
+
):
|
|
408
|
+
values = input_data.split()
|
|
409
|
+
for value in values:
|
|
410
|
+
try:
|
|
411
|
+
float(value)
|
|
412
|
+
except (TypeError, ValueError):
|
|
413
|
+
raise_parse_error(
|
|
414
|
+
node, "Requires sequence of double or float values"
|
|
415
|
+
)
|
|
416
|
+
return values
|
|
417
|
+
|
|
418
|
+
def gds_format_boolean(self, input_data, input_name=""):
|
|
419
|
+
return ("%s" % input_data).lower()
|
|
420
|
+
|
|
421
|
+
def gds_parse_boolean(self, input_data, node=None, input_name=""):
|
|
422
|
+
input_data = input_data.strip()
|
|
423
|
+
if input_data in ("true", "1"):
|
|
424
|
+
bval = True
|
|
425
|
+
elif input_data in ("false", "0"):
|
|
426
|
+
bval = False
|
|
427
|
+
else:
|
|
428
|
+
raise_parse_error(node, "Requires boolean value")
|
|
429
|
+
return bval
|
|
430
|
+
|
|
431
|
+
def gds_validate_boolean(self, input_data, node=None, input_name=""):
|
|
432
|
+
if input_data not in (
|
|
433
|
+
True,
|
|
434
|
+
1,
|
|
435
|
+
False,
|
|
436
|
+
0,
|
|
437
|
+
):
|
|
438
|
+
raise_parse_error(
|
|
439
|
+
node,
|
|
440
|
+
"Requires boolean value " "(one of True, 1, False, 0)",
|
|
441
|
+
)
|
|
442
|
+
return input_data
|
|
443
|
+
|
|
444
|
+
def gds_format_boolean_list(self, input_data, input_name=""):
|
|
445
|
+
if len(input_data) > 0 and not isinstance(
|
|
446
|
+
input_data[0], BaseStrType_
|
|
447
|
+
):
|
|
448
|
+
input_data = [str(s) for s in input_data]
|
|
449
|
+
return "%s" % " ".join(input_data)
|
|
450
|
+
|
|
451
|
+
def gds_validate_boolean_list(
|
|
452
|
+
self, input_data, node=None, input_name=""
|
|
453
|
+
):
|
|
454
|
+
values = input_data.split()
|
|
455
|
+
for value in values:
|
|
456
|
+
value = self.gds_parse_boolean(value, node, input_name)
|
|
457
|
+
if value not in (
|
|
458
|
+
True,
|
|
459
|
+
1,
|
|
460
|
+
False,
|
|
461
|
+
0,
|
|
462
|
+
):
|
|
463
|
+
raise_parse_error(
|
|
464
|
+
node,
|
|
465
|
+
"Requires sequence of boolean values "
|
|
466
|
+
"(one of True, 1, False, 0)",
|
|
467
|
+
)
|
|
468
|
+
return values
|
|
469
|
+
|
|
470
|
+
def gds_validate_datetime(self, input_data, node=None, input_name=""):
|
|
471
|
+
return input_data
|
|
472
|
+
|
|
473
|
+
def gds_format_datetime(self, input_data, input_name=""):
|
|
474
|
+
if input_data.microsecond == 0:
|
|
475
|
+
_svalue = "%04d-%02d-%02dT%02d:%02d:%02d" % (
|
|
476
|
+
input_data.year,
|
|
477
|
+
input_data.month,
|
|
478
|
+
input_data.day,
|
|
479
|
+
input_data.hour,
|
|
480
|
+
input_data.minute,
|
|
481
|
+
input_data.second,
|
|
482
|
+
)
|
|
483
|
+
else:
|
|
484
|
+
_svalue = "%04d-%02d-%02dT%02d:%02d:%02d.%s" % (
|
|
485
|
+
input_data.year,
|
|
486
|
+
input_data.month,
|
|
487
|
+
input_data.day,
|
|
488
|
+
input_data.hour,
|
|
489
|
+
input_data.minute,
|
|
490
|
+
input_data.second,
|
|
491
|
+
("%f" % (float(input_data.microsecond) / 1000000))[2:],
|
|
492
|
+
)
|
|
493
|
+
if input_data.tzinfo is not None:
|
|
494
|
+
tzoff = input_data.tzinfo.utcoffset(input_data)
|
|
495
|
+
if tzoff is not None:
|
|
496
|
+
total_seconds = tzoff.seconds + (86400 * tzoff.days)
|
|
497
|
+
if total_seconds == 0:
|
|
498
|
+
_svalue += "Z"
|
|
499
|
+
else:
|
|
500
|
+
if total_seconds < 0:
|
|
501
|
+
_svalue += "-"
|
|
502
|
+
total_seconds *= -1
|
|
503
|
+
else:
|
|
504
|
+
_svalue += "+"
|
|
505
|
+
hours = total_seconds // 3600
|
|
506
|
+
minutes = (total_seconds - (hours * 3600)) // 60
|
|
507
|
+
_svalue += "{0:02d}:{1:02d}".format(hours, minutes)
|
|
508
|
+
return _svalue
|
|
509
|
+
|
|
510
|
+
@classmethod
|
|
511
|
+
def gds_parse_datetime(cls, input_data):
|
|
512
|
+
tz = None
|
|
513
|
+
if input_data[-1] == "Z":
|
|
514
|
+
tz = GeneratedsSuper._FixedOffsetTZ(0, "UTC")
|
|
515
|
+
input_data = input_data[:-1]
|
|
516
|
+
else:
|
|
517
|
+
results = GeneratedsSuper.tzoff_pattern.search(input_data)
|
|
518
|
+
if results is not None:
|
|
519
|
+
tzoff_parts = results.group(2).split(":")
|
|
520
|
+
tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1])
|
|
521
|
+
if results.group(1) == "-":
|
|
522
|
+
tzoff *= -1
|
|
523
|
+
tz = GeneratedsSuper._FixedOffsetTZ(
|
|
524
|
+
tzoff, results.group(0)
|
|
525
|
+
)
|
|
526
|
+
input_data = input_data[:-6]
|
|
527
|
+
time_parts = input_data.split(".")
|
|
528
|
+
if len(time_parts) > 1:
|
|
529
|
+
micro_seconds = int(float("0." + time_parts[1]) * 1000000)
|
|
530
|
+
input_data = "%s.%s" % (
|
|
531
|
+
time_parts[0],
|
|
532
|
+
"{}".format(micro_seconds).rjust(6, "0"),
|
|
533
|
+
)
|
|
534
|
+
dt = datetime_.datetime.strptime(
|
|
535
|
+
input_data, "%Y-%m-%dT%H:%M:%S.%f"
|
|
536
|
+
)
|
|
537
|
+
else:
|
|
538
|
+
dt = datetime_.datetime.strptime(
|
|
539
|
+
input_data, "%Y-%m-%dT%H:%M:%S"
|
|
540
|
+
)
|
|
541
|
+
dt = dt.replace(tzinfo=tz)
|
|
542
|
+
return dt
|
|
543
|
+
|
|
544
|
+
def gds_validate_date(self, input_data, node=None, input_name=""):
|
|
545
|
+
return input_data
|
|
546
|
+
|
|
547
|
+
def gds_format_date(self, input_data, input_name=""):
|
|
548
|
+
_svalue = "%04d-%02d-%02d" % (
|
|
549
|
+
input_data.year,
|
|
550
|
+
input_data.month,
|
|
551
|
+
input_data.day,
|
|
552
|
+
)
|
|
553
|
+
try:
|
|
554
|
+
if input_data.tzinfo is not None:
|
|
555
|
+
tzoff = input_data.tzinfo.utcoffset(input_data)
|
|
556
|
+
if tzoff is not None:
|
|
557
|
+
total_seconds = tzoff.seconds + (86400 * tzoff.days)
|
|
558
|
+
if total_seconds == 0:
|
|
559
|
+
_svalue += "Z"
|
|
560
|
+
else:
|
|
561
|
+
if total_seconds < 0:
|
|
562
|
+
_svalue += "-"
|
|
563
|
+
total_seconds *= -1
|
|
564
|
+
else:
|
|
565
|
+
_svalue += "+"
|
|
566
|
+
hours = total_seconds // 3600
|
|
567
|
+
minutes = (total_seconds - (hours * 3600)) // 60
|
|
568
|
+
_svalue += "{0:02d}:{1:02d}".format(hours, minutes)
|
|
569
|
+
except AttributeError:
|
|
570
|
+
pass
|
|
571
|
+
return _svalue
|
|
572
|
+
|
|
573
|
+
@classmethod
|
|
574
|
+
def gds_parse_date(cls, input_data):
|
|
575
|
+
tz = None
|
|
576
|
+
if input_data[-1] == "Z":
|
|
577
|
+
tz = GeneratedsSuper._FixedOffsetTZ(0, "UTC")
|
|
578
|
+
input_data = input_data[:-1]
|
|
579
|
+
else:
|
|
580
|
+
results = GeneratedsSuper.tzoff_pattern.search(input_data)
|
|
581
|
+
if results is not None:
|
|
582
|
+
tzoff_parts = results.group(2).split(":")
|
|
583
|
+
tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1])
|
|
584
|
+
if results.group(1) == "-":
|
|
585
|
+
tzoff *= -1
|
|
586
|
+
tz = GeneratedsSuper._FixedOffsetTZ(
|
|
587
|
+
tzoff, results.group(0)
|
|
588
|
+
)
|
|
589
|
+
input_data = input_data[:-6]
|
|
590
|
+
dt = datetime_.datetime.strptime(input_data, "%Y-%m-%d")
|
|
591
|
+
dt = dt.replace(tzinfo=tz)
|
|
592
|
+
return dt.date()
|
|
593
|
+
|
|
594
|
+
def gds_validate_time(self, input_data, node=None, input_name=""):
|
|
595
|
+
return input_data
|
|
596
|
+
|
|
597
|
+
def gds_format_time(self, input_data, input_name=""):
|
|
598
|
+
if input_data.microsecond == 0:
|
|
599
|
+
_svalue = "%02d:%02d:%02d" % (
|
|
600
|
+
input_data.hour,
|
|
601
|
+
input_data.minute,
|
|
602
|
+
input_data.second,
|
|
603
|
+
)
|
|
604
|
+
else:
|
|
605
|
+
_svalue = "%02d:%02d:%02d.%s" % (
|
|
606
|
+
input_data.hour,
|
|
607
|
+
input_data.minute,
|
|
608
|
+
input_data.second,
|
|
609
|
+
("%f" % (float(input_data.microsecond) / 1000000))[2:],
|
|
610
|
+
)
|
|
611
|
+
if input_data.tzinfo is not None:
|
|
612
|
+
tzoff = input_data.tzinfo.utcoffset(input_data)
|
|
613
|
+
if tzoff is not None:
|
|
614
|
+
total_seconds = tzoff.seconds + (86400 * tzoff.days)
|
|
615
|
+
if total_seconds == 0:
|
|
616
|
+
_svalue += "Z"
|
|
617
|
+
else:
|
|
618
|
+
if total_seconds < 0:
|
|
619
|
+
_svalue += "-"
|
|
620
|
+
total_seconds *= -1
|
|
621
|
+
else:
|
|
622
|
+
_svalue += "+"
|
|
623
|
+
hours = total_seconds // 3600
|
|
624
|
+
minutes = (total_seconds - (hours * 3600)) // 60
|
|
625
|
+
_svalue += "{0:02d}:{1:02d}".format(hours, minutes)
|
|
626
|
+
return _svalue
|
|
627
|
+
|
|
628
|
+
def gds_validate_simple_patterns(self, patterns, target):
|
|
629
|
+
# pat is a list of lists of strings/patterns.
|
|
630
|
+
# The target value must match at least one of the patterns
|
|
631
|
+
# in order for the test to succeed.
|
|
632
|
+
found1 = True
|
|
633
|
+
target = str(target)
|
|
634
|
+
for patterns1 in patterns:
|
|
635
|
+
found2 = False
|
|
636
|
+
for patterns2 in patterns1:
|
|
637
|
+
mo = re_.search(patterns2, target)
|
|
638
|
+
if mo is not None and len(mo.group(0)) == len(target):
|
|
639
|
+
found2 = True
|
|
640
|
+
break
|
|
641
|
+
if not found2:
|
|
642
|
+
found1 = False
|
|
643
|
+
break
|
|
644
|
+
return found1
|
|
645
|
+
|
|
646
|
+
@classmethod
|
|
647
|
+
def gds_parse_time(cls, input_data):
|
|
648
|
+
tz = None
|
|
649
|
+
if input_data[-1] == "Z":
|
|
650
|
+
tz = GeneratedsSuper._FixedOffsetTZ(0, "UTC")
|
|
651
|
+
input_data = input_data[:-1]
|
|
652
|
+
else:
|
|
653
|
+
results = GeneratedsSuper.tzoff_pattern.search(input_data)
|
|
654
|
+
if results is not None:
|
|
655
|
+
tzoff_parts = results.group(2).split(":")
|
|
656
|
+
tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1])
|
|
657
|
+
if results.group(1) == "-":
|
|
658
|
+
tzoff *= -1
|
|
659
|
+
tz = GeneratedsSuper._FixedOffsetTZ(
|
|
660
|
+
tzoff, results.group(0)
|
|
661
|
+
)
|
|
662
|
+
input_data = input_data[:-6]
|
|
663
|
+
if len(input_data.split(".")) > 1:
|
|
664
|
+
dt = datetime_.datetime.strptime(input_data, "%H:%M:%S.%f")
|
|
665
|
+
else:
|
|
666
|
+
dt = datetime_.datetime.strptime(input_data, "%H:%M:%S")
|
|
667
|
+
dt = dt.replace(tzinfo=tz)
|
|
668
|
+
return dt.time()
|
|
669
|
+
|
|
670
|
+
def gds_check_cardinality_(
|
|
671
|
+
self, value, input_name, min_occurs=0, max_occurs=1, required=None
|
|
672
|
+
):
|
|
673
|
+
if value is None:
|
|
674
|
+
length = 0
|
|
675
|
+
elif isinstance(value, list):
|
|
676
|
+
length = len(value)
|
|
677
|
+
else:
|
|
678
|
+
length = 1
|
|
679
|
+
if required is not None:
|
|
680
|
+
if required and length < 1:
|
|
681
|
+
self.gds_collector_.add_message(
|
|
682
|
+
"Required value {}{} is missing".format(
|
|
683
|
+
input_name, self.gds_get_node_lineno_()
|
|
684
|
+
)
|
|
685
|
+
)
|
|
686
|
+
if length < min_occurs:
|
|
687
|
+
self.gds_collector_.add_message(
|
|
688
|
+
"Number of values for {}{} is below "
|
|
689
|
+
"the minimum allowed, "
|
|
690
|
+
"expected at least {}, found {}".format(
|
|
691
|
+
input_name,
|
|
692
|
+
self.gds_get_node_lineno_(),
|
|
693
|
+
min_occurs,
|
|
694
|
+
length,
|
|
695
|
+
)
|
|
696
|
+
)
|
|
697
|
+
elif length > max_occurs:
|
|
698
|
+
self.gds_collector_.add_message(
|
|
699
|
+
"Number of values for {}{} is above "
|
|
700
|
+
"the maximum allowed, "
|
|
701
|
+
"expected at most {}, found {}".format(
|
|
702
|
+
input_name,
|
|
703
|
+
self.gds_get_node_lineno_(),
|
|
704
|
+
max_occurs,
|
|
705
|
+
length,
|
|
706
|
+
)
|
|
707
|
+
)
|
|
708
|
+
|
|
709
|
+
def gds_validate_builtin_ST_(
|
|
710
|
+
self,
|
|
711
|
+
validator,
|
|
712
|
+
value,
|
|
713
|
+
input_name,
|
|
714
|
+
min_occurs=None,
|
|
715
|
+
max_occurs=None,
|
|
716
|
+
required=None,
|
|
717
|
+
):
|
|
718
|
+
if value is not None:
|
|
719
|
+
try:
|
|
720
|
+
validator(value, input_name=input_name)
|
|
721
|
+
except GDSParseError as parse_error:
|
|
722
|
+
self.gds_collector_.add_message(str(parse_error))
|
|
723
|
+
|
|
724
|
+
def gds_validate_defined_ST_(
|
|
725
|
+
self,
|
|
726
|
+
validator,
|
|
727
|
+
value,
|
|
728
|
+
input_name,
|
|
729
|
+
min_occurs=None,
|
|
730
|
+
max_occurs=None,
|
|
731
|
+
required=None,
|
|
732
|
+
):
|
|
733
|
+
if value is not None:
|
|
734
|
+
try:
|
|
735
|
+
validator(value)
|
|
736
|
+
except GDSParseError as parse_error:
|
|
737
|
+
self.gds_collector_.add_message(str(parse_error))
|
|
738
|
+
|
|
739
|
+
def gds_str_lower(self, instring):
|
|
740
|
+
return instring.lower()
|
|
741
|
+
|
|
742
|
+
def get_path_(self, node):
|
|
743
|
+
path_list = []
|
|
744
|
+
self.get_path_list_(node, path_list)
|
|
745
|
+
path_list.reverse()
|
|
746
|
+
path = "/".join(path_list)
|
|
747
|
+
return path
|
|
748
|
+
|
|
749
|
+
Tag_strip_pattern_ = re_.compile(r"\{.*\}")
|
|
750
|
+
|
|
751
|
+
def get_path_list_(self, node, path_list):
|
|
752
|
+
if node is None:
|
|
753
|
+
return
|
|
754
|
+
tag = GeneratedsSuper.Tag_strip_pattern_.sub("", node.tag)
|
|
755
|
+
if tag:
|
|
756
|
+
path_list.append(tag)
|
|
757
|
+
self.get_path_list_(node.getparent(), path_list)
|
|
758
|
+
|
|
759
|
+
def get_class_obj_(self, node, default_class=None):
|
|
760
|
+
class_obj1 = default_class
|
|
761
|
+
if "xsi" in node.nsmap:
|
|
762
|
+
classname = node.get("{%s}type" % node.nsmap["xsi"])
|
|
763
|
+
if classname is not None:
|
|
764
|
+
names = classname.split(":")
|
|
765
|
+
if len(names) == 2:
|
|
766
|
+
classname = names[1]
|
|
767
|
+
class_obj2 = globals().get(classname)
|
|
768
|
+
if class_obj2 is not None:
|
|
769
|
+
class_obj1 = class_obj2
|
|
770
|
+
return class_obj1
|
|
771
|
+
|
|
772
|
+
def gds_build_any(self, node, type_name=None):
|
|
773
|
+
# provide default value in case option --disable-xml is used.
|
|
774
|
+
content = ""
|
|
775
|
+
content = etree_.tostring(node, encoding="unicode")
|
|
776
|
+
return content
|
|
777
|
+
|
|
778
|
+
@classmethod
|
|
779
|
+
def gds_reverse_node_mapping(cls, mapping):
|
|
780
|
+
return dict(((v, k) for k, v in mapping.items()))
|
|
781
|
+
|
|
782
|
+
@staticmethod
|
|
783
|
+
def gds_encode(instring):
|
|
784
|
+
if sys.version_info.major == 2:
|
|
785
|
+
if ExternalEncoding:
|
|
786
|
+
encoding = ExternalEncoding
|
|
787
|
+
else:
|
|
788
|
+
encoding = "utf-8"
|
|
789
|
+
return instring.encode(encoding)
|
|
790
|
+
else:
|
|
791
|
+
return instring
|
|
792
|
+
|
|
793
|
+
@staticmethod
|
|
794
|
+
def convert_unicode(instring):
|
|
795
|
+
if isinstance(instring, str):
|
|
796
|
+
result = quote_xml(instring)
|
|
797
|
+
elif sys.version_info.major == 2 and isinstance(instring, unicode):
|
|
798
|
+
result = quote_xml(instring).encode("utf8")
|
|
799
|
+
else:
|
|
800
|
+
result = GeneratedsSuper.gds_encode(str(instring))
|
|
801
|
+
return result
|
|
802
|
+
|
|
803
|
+
def __eq__(self, other):
|
|
804
|
+
def excl_select_objs_(obj):
|
|
805
|
+
return (
|
|
806
|
+
obj[0] != "parent_object_" and obj[0] != "gds_collector_"
|
|
807
|
+
)
|
|
808
|
+
|
|
809
|
+
if type(self) != type(other):
|
|
810
|
+
return False
|
|
811
|
+
return all(
|
|
812
|
+
x == y
|
|
813
|
+
for x, y in zip_longest(
|
|
814
|
+
filter(excl_select_objs_, self.__dict__.items()),
|
|
815
|
+
filter(excl_select_objs_, other.__dict__.items()),
|
|
816
|
+
)
|
|
817
|
+
)
|
|
818
|
+
|
|
819
|
+
def __ne__(self, other):
|
|
820
|
+
return not self.__eq__(other)
|
|
821
|
+
|
|
822
|
+
# Django ETL transform hooks.
|
|
823
|
+
def gds_djo_etl_transform(self):
|
|
824
|
+
pass
|
|
825
|
+
|
|
826
|
+
def gds_djo_etl_transform_db_obj(self, dbobj):
|
|
827
|
+
pass
|
|
828
|
+
|
|
829
|
+
# SQLAlchemy ETL transform hooks.
|
|
830
|
+
def gds_sqa_etl_transform(self):
|
|
831
|
+
return 0, None
|
|
832
|
+
|
|
833
|
+
def gds_sqa_etl_transform_db_obj(self, dbobj):
|
|
834
|
+
pass
|
|
835
|
+
|
|
836
|
+
def gds_get_node_lineno_(self):
|
|
837
|
+
if (
|
|
838
|
+
hasattr(self, "gds_elementtree_node_")
|
|
839
|
+
and self.gds_elementtree_node_ is not None
|
|
840
|
+
):
|
|
841
|
+
return " near line {}".format(
|
|
842
|
+
self.gds_elementtree_node_.sourceline
|
|
843
|
+
)
|
|
844
|
+
else:
|
|
845
|
+
return ""
|
|
846
|
+
|
|
847
|
+
def getSubclassFromModule_(module, class_):
|
|
848
|
+
"""Get the subclass of a class from a specific module."""
|
|
849
|
+
name = class_.__name__ + "Sub"
|
|
850
|
+
if hasattr(module, name):
|
|
851
|
+
return getattr(module, name)
|
|
852
|
+
else:
|
|
853
|
+
return None
|
|
854
|
+
|
|
855
|
+
|
|
856
|
+
#
|
|
857
|
+
# If you have installed IPython you can uncomment and use the following.
|
|
858
|
+
# IPython is available from http://ipython.scipy.org/.
|
|
859
|
+
#
|
|
860
|
+
|
|
861
|
+
## from IPython.Shell import IPShellEmbed
|
|
862
|
+
## args = ''
|
|
863
|
+
## ipshell = IPShellEmbed(args,
|
|
864
|
+
## banner = 'Dropping into IPython',
|
|
865
|
+
## exit_msg = 'Leaving Interpreter, back to program.')
|
|
866
|
+
|
|
867
|
+
# Then use the following line where and when you want to drop into the
|
|
868
|
+
# IPython shell:
|
|
869
|
+
# ipshell('<some message> -- Entering ipshell.\nHit Ctrl-D to exit')
|
|
870
|
+
|
|
871
|
+
#
|
|
872
|
+
# Globals
|
|
873
|
+
#
|
|
874
|
+
|
|
875
|
+
ExternalEncoding = ""
|
|
876
|
+
# Set this to false in order to deactivate during export, the use of
|
|
877
|
+
# name space prefixes captured from the input document.
|
|
878
|
+
UseCapturedNS_ = True
|
|
879
|
+
CapturedNsmap_ = {}
|
|
880
|
+
Tag_pattern_ = re_.compile(r"({.*})?(.*)")
|
|
881
|
+
String_cleanup_pat_ = re_.compile(r"[\n\r\s]+")
|
|
882
|
+
Namespace_extract_pat_ = re_.compile(r"{(.*)}(.*)")
|
|
883
|
+
CDATA_pattern_ = re_.compile(r"<!\[CDATA\[.*?\]\]>", re_.DOTALL)
|
|
884
|
+
|
|
885
|
+
# Change this to redirect the generated superclass module to use a
|
|
886
|
+
# specific subclass module.
|
|
887
|
+
CurrentSubclassModule_ = None
|
|
888
|
+
|
|
889
|
+
#
|
|
890
|
+
# Support/utility functions.
|
|
891
|
+
#
|
|
892
|
+
|
|
893
|
+
|
|
894
|
+
def showIndent(outfile, level, pretty_print=True):
|
|
895
|
+
if pretty_print:
|
|
896
|
+
for idx in range(level):
|
|
897
|
+
outfile.write(" ")
|
|
898
|
+
|
|
899
|
+
|
|
900
|
+
def quote_xml(inStr):
|
|
901
|
+
"Escape markup chars, but do not modify CDATA sections."
|
|
902
|
+
if not inStr:
|
|
903
|
+
return ""
|
|
904
|
+
s1 = isinstance(inStr, BaseStrType_) and inStr or "%s" % inStr
|
|
905
|
+
s2 = ""
|
|
906
|
+
pos = 0
|
|
907
|
+
matchobjects = CDATA_pattern_.finditer(s1)
|
|
908
|
+
for mo in matchobjects:
|
|
909
|
+
s3 = s1[pos : mo.start()]
|
|
910
|
+
s2 += quote_xml_aux(s3)
|
|
911
|
+
s2 += s1[mo.start() : mo.end()]
|
|
912
|
+
pos = mo.end()
|
|
913
|
+
s3 = s1[pos:]
|
|
914
|
+
s2 += quote_xml_aux(s3)
|
|
915
|
+
return s2
|
|
916
|
+
|
|
917
|
+
|
|
918
|
+
def quote_xml_aux(inStr):
|
|
919
|
+
s1 = inStr.replace("&", "&")
|
|
920
|
+
s1 = s1.replace("<", "<")
|
|
921
|
+
s1 = s1.replace(">", ">")
|
|
922
|
+
return s1
|
|
923
|
+
|
|
924
|
+
|
|
925
|
+
def quote_attrib(inStr):
|
|
926
|
+
s1 = isinstance(inStr, BaseStrType_) and inStr or "%s" % inStr
|
|
927
|
+
s1 = s1.replace("&", "&")
|
|
928
|
+
s1 = s1.replace("<", "<")
|
|
929
|
+
s1 = s1.replace(">", ">")
|
|
930
|
+
s1 = s1.replace("\n", " ")
|
|
931
|
+
if '"' in s1:
|
|
932
|
+
if "'" in s1:
|
|
933
|
+
s1 = '"%s"' % s1.replace('"', """)
|
|
934
|
+
else:
|
|
935
|
+
s1 = "'%s'" % s1
|
|
936
|
+
else:
|
|
937
|
+
s1 = '"%s"' % s1
|
|
938
|
+
return s1
|
|
939
|
+
|
|
940
|
+
|
|
941
|
+
def quote_python(inStr):
|
|
942
|
+
s1 = inStr
|
|
943
|
+
if s1.find("'") == -1:
|
|
944
|
+
if s1.find("\n") == -1:
|
|
945
|
+
return "'%s'" % s1
|
|
946
|
+
else:
|
|
947
|
+
return "'''%s'''" % s1
|
|
948
|
+
else:
|
|
949
|
+
if s1.find('"') != -1:
|
|
950
|
+
s1 = s1.replace('"', '\\"')
|
|
951
|
+
if s1.find("\n") == -1:
|
|
952
|
+
return '"%s"' % s1
|
|
953
|
+
else:
|
|
954
|
+
return '"""%s"""' % s1
|
|
955
|
+
|
|
956
|
+
|
|
957
|
+
def get_all_text_(node):
|
|
958
|
+
if node.text is not None:
|
|
959
|
+
text = node.text
|
|
960
|
+
else:
|
|
961
|
+
text = ""
|
|
962
|
+
for child in node:
|
|
963
|
+
if child.tail is not None:
|
|
964
|
+
text += child.tail
|
|
965
|
+
return text
|
|
966
|
+
|
|
967
|
+
|
|
968
|
+
def find_attr_value_(attr_name, node):
|
|
969
|
+
attrs = node.attrib
|
|
970
|
+
attr_parts = attr_name.split(":")
|
|
971
|
+
value = None
|
|
972
|
+
if len(attr_parts) == 1:
|
|
973
|
+
value = attrs.get(attr_name)
|
|
974
|
+
elif len(attr_parts) == 2:
|
|
975
|
+
prefix, name = attr_parts
|
|
976
|
+
if prefix == "xml":
|
|
977
|
+
namespace = "http://www.w3.org/XML/1998/namespace"
|
|
978
|
+
else:
|
|
979
|
+
namespace = node.nsmap.get(prefix)
|
|
980
|
+
if namespace is not None:
|
|
981
|
+
value = attrs.get(
|
|
982
|
+
"{%s}%s"
|
|
983
|
+
% (
|
|
984
|
+
namespace,
|
|
985
|
+
name,
|
|
986
|
+
)
|
|
987
|
+
)
|
|
988
|
+
return value
|
|
989
|
+
|
|
990
|
+
|
|
991
|
+
def encode_str_2_3(instr):
|
|
992
|
+
return instr
|
|
993
|
+
|
|
994
|
+
|
|
995
|
+
class GDSParseError(Exception):
|
|
996
|
+
pass
|
|
997
|
+
|
|
998
|
+
|
|
999
|
+
def raise_parse_error(node, msg):
|
|
1000
|
+
if node is not None:
|
|
1001
|
+
msg = "%s (element %s/line %d)" % (
|
|
1002
|
+
msg,
|
|
1003
|
+
node.tag,
|
|
1004
|
+
node.sourceline,
|
|
1005
|
+
)
|
|
1006
|
+
raise GDSParseError(msg)
|
|
1007
|
+
|
|
1008
|
+
|
|
1009
|
+
class MixedContainer:
|
|
1010
|
+
# Constants for category:
|
|
1011
|
+
CategoryNone = 0
|
|
1012
|
+
CategoryText = 1
|
|
1013
|
+
CategorySimple = 2
|
|
1014
|
+
CategoryComplex = 3
|
|
1015
|
+
# Constants for content_type:
|
|
1016
|
+
TypeNone = 0
|
|
1017
|
+
TypeText = 1
|
|
1018
|
+
TypeString = 2
|
|
1019
|
+
TypeInteger = 3
|
|
1020
|
+
TypeFloat = 4
|
|
1021
|
+
TypeDecimal = 5
|
|
1022
|
+
TypeDouble = 6
|
|
1023
|
+
TypeBoolean = 7
|
|
1024
|
+
TypeBase64 = 8
|
|
1025
|
+
|
|
1026
|
+
def __init__(self, category, content_type, name, value):
|
|
1027
|
+
self.category = category
|
|
1028
|
+
self.content_type = content_type
|
|
1029
|
+
self.name = name
|
|
1030
|
+
self.value = value
|
|
1031
|
+
|
|
1032
|
+
def getCategory(self):
|
|
1033
|
+
return self.category
|
|
1034
|
+
|
|
1035
|
+
def getContenttype(self, content_type):
|
|
1036
|
+
return self.content_type
|
|
1037
|
+
|
|
1038
|
+
def getValue(self):
|
|
1039
|
+
return self.value
|
|
1040
|
+
|
|
1041
|
+
def getName(self):
|
|
1042
|
+
return self.name
|
|
1043
|
+
|
|
1044
|
+
def export(self, outfile, level, name, namespace, pretty_print=True):
|
|
1045
|
+
if self.category == MixedContainer.CategoryText:
|
|
1046
|
+
# Prevent exporting empty content as empty lines.
|
|
1047
|
+
if self.value.strip():
|
|
1048
|
+
outfile.write(self.value)
|
|
1049
|
+
elif self.category == MixedContainer.CategorySimple:
|
|
1050
|
+
self.exportSimple(outfile, level, name)
|
|
1051
|
+
else: # category == MixedContainer.CategoryComplex
|
|
1052
|
+
self.value.export(
|
|
1053
|
+
outfile,
|
|
1054
|
+
level,
|
|
1055
|
+
namespace,
|
|
1056
|
+
name_=name,
|
|
1057
|
+
pretty_print=pretty_print,
|
|
1058
|
+
)
|
|
1059
|
+
|
|
1060
|
+
def exportSimple(self, outfile, level, name):
|
|
1061
|
+
if self.content_type == MixedContainer.TypeString:
|
|
1062
|
+
outfile.write("<%s>%s</%s>" % (self.name, self.value, self.name))
|
|
1063
|
+
elif (
|
|
1064
|
+
self.content_type == MixedContainer.TypeInteger
|
|
1065
|
+
or self.content_type == MixedContainer.TypeBoolean
|
|
1066
|
+
):
|
|
1067
|
+
outfile.write("<%s>%d</%s>" % (self.name, self.value, self.name))
|
|
1068
|
+
elif (
|
|
1069
|
+
self.content_type == MixedContainer.TypeFloat
|
|
1070
|
+
or self.content_type == MixedContainer.TypeDecimal
|
|
1071
|
+
):
|
|
1072
|
+
outfile.write("<%s>%f</%s>" % (self.name, self.value, self.name))
|
|
1073
|
+
elif self.content_type == MixedContainer.TypeDouble:
|
|
1074
|
+
outfile.write("<%s>%g</%s>" % (self.name, self.value, self.name))
|
|
1075
|
+
elif self.content_type == MixedContainer.TypeBase64:
|
|
1076
|
+
outfile.write(
|
|
1077
|
+
"<%s>%s</%s>"
|
|
1078
|
+
% (self.name, base64.b64encode(self.value), self.name)
|
|
1079
|
+
)
|
|
1080
|
+
|
|
1081
|
+
def to_etree(
|
|
1082
|
+
self, element, mapping_=None, reverse_mapping_=None, nsmap_=None
|
|
1083
|
+
):
|
|
1084
|
+
if self.category == MixedContainer.CategoryText:
|
|
1085
|
+
# Prevent exporting empty content as empty lines.
|
|
1086
|
+
if self.value.strip():
|
|
1087
|
+
if len(element) > 0:
|
|
1088
|
+
if element[-1].tail is None:
|
|
1089
|
+
element[-1].tail = self.value
|
|
1090
|
+
else:
|
|
1091
|
+
element[-1].tail += self.value
|
|
1092
|
+
else:
|
|
1093
|
+
if element.text is None:
|
|
1094
|
+
element.text = self.value
|
|
1095
|
+
else:
|
|
1096
|
+
element.text += self.value
|
|
1097
|
+
elif self.category == MixedContainer.CategorySimple:
|
|
1098
|
+
subelement = etree_.SubElement(element, "%s" % self.name)
|
|
1099
|
+
subelement.text = self.to_etree_simple()
|
|
1100
|
+
else: # category == MixedContainer.CategoryComplex
|
|
1101
|
+
self.value.to_etree(element)
|
|
1102
|
+
|
|
1103
|
+
def to_etree_simple(
|
|
1104
|
+
self, mapping_=None, reverse_mapping_=None, nsmap_=None
|
|
1105
|
+
):
|
|
1106
|
+
if self.content_type == MixedContainer.TypeString:
|
|
1107
|
+
text = self.value
|
|
1108
|
+
elif (
|
|
1109
|
+
self.content_type == MixedContainer.TypeInteger
|
|
1110
|
+
or self.content_type == MixedContainer.TypeBoolean
|
|
1111
|
+
):
|
|
1112
|
+
text = "%d" % self.value
|
|
1113
|
+
elif (
|
|
1114
|
+
self.content_type == MixedContainer.TypeFloat
|
|
1115
|
+
or self.content_type == MixedContainer.TypeDecimal
|
|
1116
|
+
):
|
|
1117
|
+
text = "%f" % self.value
|
|
1118
|
+
elif self.content_type == MixedContainer.TypeDouble:
|
|
1119
|
+
text = "%g" % self.value
|
|
1120
|
+
elif self.content_type == MixedContainer.TypeBase64:
|
|
1121
|
+
text = "%s" % base64.b64encode(self.value)
|
|
1122
|
+
return text
|
|
1123
|
+
|
|
1124
|
+
def exportLiteral(self, outfile, level, name):
|
|
1125
|
+
if self.category == MixedContainer.CategoryText:
|
|
1126
|
+
showIndent(outfile, level)
|
|
1127
|
+
outfile.write(
|
|
1128
|
+
'model_.MixedContainer(%d, %d, "%s", "%s"),\n'
|
|
1129
|
+
% (self.category, self.content_type, self.name, self.value)
|
|
1130
|
+
)
|
|
1131
|
+
elif self.category == MixedContainer.CategorySimple:
|
|
1132
|
+
showIndent(outfile, level)
|
|
1133
|
+
outfile.write(
|
|
1134
|
+
'model_.MixedContainer(%d, %d, "%s", "%s"),\n'
|
|
1135
|
+
% (self.category, self.content_type, self.name, self.value)
|
|
1136
|
+
)
|
|
1137
|
+
else: # category == MixedContainer.CategoryComplex
|
|
1138
|
+
showIndent(outfile, level)
|
|
1139
|
+
outfile.write(
|
|
1140
|
+
'model_.MixedContainer(%d, %d, "%s",\n'
|
|
1141
|
+
% (
|
|
1142
|
+
self.category,
|
|
1143
|
+
self.content_type,
|
|
1144
|
+
self.name,
|
|
1145
|
+
)
|
|
1146
|
+
)
|
|
1147
|
+
self.value.exportLiteral(outfile, level + 1)
|
|
1148
|
+
showIndent(outfile, level)
|
|
1149
|
+
outfile.write(")\n")
|
|
1150
|
+
|
|
1151
|
+
|
|
1152
|
+
class MemberSpec_(object):
|
|
1153
|
+
def __init__(
|
|
1154
|
+
self,
|
|
1155
|
+
name="",
|
|
1156
|
+
data_type="",
|
|
1157
|
+
container=0,
|
|
1158
|
+
optional=0,
|
|
1159
|
+
child_attrs=None,
|
|
1160
|
+
choice=None,
|
|
1161
|
+
):
|
|
1162
|
+
self.name = name
|
|
1163
|
+
self.data_type = data_type
|
|
1164
|
+
self.container = container
|
|
1165
|
+
self.child_attrs = child_attrs
|
|
1166
|
+
self.choice = choice
|
|
1167
|
+
self.optional = optional
|
|
1168
|
+
|
|
1169
|
+
def set_name(self, name):
|
|
1170
|
+
self.name = name
|
|
1171
|
+
|
|
1172
|
+
def get_name(self):
|
|
1173
|
+
return self.name
|
|
1174
|
+
|
|
1175
|
+
def set_data_type(self, data_type):
|
|
1176
|
+
self.data_type = data_type
|
|
1177
|
+
|
|
1178
|
+
def get_data_type_chain(self):
|
|
1179
|
+
return self.data_type
|
|
1180
|
+
|
|
1181
|
+
def get_data_type(self):
|
|
1182
|
+
if isinstance(self.data_type, list):
|
|
1183
|
+
if len(self.data_type) > 0:
|
|
1184
|
+
return self.data_type[-1]
|
|
1185
|
+
else:
|
|
1186
|
+
return "xs:string"
|
|
1187
|
+
else:
|
|
1188
|
+
return self.data_type
|
|
1189
|
+
|
|
1190
|
+
def set_container(self, container):
|
|
1191
|
+
self.container = container
|
|
1192
|
+
|
|
1193
|
+
def get_container(self):
|
|
1194
|
+
return self.container
|
|
1195
|
+
|
|
1196
|
+
def set_child_attrs(self, child_attrs):
|
|
1197
|
+
self.child_attrs = child_attrs
|
|
1198
|
+
|
|
1199
|
+
def get_child_attrs(self):
|
|
1200
|
+
return self.child_attrs
|
|
1201
|
+
|
|
1202
|
+
def set_choice(self, choice):
|
|
1203
|
+
self.choice = choice
|
|
1204
|
+
|
|
1205
|
+
def get_choice(self):
|
|
1206
|
+
return self.choice
|
|
1207
|
+
|
|
1208
|
+
def set_optional(self, optional):
|
|
1209
|
+
self.optional = optional
|
|
1210
|
+
|
|
1211
|
+
def get_optional(self):
|
|
1212
|
+
return self.optional
|
|
1213
|
+
|
|
1214
|
+
|
|
1215
|
+
def _cast(typ, value):
|
|
1216
|
+
if typ is None or value is None:
|
|
1217
|
+
return value
|
|
1218
|
+
return typ(value)
|
|
1219
|
+
|
|
1220
|
+
|
|
1221
|
+
#
|
|
1222
|
+
# Start enum classes
|
|
1223
|
+
#
|
|
1224
|
+
#
|
|
1225
|
+
# Start data representation classes
|
|
1226
|
+
#
|
|
1227
|
+
class root(GeneratedsSuper):
|
|
1228
|
+
__hash__ = GeneratedsSuper.__hash__
|
|
1229
|
+
subclass = None
|
|
1230
|
+
superclass = None
|
|
1231
|
+
|
|
1232
|
+
def __init__(
|
|
1233
|
+
self,
|
|
1234
|
+
specVersion=None,
|
|
1235
|
+
URLBase=None,
|
|
1236
|
+
device=None,
|
|
1237
|
+
gds_collector_=None,
|
|
1238
|
+
**kwargs_
|
|
1239
|
+
):
|
|
1240
|
+
self.gds_collector_ = gds_collector_
|
|
1241
|
+
self.gds_elementtree_node_ = None
|
|
1242
|
+
self.original_tagname_ = None
|
|
1243
|
+
self.parent_object_ = kwargs_.get("parent_object_")
|
|
1244
|
+
self.ns_prefix_ = None
|
|
1245
|
+
self.specVersion = specVersion
|
|
1246
|
+
self.specVersion_nsprefix_ = None
|
|
1247
|
+
self.URLBase = URLBase
|
|
1248
|
+
self.URLBase_nsprefix_ = None
|
|
1249
|
+
self.device = device
|
|
1250
|
+
self.device_nsprefix_ = None
|
|
1251
|
+
self.anyAttributes_ = {}
|
|
1252
|
+
|
|
1253
|
+
def factory(*args_, **kwargs_):
|
|
1254
|
+
if CurrentSubclassModule_ is not None:
|
|
1255
|
+
subclass = getSubclassFromModule_(CurrentSubclassModule_, root)
|
|
1256
|
+
if subclass is not None:
|
|
1257
|
+
return subclass(*args_, **kwargs_)
|
|
1258
|
+
if root.subclass:
|
|
1259
|
+
return root.subclass(*args_, **kwargs_)
|
|
1260
|
+
else:
|
|
1261
|
+
return root(*args_, **kwargs_)
|
|
1262
|
+
|
|
1263
|
+
factory = staticmethod(factory)
|
|
1264
|
+
|
|
1265
|
+
def get_ns_prefix_(self):
|
|
1266
|
+
return self.ns_prefix_
|
|
1267
|
+
|
|
1268
|
+
def set_ns_prefix_(self, ns_prefix):
|
|
1269
|
+
self.ns_prefix_ = ns_prefix
|
|
1270
|
+
|
|
1271
|
+
def get_specVersion(self):
|
|
1272
|
+
return self.specVersion
|
|
1273
|
+
|
|
1274
|
+
def set_specVersion(self, specVersion):
|
|
1275
|
+
self.specVersion = specVersion
|
|
1276
|
+
|
|
1277
|
+
def get_URLBase(self):
|
|
1278
|
+
return self.URLBase
|
|
1279
|
+
|
|
1280
|
+
def set_URLBase(self, URLBase):
|
|
1281
|
+
self.URLBase = URLBase
|
|
1282
|
+
|
|
1283
|
+
def get_device(self):
|
|
1284
|
+
return self.device
|
|
1285
|
+
|
|
1286
|
+
def set_device(self, device):
|
|
1287
|
+
self.device = device
|
|
1288
|
+
|
|
1289
|
+
def get_anyAttributes_(self):
|
|
1290
|
+
return self.anyAttributes_
|
|
1291
|
+
|
|
1292
|
+
def set_anyAttributes_(self, anyAttributes_):
|
|
1293
|
+
self.anyAttributes_ = anyAttributes_
|
|
1294
|
+
|
|
1295
|
+
def has__content(self):
|
|
1296
|
+
if (
|
|
1297
|
+
self.specVersion is not None
|
|
1298
|
+
or self.URLBase is not None
|
|
1299
|
+
or self.device is not None
|
|
1300
|
+
):
|
|
1301
|
+
return True
|
|
1302
|
+
else:
|
|
1303
|
+
return False
|
|
1304
|
+
|
|
1305
|
+
def export(
|
|
1306
|
+
self,
|
|
1307
|
+
outfile,
|
|
1308
|
+
level,
|
|
1309
|
+
namespaceprefix_="",
|
|
1310
|
+
namespacedef_='xmlns:tns="urn:schemas-upnp-org:device-1-0" xmlns:None="urn:schemas-upnp-org:device-1-0" ',
|
|
1311
|
+
name_="root",
|
|
1312
|
+
pretty_print=True,
|
|
1313
|
+
):
|
|
1314
|
+
imported_ns_def_ = GenerateDSNamespaceDefs_.get("root")
|
|
1315
|
+
if imported_ns_def_ is not None:
|
|
1316
|
+
namespacedef_ = imported_ns_def_
|
|
1317
|
+
if pretty_print:
|
|
1318
|
+
eol_ = "\n"
|
|
1319
|
+
else:
|
|
1320
|
+
eol_ = ""
|
|
1321
|
+
if self.original_tagname_ is not None and name_ == "root":
|
|
1322
|
+
name_ = self.original_tagname_
|
|
1323
|
+
if UseCapturedNS_ and self.ns_prefix_:
|
|
1324
|
+
namespaceprefix_ = self.ns_prefix_ + ":"
|
|
1325
|
+
showIndent(outfile, level, pretty_print)
|
|
1326
|
+
outfile.write(
|
|
1327
|
+
"<%s%s%s"
|
|
1328
|
+
% (
|
|
1329
|
+
namespaceprefix_,
|
|
1330
|
+
name_,
|
|
1331
|
+
namespacedef_ and " " + namespacedef_ or "",
|
|
1332
|
+
)
|
|
1333
|
+
)
|
|
1334
|
+
already_processed = set()
|
|
1335
|
+
self._exportAttributes(
|
|
1336
|
+
outfile, level, already_processed, namespaceprefix_, name_="root"
|
|
1337
|
+
)
|
|
1338
|
+
if self.has__content():
|
|
1339
|
+
outfile.write(">%s" % (eol_,))
|
|
1340
|
+
self._exportChildren(
|
|
1341
|
+
outfile,
|
|
1342
|
+
level + 1,
|
|
1343
|
+
namespaceprefix_,
|
|
1344
|
+
namespacedef_,
|
|
1345
|
+
name_="root",
|
|
1346
|
+
pretty_print=pretty_print,
|
|
1347
|
+
)
|
|
1348
|
+
showIndent(outfile, level, pretty_print)
|
|
1349
|
+
outfile.write("</%s%s>%s" % (namespaceprefix_, name_, eol_))
|
|
1350
|
+
else:
|
|
1351
|
+
outfile.write("/>%s" % (eol_,))
|
|
1352
|
+
|
|
1353
|
+
def _exportAttributes(
|
|
1354
|
+
self,
|
|
1355
|
+
outfile,
|
|
1356
|
+
level,
|
|
1357
|
+
already_processed,
|
|
1358
|
+
namespaceprefix_="",
|
|
1359
|
+
name_="root",
|
|
1360
|
+
):
|
|
1361
|
+
unique_counter = 0
|
|
1362
|
+
for name, value in self.anyAttributes_.items():
|
|
1363
|
+
xsinamespaceprefix = "xsi"
|
|
1364
|
+
xsinamespace1 = "http://www.w3.org/2001/XMLSchema-instance"
|
|
1365
|
+
xsinamespace2 = "{%s}" % (xsinamespace1,)
|
|
1366
|
+
if name.startswith(xsinamespace2):
|
|
1367
|
+
name1 = name[len(xsinamespace2) :]
|
|
1368
|
+
name2 = "%s:%s" % (
|
|
1369
|
+
xsinamespaceprefix,
|
|
1370
|
+
name1,
|
|
1371
|
+
)
|
|
1372
|
+
if name2 not in already_processed:
|
|
1373
|
+
already_processed.add(name2)
|
|
1374
|
+
outfile.write(
|
|
1375
|
+
" %s=%s"
|
|
1376
|
+
% (
|
|
1377
|
+
name2,
|
|
1378
|
+
quote_attrib(value),
|
|
1379
|
+
)
|
|
1380
|
+
)
|
|
1381
|
+
else:
|
|
1382
|
+
mo = re_.match(Namespace_extract_pat_, name)
|
|
1383
|
+
if mo is not None:
|
|
1384
|
+
namespace, name = mo.group(1, 2)
|
|
1385
|
+
if name not in already_processed:
|
|
1386
|
+
already_processed.add(name)
|
|
1387
|
+
if namespace == "http://www.w3.org/XML/1998/namespace":
|
|
1388
|
+
outfile.write(
|
|
1389
|
+
" %s=%s"
|
|
1390
|
+
% (
|
|
1391
|
+
name,
|
|
1392
|
+
quote_attrib(value),
|
|
1393
|
+
)
|
|
1394
|
+
)
|
|
1395
|
+
else:
|
|
1396
|
+
unique_counter += 1
|
|
1397
|
+
outfile.write(
|
|
1398
|
+
' xmlns:%d="%s"'
|
|
1399
|
+
% (
|
|
1400
|
+
unique_counter,
|
|
1401
|
+
namespace,
|
|
1402
|
+
)
|
|
1403
|
+
)
|
|
1404
|
+
outfile.write(
|
|
1405
|
+
" %d:%s=%s"
|
|
1406
|
+
% (
|
|
1407
|
+
unique_counter,
|
|
1408
|
+
name,
|
|
1409
|
+
quote_attrib(value),
|
|
1410
|
+
)
|
|
1411
|
+
)
|
|
1412
|
+
else:
|
|
1413
|
+
if name not in already_processed:
|
|
1414
|
+
already_processed.add(name)
|
|
1415
|
+
outfile.write(
|
|
1416
|
+
" %s=%s"
|
|
1417
|
+
% (
|
|
1418
|
+
name,
|
|
1419
|
+
quote_attrib(value),
|
|
1420
|
+
)
|
|
1421
|
+
)
|
|
1422
|
+
pass
|
|
1423
|
+
|
|
1424
|
+
def _exportChildren(
|
|
1425
|
+
self,
|
|
1426
|
+
outfile,
|
|
1427
|
+
level,
|
|
1428
|
+
namespaceprefix_="",
|
|
1429
|
+
namespacedef_='xmlns:tns="urn:schemas-upnp-org:device-1-0" xmlns:None="urn:schemas-upnp-org:device-1-0" ',
|
|
1430
|
+
name_="root",
|
|
1431
|
+
fromsubclass_=False,
|
|
1432
|
+
pretty_print=True,
|
|
1433
|
+
):
|
|
1434
|
+
if pretty_print:
|
|
1435
|
+
eol_ = "\n"
|
|
1436
|
+
else:
|
|
1437
|
+
eol_ = ""
|
|
1438
|
+
if self.specVersion is not None:
|
|
1439
|
+
namespaceprefix_ = (
|
|
1440
|
+
self.specVersion_nsprefix_ + ":"
|
|
1441
|
+
if (UseCapturedNS_ and self.specVersion_nsprefix_)
|
|
1442
|
+
else ""
|
|
1443
|
+
)
|
|
1444
|
+
self.specVersion.export(
|
|
1445
|
+
outfile,
|
|
1446
|
+
level,
|
|
1447
|
+
namespaceprefix_,
|
|
1448
|
+
namespacedef_="",
|
|
1449
|
+
name_="specVersion",
|
|
1450
|
+
pretty_print=pretty_print,
|
|
1451
|
+
)
|
|
1452
|
+
if self.URLBase is not None:
|
|
1453
|
+
namespaceprefix_ = (
|
|
1454
|
+
self.URLBase_nsprefix_ + ":"
|
|
1455
|
+
if (UseCapturedNS_ and self.URLBase_nsprefix_)
|
|
1456
|
+
else ""
|
|
1457
|
+
)
|
|
1458
|
+
showIndent(outfile, level, pretty_print)
|
|
1459
|
+
outfile.write(
|
|
1460
|
+
"<%sURLBase>%s</%sURLBase>%s"
|
|
1461
|
+
% (
|
|
1462
|
+
namespaceprefix_,
|
|
1463
|
+
self.gds_encode(
|
|
1464
|
+
self.gds_format_string(
|
|
1465
|
+
quote_xml(self.URLBase), input_name="URLBase"
|
|
1466
|
+
)
|
|
1467
|
+
),
|
|
1468
|
+
namespaceprefix_,
|
|
1469
|
+
eol_,
|
|
1470
|
+
)
|
|
1471
|
+
)
|
|
1472
|
+
if self.device is not None:
|
|
1473
|
+
namespaceprefix_ = (
|
|
1474
|
+
self.device_nsprefix_ + ":"
|
|
1475
|
+
if (UseCapturedNS_ and self.device_nsprefix_)
|
|
1476
|
+
else ""
|
|
1477
|
+
)
|
|
1478
|
+
self.device.export(
|
|
1479
|
+
outfile,
|
|
1480
|
+
level,
|
|
1481
|
+
namespaceprefix_,
|
|
1482
|
+
namespacedef_="",
|
|
1483
|
+
name_="device",
|
|
1484
|
+
pretty_print=pretty_print,
|
|
1485
|
+
)
|
|
1486
|
+
|
|
1487
|
+
def build(self, node, gds_collector_=None):
|
|
1488
|
+
self.gds_collector_ = gds_collector_
|
|
1489
|
+
if SaveElementTreeNode:
|
|
1490
|
+
self.gds_elementtree_node_ = node
|
|
1491
|
+
already_processed = set()
|
|
1492
|
+
self.ns_prefix_ = node.prefix
|
|
1493
|
+
self._buildAttributes(node, node.attrib, already_processed)
|
|
1494
|
+
for child in node:
|
|
1495
|
+
nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
|
|
1496
|
+
self._buildChildren(
|
|
1497
|
+
child, node, nodeName_, gds_collector_=gds_collector_
|
|
1498
|
+
)
|
|
1499
|
+
return self
|
|
1500
|
+
|
|
1501
|
+
def _buildAttributes(self, node, attrs, already_processed):
|
|
1502
|
+
self.anyAttributes_ = {}
|
|
1503
|
+
for name, value in attrs.items():
|
|
1504
|
+
if name not in already_processed:
|
|
1505
|
+
self.anyAttributes_[name] = value
|
|
1506
|
+
|
|
1507
|
+
def _buildChildren(
|
|
1508
|
+
self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None
|
|
1509
|
+
):
|
|
1510
|
+
if nodeName_ == "specVersion":
|
|
1511
|
+
obj_ = SpecVersionType.factory(parent_object_=self)
|
|
1512
|
+
obj_.build(child_, gds_collector_=gds_collector_)
|
|
1513
|
+
self.specVersion = obj_
|
|
1514
|
+
obj_.original_tagname_ = "specVersion"
|
|
1515
|
+
elif nodeName_ == "URLBase":
|
|
1516
|
+
value_ = child_.text
|
|
1517
|
+
value_ = self.gds_parse_string(value_, node, "URLBase")
|
|
1518
|
+
value_ = self.gds_validate_string(value_, node, "URLBase")
|
|
1519
|
+
self.URLBase = value_
|
|
1520
|
+
self.URLBase_nsprefix_ = child_.prefix
|
|
1521
|
+
elif nodeName_ == "device":
|
|
1522
|
+
obj_ = DeviceType.factory(parent_object_=self)
|
|
1523
|
+
obj_.build(child_, gds_collector_=gds_collector_)
|
|
1524
|
+
self.device = obj_
|
|
1525
|
+
obj_.original_tagname_ = "device"
|
|
1526
|
+
|
|
1527
|
+
|
|
1528
|
+
# end class root
|
|
1529
|
+
|
|
1530
|
+
|
|
1531
|
+
class SpecVersionType(GeneratedsSuper):
|
|
1532
|
+
__hash__ = GeneratedsSuper.__hash__
|
|
1533
|
+
subclass = None
|
|
1534
|
+
superclass = None
|
|
1535
|
+
|
|
1536
|
+
def __init__(self, major=None, minor=None, gds_collector_=None, **kwargs_):
|
|
1537
|
+
self.gds_collector_ = gds_collector_
|
|
1538
|
+
self.gds_elementtree_node_ = None
|
|
1539
|
+
self.original_tagname_ = None
|
|
1540
|
+
self.parent_object_ = kwargs_.get("parent_object_")
|
|
1541
|
+
self.ns_prefix_ = None
|
|
1542
|
+
self.major = major
|
|
1543
|
+
self.major_nsprefix_ = None
|
|
1544
|
+
self.minor = minor
|
|
1545
|
+
self.minor_nsprefix_ = None
|
|
1546
|
+
|
|
1547
|
+
def factory(*args_, **kwargs_):
|
|
1548
|
+
if CurrentSubclassModule_ is not None:
|
|
1549
|
+
subclass = getSubclassFromModule_(
|
|
1550
|
+
CurrentSubclassModule_, SpecVersionType
|
|
1551
|
+
)
|
|
1552
|
+
if subclass is not None:
|
|
1553
|
+
return subclass(*args_, **kwargs_)
|
|
1554
|
+
if SpecVersionType.subclass:
|
|
1555
|
+
return SpecVersionType.subclass(*args_, **kwargs_)
|
|
1556
|
+
else:
|
|
1557
|
+
return SpecVersionType(*args_, **kwargs_)
|
|
1558
|
+
|
|
1559
|
+
factory = staticmethod(factory)
|
|
1560
|
+
|
|
1561
|
+
def get_ns_prefix_(self):
|
|
1562
|
+
return self.ns_prefix_
|
|
1563
|
+
|
|
1564
|
+
def set_ns_prefix_(self, ns_prefix):
|
|
1565
|
+
self.ns_prefix_ = ns_prefix
|
|
1566
|
+
|
|
1567
|
+
def get_major(self):
|
|
1568
|
+
return self.major
|
|
1569
|
+
|
|
1570
|
+
def set_major(self, major):
|
|
1571
|
+
self.major = major
|
|
1572
|
+
|
|
1573
|
+
def get_minor(self):
|
|
1574
|
+
return self.minor
|
|
1575
|
+
|
|
1576
|
+
def set_minor(self, minor):
|
|
1577
|
+
self.minor = minor
|
|
1578
|
+
|
|
1579
|
+
def has__content(self):
|
|
1580
|
+
if self.major is not None or self.minor is not None:
|
|
1581
|
+
return True
|
|
1582
|
+
else:
|
|
1583
|
+
return False
|
|
1584
|
+
|
|
1585
|
+
def export(
|
|
1586
|
+
self,
|
|
1587
|
+
outfile,
|
|
1588
|
+
level,
|
|
1589
|
+
namespaceprefix_="",
|
|
1590
|
+
namespacedef_='xmlns:tns="urn:schemas-upnp-org:device-1-0" xmlns:None="urn:schemas-upnp-org:device-1-0" ',
|
|
1591
|
+
name_="SpecVersionType",
|
|
1592
|
+
pretty_print=True,
|
|
1593
|
+
):
|
|
1594
|
+
imported_ns_def_ = GenerateDSNamespaceDefs_.get("SpecVersionType")
|
|
1595
|
+
if imported_ns_def_ is not None:
|
|
1596
|
+
namespacedef_ = imported_ns_def_
|
|
1597
|
+
if pretty_print:
|
|
1598
|
+
eol_ = "\n"
|
|
1599
|
+
else:
|
|
1600
|
+
eol_ = ""
|
|
1601
|
+
if self.original_tagname_ is not None and name_ == "SpecVersionType":
|
|
1602
|
+
name_ = self.original_tagname_
|
|
1603
|
+
if UseCapturedNS_ and self.ns_prefix_:
|
|
1604
|
+
namespaceprefix_ = self.ns_prefix_ + ":"
|
|
1605
|
+
showIndent(outfile, level, pretty_print)
|
|
1606
|
+
outfile.write(
|
|
1607
|
+
"<%s%s%s"
|
|
1608
|
+
% (
|
|
1609
|
+
namespaceprefix_,
|
|
1610
|
+
name_,
|
|
1611
|
+
namespacedef_ and " " + namespacedef_ or "",
|
|
1612
|
+
)
|
|
1613
|
+
)
|
|
1614
|
+
already_processed = set()
|
|
1615
|
+
self._exportAttributes(
|
|
1616
|
+
outfile,
|
|
1617
|
+
level,
|
|
1618
|
+
already_processed,
|
|
1619
|
+
namespaceprefix_,
|
|
1620
|
+
name_="SpecVersionType",
|
|
1621
|
+
)
|
|
1622
|
+
if self.has__content():
|
|
1623
|
+
outfile.write(">%s" % (eol_,))
|
|
1624
|
+
self._exportChildren(
|
|
1625
|
+
outfile,
|
|
1626
|
+
level + 1,
|
|
1627
|
+
namespaceprefix_,
|
|
1628
|
+
namespacedef_,
|
|
1629
|
+
name_="SpecVersionType",
|
|
1630
|
+
pretty_print=pretty_print,
|
|
1631
|
+
)
|
|
1632
|
+
showIndent(outfile, level, pretty_print)
|
|
1633
|
+
outfile.write("</%s%s>%s" % (namespaceprefix_, name_, eol_))
|
|
1634
|
+
else:
|
|
1635
|
+
outfile.write("/>%s" % (eol_,))
|
|
1636
|
+
|
|
1637
|
+
def _exportAttributes(
|
|
1638
|
+
self,
|
|
1639
|
+
outfile,
|
|
1640
|
+
level,
|
|
1641
|
+
already_processed,
|
|
1642
|
+
namespaceprefix_="",
|
|
1643
|
+
name_="SpecVersionType",
|
|
1644
|
+
):
|
|
1645
|
+
pass
|
|
1646
|
+
|
|
1647
|
+
def _exportChildren(
|
|
1648
|
+
self,
|
|
1649
|
+
outfile,
|
|
1650
|
+
level,
|
|
1651
|
+
namespaceprefix_="",
|
|
1652
|
+
namespacedef_='xmlns:tns="urn:schemas-upnp-org:device-1-0" xmlns:None="urn:schemas-upnp-org:device-1-0" ',
|
|
1653
|
+
name_="SpecVersionType",
|
|
1654
|
+
fromsubclass_=False,
|
|
1655
|
+
pretty_print=True,
|
|
1656
|
+
):
|
|
1657
|
+
if pretty_print:
|
|
1658
|
+
eol_ = "\n"
|
|
1659
|
+
else:
|
|
1660
|
+
eol_ = ""
|
|
1661
|
+
if self.major is not None:
|
|
1662
|
+
namespaceprefix_ = (
|
|
1663
|
+
self.major_nsprefix_ + ":"
|
|
1664
|
+
if (UseCapturedNS_ and self.major_nsprefix_)
|
|
1665
|
+
else ""
|
|
1666
|
+
)
|
|
1667
|
+
showIndent(outfile, level, pretty_print)
|
|
1668
|
+
outfile.write(
|
|
1669
|
+
"<%smajor>%s</%smajor>%s"
|
|
1670
|
+
% (
|
|
1671
|
+
namespaceprefix_,
|
|
1672
|
+
self.gds_format_integer(self.major, input_name="major"),
|
|
1673
|
+
namespaceprefix_,
|
|
1674
|
+
eol_,
|
|
1675
|
+
)
|
|
1676
|
+
)
|
|
1677
|
+
if self.minor is not None:
|
|
1678
|
+
namespaceprefix_ = (
|
|
1679
|
+
self.minor_nsprefix_ + ":"
|
|
1680
|
+
if (UseCapturedNS_ and self.minor_nsprefix_)
|
|
1681
|
+
else ""
|
|
1682
|
+
)
|
|
1683
|
+
showIndent(outfile, level, pretty_print)
|
|
1684
|
+
outfile.write(
|
|
1685
|
+
"<%sminor>%s</%sminor>%s"
|
|
1686
|
+
% (
|
|
1687
|
+
namespaceprefix_,
|
|
1688
|
+
self.gds_format_integer(self.minor, input_name="minor"),
|
|
1689
|
+
namespaceprefix_,
|
|
1690
|
+
eol_,
|
|
1691
|
+
)
|
|
1692
|
+
)
|
|
1693
|
+
|
|
1694
|
+
def build(self, node, gds_collector_=None):
|
|
1695
|
+
self.gds_collector_ = gds_collector_
|
|
1696
|
+
if SaveElementTreeNode:
|
|
1697
|
+
self.gds_elementtree_node_ = node
|
|
1698
|
+
already_processed = set()
|
|
1699
|
+
self.ns_prefix_ = node.prefix
|
|
1700
|
+
self._buildAttributes(node, node.attrib, already_processed)
|
|
1701
|
+
for child in node:
|
|
1702
|
+
nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
|
|
1703
|
+
self._buildChildren(
|
|
1704
|
+
child, node, nodeName_, gds_collector_=gds_collector_
|
|
1705
|
+
)
|
|
1706
|
+
return self
|
|
1707
|
+
|
|
1708
|
+
def _buildAttributes(self, node, attrs, already_processed):
|
|
1709
|
+
pass
|
|
1710
|
+
|
|
1711
|
+
def _buildChildren(
|
|
1712
|
+
self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None
|
|
1713
|
+
):
|
|
1714
|
+
if nodeName_ == "major" and child_.text:
|
|
1715
|
+
sval_ = child_.text
|
|
1716
|
+
ival_ = self.gds_parse_integer(sval_, node, "major")
|
|
1717
|
+
ival_ = self.gds_validate_integer(ival_, node, "major")
|
|
1718
|
+
self.major = ival_
|
|
1719
|
+
self.major_nsprefix_ = child_.prefix
|
|
1720
|
+
elif nodeName_ == "minor" and child_.text:
|
|
1721
|
+
sval_ = child_.text
|
|
1722
|
+
ival_ = self.gds_parse_integer(sval_, node, "minor")
|
|
1723
|
+
ival_ = self.gds_validate_integer(ival_, node, "minor")
|
|
1724
|
+
self.minor = ival_
|
|
1725
|
+
self.minor_nsprefix_ = child_.prefix
|
|
1726
|
+
|
|
1727
|
+
|
|
1728
|
+
# end class SpecVersionType
|
|
1729
|
+
|
|
1730
|
+
|
|
1731
|
+
class DeviceType(GeneratedsSuper):
|
|
1732
|
+
__hash__ = GeneratedsSuper.__hash__
|
|
1733
|
+
subclass = None
|
|
1734
|
+
superclass = None
|
|
1735
|
+
|
|
1736
|
+
def __init__(
|
|
1737
|
+
self,
|
|
1738
|
+
deviceType=None,
|
|
1739
|
+
friendlyName=None,
|
|
1740
|
+
manufacturer=None,
|
|
1741
|
+
manufacturerURL=None,
|
|
1742
|
+
modelDescription=None,
|
|
1743
|
+
modelName=None,
|
|
1744
|
+
modelNumber=None,
|
|
1745
|
+
modelURL=None,
|
|
1746
|
+
serialNumber=None,
|
|
1747
|
+
UDN=None,
|
|
1748
|
+
macAddress=None,
|
|
1749
|
+
UPC=None,
|
|
1750
|
+
iconList=None,
|
|
1751
|
+
serviceList=None,
|
|
1752
|
+
deviceList=None,
|
|
1753
|
+
presentationURL=None,
|
|
1754
|
+
anytypeobjs_=None,
|
|
1755
|
+
gds_collector_=None,
|
|
1756
|
+
**kwargs_
|
|
1757
|
+
):
|
|
1758
|
+
self.gds_collector_ = gds_collector_
|
|
1759
|
+
self.gds_elementtree_node_ = None
|
|
1760
|
+
self.original_tagname_ = None
|
|
1761
|
+
self.parent_object_ = kwargs_.get("parent_object_")
|
|
1762
|
+
self.ns_prefix_ = None
|
|
1763
|
+
self.deviceType = deviceType
|
|
1764
|
+
self.deviceType_nsprefix_ = None
|
|
1765
|
+
self.friendlyName = friendlyName
|
|
1766
|
+
self.friendlyName_nsprefix_ = None
|
|
1767
|
+
self.manufacturer = manufacturer
|
|
1768
|
+
self.manufacturer_nsprefix_ = None
|
|
1769
|
+
self.manufacturerURL = manufacturerURL
|
|
1770
|
+
self.manufacturerURL_nsprefix_ = None
|
|
1771
|
+
self.modelDescription = modelDescription
|
|
1772
|
+
self.modelDescription_nsprefix_ = None
|
|
1773
|
+
self.modelName = modelName
|
|
1774
|
+
self.modelName_nsprefix_ = None
|
|
1775
|
+
self.modelNumber = modelNumber
|
|
1776
|
+
self.modelNumber_nsprefix_ = None
|
|
1777
|
+
self.modelURL = modelURL
|
|
1778
|
+
self.modelURL_nsprefix_ = None
|
|
1779
|
+
self.serialNumber = serialNumber
|
|
1780
|
+
self.serialNumber_nsprefix_ = None
|
|
1781
|
+
self.UDN = UDN
|
|
1782
|
+
self.UDN_nsprefix_ = None
|
|
1783
|
+
self.macAddress = macAddress
|
|
1784
|
+
self.macAddress_nsprefix_ = None
|
|
1785
|
+
self.UPC = UPC
|
|
1786
|
+
self.UPC_nsprefix_ = None
|
|
1787
|
+
self.iconList = iconList
|
|
1788
|
+
self.iconList_nsprefix_ = None
|
|
1789
|
+
self.serviceList = serviceList
|
|
1790
|
+
self.serviceList_nsprefix_ = None
|
|
1791
|
+
self.deviceList = deviceList
|
|
1792
|
+
self.deviceList_nsprefix_ = None
|
|
1793
|
+
self.presentationURL = presentationURL
|
|
1794
|
+
self.presentationURL_nsprefix_ = None
|
|
1795
|
+
if anytypeobjs_ is None:
|
|
1796
|
+
self.anytypeobjs_ = []
|
|
1797
|
+
else:
|
|
1798
|
+
self.anytypeobjs_ = anytypeobjs_
|
|
1799
|
+
|
|
1800
|
+
def factory(*args_, **kwargs_):
|
|
1801
|
+
if CurrentSubclassModule_ is not None:
|
|
1802
|
+
subclass = getSubclassFromModule_(
|
|
1803
|
+
CurrentSubclassModule_, DeviceType
|
|
1804
|
+
)
|
|
1805
|
+
if subclass is not None:
|
|
1806
|
+
return subclass(*args_, **kwargs_)
|
|
1807
|
+
if DeviceType.subclass:
|
|
1808
|
+
return DeviceType.subclass(*args_, **kwargs_)
|
|
1809
|
+
else:
|
|
1810
|
+
return DeviceType(*args_, **kwargs_)
|
|
1811
|
+
|
|
1812
|
+
factory = staticmethod(factory)
|
|
1813
|
+
|
|
1814
|
+
def get_ns_prefix_(self):
|
|
1815
|
+
return self.ns_prefix_
|
|
1816
|
+
|
|
1817
|
+
def set_ns_prefix_(self, ns_prefix):
|
|
1818
|
+
self.ns_prefix_ = ns_prefix
|
|
1819
|
+
|
|
1820
|
+
def get_deviceType(self):
|
|
1821
|
+
return self.deviceType
|
|
1822
|
+
|
|
1823
|
+
def set_deviceType(self, deviceType):
|
|
1824
|
+
self.deviceType = deviceType
|
|
1825
|
+
|
|
1826
|
+
def get_friendlyName(self):
|
|
1827
|
+
return self.friendlyName
|
|
1828
|
+
|
|
1829
|
+
def set_friendlyName(self, friendlyName):
|
|
1830
|
+
self.friendlyName = friendlyName
|
|
1831
|
+
|
|
1832
|
+
def get_manufacturer(self):
|
|
1833
|
+
return self.manufacturer
|
|
1834
|
+
|
|
1835
|
+
def set_manufacturer(self, manufacturer):
|
|
1836
|
+
self.manufacturer = manufacturer
|
|
1837
|
+
|
|
1838
|
+
def get_manufacturerURL(self):
|
|
1839
|
+
return self.manufacturerURL
|
|
1840
|
+
|
|
1841
|
+
def set_manufacturerURL(self, manufacturerURL):
|
|
1842
|
+
self.manufacturerURL = manufacturerURL
|
|
1843
|
+
|
|
1844
|
+
def get_modelDescription(self):
|
|
1845
|
+
return self.modelDescription
|
|
1846
|
+
|
|
1847
|
+
def set_modelDescription(self, modelDescription):
|
|
1848
|
+
self.modelDescription = modelDescription
|
|
1849
|
+
|
|
1850
|
+
def get_modelName(self):
|
|
1851
|
+
return self.modelName
|
|
1852
|
+
|
|
1853
|
+
def set_modelName(self, modelName):
|
|
1854
|
+
self.modelName = modelName
|
|
1855
|
+
|
|
1856
|
+
def get_modelNumber(self):
|
|
1857
|
+
return self.modelNumber
|
|
1858
|
+
|
|
1859
|
+
def set_modelNumber(self, modelNumber):
|
|
1860
|
+
self.modelNumber = modelNumber
|
|
1861
|
+
|
|
1862
|
+
def get_modelURL(self):
|
|
1863
|
+
return self.modelURL
|
|
1864
|
+
|
|
1865
|
+
def set_modelURL(self, modelURL):
|
|
1866
|
+
self.modelURL = modelURL
|
|
1867
|
+
|
|
1868
|
+
def get_serialNumber(self):
|
|
1869
|
+
return self.serialNumber
|
|
1870
|
+
|
|
1871
|
+
def set_serialNumber(self, serialNumber):
|
|
1872
|
+
self.serialNumber = serialNumber
|
|
1873
|
+
|
|
1874
|
+
def get_UDN(self):
|
|
1875
|
+
return self.UDN
|
|
1876
|
+
|
|
1877
|
+
def set_UDN(self, UDN):
|
|
1878
|
+
self.UDN = UDN
|
|
1879
|
+
|
|
1880
|
+
def get_macAddress(self):
|
|
1881
|
+
return self.macAddress
|
|
1882
|
+
|
|
1883
|
+
def set_macAddress(self, macAddress):
|
|
1884
|
+
self.macAddress = macAddress
|
|
1885
|
+
|
|
1886
|
+
def get_UPC(self):
|
|
1887
|
+
return self.UPC
|
|
1888
|
+
|
|
1889
|
+
def set_UPC(self, UPC):
|
|
1890
|
+
self.UPC = UPC
|
|
1891
|
+
|
|
1892
|
+
def get_iconList(self):
|
|
1893
|
+
return self.iconList
|
|
1894
|
+
|
|
1895
|
+
def set_iconList(self, iconList):
|
|
1896
|
+
self.iconList = iconList
|
|
1897
|
+
|
|
1898
|
+
def get_serviceList(self):
|
|
1899
|
+
return self.serviceList
|
|
1900
|
+
|
|
1901
|
+
def set_serviceList(self, serviceList):
|
|
1902
|
+
self.serviceList = serviceList
|
|
1903
|
+
|
|
1904
|
+
def get_deviceList(self):
|
|
1905
|
+
return self.deviceList
|
|
1906
|
+
|
|
1907
|
+
def set_deviceList(self, deviceList):
|
|
1908
|
+
self.deviceList = deviceList
|
|
1909
|
+
|
|
1910
|
+
def get_presentationURL(self):
|
|
1911
|
+
return self.presentationURL
|
|
1912
|
+
|
|
1913
|
+
def set_presentationURL(self, presentationURL):
|
|
1914
|
+
self.presentationURL = presentationURL
|
|
1915
|
+
|
|
1916
|
+
def get_anytypeobjs_(self):
|
|
1917
|
+
return self.anytypeobjs_
|
|
1918
|
+
|
|
1919
|
+
def set_anytypeobjs_(self, anytypeobjs_):
|
|
1920
|
+
self.anytypeobjs_ = anytypeobjs_
|
|
1921
|
+
|
|
1922
|
+
def add_anytypeobjs_(self, value):
|
|
1923
|
+
self.anytypeobjs_.append(value)
|
|
1924
|
+
|
|
1925
|
+
def insert_anytypeobjs_(self, index, value):
|
|
1926
|
+
self._anytypeobjs_[index] = value
|
|
1927
|
+
|
|
1928
|
+
def has__content(self):
|
|
1929
|
+
if (
|
|
1930
|
+
self.deviceType is not None
|
|
1931
|
+
or self.friendlyName is not None
|
|
1932
|
+
or self.manufacturer is not None
|
|
1933
|
+
or self.manufacturerURL is not None
|
|
1934
|
+
or self.modelDescription is not None
|
|
1935
|
+
or self.modelName is not None
|
|
1936
|
+
or self.modelNumber is not None
|
|
1937
|
+
or self.modelURL is not None
|
|
1938
|
+
or self.serialNumber is not None
|
|
1939
|
+
or self.UDN is not None
|
|
1940
|
+
or self.macAddress is not None
|
|
1941
|
+
or self.UPC is not None
|
|
1942
|
+
or self.iconList is not None
|
|
1943
|
+
or self.serviceList is not None
|
|
1944
|
+
or self.deviceList is not None
|
|
1945
|
+
or self.presentationURL is not None
|
|
1946
|
+
or self.anytypeobjs_
|
|
1947
|
+
):
|
|
1948
|
+
return True
|
|
1949
|
+
else:
|
|
1950
|
+
return False
|
|
1951
|
+
|
|
1952
|
+
def export(
|
|
1953
|
+
self,
|
|
1954
|
+
outfile,
|
|
1955
|
+
level,
|
|
1956
|
+
namespaceprefix_="",
|
|
1957
|
+
namespacedef_='xmlns:tns="urn:schemas-upnp-org:device-1-0" xmlns:None="urn:schemas-upnp-org:device-1-0" ',
|
|
1958
|
+
name_="DeviceType",
|
|
1959
|
+
pretty_print=True,
|
|
1960
|
+
):
|
|
1961
|
+
imported_ns_def_ = GenerateDSNamespaceDefs_.get("DeviceType")
|
|
1962
|
+
if imported_ns_def_ is not None:
|
|
1963
|
+
namespacedef_ = imported_ns_def_
|
|
1964
|
+
if pretty_print:
|
|
1965
|
+
eol_ = "\n"
|
|
1966
|
+
else:
|
|
1967
|
+
eol_ = ""
|
|
1968
|
+
if self.original_tagname_ is not None and name_ == "DeviceType":
|
|
1969
|
+
name_ = self.original_tagname_
|
|
1970
|
+
if UseCapturedNS_ and self.ns_prefix_:
|
|
1971
|
+
namespaceprefix_ = self.ns_prefix_ + ":"
|
|
1972
|
+
showIndent(outfile, level, pretty_print)
|
|
1973
|
+
outfile.write(
|
|
1974
|
+
"<%s%s%s"
|
|
1975
|
+
% (
|
|
1976
|
+
namespaceprefix_,
|
|
1977
|
+
name_,
|
|
1978
|
+
namespacedef_ and " " + namespacedef_ or "",
|
|
1979
|
+
)
|
|
1980
|
+
)
|
|
1981
|
+
already_processed = set()
|
|
1982
|
+
self._exportAttributes(
|
|
1983
|
+
outfile,
|
|
1984
|
+
level,
|
|
1985
|
+
already_processed,
|
|
1986
|
+
namespaceprefix_,
|
|
1987
|
+
name_="DeviceType",
|
|
1988
|
+
)
|
|
1989
|
+
if self.has__content():
|
|
1990
|
+
outfile.write(">%s" % (eol_,))
|
|
1991
|
+
self._exportChildren(
|
|
1992
|
+
outfile,
|
|
1993
|
+
level + 1,
|
|
1994
|
+
namespaceprefix_,
|
|
1995
|
+
namespacedef_,
|
|
1996
|
+
name_="DeviceType",
|
|
1997
|
+
pretty_print=pretty_print,
|
|
1998
|
+
)
|
|
1999
|
+
showIndent(outfile, level, pretty_print)
|
|
2000
|
+
outfile.write("</%s%s>%s" % (namespaceprefix_, name_, eol_))
|
|
2001
|
+
else:
|
|
2002
|
+
outfile.write("/>%s" % (eol_,))
|
|
2003
|
+
|
|
2004
|
+
def _exportAttributes(
|
|
2005
|
+
self,
|
|
2006
|
+
outfile,
|
|
2007
|
+
level,
|
|
2008
|
+
already_processed,
|
|
2009
|
+
namespaceprefix_="",
|
|
2010
|
+
name_="DeviceType",
|
|
2011
|
+
):
|
|
2012
|
+
pass
|
|
2013
|
+
|
|
2014
|
+
def _exportChildren(
|
|
2015
|
+
self,
|
|
2016
|
+
outfile,
|
|
2017
|
+
level,
|
|
2018
|
+
namespaceprefix_="",
|
|
2019
|
+
namespacedef_='xmlns:tns="urn:schemas-upnp-org:device-1-0" xmlns:None="urn:schemas-upnp-org:device-1-0" ',
|
|
2020
|
+
name_="DeviceType",
|
|
2021
|
+
fromsubclass_=False,
|
|
2022
|
+
pretty_print=True,
|
|
2023
|
+
):
|
|
2024
|
+
if pretty_print:
|
|
2025
|
+
eol_ = "\n"
|
|
2026
|
+
else:
|
|
2027
|
+
eol_ = ""
|
|
2028
|
+
if self.deviceType is not None:
|
|
2029
|
+
namespaceprefix_ = (
|
|
2030
|
+
self.deviceType_nsprefix_ + ":"
|
|
2031
|
+
if (UseCapturedNS_ and self.deviceType_nsprefix_)
|
|
2032
|
+
else ""
|
|
2033
|
+
)
|
|
2034
|
+
showIndent(outfile, level, pretty_print)
|
|
2035
|
+
outfile.write(
|
|
2036
|
+
"<%sdeviceType>%s</%sdeviceType>%s"
|
|
2037
|
+
% (
|
|
2038
|
+
namespaceprefix_,
|
|
2039
|
+
self.gds_encode(
|
|
2040
|
+
self.gds_format_string(
|
|
2041
|
+
quote_xml(self.deviceType), input_name="deviceType"
|
|
2042
|
+
)
|
|
2043
|
+
),
|
|
2044
|
+
namespaceprefix_,
|
|
2045
|
+
eol_,
|
|
2046
|
+
)
|
|
2047
|
+
)
|
|
2048
|
+
if self.friendlyName is not None:
|
|
2049
|
+
namespaceprefix_ = (
|
|
2050
|
+
self.friendlyName_nsprefix_ + ":"
|
|
2051
|
+
if (UseCapturedNS_ and self.friendlyName_nsprefix_)
|
|
2052
|
+
else ""
|
|
2053
|
+
)
|
|
2054
|
+
showIndent(outfile, level, pretty_print)
|
|
2055
|
+
outfile.write(
|
|
2056
|
+
"<%sfriendlyName>%s</%sfriendlyName>%s"
|
|
2057
|
+
% (
|
|
2058
|
+
namespaceprefix_,
|
|
2059
|
+
self.gds_encode(
|
|
2060
|
+
self.gds_format_string(
|
|
2061
|
+
quote_xml(self.friendlyName),
|
|
2062
|
+
input_name="friendlyName",
|
|
2063
|
+
)
|
|
2064
|
+
),
|
|
2065
|
+
namespaceprefix_,
|
|
2066
|
+
eol_,
|
|
2067
|
+
)
|
|
2068
|
+
)
|
|
2069
|
+
if self.manufacturer is not None:
|
|
2070
|
+
namespaceprefix_ = (
|
|
2071
|
+
self.manufacturer_nsprefix_ + ":"
|
|
2072
|
+
if (UseCapturedNS_ and self.manufacturer_nsprefix_)
|
|
2073
|
+
else ""
|
|
2074
|
+
)
|
|
2075
|
+
showIndent(outfile, level, pretty_print)
|
|
2076
|
+
outfile.write(
|
|
2077
|
+
"<%smanufacturer>%s</%smanufacturer>%s"
|
|
2078
|
+
% (
|
|
2079
|
+
namespaceprefix_,
|
|
2080
|
+
self.gds_encode(
|
|
2081
|
+
self.gds_format_string(
|
|
2082
|
+
quote_xml(self.manufacturer),
|
|
2083
|
+
input_name="manufacturer",
|
|
2084
|
+
)
|
|
2085
|
+
),
|
|
2086
|
+
namespaceprefix_,
|
|
2087
|
+
eol_,
|
|
2088
|
+
)
|
|
2089
|
+
)
|
|
2090
|
+
if self.manufacturerURL is not None:
|
|
2091
|
+
namespaceprefix_ = (
|
|
2092
|
+
self.manufacturerURL_nsprefix_ + ":"
|
|
2093
|
+
if (UseCapturedNS_ and self.manufacturerURL_nsprefix_)
|
|
2094
|
+
else ""
|
|
2095
|
+
)
|
|
2096
|
+
showIndent(outfile, level, pretty_print)
|
|
2097
|
+
outfile.write(
|
|
2098
|
+
"<%smanufacturerURL>%s</%smanufacturerURL>%s"
|
|
2099
|
+
% (
|
|
2100
|
+
namespaceprefix_,
|
|
2101
|
+
self.gds_encode(
|
|
2102
|
+
self.gds_format_string(
|
|
2103
|
+
quote_xml(self.manufacturerURL),
|
|
2104
|
+
input_name="manufacturerURL",
|
|
2105
|
+
)
|
|
2106
|
+
),
|
|
2107
|
+
namespaceprefix_,
|
|
2108
|
+
eol_,
|
|
2109
|
+
)
|
|
2110
|
+
)
|
|
2111
|
+
if self.modelDescription is not None:
|
|
2112
|
+
namespaceprefix_ = (
|
|
2113
|
+
self.modelDescription_nsprefix_ + ":"
|
|
2114
|
+
if (UseCapturedNS_ and self.modelDescription_nsprefix_)
|
|
2115
|
+
else ""
|
|
2116
|
+
)
|
|
2117
|
+
showIndent(outfile, level, pretty_print)
|
|
2118
|
+
outfile.write(
|
|
2119
|
+
"<%smodelDescription>%s</%smodelDescription>%s"
|
|
2120
|
+
% (
|
|
2121
|
+
namespaceprefix_,
|
|
2122
|
+
self.gds_encode(
|
|
2123
|
+
self.gds_format_string(
|
|
2124
|
+
quote_xml(self.modelDescription),
|
|
2125
|
+
input_name="modelDescription",
|
|
2126
|
+
)
|
|
2127
|
+
),
|
|
2128
|
+
namespaceprefix_,
|
|
2129
|
+
eol_,
|
|
2130
|
+
)
|
|
2131
|
+
)
|
|
2132
|
+
if self.modelName is not None:
|
|
2133
|
+
namespaceprefix_ = (
|
|
2134
|
+
self.modelName_nsprefix_ + ":"
|
|
2135
|
+
if (UseCapturedNS_ and self.modelName_nsprefix_)
|
|
2136
|
+
else ""
|
|
2137
|
+
)
|
|
2138
|
+
showIndent(outfile, level, pretty_print)
|
|
2139
|
+
outfile.write(
|
|
2140
|
+
"<%smodelName>%s</%smodelName>%s"
|
|
2141
|
+
% (
|
|
2142
|
+
namespaceprefix_,
|
|
2143
|
+
self.gds_encode(
|
|
2144
|
+
self.gds_format_string(
|
|
2145
|
+
quote_xml(self.modelName), input_name="modelName"
|
|
2146
|
+
)
|
|
2147
|
+
),
|
|
2148
|
+
namespaceprefix_,
|
|
2149
|
+
eol_,
|
|
2150
|
+
)
|
|
2151
|
+
)
|
|
2152
|
+
if self.modelNumber is not None:
|
|
2153
|
+
namespaceprefix_ = (
|
|
2154
|
+
self.modelNumber_nsprefix_ + ":"
|
|
2155
|
+
if (UseCapturedNS_ and self.modelNumber_nsprefix_)
|
|
2156
|
+
else ""
|
|
2157
|
+
)
|
|
2158
|
+
showIndent(outfile, level, pretty_print)
|
|
2159
|
+
outfile.write(
|
|
2160
|
+
"<%smodelNumber>%s</%smodelNumber>%s"
|
|
2161
|
+
% (
|
|
2162
|
+
namespaceprefix_,
|
|
2163
|
+
self.gds_encode(
|
|
2164
|
+
self.gds_format_string(
|
|
2165
|
+
quote_xml(self.modelNumber),
|
|
2166
|
+
input_name="modelNumber",
|
|
2167
|
+
)
|
|
2168
|
+
),
|
|
2169
|
+
namespaceprefix_,
|
|
2170
|
+
eol_,
|
|
2171
|
+
)
|
|
2172
|
+
)
|
|
2173
|
+
if self.modelURL is not None:
|
|
2174
|
+
namespaceprefix_ = (
|
|
2175
|
+
self.modelURL_nsprefix_ + ":"
|
|
2176
|
+
if (UseCapturedNS_ and self.modelURL_nsprefix_)
|
|
2177
|
+
else ""
|
|
2178
|
+
)
|
|
2179
|
+
showIndent(outfile, level, pretty_print)
|
|
2180
|
+
outfile.write(
|
|
2181
|
+
"<%smodelURL>%s</%smodelURL>%s"
|
|
2182
|
+
% (
|
|
2183
|
+
namespaceprefix_,
|
|
2184
|
+
self.gds_encode(
|
|
2185
|
+
self.gds_format_string(
|
|
2186
|
+
quote_xml(self.modelURL), input_name="modelURL"
|
|
2187
|
+
)
|
|
2188
|
+
),
|
|
2189
|
+
namespaceprefix_,
|
|
2190
|
+
eol_,
|
|
2191
|
+
)
|
|
2192
|
+
)
|
|
2193
|
+
if self.serialNumber is not None:
|
|
2194
|
+
namespaceprefix_ = (
|
|
2195
|
+
self.serialNumber_nsprefix_ + ":"
|
|
2196
|
+
if (UseCapturedNS_ and self.serialNumber_nsprefix_)
|
|
2197
|
+
else ""
|
|
2198
|
+
)
|
|
2199
|
+
showIndent(outfile, level, pretty_print)
|
|
2200
|
+
outfile.write(
|
|
2201
|
+
"<%sserialNumber>%s</%sserialNumber>%s"
|
|
2202
|
+
% (
|
|
2203
|
+
namespaceprefix_,
|
|
2204
|
+
self.gds_encode(
|
|
2205
|
+
self.gds_format_string(
|
|
2206
|
+
quote_xml(self.serialNumber),
|
|
2207
|
+
input_name="serialNumber",
|
|
2208
|
+
)
|
|
2209
|
+
),
|
|
2210
|
+
namespaceprefix_,
|
|
2211
|
+
eol_,
|
|
2212
|
+
)
|
|
2213
|
+
)
|
|
2214
|
+
if self.UDN is not None:
|
|
2215
|
+
namespaceprefix_ = (
|
|
2216
|
+
self.UDN_nsprefix_ + ":"
|
|
2217
|
+
if (UseCapturedNS_ and self.UDN_nsprefix_)
|
|
2218
|
+
else ""
|
|
2219
|
+
)
|
|
2220
|
+
showIndent(outfile, level, pretty_print)
|
|
2221
|
+
outfile.write(
|
|
2222
|
+
"<%sUDN>%s</%sUDN>%s"
|
|
2223
|
+
% (
|
|
2224
|
+
namespaceprefix_,
|
|
2225
|
+
self.gds_encode(
|
|
2226
|
+
self.gds_format_string(
|
|
2227
|
+
quote_xml(self.UDN), input_name="UDN"
|
|
2228
|
+
)
|
|
2229
|
+
),
|
|
2230
|
+
namespaceprefix_,
|
|
2231
|
+
eol_,
|
|
2232
|
+
)
|
|
2233
|
+
)
|
|
2234
|
+
if self.macAddress is not None:
|
|
2235
|
+
namespaceprefix_ = (
|
|
2236
|
+
self.macAddress_nsprefix_ + ":"
|
|
2237
|
+
if (UseCapturedNS_ and self.macAddress_nsprefix_)
|
|
2238
|
+
else ""
|
|
2239
|
+
)
|
|
2240
|
+
showIndent(outfile, level, pretty_print)
|
|
2241
|
+
outfile.write(
|
|
2242
|
+
"<%smacAddress>%s</%smacAddress>%s"
|
|
2243
|
+
% (
|
|
2244
|
+
namespaceprefix_,
|
|
2245
|
+
self.gds_encode(
|
|
2246
|
+
self.gds_format_string(
|
|
2247
|
+
quote_xml(self.macAddress), input_name="macAddress"
|
|
2248
|
+
)
|
|
2249
|
+
),
|
|
2250
|
+
namespaceprefix_,
|
|
2251
|
+
eol_,
|
|
2252
|
+
)
|
|
2253
|
+
)
|
|
2254
|
+
if self.UPC is not None:
|
|
2255
|
+
namespaceprefix_ = (
|
|
2256
|
+
self.UPC_nsprefix_ + ":"
|
|
2257
|
+
if (UseCapturedNS_ and self.UPC_nsprefix_)
|
|
2258
|
+
else ""
|
|
2259
|
+
)
|
|
2260
|
+
showIndent(outfile, level, pretty_print)
|
|
2261
|
+
outfile.write(
|
|
2262
|
+
"<%sUPC>%s</%sUPC>%s"
|
|
2263
|
+
% (
|
|
2264
|
+
namespaceprefix_,
|
|
2265
|
+
self.gds_encode(
|
|
2266
|
+
self.gds_format_string(
|
|
2267
|
+
quote_xml(self.UPC), input_name="UPC"
|
|
2268
|
+
)
|
|
2269
|
+
),
|
|
2270
|
+
namespaceprefix_,
|
|
2271
|
+
eol_,
|
|
2272
|
+
)
|
|
2273
|
+
)
|
|
2274
|
+
if self.iconList is not None:
|
|
2275
|
+
namespaceprefix_ = (
|
|
2276
|
+
self.iconList_nsprefix_ + ":"
|
|
2277
|
+
if (UseCapturedNS_ and self.iconList_nsprefix_)
|
|
2278
|
+
else ""
|
|
2279
|
+
)
|
|
2280
|
+
self.iconList.export(
|
|
2281
|
+
outfile,
|
|
2282
|
+
level,
|
|
2283
|
+
namespaceprefix_,
|
|
2284
|
+
namespacedef_="",
|
|
2285
|
+
name_="iconList",
|
|
2286
|
+
pretty_print=pretty_print,
|
|
2287
|
+
)
|
|
2288
|
+
if self.serviceList is not None:
|
|
2289
|
+
namespaceprefix_ = (
|
|
2290
|
+
self.serviceList_nsprefix_ + ":"
|
|
2291
|
+
if (UseCapturedNS_ and self.serviceList_nsprefix_)
|
|
2292
|
+
else ""
|
|
2293
|
+
)
|
|
2294
|
+
self.serviceList.export(
|
|
2295
|
+
outfile,
|
|
2296
|
+
level,
|
|
2297
|
+
namespaceprefix_,
|
|
2298
|
+
namespacedef_="",
|
|
2299
|
+
name_="serviceList",
|
|
2300
|
+
pretty_print=pretty_print,
|
|
2301
|
+
)
|
|
2302
|
+
if self.deviceList is not None:
|
|
2303
|
+
namespaceprefix_ = (
|
|
2304
|
+
self.deviceList_nsprefix_ + ":"
|
|
2305
|
+
if (UseCapturedNS_ and self.deviceList_nsprefix_)
|
|
2306
|
+
else ""
|
|
2307
|
+
)
|
|
2308
|
+
self.deviceList.export(
|
|
2309
|
+
outfile,
|
|
2310
|
+
level,
|
|
2311
|
+
namespaceprefix_,
|
|
2312
|
+
namespacedef_="",
|
|
2313
|
+
name_="deviceList",
|
|
2314
|
+
pretty_print=pretty_print,
|
|
2315
|
+
)
|
|
2316
|
+
if self.presentationURL is not None:
|
|
2317
|
+
namespaceprefix_ = (
|
|
2318
|
+
self.presentationURL_nsprefix_ + ":"
|
|
2319
|
+
if (UseCapturedNS_ and self.presentationURL_nsprefix_)
|
|
2320
|
+
else ""
|
|
2321
|
+
)
|
|
2322
|
+
showIndent(outfile, level, pretty_print)
|
|
2323
|
+
outfile.write(
|
|
2324
|
+
"<%spresentationURL>%s</%spresentationURL>%s"
|
|
2325
|
+
% (
|
|
2326
|
+
namespaceprefix_,
|
|
2327
|
+
self.gds_encode(
|
|
2328
|
+
self.gds_format_string(
|
|
2329
|
+
quote_xml(self.presentationURL),
|
|
2330
|
+
input_name="presentationURL",
|
|
2331
|
+
)
|
|
2332
|
+
),
|
|
2333
|
+
namespaceprefix_,
|
|
2334
|
+
eol_,
|
|
2335
|
+
)
|
|
2336
|
+
)
|
|
2337
|
+
if not fromsubclass_:
|
|
2338
|
+
for obj_ in self.anytypeobjs_:
|
|
2339
|
+
showIndent(outfile, level, pretty_print)
|
|
2340
|
+
outfile.write(str(obj_))
|
|
2341
|
+
outfile.write("\n")
|
|
2342
|
+
|
|
2343
|
+
def build(self, node, gds_collector_=None):
|
|
2344
|
+
self.gds_collector_ = gds_collector_
|
|
2345
|
+
if SaveElementTreeNode:
|
|
2346
|
+
self.gds_elementtree_node_ = node
|
|
2347
|
+
already_processed = set()
|
|
2348
|
+
self.ns_prefix_ = node.prefix
|
|
2349
|
+
self._buildAttributes(node, node.attrib, already_processed)
|
|
2350
|
+
for child in node:
|
|
2351
|
+
nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
|
|
2352
|
+
self._buildChildren(
|
|
2353
|
+
child, node, nodeName_, gds_collector_=gds_collector_
|
|
2354
|
+
)
|
|
2355
|
+
return self
|
|
2356
|
+
|
|
2357
|
+
def _buildAttributes(self, node, attrs, already_processed):
|
|
2358
|
+
pass
|
|
2359
|
+
|
|
2360
|
+
def _buildChildren(
|
|
2361
|
+
self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None
|
|
2362
|
+
):
|
|
2363
|
+
if nodeName_ == "deviceType":
|
|
2364
|
+
value_ = child_.text
|
|
2365
|
+
value_ = self.gds_parse_string(value_, node, "deviceType")
|
|
2366
|
+
value_ = self.gds_validate_string(value_, node, "deviceType")
|
|
2367
|
+
self.deviceType = value_
|
|
2368
|
+
self.deviceType_nsprefix_ = child_.prefix
|
|
2369
|
+
elif nodeName_ == "friendlyName":
|
|
2370
|
+
value_ = child_.text
|
|
2371
|
+
value_ = self.gds_parse_string(value_, node, "friendlyName")
|
|
2372
|
+
value_ = self.gds_validate_string(value_, node, "friendlyName")
|
|
2373
|
+
self.friendlyName = value_
|
|
2374
|
+
self.friendlyName_nsprefix_ = child_.prefix
|
|
2375
|
+
elif nodeName_ == "manufacturer":
|
|
2376
|
+
value_ = child_.text
|
|
2377
|
+
value_ = self.gds_parse_string(value_, node, "manufacturer")
|
|
2378
|
+
value_ = self.gds_validate_string(value_, node, "manufacturer")
|
|
2379
|
+
self.manufacturer = value_
|
|
2380
|
+
self.manufacturer_nsprefix_ = child_.prefix
|
|
2381
|
+
elif nodeName_ == "manufacturerURL":
|
|
2382
|
+
value_ = child_.text
|
|
2383
|
+
value_ = self.gds_parse_string(value_, node, "manufacturerURL")
|
|
2384
|
+
value_ = self.gds_validate_string(value_, node, "manufacturerURL")
|
|
2385
|
+
self.manufacturerURL = value_
|
|
2386
|
+
self.manufacturerURL_nsprefix_ = child_.prefix
|
|
2387
|
+
elif nodeName_ == "modelDescription":
|
|
2388
|
+
value_ = child_.text
|
|
2389
|
+
value_ = self.gds_parse_string(value_, node, "modelDescription")
|
|
2390
|
+
value_ = self.gds_validate_string(value_, node, "modelDescription")
|
|
2391
|
+
self.modelDescription = value_
|
|
2392
|
+
self.modelDescription_nsprefix_ = child_.prefix
|
|
2393
|
+
elif nodeName_ == "modelName":
|
|
2394
|
+
value_ = child_.text
|
|
2395
|
+
value_ = self.gds_parse_string(value_, node, "modelName")
|
|
2396
|
+
value_ = self.gds_validate_string(value_, node, "modelName")
|
|
2397
|
+
self.modelName = value_
|
|
2398
|
+
self.modelName_nsprefix_ = child_.prefix
|
|
2399
|
+
elif nodeName_ == "modelNumber":
|
|
2400
|
+
value_ = child_.text
|
|
2401
|
+
value_ = self.gds_parse_string(value_, node, "modelNumber")
|
|
2402
|
+
value_ = self.gds_validate_string(value_, node, "modelNumber")
|
|
2403
|
+
self.modelNumber = value_
|
|
2404
|
+
self.modelNumber_nsprefix_ = child_.prefix
|
|
2405
|
+
elif nodeName_ == "modelURL":
|
|
2406
|
+
value_ = child_.text
|
|
2407
|
+
value_ = self.gds_parse_string(value_, node, "modelURL")
|
|
2408
|
+
value_ = self.gds_validate_string(value_, node, "modelURL")
|
|
2409
|
+
self.modelURL = value_
|
|
2410
|
+
self.modelURL_nsprefix_ = child_.prefix
|
|
2411
|
+
elif nodeName_ == "serialNumber":
|
|
2412
|
+
value_ = child_.text
|
|
2413
|
+
value_ = self.gds_parse_string(value_, node, "serialNumber")
|
|
2414
|
+
value_ = self.gds_validate_string(value_, node, "serialNumber")
|
|
2415
|
+
self.serialNumber = value_
|
|
2416
|
+
self.serialNumber_nsprefix_ = child_.prefix
|
|
2417
|
+
elif nodeName_ == "UDN":
|
|
2418
|
+
value_ = child_.text
|
|
2419
|
+
value_ = self.gds_parse_string(value_, node, "UDN")
|
|
2420
|
+
value_ = self.gds_validate_string(value_, node, "UDN")
|
|
2421
|
+
self.UDN = value_
|
|
2422
|
+
self.UDN_nsprefix_ = child_.prefix
|
|
2423
|
+
elif nodeName_ == "macAddress":
|
|
2424
|
+
value_ = child_.text
|
|
2425
|
+
value_ = self.gds_parse_string(value_, node, "macAddress")
|
|
2426
|
+
value_ = self.gds_validate_string(value_, node, "macAddress")
|
|
2427
|
+
self.macAddress = value_
|
|
2428
|
+
self.macAddress_nsprefix_ = child_.prefix
|
|
2429
|
+
elif nodeName_ == "UPC":
|
|
2430
|
+
value_ = child_.text
|
|
2431
|
+
value_ = self.gds_parse_string(value_, node, "UPC")
|
|
2432
|
+
value_ = self.gds_validate_string(value_, node, "UPC")
|
|
2433
|
+
self.UPC = value_
|
|
2434
|
+
self.UPC_nsprefix_ = child_.prefix
|
|
2435
|
+
elif nodeName_ == "iconList":
|
|
2436
|
+
obj_ = IconListType.factory(parent_object_=self)
|
|
2437
|
+
obj_.build(child_, gds_collector_=gds_collector_)
|
|
2438
|
+
self.iconList = obj_
|
|
2439
|
+
obj_.original_tagname_ = "iconList"
|
|
2440
|
+
elif nodeName_ == "serviceList":
|
|
2441
|
+
obj_ = ServiceListType.factory(parent_object_=self)
|
|
2442
|
+
obj_.build(child_, gds_collector_=gds_collector_)
|
|
2443
|
+
self.serviceList = obj_
|
|
2444
|
+
obj_.original_tagname_ = "serviceList"
|
|
2445
|
+
elif nodeName_ == "deviceList":
|
|
2446
|
+
obj_ = DeviceListType.factory(parent_object_=self)
|
|
2447
|
+
obj_.build(child_, gds_collector_=gds_collector_)
|
|
2448
|
+
self.deviceList = obj_
|
|
2449
|
+
obj_.original_tagname_ = "deviceList"
|
|
2450
|
+
elif nodeName_ == "presentationURL":
|
|
2451
|
+
value_ = child_.text
|
|
2452
|
+
value_ = self.gds_parse_string(value_, node, "presentationURL")
|
|
2453
|
+
value_ = self.gds_validate_string(value_, node, "presentationURL")
|
|
2454
|
+
self.presentationURL = value_
|
|
2455
|
+
self.presentationURL_nsprefix_ = child_.prefix
|
|
2456
|
+
else:
|
|
2457
|
+
content_ = self.gds_build_any(child_, "DeviceType")
|
|
2458
|
+
self.anytypeobjs_.append(content_)
|
|
2459
|
+
|
|
2460
|
+
|
|
2461
|
+
# end class DeviceType
|
|
2462
|
+
|
|
2463
|
+
|
|
2464
|
+
class IconListType(GeneratedsSuper):
|
|
2465
|
+
__hash__ = GeneratedsSuper.__hash__
|
|
2466
|
+
subclass = None
|
|
2467
|
+
superclass = None
|
|
2468
|
+
|
|
2469
|
+
def __init__(self, icon=None, gds_collector_=None, **kwargs_):
|
|
2470
|
+
self.gds_collector_ = gds_collector_
|
|
2471
|
+
self.gds_elementtree_node_ = None
|
|
2472
|
+
self.original_tagname_ = None
|
|
2473
|
+
self.parent_object_ = kwargs_.get("parent_object_")
|
|
2474
|
+
self.ns_prefix_ = None
|
|
2475
|
+
if icon is None:
|
|
2476
|
+
self.icon = []
|
|
2477
|
+
else:
|
|
2478
|
+
self.icon = icon
|
|
2479
|
+
self.icon_nsprefix_ = None
|
|
2480
|
+
|
|
2481
|
+
def factory(*args_, **kwargs_):
|
|
2482
|
+
if CurrentSubclassModule_ is not None:
|
|
2483
|
+
subclass = getSubclassFromModule_(
|
|
2484
|
+
CurrentSubclassModule_, IconListType
|
|
2485
|
+
)
|
|
2486
|
+
if subclass is not None:
|
|
2487
|
+
return subclass(*args_, **kwargs_)
|
|
2488
|
+
if IconListType.subclass:
|
|
2489
|
+
return IconListType.subclass(*args_, **kwargs_)
|
|
2490
|
+
else:
|
|
2491
|
+
return IconListType(*args_, **kwargs_)
|
|
2492
|
+
|
|
2493
|
+
factory = staticmethod(factory)
|
|
2494
|
+
|
|
2495
|
+
def get_ns_prefix_(self):
|
|
2496
|
+
return self.ns_prefix_
|
|
2497
|
+
|
|
2498
|
+
def set_ns_prefix_(self, ns_prefix):
|
|
2499
|
+
self.ns_prefix_ = ns_prefix
|
|
2500
|
+
|
|
2501
|
+
def get_icon(self):
|
|
2502
|
+
return self.icon
|
|
2503
|
+
|
|
2504
|
+
def set_icon(self, icon):
|
|
2505
|
+
self.icon = icon
|
|
2506
|
+
|
|
2507
|
+
def add_icon(self, value):
|
|
2508
|
+
self.icon.append(value)
|
|
2509
|
+
|
|
2510
|
+
def insert_icon_at(self, index, value):
|
|
2511
|
+
self.icon.insert(index, value)
|
|
2512
|
+
|
|
2513
|
+
def replace_icon_at(self, index, value):
|
|
2514
|
+
self.icon[index] = value
|
|
2515
|
+
|
|
2516
|
+
def has__content(self):
|
|
2517
|
+
if self.icon:
|
|
2518
|
+
return True
|
|
2519
|
+
else:
|
|
2520
|
+
return False
|
|
2521
|
+
|
|
2522
|
+
def export(
|
|
2523
|
+
self,
|
|
2524
|
+
outfile,
|
|
2525
|
+
level,
|
|
2526
|
+
namespaceprefix_="",
|
|
2527
|
+
namespacedef_='xmlns:tns="urn:schemas-upnp-org:device-1-0" xmlns:None="urn:schemas-upnp-org:device-1-0" ',
|
|
2528
|
+
name_="IconListType",
|
|
2529
|
+
pretty_print=True,
|
|
2530
|
+
):
|
|
2531
|
+
imported_ns_def_ = GenerateDSNamespaceDefs_.get("IconListType")
|
|
2532
|
+
if imported_ns_def_ is not None:
|
|
2533
|
+
namespacedef_ = imported_ns_def_
|
|
2534
|
+
if pretty_print:
|
|
2535
|
+
eol_ = "\n"
|
|
2536
|
+
else:
|
|
2537
|
+
eol_ = ""
|
|
2538
|
+
if self.original_tagname_ is not None and name_ == "IconListType":
|
|
2539
|
+
name_ = self.original_tagname_
|
|
2540
|
+
if UseCapturedNS_ and self.ns_prefix_:
|
|
2541
|
+
namespaceprefix_ = self.ns_prefix_ + ":"
|
|
2542
|
+
showIndent(outfile, level, pretty_print)
|
|
2543
|
+
outfile.write(
|
|
2544
|
+
"<%s%s%s"
|
|
2545
|
+
% (
|
|
2546
|
+
namespaceprefix_,
|
|
2547
|
+
name_,
|
|
2548
|
+
namespacedef_ and " " + namespacedef_ or "",
|
|
2549
|
+
)
|
|
2550
|
+
)
|
|
2551
|
+
already_processed = set()
|
|
2552
|
+
self._exportAttributes(
|
|
2553
|
+
outfile,
|
|
2554
|
+
level,
|
|
2555
|
+
already_processed,
|
|
2556
|
+
namespaceprefix_,
|
|
2557
|
+
name_="IconListType",
|
|
2558
|
+
)
|
|
2559
|
+
if self.has__content():
|
|
2560
|
+
outfile.write(">%s" % (eol_,))
|
|
2561
|
+
self._exportChildren(
|
|
2562
|
+
outfile,
|
|
2563
|
+
level + 1,
|
|
2564
|
+
namespaceprefix_,
|
|
2565
|
+
namespacedef_,
|
|
2566
|
+
name_="IconListType",
|
|
2567
|
+
pretty_print=pretty_print,
|
|
2568
|
+
)
|
|
2569
|
+
showIndent(outfile, level, pretty_print)
|
|
2570
|
+
outfile.write("</%s%s>%s" % (namespaceprefix_, name_, eol_))
|
|
2571
|
+
else:
|
|
2572
|
+
outfile.write("/>%s" % (eol_,))
|
|
2573
|
+
|
|
2574
|
+
def _exportAttributes(
|
|
2575
|
+
self,
|
|
2576
|
+
outfile,
|
|
2577
|
+
level,
|
|
2578
|
+
already_processed,
|
|
2579
|
+
namespaceprefix_="",
|
|
2580
|
+
name_="IconListType",
|
|
2581
|
+
):
|
|
2582
|
+
pass
|
|
2583
|
+
|
|
2584
|
+
def _exportChildren(
|
|
2585
|
+
self,
|
|
2586
|
+
outfile,
|
|
2587
|
+
level,
|
|
2588
|
+
namespaceprefix_="",
|
|
2589
|
+
namespacedef_='xmlns:tns="urn:schemas-upnp-org:device-1-0" xmlns:None="urn:schemas-upnp-org:device-1-0" ',
|
|
2590
|
+
name_="IconListType",
|
|
2591
|
+
fromsubclass_=False,
|
|
2592
|
+
pretty_print=True,
|
|
2593
|
+
):
|
|
2594
|
+
if pretty_print:
|
|
2595
|
+
eol_ = "\n"
|
|
2596
|
+
else:
|
|
2597
|
+
eol_ = ""
|
|
2598
|
+
for icon_ in self.icon:
|
|
2599
|
+
namespaceprefix_ = (
|
|
2600
|
+
self.icon_nsprefix_ + ":"
|
|
2601
|
+
if (UseCapturedNS_ and self.icon_nsprefix_)
|
|
2602
|
+
else ""
|
|
2603
|
+
)
|
|
2604
|
+
icon_.export(
|
|
2605
|
+
outfile,
|
|
2606
|
+
level,
|
|
2607
|
+
namespaceprefix_,
|
|
2608
|
+
namespacedef_="",
|
|
2609
|
+
name_="icon",
|
|
2610
|
+
pretty_print=pretty_print,
|
|
2611
|
+
)
|
|
2612
|
+
|
|
2613
|
+
def build(self, node, gds_collector_=None):
|
|
2614
|
+
self.gds_collector_ = gds_collector_
|
|
2615
|
+
if SaveElementTreeNode:
|
|
2616
|
+
self.gds_elementtree_node_ = node
|
|
2617
|
+
already_processed = set()
|
|
2618
|
+
self.ns_prefix_ = node.prefix
|
|
2619
|
+
self._buildAttributes(node, node.attrib, already_processed)
|
|
2620
|
+
for child in node:
|
|
2621
|
+
nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
|
|
2622
|
+
self._buildChildren(
|
|
2623
|
+
child, node, nodeName_, gds_collector_=gds_collector_
|
|
2624
|
+
)
|
|
2625
|
+
return self
|
|
2626
|
+
|
|
2627
|
+
def _buildAttributes(self, node, attrs, already_processed):
|
|
2628
|
+
pass
|
|
2629
|
+
|
|
2630
|
+
def _buildChildren(
|
|
2631
|
+
self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None
|
|
2632
|
+
):
|
|
2633
|
+
if nodeName_ == "icon":
|
|
2634
|
+
obj_ = iconType.factory(parent_object_=self)
|
|
2635
|
+
obj_.build(child_, gds_collector_=gds_collector_)
|
|
2636
|
+
self.icon.append(obj_)
|
|
2637
|
+
obj_.original_tagname_ = "icon"
|
|
2638
|
+
|
|
2639
|
+
|
|
2640
|
+
# end class IconListType
|
|
2641
|
+
|
|
2642
|
+
|
|
2643
|
+
class ServiceListType(GeneratedsSuper):
|
|
2644
|
+
__hash__ = GeneratedsSuper.__hash__
|
|
2645
|
+
subclass = None
|
|
2646
|
+
superclass = None
|
|
2647
|
+
|
|
2648
|
+
def __init__(self, service=None, gds_collector_=None, **kwargs_):
|
|
2649
|
+
self.gds_collector_ = gds_collector_
|
|
2650
|
+
self.gds_elementtree_node_ = None
|
|
2651
|
+
self.original_tagname_ = None
|
|
2652
|
+
self.parent_object_ = kwargs_.get("parent_object_")
|
|
2653
|
+
self.ns_prefix_ = None
|
|
2654
|
+
if service is None:
|
|
2655
|
+
self.service = []
|
|
2656
|
+
else:
|
|
2657
|
+
self.service = service
|
|
2658
|
+
self.service_nsprefix_ = None
|
|
2659
|
+
|
|
2660
|
+
def factory(*args_, **kwargs_):
|
|
2661
|
+
if CurrentSubclassModule_ is not None:
|
|
2662
|
+
subclass = getSubclassFromModule_(
|
|
2663
|
+
CurrentSubclassModule_, ServiceListType
|
|
2664
|
+
)
|
|
2665
|
+
if subclass is not None:
|
|
2666
|
+
return subclass(*args_, **kwargs_)
|
|
2667
|
+
if ServiceListType.subclass:
|
|
2668
|
+
return ServiceListType.subclass(*args_, **kwargs_)
|
|
2669
|
+
else:
|
|
2670
|
+
return ServiceListType(*args_, **kwargs_)
|
|
2671
|
+
|
|
2672
|
+
factory = staticmethod(factory)
|
|
2673
|
+
|
|
2674
|
+
def get_ns_prefix_(self):
|
|
2675
|
+
return self.ns_prefix_
|
|
2676
|
+
|
|
2677
|
+
def set_ns_prefix_(self, ns_prefix):
|
|
2678
|
+
self.ns_prefix_ = ns_prefix
|
|
2679
|
+
|
|
2680
|
+
def get_service(self):
|
|
2681
|
+
return self.service
|
|
2682
|
+
|
|
2683
|
+
def set_service(self, service):
|
|
2684
|
+
self.service = service
|
|
2685
|
+
|
|
2686
|
+
def add_service(self, value):
|
|
2687
|
+
self.service.append(value)
|
|
2688
|
+
|
|
2689
|
+
def insert_service_at(self, index, value):
|
|
2690
|
+
self.service.insert(index, value)
|
|
2691
|
+
|
|
2692
|
+
def replace_service_at(self, index, value):
|
|
2693
|
+
self.service[index] = value
|
|
2694
|
+
|
|
2695
|
+
def has__content(self):
|
|
2696
|
+
if self.service:
|
|
2697
|
+
return True
|
|
2698
|
+
else:
|
|
2699
|
+
return False
|
|
2700
|
+
|
|
2701
|
+
def export(
|
|
2702
|
+
self,
|
|
2703
|
+
outfile,
|
|
2704
|
+
level,
|
|
2705
|
+
namespaceprefix_="",
|
|
2706
|
+
namespacedef_='xmlns:tns="urn:schemas-upnp-org:device-1-0" xmlns:None="urn:schemas-upnp-org:device-1-0" ',
|
|
2707
|
+
name_="ServiceListType",
|
|
2708
|
+
pretty_print=True,
|
|
2709
|
+
):
|
|
2710
|
+
imported_ns_def_ = GenerateDSNamespaceDefs_.get("ServiceListType")
|
|
2711
|
+
if imported_ns_def_ is not None:
|
|
2712
|
+
namespacedef_ = imported_ns_def_
|
|
2713
|
+
if pretty_print:
|
|
2714
|
+
eol_ = "\n"
|
|
2715
|
+
else:
|
|
2716
|
+
eol_ = ""
|
|
2717
|
+
if self.original_tagname_ is not None and name_ == "ServiceListType":
|
|
2718
|
+
name_ = self.original_tagname_
|
|
2719
|
+
if UseCapturedNS_ and self.ns_prefix_:
|
|
2720
|
+
namespaceprefix_ = self.ns_prefix_ + ":"
|
|
2721
|
+
showIndent(outfile, level, pretty_print)
|
|
2722
|
+
outfile.write(
|
|
2723
|
+
"<%s%s%s"
|
|
2724
|
+
% (
|
|
2725
|
+
namespaceprefix_,
|
|
2726
|
+
name_,
|
|
2727
|
+
namespacedef_ and " " + namespacedef_ or "",
|
|
2728
|
+
)
|
|
2729
|
+
)
|
|
2730
|
+
already_processed = set()
|
|
2731
|
+
self._exportAttributes(
|
|
2732
|
+
outfile,
|
|
2733
|
+
level,
|
|
2734
|
+
already_processed,
|
|
2735
|
+
namespaceprefix_,
|
|
2736
|
+
name_="ServiceListType",
|
|
2737
|
+
)
|
|
2738
|
+
if self.has__content():
|
|
2739
|
+
outfile.write(">%s" % (eol_,))
|
|
2740
|
+
self._exportChildren(
|
|
2741
|
+
outfile,
|
|
2742
|
+
level + 1,
|
|
2743
|
+
namespaceprefix_,
|
|
2744
|
+
namespacedef_,
|
|
2745
|
+
name_="ServiceListType",
|
|
2746
|
+
pretty_print=pretty_print,
|
|
2747
|
+
)
|
|
2748
|
+
showIndent(outfile, level, pretty_print)
|
|
2749
|
+
outfile.write("</%s%s>%s" % (namespaceprefix_, name_, eol_))
|
|
2750
|
+
else:
|
|
2751
|
+
outfile.write("/>%s" % (eol_,))
|
|
2752
|
+
|
|
2753
|
+
def _exportAttributes(
|
|
2754
|
+
self,
|
|
2755
|
+
outfile,
|
|
2756
|
+
level,
|
|
2757
|
+
already_processed,
|
|
2758
|
+
namespaceprefix_="",
|
|
2759
|
+
name_="ServiceListType",
|
|
2760
|
+
):
|
|
2761
|
+
pass
|
|
2762
|
+
|
|
2763
|
+
def _exportChildren(
|
|
2764
|
+
self,
|
|
2765
|
+
outfile,
|
|
2766
|
+
level,
|
|
2767
|
+
namespaceprefix_="",
|
|
2768
|
+
namespacedef_='xmlns:tns="urn:schemas-upnp-org:device-1-0" xmlns:None="urn:schemas-upnp-org:device-1-0" ',
|
|
2769
|
+
name_="ServiceListType",
|
|
2770
|
+
fromsubclass_=False,
|
|
2771
|
+
pretty_print=True,
|
|
2772
|
+
):
|
|
2773
|
+
if pretty_print:
|
|
2774
|
+
eol_ = "\n"
|
|
2775
|
+
else:
|
|
2776
|
+
eol_ = ""
|
|
2777
|
+
for service_ in self.service:
|
|
2778
|
+
namespaceprefix_ = (
|
|
2779
|
+
self.service_nsprefix_ + ":"
|
|
2780
|
+
if (UseCapturedNS_ and self.service_nsprefix_)
|
|
2781
|
+
else ""
|
|
2782
|
+
)
|
|
2783
|
+
service_.export(
|
|
2784
|
+
outfile,
|
|
2785
|
+
level,
|
|
2786
|
+
namespaceprefix_,
|
|
2787
|
+
namespacedef_="",
|
|
2788
|
+
name_="service",
|
|
2789
|
+
pretty_print=pretty_print,
|
|
2790
|
+
)
|
|
2791
|
+
|
|
2792
|
+
def build(self, node, gds_collector_=None):
|
|
2793
|
+
self.gds_collector_ = gds_collector_
|
|
2794
|
+
if SaveElementTreeNode:
|
|
2795
|
+
self.gds_elementtree_node_ = node
|
|
2796
|
+
already_processed = set()
|
|
2797
|
+
self.ns_prefix_ = node.prefix
|
|
2798
|
+
self._buildAttributes(node, node.attrib, already_processed)
|
|
2799
|
+
for child in node:
|
|
2800
|
+
nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
|
|
2801
|
+
self._buildChildren(
|
|
2802
|
+
child, node, nodeName_, gds_collector_=gds_collector_
|
|
2803
|
+
)
|
|
2804
|
+
return self
|
|
2805
|
+
|
|
2806
|
+
def _buildAttributes(self, node, attrs, already_processed):
|
|
2807
|
+
pass
|
|
2808
|
+
|
|
2809
|
+
def _buildChildren(
|
|
2810
|
+
self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None
|
|
2811
|
+
):
|
|
2812
|
+
if nodeName_ == "service":
|
|
2813
|
+
obj_ = serviceType.factory(parent_object_=self)
|
|
2814
|
+
obj_.build(child_, gds_collector_=gds_collector_)
|
|
2815
|
+
self.service.append(obj_)
|
|
2816
|
+
obj_.original_tagname_ = "service"
|
|
2817
|
+
|
|
2818
|
+
|
|
2819
|
+
# end class ServiceListType
|
|
2820
|
+
|
|
2821
|
+
|
|
2822
|
+
class DeviceListType(GeneratedsSuper):
|
|
2823
|
+
__hash__ = GeneratedsSuper.__hash__
|
|
2824
|
+
subclass = None
|
|
2825
|
+
superclass = None
|
|
2826
|
+
|
|
2827
|
+
def __init__(self, device=None, gds_collector_=None, **kwargs_):
|
|
2828
|
+
self.gds_collector_ = gds_collector_
|
|
2829
|
+
self.gds_elementtree_node_ = None
|
|
2830
|
+
self.original_tagname_ = None
|
|
2831
|
+
self.parent_object_ = kwargs_.get("parent_object_")
|
|
2832
|
+
self.ns_prefix_ = None
|
|
2833
|
+
if device is None:
|
|
2834
|
+
self.device = []
|
|
2835
|
+
else:
|
|
2836
|
+
self.device = device
|
|
2837
|
+
self.device_nsprefix_ = None
|
|
2838
|
+
|
|
2839
|
+
def factory(*args_, **kwargs_):
|
|
2840
|
+
if CurrentSubclassModule_ is not None:
|
|
2841
|
+
subclass = getSubclassFromModule_(
|
|
2842
|
+
CurrentSubclassModule_, DeviceListType
|
|
2843
|
+
)
|
|
2844
|
+
if subclass is not None:
|
|
2845
|
+
return subclass(*args_, **kwargs_)
|
|
2846
|
+
if DeviceListType.subclass:
|
|
2847
|
+
return DeviceListType.subclass(*args_, **kwargs_)
|
|
2848
|
+
else:
|
|
2849
|
+
return DeviceListType(*args_, **kwargs_)
|
|
2850
|
+
|
|
2851
|
+
factory = staticmethod(factory)
|
|
2852
|
+
|
|
2853
|
+
def get_ns_prefix_(self):
|
|
2854
|
+
return self.ns_prefix_
|
|
2855
|
+
|
|
2856
|
+
def set_ns_prefix_(self, ns_prefix):
|
|
2857
|
+
self.ns_prefix_ = ns_prefix
|
|
2858
|
+
|
|
2859
|
+
def get_device(self):
|
|
2860
|
+
return self.device
|
|
2861
|
+
|
|
2862
|
+
def set_device(self, device):
|
|
2863
|
+
self.device = device
|
|
2864
|
+
|
|
2865
|
+
def add_device(self, value):
|
|
2866
|
+
self.device.append(value)
|
|
2867
|
+
|
|
2868
|
+
def insert_device_at(self, index, value):
|
|
2869
|
+
self.device.insert(index, value)
|
|
2870
|
+
|
|
2871
|
+
def replace_device_at(self, index, value):
|
|
2872
|
+
self.device[index] = value
|
|
2873
|
+
|
|
2874
|
+
def has__content(self):
|
|
2875
|
+
if self.device:
|
|
2876
|
+
return True
|
|
2877
|
+
else:
|
|
2878
|
+
return False
|
|
2879
|
+
|
|
2880
|
+
def export(
|
|
2881
|
+
self,
|
|
2882
|
+
outfile,
|
|
2883
|
+
level,
|
|
2884
|
+
namespaceprefix_="",
|
|
2885
|
+
namespacedef_='xmlns:tns="urn:schemas-upnp-org:device-1-0" xmlns:None="urn:schemas-upnp-org:device-1-0" ',
|
|
2886
|
+
name_="DeviceListType",
|
|
2887
|
+
pretty_print=True,
|
|
2888
|
+
):
|
|
2889
|
+
imported_ns_def_ = GenerateDSNamespaceDefs_.get("DeviceListType")
|
|
2890
|
+
if imported_ns_def_ is not None:
|
|
2891
|
+
namespacedef_ = imported_ns_def_
|
|
2892
|
+
if pretty_print:
|
|
2893
|
+
eol_ = "\n"
|
|
2894
|
+
else:
|
|
2895
|
+
eol_ = ""
|
|
2896
|
+
if self.original_tagname_ is not None and name_ == "DeviceListType":
|
|
2897
|
+
name_ = self.original_tagname_
|
|
2898
|
+
if UseCapturedNS_ and self.ns_prefix_:
|
|
2899
|
+
namespaceprefix_ = self.ns_prefix_ + ":"
|
|
2900
|
+
showIndent(outfile, level, pretty_print)
|
|
2901
|
+
outfile.write(
|
|
2902
|
+
"<%s%s%s"
|
|
2903
|
+
% (
|
|
2904
|
+
namespaceprefix_,
|
|
2905
|
+
name_,
|
|
2906
|
+
namespacedef_ and " " + namespacedef_ or "",
|
|
2907
|
+
)
|
|
2908
|
+
)
|
|
2909
|
+
already_processed = set()
|
|
2910
|
+
self._exportAttributes(
|
|
2911
|
+
outfile,
|
|
2912
|
+
level,
|
|
2913
|
+
already_processed,
|
|
2914
|
+
namespaceprefix_,
|
|
2915
|
+
name_="DeviceListType",
|
|
2916
|
+
)
|
|
2917
|
+
if self.has__content():
|
|
2918
|
+
outfile.write(">%s" % (eol_,))
|
|
2919
|
+
self._exportChildren(
|
|
2920
|
+
outfile,
|
|
2921
|
+
level + 1,
|
|
2922
|
+
namespaceprefix_,
|
|
2923
|
+
namespacedef_,
|
|
2924
|
+
name_="DeviceListType",
|
|
2925
|
+
pretty_print=pretty_print,
|
|
2926
|
+
)
|
|
2927
|
+
showIndent(outfile, level, pretty_print)
|
|
2928
|
+
outfile.write("</%s%s>%s" % (namespaceprefix_, name_, eol_))
|
|
2929
|
+
else:
|
|
2930
|
+
outfile.write("/>%s" % (eol_,))
|
|
2931
|
+
|
|
2932
|
+
def _exportAttributes(
|
|
2933
|
+
self,
|
|
2934
|
+
outfile,
|
|
2935
|
+
level,
|
|
2936
|
+
already_processed,
|
|
2937
|
+
namespaceprefix_="",
|
|
2938
|
+
name_="DeviceListType",
|
|
2939
|
+
):
|
|
2940
|
+
pass
|
|
2941
|
+
|
|
2942
|
+
def _exportChildren(
|
|
2943
|
+
self,
|
|
2944
|
+
outfile,
|
|
2945
|
+
level,
|
|
2946
|
+
namespaceprefix_="",
|
|
2947
|
+
namespacedef_='xmlns:tns="urn:schemas-upnp-org:device-1-0" xmlns:None="urn:schemas-upnp-org:device-1-0" ',
|
|
2948
|
+
name_="DeviceListType",
|
|
2949
|
+
fromsubclass_=False,
|
|
2950
|
+
pretty_print=True,
|
|
2951
|
+
):
|
|
2952
|
+
if pretty_print:
|
|
2953
|
+
eol_ = "\n"
|
|
2954
|
+
else:
|
|
2955
|
+
eol_ = ""
|
|
2956
|
+
for device_ in self.device:
|
|
2957
|
+
namespaceprefix_ = (
|
|
2958
|
+
self.device_nsprefix_ + ":"
|
|
2959
|
+
if (UseCapturedNS_ and self.device_nsprefix_)
|
|
2960
|
+
else ""
|
|
2961
|
+
)
|
|
2962
|
+
device_.export(
|
|
2963
|
+
outfile,
|
|
2964
|
+
level,
|
|
2965
|
+
namespaceprefix_,
|
|
2966
|
+
namespacedef_="",
|
|
2967
|
+
name_="device",
|
|
2968
|
+
pretty_print=pretty_print,
|
|
2969
|
+
)
|
|
2970
|
+
|
|
2971
|
+
def build(self, node, gds_collector_=None):
|
|
2972
|
+
self.gds_collector_ = gds_collector_
|
|
2973
|
+
if SaveElementTreeNode:
|
|
2974
|
+
self.gds_elementtree_node_ = node
|
|
2975
|
+
already_processed = set()
|
|
2976
|
+
self.ns_prefix_ = node.prefix
|
|
2977
|
+
self._buildAttributes(node, node.attrib, already_processed)
|
|
2978
|
+
for child in node:
|
|
2979
|
+
nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
|
|
2980
|
+
self._buildChildren(
|
|
2981
|
+
child, node, nodeName_, gds_collector_=gds_collector_
|
|
2982
|
+
)
|
|
2983
|
+
return self
|
|
2984
|
+
|
|
2985
|
+
def _buildAttributes(self, node, attrs, already_processed):
|
|
2986
|
+
pass
|
|
2987
|
+
|
|
2988
|
+
def _buildChildren(
|
|
2989
|
+
self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None
|
|
2990
|
+
):
|
|
2991
|
+
if nodeName_ == "device":
|
|
2992
|
+
obj_ = DeviceType.factory(parent_object_=self)
|
|
2993
|
+
obj_.build(child_, gds_collector_=gds_collector_)
|
|
2994
|
+
self.device.append(obj_)
|
|
2995
|
+
obj_.original_tagname_ = "device"
|
|
2996
|
+
|
|
2997
|
+
|
|
2998
|
+
# end class DeviceListType
|
|
2999
|
+
|
|
3000
|
+
|
|
3001
|
+
class iconType(GeneratedsSuper):
|
|
3002
|
+
__hash__ = GeneratedsSuper.__hash__
|
|
3003
|
+
subclass = None
|
|
3004
|
+
superclass = None
|
|
3005
|
+
|
|
3006
|
+
def __init__(
|
|
3007
|
+
self,
|
|
3008
|
+
mimetype=None,
|
|
3009
|
+
width=None,
|
|
3010
|
+
height=None,
|
|
3011
|
+
depth=None,
|
|
3012
|
+
url=None,
|
|
3013
|
+
gds_collector_=None,
|
|
3014
|
+
**kwargs_
|
|
3015
|
+
):
|
|
3016
|
+
self.gds_collector_ = gds_collector_
|
|
3017
|
+
self.gds_elementtree_node_ = None
|
|
3018
|
+
self.original_tagname_ = None
|
|
3019
|
+
self.parent_object_ = kwargs_.get("parent_object_")
|
|
3020
|
+
self.ns_prefix_ = None
|
|
3021
|
+
self.mimetype = mimetype
|
|
3022
|
+
self.mimetype_nsprefix_ = None
|
|
3023
|
+
self.width = width
|
|
3024
|
+
self.width_nsprefix_ = None
|
|
3025
|
+
self.height = height
|
|
3026
|
+
self.height_nsprefix_ = None
|
|
3027
|
+
self.depth = depth
|
|
3028
|
+
self.depth_nsprefix_ = None
|
|
3029
|
+
self.url = url
|
|
3030
|
+
self.url_nsprefix_ = None
|
|
3031
|
+
|
|
3032
|
+
def factory(*args_, **kwargs_):
|
|
3033
|
+
if CurrentSubclassModule_ is not None:
|
|
3034
|
+
subclass = getSubclassFromModule_(CurrentSubclassModule_, iconType)
|
|
3035
|
+
if subclass is not None:
|
|
3036
|
+
return subclass(*args_, **kwargs_)
|
|
3037
|
+
if iconType.subclass:
|
|
3038
|
+
return iconType.subclass(*args_, **kwargs_)
|
|
3039
|
+
else:
|
|
3040
|
+
return iconType(*args_, **kwargs_)
|
|
3041
|
+
|
|
3042
|
+
factory = staticmethod(factory)
|
|
3043
|
+
|
|
3044
|
+
def get_ns_prefix_(self):
|
|
3045
|
+
return self.ns_prefix_
|
|
3046
|
+
|
|
3047
|
+
def set_ns_prefix_(self, ns_prefix):
|
|
3048
|
+
self.ns_prefix_ = ns_prefix
|
|
3049
|
+
|
|
3050
|
+
def get_mimetype(self):
|
|
3051
|
+
return self.mimetype
|
|
3052
|
+
|
|
3053
|
+
def set_mimetype(self, mimetype):
|
|
3054
|
+
self.mimetype = mimetype
|
|
3055
|
+
|
|
3056
|
+
def get_width(self):
|
|
3057
|
+
return self.width
|
|
3058
|
+
|
|
3059
|
+
def set_width(self, width):
|
|
3060
|
+
self.width = width
|
|
3061
|
+
|
|
3062
|
+
def get_height(self):
|
|
3063
|
+
return self.height
|
|
3064
|
+
|
|
3065
|
+
def set_height(self, height):
|
|
3066
|
+
self.height = height
|
|
3067
|
+
|
|
3068
|
+
def get_depth(self):
|
|
3069
|
+
return self.depth
|
|
3070
|
+
|
|
3071
|
+
def set_depth(self, depth):
|
|
3072
|
+
self.depth = depth
|
|
3073
|
+
|
|
3074
|
+
def get_url(self):
|
|
3075
|
+
return self.url
|
|
3076
|
+
|
|
3077
|
+
def set_url(self, url):
|
|
3078
|
+
self.url = url
|
|
3079
|
+
|
|
3080
|
+
def has__content(self):
|
|
3081
|
+
if (
|
|
3082
|
+
self.mimetype is not None
|
|
3083
|
+
or self.width is not None
|
|
3084
|
+
or self.height is not None
|
|
3085
|
+
or self.depth is not None
|
|
3086
|
+
or self.url is not None
|
|
3087
|
+
):
|
|
3088
|
+
return True
|
|
3089
|
+
else:
|
|
3090
|
+
return False
|
|
3091
|
+
|
|
3092
|
+
def export(
|
|
3093
|
+
self,
|
|
3094
|
+
outfile,
|
|
3095
|
+
level,
|
|
3096
|
+
namespaceprefix_="",
|
|
3097
|
+
namespacedef_='xmlns:tns="urn:schemas-upnp-org:device-1-0" xmlns:None="urn:schemas-upnp-org:device-1-0" ',
|
|
3098
|
+
name_="iconType",
|
|
3099
|
+
pretty_print=True,
|
|
3100
|
+
):
|
|
3101
|
+
imported_ns_def_ = GenerateDSNamespaceDefs_.get("iconType")
|
|
3102
|
+
if imported_ns_def_ is not None:
|
|
3103
|
+
namespacedef_ = imported_ns_def_
|
|
3104
|
+
if pretty_print:
|
|
3105
|
+
eol_ = "\n"
|
|
3106
|
+
else:
|
|
3107
|
+
eol_ = ""
|
|
3108
|
+
if self.original_tagname_ is not None and name_ == "iconType":
|
|
3109
|
+
name_ = self.original_tagname_
|
|
3110
|
+
if UseCapturedNS_ and self.ns_prefix_:
|
|
3111
|
+
namespaceprefix_ = self.ns_prefix_ + ":"
|
|
3112
|
+
showIndent(outfile, level, pretty_print)
|
|
3113
|
+
outfile.write(
|
|
3114
|
+
"<%s%s%s"
|
|
3115
|
+
% (
|
|
3116
|
+
namespaceprefix_,
|
|
3117
|
+
name_,
|
|
3118
|
+
namespacedef_ and " " + namespacedef_ or "",
|
|
3119
|
+
)
|
|
3120
|
+
)
|
|
3121
|
+
already_processed = set()
|
|
3122
|
+
self._exportAttributes(
|
|
3123
|
+
outfile,
|
|
3124
|
+
level,
|
|
3125
|
+
already_processed,
|
|
3126
|
+
namespaceprefix_,
|
|
3127
|
+
name_="iconType",
|
|
3128
|
+
)
|
|
3129
|
+
if self.has__content():
|
|
3130
|
+
outfile.write(">%s" % (eol_,))
|
|
3131
|
+
self._exportChildren(
|
|
3132
|
+
outfile,
|
|
3133
|
+
level + 1,
|
|
3134
|
+
namespaceprefix_,
|
|
3135
|
+
namespacedef_,
|
|
3136
|
+
name_="iconType",
|
|
3137
|
+
pretty_print=pretty_print,
|
|
3138
|
+
)
|
|
3139
|
+
showIndent(outfile, level, pretty_print)
|
|
3140
|
+
outfile.write("</%s%s>%s" % (namespaceprefix_, name_, eol_))
|
|
3141
|
+
else:
|
|
3142
|
+
outfile.write("/>%s" % (eol_,))
|
|
3143
|
+
|
|
3144
|
+
def _exportAttributes(
|
|
3145
|
+
self,
|
|
3146
|
+
outfile,
|
|
3147
|
+
level,
|
|
3148
|
+
already_processed,
|
|
3149
|
+
namespaceprefix_="",
|
|
3150
|
+
name_="iconType",
|
|
3151
|
+
):
|
|
3152
|
+
pass
|
|
3153
|
+
|
|
3154
|
+
def _exportChildren(
|
|
3155
|
+
self,
|
|
3156
|
+
outfile,
|
|
3157
|
+
level,
|
|
3158
|
+
namespaceprefix_="",
|
|
3159
|
+
namespacedef_='xmlns:tns="urn:schemas-upnp-org:device-1-0" xmlns:None="urn:schemas-upnp-org:device-1-0" ',
|
|
3160
|
+
name_="iconType",
|
|
3161
|
+
fromsubclass_=False,
|
|
3162
|
+
pretty_print=True,
|
|
3163
|
+
):
|
|
3164
|
+
if pretty_print:
|
|
3165
|
+
eol_ = "\n"
|
|
3166
|
+
else:
|
|
3167
|
+
eol_ = ""
|
|
3168
|
+
if self.mimetype is not None:
|
|
3169
|
+
namespaceprefix_ = (
|
|
3170
|
+
self.mimetype_nsprefix_ + ":"
|
|
3171
|
+
if (UseCapturedNS_ and self.mimetype_nsprefix_)
|
|
3172
|
+
else ""
|
|
3173
|
+
)
|
|
3174
|
+
showIndent(outfile, level, pretty_print)
|
|
3175
|
+
outfile.write(
|
|
3176
|
+
"<%smimetype>%s</%smimetype>%s"
|
|
3177
|
+
% (
|
|
3178
|
+
namespaceprefix_,
|
|
3179
|
+
self.gds_encode(
|
|
3180
|
+
self.gds_format_string(
|
|
3181
|
+
quote_xml(self.mimetype), input_name="mimetype"
|
|
3182
|
+
)
|
|
3183
|
+
),
|
|
3184
|
+
namespaceprefix_,
|
|
3185
|
+
eol_,
|
|
3186
|
+
)
|
|
3187
|
+
)
|
|
3188
|
+
if self.width is not None:
|
|
3189
|
+
namespaceprefix_ = (
|
|
3190
|
+
self.width_nsprefix_ + ":"
|
|
3191
|
+
if (UseCapturedNS_ and self.width_nsprefix_)
|
|
3192
|
+
else ""
|
|
3193
|
+
)
|
|
3194
|
+
showIndent(outfile, level, pretty_print)
|
|
3195
|
+
outfile.write(
|
|
3196
|
+
"<%swidth>%s</%swidth>%s"
|
|
3197
|
+
% (
|
|
3198
|
+
namespaceprefix_,
|
|
3199
|
+
self.gds_format_integer(self.width, input_name="width"),
|
|
3200
|
+
namespaceprefix_,
|
|
3201
|
+
eol_,
|
|
3202
|
+
)
|
|
3203
|
+
)
|
|
3204
|
+
if self.height is not None:
|
|
3205
|
+
namespaceprefix_ = (
|
|
3206
|
+
self.height_nsprefix_ + ":"
|
|
3207
|
+
if (UseCapturedNS_ and self.height_nsprefix_)
|
|
3208
|
+
else ""
|
|
3209
|
+
)
|
|
3210
|
+
showIndent(outfile, level, pretty_print)
|
|
3211
|
+
outfile.write(
|
|
3212
|
+
"<%sheight>%s</%sheight>%s"
|
|
3213
|
+
% (
|
|
3214
|
+
namespaceprefix_,
|
|
3215
|
+
self.gds_format_integer(self.height, input_name="height"),
|
|
3216
|
+
namespaceprefix_,
|
|
3217
|
+
eol_,
|
|
3218
|
+
)
|
|
3219
|
+
)
|
|
3220
|
+
if self.depth is not None:
|
|
3221
|
+
namespaceprefix_ = (
|
|
3222
|
+
self.depth_nsprefix_ + ":"
|
|
3223
|
+
if (UseCapturedNS_ and self.depth_nsprefix_)
|
|
3224
|
+
else ""
|
|
3225
|
+
)
|
|
3226
|
+
showIndent(outfile, level, pretty_print)
|
|
3227
|
+
outfile.write(
|
|
3228
|
+
"<%sdepth>%s</%sdepth>%s"
|
|
3229
|
+
% (
|
|
3230
|
+
namespaceprefix_,
|
|
3231
|
+
self.gds_format_integer(self.depth, input_name="depth"),
|
|
3232
|
+
namespaceprefix_,
|
|
3233
|
+
eol_,
|
|
3234
|
+
)
|
|
3235
|
+
)
|
|
3236
|
+
if self.url is not None:
|
|
3237
|
+
namespaceprefix_ = (
|
|
3238
|
+
self.url_nsprefix_ + ":"
|
|
3239
|
+
if (UseCapturedNS_ and self.url_nsprefix_)
|
|
3240
|
+
else ""
|
|
3241
|
+
)
|
|
3242
|
+
showIndent(outfile, level, pretty_print)
|
|
3243
|
+
outfile.write(
|
|
3244
|
+
"<%surl>%s</%surl>%s"
|
|
3245
|
+
% (
|
|
3246
|
+
namespaceprefix_,
|
|
3247
|
+
self.gds_encode(
|
|
3248
|
+
self.gds_format_string(
|
|
3249
|
+
quote_xml(self.url), input_name="url"
|
|
3250
|
+
)
|
|
3251
|
+
),
|
|
3252
|
+
namespaceprefix_,
|
|
3253
|
+
eol_,
|
|
3254
|
+
)
|
|
3255
|
+
)
|
|
3256
|
+
|
|
3257
|
+
def build(self, node, gds_collector_=None):
|
|
3258
|
+
self.gds_collector_ = gds_collector_
|
|
3259
|
+
if SaveElementTreeNode:
|
|
3260
|
+
self.gds_elementtree_node_ = node
|
|
3261
|
+
already_processed = set()
|
|
3262
|
+
self.ns_prefix_ = node.prefix
|
|
3263
|
+
self._buildAttributes(node, node.attrib, already_processed)
|
|
3264
|
+
for child in node:
|
|
3265
|
+
nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
|
|
3266
|
+
self._buildChildren(
|
|
3267
|
+
child, node, nodeName_, gds_collector_=gds_collector_
|
|
3268
|
+
)
|
|
3269
|
+
return self
|
|
3270
|
+
|
|
3271
|
+
def _buildAttributes(self, node, attrs, already_processed):
|
|
3272
|
+
pass
|
|
3273
|
+
|
|
3274
|
+
def _buildChildren(
|
|
3275
|
+
self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None
|
|
3276
|
+
):
|
|
3277
|
+
if nodeName_ == "mimetype":
|
|
3278
|
+
value_ = child_.text
|
|
3279
|
+
value_ = self.gds_parse_string(value_, node, "mimetype")
|
|
3280
|
+
value_ = self.gds_validate_string(value_, node, "mimetype")
|
|
3281
|
+
self.mimetype = value_
|
|
3282
|
+
self.mimetype_nsprefix_ = child_.prefix
|
|
3283
|
+
elif nodeName_ == "width" and child_.text:
|
|
3284
|
+
sval_ = child_.text
|
|
3285
|
+
ival_ = self.gds_parse_integer(sval_, node, "width")
|
|
3286
|
+
ival_ = self.gds_validate_integer(ival_, node, "width")
|
|
3287
|
+
self.width = ival_
|
|
3288
|
+
self.width_nsprefix_ = child_.prefix
|
|
3289
|
+
elif nodeName_ == "height" and child_.text:
|
|
3290
|
+
sval_ = child_.text
|
|
3291
|
+
ival_ = self.gds_parse_integer(sval_, node, "height")
|
|
3292
|
+
ival_ = self.gds_validate_integer(ival_, node, "height")
|
|
3293
|
+
self.height = ival_
|
|
3294
|
+
self.height_nsprefix_ = child_.prefix
|
|
3295
|
+
elif nodeName_ == "depth" and child_.text:
|
|
3296
|
+
sval_ = child_.text
|
|
3297
|
+
ival_ = self.gds_parse_integer(sval_, node, "depth")
|
|
3298
|
+
ival_ = self.gds_validate_integer(ival_, node, "depth")
|
|
3299
|
+
self.depth = ival_
|
|
3300
|
+
self.depth_nsprefix_ = child_.prefix
|
|
3301
|
+
elif nodeName_ == "url":
|
|
3302
|
+
value_ = child_.text
|
|
3303
|
+
value_ = self.gds_parse_string(value_, node, "url")
|
|
3304
|
+
value_ = self.gds_validate_string(value_, node, "url")
|
|
3305
|
+
self.url = value_
|
|
3306
|
+
self.url_nsprefix_ = child_.prefix
|
|
3307
|
+
|
|
3308
|
+
|
|
3309
|
+
# end class iconType
|
|
3310
|
+
|
|
3311
|
+
|
|
3312
|
+
class serviceType(GeneratedsSuper):
|
|
3313
|
+
__hash__ = GeneratedsSuper.__hash__
|
|
3314
|
+
subclass = None
|
|
3315
|
+
superclass = None
|
|
3316
|
+
|
|
3317
|
+
def __init__(
|
|
3318
|
+
self,
|
|
3319
|
+
serviceType_member=None,
|
|
3320
|
+
serviceId=None,
|
|
3321
|
+
SCPDURL=None,
|
|
3322
|
+
controlURL=None,
|
|
3323
|
+
eventSubURL=None,
|
|
3324
|
+
gds_collector_=None,
|
|
3325
|
+
**kwargs_
|
|
3326
|
+
):
|
|
3327
|
+
self.gds_collector_ = gds_collector_
|
|
3328
|
+
self.gds_elementtree_node_ = None
|
|
3329
|
+
self.original_tagname_ = None
|
|
3330
|
+
self.parent_object_ = kwargs_.get("parent_object_")
|
|
3331
|
+
self.ns_prefix_ = None
|
|
3332
|
+
self.serviceType = serviceType_member
|
|
3333
|
+
self.serviceType_nsprefix_ = None
|
|
3334
|
+
self.serviceId = serviceId
|
|
3335
|
+
self.serviceId_nsprefix_ = None
|
|
3336
|
+
self.SCPDURL = SCPDURL
|
|
3337
|
+
self.SCPDURL_nsprefix_ = None
|
|
3338
|
+
self.controlURL = controlURL
|
|
3339
|
+
self.controlURL_nsprefix_ = None
|
|
3340
|
+
self.eventSubURL = eventSubURL
|
|
3341
|
+
self.eventSubURL_nsprefix_ = None
|
|
3342
|
+
|
|
3343
|
+
def factory(*args_, **kwargs_):
|
|
3344
|
+
if CurrentSubclassModule_ is not None:
|
|
3345
|
+
subclass = getSubclassFromModule_(
|
|
3346
|
+
CurrentSubclassModule_, serviceType
|
|
3347
|
+
)
|
|
3348
|
+
if subclass is not None:
|
|
3349
|
+
return subclass(*args_, **kwargs_)
|
|
3350
|
+
if serviceType.subclass:
|
|
3351
|
+
return serviceType.subclass(*args_, **kwargs_)
|
|
3352
|
+
else:
|
|
3353
|
+
return serviceType(*args_, **kwargs_)
|
|
3354
|
+
|
|
3355
|
+
factory = staticmethod(factory)
|
|
3356
|
+
|
|
3357
|
+
def get_ns_prefix_(self):
|
|
3358
|
+
return self.ns_prefix_
|
|
3359
|
+
|
|
3360
|
+
def set_ns_prefix_(self, ns_prefix):
|
|
3361
|
+
self.ns_prefix_ = ns_prefix
|
|
3362
|
+
|
|
3363
|
+
def get_serviceType(self):
|
|
3364
|
+
return self.serviceType
|
|
3365
|
+
|
|
3366
|
+
def set_serviceType(self, serviceType):
|
|
3367
|
+
self.serviceType = serviceType
|
|
3368
|
+
|
|
3369
|
+
def get_serviceId(self):
|
|
3370
|
+
return self.serviceId
|
|
3371
|
+
|
|
3372
|
+
def set_serviceId(self, serviceId):
|
|
3373
|
+
self.serviceId = serviceId
|
|
3374
|
+
|
|
3375
|
+
def get_SCPDURL(self):
|
|
3376
|
+
return self.SCPDURL
|
|
3377
|
+
|
|
3378
|
+
def set_SCPDURL(self, SCPDURL):
|
|
3379
|
+
self.SCPDURL = SCPDURL
|
|
3380
|
+
|
|
3381
|
+
def get_controlURL(self):
|
|
3382
|
+
return self.controlURL
|
|
3383
|
+
|
|
3384
|
+
def set_controlURL(self, controlURL):
|
|
3385
|
+
self.controlURL = controlURL
|
|
3386
|
+
|
|
3387
|
+
def get_eventSubURL(self):
|
|
3388
|
+
return self.eventSubURL
|
|
3389
|
+
|
|
3390
|
+
def set_eventSubURL(self, eventSubURL):
|
|
3391
|
+
self.eventSubURL = eventSubURL
|
|
3392
|
+
|
|
3393
|
+
def has__content(self):
|
|
3394
|
+
if (
|
|
3395
|
+
self.serviceType is not None
|
|
3396
|
+
or self.serviceId is not None
|
|
3397
|
+
or self.SCPDURL is not None
|
|
3398
|
+
or self.controlURL is not None
|
|
3399
|
+
or self.eventSubURL is not None
|
|
3400
|
+
):
|
|
3401
|
+
return True
|
|
3402
|
+
else:
|
|
3403
|
+
return False
|
|
3404
|
+
|
|
3405
|
+
def export(
|
|
3406
|
+
self,
|
|
3407
|
+
outfile,
|
|
3408
|
+
level,
|
|
3409
|
+
namespaceprefix_="",
|
|
3410
|
+
namespacedef_='xmlns:tns="urn:schemas-upnp-org:device-1-0" xmlns:None="urn:schemas-upnp-org:device-1-0" ',
|
|
3411
|
+
name_="serviceType",
|
|
3412
|
+
pretty_print=True,
|
|
3413
|
+
):
|
|
3414
|
+
imported_ns_def_ = GenerateDSNamespaceDefs_.get("serviceType")
|
|
3415
|
+
if imported_ns_def_ is not None:
|
|
3416
|
+
namespacedef_ = imported_ns_def_
|
|
3417
|
+
if pretty_print:
|
|
3418
|
+
eol_ = "\n"
|
|
3419
|
+
else:
|
|
3420
|
+
eol_ = ""
|
|
3421
|
+
if self.original_tagname_ is not None and name_ == "serviceType":
|
|
3422
|
+
name_ = self.original_tagname_
|
|
3423
|
+
if UseCapturedNS_ and self.ns_prefix_:
|
|
3424
|
+
namespaceprefix_ = self.ns_prefix_ + ":"
|
|
3425
|
+
showIndent(outfile, level, pretty_print)
|
|
3426
|
+
outfile.write(
|
|
3427
|
+
"<%s%s%s"
|
|
3428
|
+
% (
|
|
3429
|
+
namespaceprefix_,
|
|
3430
|
+
name_,
|
|
3431
|
+
namespacedef_ and " " + namespacedef_ or "",
|
|
3432
|
+
)
|
|
3433
|
+
)
|
|
3434
|
+
already_processed = set()
|
|
3435
|
+
self._exportAttributes(
|
|
3436
|
+
outfile,
|
|
3437
|
+
level,
|
|
3438
|
+
already_processed,
|
|
3439
|
+
namespaceprefix_,
|
|
3440
|
+
name_="serviceType",
|
|
3441
|
+
)
|
|
3442
|
+
if self.has__content():
|
|
3443
|
+
outfile.write(">%s" % (eol_,))
|
|
3444
|
+
self._exportChildren(
|
|
3445
|
+
outfile,
|
|
3446
|
+
level + 1,
|
|
3447
|
+
namespaceprefix_,
|
|
3448
|
+
namespacedef_,
|
|
3449
|
+
name_="serviceType",
|
|
3450
|
+
pretty_print=pretty_print,
|
|
3451
|
+
)
|
|
3452
|
+
showIndent(outfile, level, pretty_print)
|
|
3453
|
+
outfile.write("</%s%s>%s" % (namespaceprefix_, name_, eol_))
|
|
3454
|
+
else:
|
|
3455
|
+
outfile.write("/>%s" % (eol_,))
|
|
3456
|
+
|
|
3457
|
+
def _exportAttributes(
|
|
3458
|
+
self,
|
|
3459
|
+
outfile,
|
|
3460
|
+
level,
|
|
3461
|
+
already_processed,
|
|
3462
|
+
namespaceprefix_="",
|
|
3463
|
+
name_="serviceType",
|
|
3464
|
+
):
|
|
3465
|
+
pass
|
|
3466
|
+
|
|
3467
|
+
def _exportChildren(
|
|
3468
|
+
self,
|
|
3469
|
+
outfile,
|
|
3470
|
+
level,
|
|
3471
|
+
namespaceprefix_="",
|
|
3472
|
+
namespacedef_='xmlns:tns="urn:schemas-upnp-org:device-1-0" xmlns:None="urn:schemas-upnp-org:device-1-0" ',
|
|
3473
|
+
name_="serviceType",
|
|
3474
|
+
fromsubclass_=False,
|
|
3475
|
+
pretty_print=True,
|
|
3476
|
+
):
|
|
3477
|
+
if pretty_print:
|
|
3478
|
+
eol_ = "\n"
|
|
3479
|
+
else:
|
|
3480
|
+
eol_ = ""
|
|
3481
|
+
if self.serviceType is not None:
|
|
3482
|
+
namespaceprefix_ = (
|
|
3483
|
+
self.serviceType_nsprefix_ + ":"
|
|
3484
|
+
if (UseCapturedNS_ and self.serviceType_nsprefix_)
|
|
3485
|
+
else ""
|
|
3486
|
+
)
|
|
3487
|
+
showIndent(outfile, level, pretty_print)
|
|
3488
|
+
outfile.write(
|
|
3489
|
+
"<%sserviceType>%s</%sserviceType>%s"
|
|
3490
|
+
% (
|
|
3491
|
+
namespaceprefix_,
|
|
3492
|
+
self.gds_encode(
|
|
3493
|
+
self.gds_format_string(
|
|
3494
|
+
quote_xml(self.serviceType),
|
|
3495
|
+
input_name="serviceType",
|
|
3496
|
+
)
|
|
3497
|
+
),
|
|
3498
|
+
namespaceprefix_,
|
|
3499
|
+
eol_,
|
|
3500
|
+
)
|
|
3501
|
+
)
|
|
3502
|
+
if self.serviceId is not None:
|
|
3503
|
+
namespaceprefix_ = (
|
|
3504
|
+
self.serviceId_nsprefix_ + ":"
|
|
3505
|
+
if (UseCapturedNS_ and self.serviceId_nsprefix_)
|
|
3506
|
+
else ""
|
|
3507
|
+
)
|
|
3508
|
+
showIndent(outfile, level, pretty_print)
|
|
3509
|
+
outfile.write(
|
|
3510
|
+
"<%sserviceId>%s</%sserviceId>%s"
|
|
3511
|
+
% (
|
|
3512
|
+
namespaceprefix_,
|
|
3513
|
+
self.gds_encode(
|
|
3514
|
+
self.gds_format_string(
|
|
3515
|
+
quote_xml(self.serviceId), input_name="serviceId"
|
|
3516
|
+
)
|
|
3517
|
+
),
|
|
3518
|
+
namespaceprefix_,
|
|
3519
|
+
eol_,
|
|
3520
|
+
)
|
|
3521
|
+
)
|
|
3522
|
+
if self.SCPDURL is not None:
|
|
3523
|
+
namespaceprefix_ = (
|
|
3524
|
+
self.SCPDURL_nsprefix_ + ":"
|
|
3525
|
+
if (UseCapturedNS_ and self.SCPDURL_nsprefix_)
|
|
3526
|
+
else ""
|
|
3527
|
+
)
|
|
3528
|
+
showIndent(outfile, level, pretty_print)
|
|
3529
|
+
outfile.write(
|
|
3530
|
+
"<%sSCPDURL>%s</%sSCPDURL>%s"
|
|
3531
|
+
% (
|
|
3532
|
+
namespaceprefix_,
|
|
3533
|
+
self.gds_encode(
|
|
3534
|
+
self.gds_format_string(
|
|
3535
|
+
quote_xml(self.SCPDURL), input_name="SCPDURL"
|
|
3536
|
+
)
|
|
3537
|
+
),
|
|
3538
|
+
namespaceprefix_,
|
|
3539
|
+
eol_,
|
|
3540
|
+
)
|
|
3541
|
+
)
|
|
3542
|
+
if self.controlURL is not None:
|
|
3543
|
+
namespaceprefix_ = (
|
|
3544
|
+
self.controlURL_nsprefix_ + ":"
|
|
3545
|
+
if (UseCapturedNS_ and self.controlURL_nsprefix_)
|
|
3546
|
+
else ""
|
|
3547
|
+
)
|
|
3548
|
+
showIndent(outfile, level, pretty_print)
|
|
3549
|
+
outfile.write(
|
|
3550
|
+
"<%scontrolURL>%s</%scontrolURL>%s"
|
|
3551
|
+
% (
|
|
3552
|
+
namespaceprefix_,
|
|
3553
|
+
self.gds_encode(
|
|
3554
|
+
self.gds_format_string(
|
|
3555
|
+
quote_xml(self.controlURL), input_name="controlURL"
|
|
3556
|
+
)
|
|
3557
|
+
),
|
|
3558
|
+
namespaceprefix_,
|
|
3559
|
+
eol_,
|
|
3560
|
+
)
|
|
3561
|
+
)
|
|
3562
|
+
if self.eventSubURL is not None:
|
|
3563
|
+
namespaceprefix_ = (
|
|
3564
|
+
self.eventSubURL_nsprefix_ + ":"
|
|
3565
|
+
if (UseCapturedNS_ and self.eventSubURL_nsprefix_)
|
|
3566
|
+
else ""
|
|
3567
|
+
)
|
|
3568
|
+
showIndent(outfile, level, pretty_print)
|
|
3569
|
+
outfile.write(
|
|
3570
|
+
"<%seventSubURL>%s</%seventSubURL>%s"
|
|
3571
|
+
% (
|
|
3572
|
+
namespaceprefix_,
|
|
3573
|
+
self.gds_encode(
|
|
3574
|
+
self.gds_format_string(
|
|
3575
|
+
quote_xml(self.eventSubURL),
|
|
3576
|
+
input_name="eventSubURL",
|
|
3577
|
+
)
|
|
3578
|
+
),
|
|
3579
|
+
namespaceprefix_,
|
|
3580
|
+
eol_,
|
|
3581
|
+
)
|
|
3582
|
+
)
|
|
3583
|
+
|
|
3584
|
+
def build(self, node, gds_collector_=None):
|
|
3585
|
+
self.gds_collector_ = gds_collector_
|
|
3586
|
+
if SaveElementTreeNode:
|
|
3587
|
+
self.gds_elementtree_node_ = node
|
|
3588
|
+
already_processed = set()
|
|
3589
|
+
self.ns_prefix_ = node.prefix
|
|
3590
|
+
self._buildAttributes(node, node.attrib, already_processed)
|
|
3591
|
+
for child in node:
|
|
3592
|
+
nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
|
|
3593
|
+
self._buildChildren(
|
|
3594
|
+
child, node, nodeName_, gds_collector_=gds_collector_
|
|
3595
|
+
)
|
|
3596
|
+
return self
|
|
3597
|
+
|
|
3598
|
+
def _buildAttributes(self, node, attrs, already_processed):
|
|
3599
|
+
pass
|
|
3600
|
+
|
|
3601
|
+
def _buildChildren(
|
|
3602
|
+
self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None
|
|
3603
|
+
):
|
|
3604
|
+
if nodeName_ == "serviceType":
|
|
3605
|
+
value_ = child_.text
|
|
3606
|
+
value_ = self.gds_parse_string(value_, node, "serviceType")
|
|
3607
|
+
value_ = self.gds_validate_string(value_, node, "serviceType")
|
|
3608
|
+
self.serviceType = value_
|
|
3609
|
+
self.serviceType_nsprefix_ = child_.prefix
|
|
3610
|
+
elif nodeName_ == "serviceId":
|
|
3611
|
+
value_ = child_.text
|
|
3612
|
+
value_ = self.gds_parse_string(value_, node, "serviceId")
|
|
3613
|
+
value_ = self.gds_validate_string(value_, node, "serviceId")
|
|
3614
|
+
self.serviceId = value_
|
|
3615
|
+
self.serviceId_nsprefix_ = child_.prefix
|
|
3616
|
+
elif nodeName_ == "SCPDURL":
|
|
3617
|
+
value_ = child_.text
|
|
3618
|
+
value_ = self.gds_parse_string(value_, node, "SCPDURL")
|
|
3619
|
+
value_ = self.gds_validate_string(value_, node, "SCPDURL")
|
|
3620
|
+
self.SCPDURL = value_
|
|
3621
|
+
self.SCPDURL_nsprefix_ = child_.prefix
|
|
3622
|
+
elif nodeName_ == "controlURL":
|
|
3623
|
+
value_ = child_.text
|
|
3624
|
+
value_ = self.gds_parse_string(value_, node, "controlURL")
|
|
3625
|
+
value_ = self.gds_validate_string(value_, node, "controlURL")
|
|
3626
|
+
self.controlURL = value_
|
|
3627
|
+
self.controlURL_nsprefix_ = child_.prefix
|
|
3628
|
+
elif nodeName_ == "eventSubURL":
|
|
3629
|
+
value_ = child_.text
|
|
3630
|
+
value_ = self.gds_parse_string(value_, node, "eventSubURL")
|
|
3631
|
+
value_ = self.gds_validate_string(value_, node, "eventSubURL")
|
|
3632
|
+
self.eventSubURL = value_
|
|
3633
|
+
self.eventSubURL_nsprefix_ = child_.prefix
|
|
3634
|
+
|
|
3635
|
+
|
|
3636
|
+
# end class serviceType
|
|
3637
|
+
|
|
3638
|
+
|
|
3639
|
+
#
|
|
3640
|
+
# End data representation classes.
|
|
3641
|
+
#
|
|
3642
|
+
|
|
3643
|
+
|
|
3644
|
+
GDSClassesMapping = {}
|
|
3645
|
+
|
|
3646
|
+
|
|
3647
|
+
USAGE_TEXT = """
|
|
3648
|
+
Usage: python <Parser>.py [ -s ] <in_xml_file>
|
|
3649
|
+
"""
|
|
3650
|
+
|
|
3651
|
+
|
|
3652
|
+
def usage():
|
|
3653
|
+
print(USAGE_TEXT)
|
|
3654
|
+
sys.exit(1)
|
|
3655
|
+
|
|
3656
|
+
|
|
3657
|
+
def get_root_tag(node):
|
|
3658
|
+
tag = Tag_pattern_.match(node.tag).groups()[-1]
|
|
3659
|
+
prefix_tag = TagNamePrefix + tag
|
|
3660
|
+
rootClass = GDSClassesMapping.get(prefix_tag)
|
|
3661
|
+
if rootClass is None:
|
|
3662
|
+
rootClass = globals().get(prefix_tag)
|
|
3663
|
+
return tag, rootClass
|
|
3664
|
+
|
|
3665
|
+
|
|
3666
|
+
def get_required_ns_prefix_defs(rootNode):
|
|
3667
|
+
"""Get all name space prefix definitions required in this XML doc.
|
|
3668
|
+
Return a dictionary of definitions and a char string of definitions.
|
|
3669
|
+
"""
|
|
3670
|
+
nsmap = {
|
|
3671
|
+
prefix: uri
|
|
3672
|
+
for node in rootNode.iter()
|
|
3673
|
+
for (prefix, uri) in node.nsmap.items()
|
|
3674
|
+
if prefix is not None
|
|
3675
|
+
}
|
|
3676
|
+
namespacedefs = " ".join(
|
|
3677
|
+
['xmlns:{}="{}"'.format(prefix, uri) for prefix, uri in nsmap.items()]
|
|
3678
|
+
)
|
|
3679
|
+
return nsmap, namespacedefs
|
|
3680
|
+
|
|
3681
|
+
|
|
3682
|
+
def parse(inFileName, silence=False, print_warnings=True):
|
|
3683
|
+
global CapturedNsmap_
|
|
3684
|
+
gds_collector = GdsCollector_()
|
|
3685
|
+
parser = None
|
|
3686
|
+
doc = parsexml_(inFileName, parser)
|
|
3687
|
+
rootNode = doc.getroot()
|
|
3688
|
+
rootTag, rootClass = get_root_tag(rootNode)
|
|
3689
|
+
if rootClass is None:
|
|
3690
|
+
rootTag = "root"
|
|
3691
|
+
rootClass = root
|
|
3692
|
+
rootObj = rootClass.factory()
|
|
3693
|
+
rootObj.build(rootNode, gds_collector_=gds_collector)
|
|
3694
|
+
CapturedNsmap_, namespacedefs = get_required_ns_prefix_defs(rootNode)
|
|
3695
|
+
if not SaveElementTreeNode:
|
|
3696
|
+
doc = None
|
|
3697
|
+
rootNode = None
|
|
3698
|
+
if not silence:
|
|
3699
|
+
sys.stdout.write('<?xml version="1.0" ?>\n')
|
|
3700
|
+
rootObj.export(
|
|
3701
|
+
sys.stdout,
|
|
3702
|
+
0,
|
|
3703
|
+
name_=rootTag,
|
|
3704
|
+
namespacedef_=namespacedefs,
|
|
3705
|
+
pretty_print=True,
|
|
3706
|
+
)
|
|
3707
|
+
if print_warnings and len(gds_collector.get_messages()) > 0:
|
|
3708
|
+
separator = ("-" * 50) + "\n"
|
|
3709
|
+
sys.stderr.write(separator)
|
|
3710
|
+
sys.stderr.write(
|
|
3711
|
+
"----- Warnings -- count: {} -----\n".format(
|
|
3712
|
+
len(gds_collector.get_messages()),
|
|
3713
|
+
)
|
|
3714
|
+
)
|
|
3715
|
+
gds_collector.write_messages(sys.stderr)
|
|
3716
|
+
sys.stderr.write(separator)
|
|
3717
|
+
return rootObj
|
|
3718
|
+
|
|
3719
|
+
|
|
3720
|
+
def parseEtree(
|
|
3721
|
+
inFileName,
|
|
3722
|
+
silence=False,
|
|
3723
|
+
print_warnings=True,
|
|
3724
|
+
mapping=None,
|
|
3725
|
+
reverse_mapping=None,
|
|
3726
|
+
nsmap=None,
|
|
3727
|
+
):
|
|
3728
|
+
parser = None
|
|
3729
|
+
doc = parsexml_(inFileName, parser)
|
|
3730
|
+
gds_collector = GdsCollector_()
|
|
3731
|
+
rootNode = doc.getroot()
|
|
3732
|
+
rootTag, rootClass = get_root_tag(rootNode)
|
|
3733
|
+
if rootClass is None:
|
|
3734
|
+
rootTag = "root"
|
|
3735
|
+
rootClass = root
|
|
3736
|
+
rootObj = rootClass.factory()
|
|
3737
|
+
rootObj.build(rootNode, gds_collector_=gds_collector)
|
|
3738
|
+
if mapping is None:
|
|
3739
|
+
mapping = {}
|
|
3740
|
+
if reverse_mapping is None:
|
|
3741
|
+
reverse_mapping = {}
|
|
3742
|
+
rootElement = rootObj.to_etree(
|
|
3743
|
+
None,
|
|
3744
|
+
name_=rootTag,
|
|
3745
|
+
mapping_=mapping,
|
|
3746
|
+
reverse_mapping_=reverse_mapping,
|
|
3747
|
+
nsmap_=nsmap,
|
|
3748
|
+
)
|
|
3749
|
+
reverse_node_mapping = rootObj.gds_reverse_node_mapping(mapping)
|
|
3750
|
+
# Enable Python to collect the space used by the DOM.
|
|
3751
|
+
if not SaveElementTreeNode:
|
|
3752
|
+
doc = None
|
|
3753
|
+
rootNode = None
|
|
3754
|
+
if not silence:
|
|
3755
|
+
content = etree_.tostring(
|
|
3756
|
+
rootElement,
|
|
3757
|
+
pretty_print=True,
|
|
3758
|
+
xml_declaration=True,
|
|
3759
|
+
encoding="utf-8",
|
|
3760
|
+
)
|
|
3761
|
+
sys.stdout.write(str(content))
|
|
3762
|
+
sys.stdout.write("\n")
|
|
3763
|
+
if print_warnings and len(gds_collector.get_messages()) > 0:
|
|
3764
|
+
separator = ("-" * 50) + "\n"
|
|
3765
|
+
sys.stderr.write(separator)
|
|
3766
|
+
sys.stderr.write(
|
|
3767
|
+
"----- Warnings -- count: {} -----\n".format(
|
|
3768
|
+
len(gds_collector.get_messages()),
|
|
3769
|
+
)
|
|
3770
|
+
)
|
|
3771
|
+
gds_collector.write_messages(sys.stderr)
|
|
3772
|
+
sys.stderr.write(separator)
|
|
3773
|
+
return rootObj, rootElement, mapping, reverse_node_mapping
|
|
3774
|
+
|
|
3775
|
+
|
|
3776
|
+
def parseString(inString, silence=False, print_warnings=True):
|
|
3777
|
+
"""Parse a string, create the object tree, and export it.
|
|
3778
|
+
|
|
3779
|
+
Arguments:
|
|
3780
|
+
- inString -- A string. This XML fragment should not start
|
|
3781
|
+
with an XML declaration containing an encoding.
|
|
3782
|
+
- silence -- A boolean. If False, export the object.
|
|
3783
|
+
Returns -- The root object in the tree.
|
|
3784
|
+
"""
|
|
3785
|
+
parser = None
|
|
3786
|
+
rootNode = parsexmlstring_(inString, parser)
|
|
3787
|
+
gds_collector = GdsCollector_()
|
|
3788
|
+
rootTag, rootClass = get_root_tag(rootNode)
|
|
3789
|
+
if rootClass is None:
|
|
3790
|
+
rootTag = "root"
|
|
3791
|
+
rootClass = root
|
|
3792
|
+
rootObj = rootClass.factory()
|
|
3793
|
+
rootObj.build(rootNode, gds_collector_=gds_collector)
|
|
3794
|
+
if not SaveElementTreeNode:
|
|
3795
|
+
rootNode = None
|
|
3796
|
+
if not silence:
|
|
3797
|
+
sys.stdout.write('<?xml version="1.0" ?>\n')
|
|
3798
|
+
rootObj.export(
|
|
3799
|
+
sys.stdout,
|
|
3800
|
+
0,
|
|
3801
|
+
name_=rootTag,
|
|
3802
|
+
namespacedef_='xmlns:tns="urn:schemas-upnp-org:device-1-0"',
|
|
3803
|
+
)
|
|
3804
|
+
if print_warnings and len(gds_collector.get_messages()) > 0:
|
|
3805
|
+
separator = ("-" * 50) + "\n"
|
|
3806
|
+
sys.stderr.write(separator)
|
|
3807
|
+
sys.stderr.write(
|
|
3808
|
+
"----- Warnings -- count: {} -----\n".format(
|
|
3809
|
+
len(gds_collector.get_messages()),
|
|
3810
|
+
)
|
|
3811
|
+
)
|
|
3812
|
+
gds_collector.write_messages(sys.stderr)
|
|
3813
|
+
sys.stderr.write(separator)
|
|
3814
|
+
return rootObj
|
|
3815
|
+
|
|
3816
|
+
|
|
3817
|
+
def parseLiteral(inFileName, silence=False, print_warnings=True):
|
|
3818
|
+
parser = None
|
|
3819
|
+
doc = parsexml_(inFileName, parser)
|
|
3820
|
+
gds_collector = GdsCollector_()
|
|
3821
|
+
rootNode = doc.getroot()
|
|
3822
|
+
rootTag, rootClass = get_root_tag(rootNode)
|
|
3823
|
+
if rootClass is None:
|
|
3824
|
+
rootTag = "root"
|
|
3825
|
+
rootClass = root
|
|
3826
|
+
rootObj = rootClass.factory()
|
|
3827
|
+
rootObj.build(rootNode, gds_collector_=gds_collector)
|
|
3828
|
+
# Enable Python to collect the space used by the DOM.
|
|
3829
|
+
if not SaveElementTreeNode:
|
|
3830
|
+
doc = None
|
|
3831
|
+
rootNode = None
|
|
3832
|
+
if not silence:
|
|
3833
|
+
sys.stdout.write("#from device import *\n\n")
|
|
3834
|
+
sys.stdout.write("import device as model_\n\n")
|
|
3835
|
+
sys.stdout.write("rootObj = model_.rootClass(\n")
|
|
3836
|
+
rootObj.exportLiteral(sys.stdout, 0, name_=rootTag)
|
|
3837
|
+
sys.stdout.write(")\n")
|
|
3838
|
+
if print_warnings and len(gds_collector.get_messages()) > 0:
|
|
3839
|
+
separator = ("-" * 50) + "\n"
|
|
3840
|
+
sys.stderr.write(separator)
|
|
3841
|
+
sys.stderr.write(
|
|
3842
|
+
"----- Warnings -- count: {} -----\n".format(
|
|
3843
|
+
len(gds_collector.get_messages()),
|
|
3844
|
+
)
|
|
3845
|
+
)
|
|
3846
|
+
gds_collector.write_messages(sys.stderr)
|
|
3847
|
+
sys.stderr.write(separator)
|
|
3848
|
+
return rootObj
|
|
3849
|
+
|
|
3850
|
+
|
|
3851
|
+
def main():
|
|
3852
|
+
args = sys.argv[1:]
|
|
3853
|
+
if len(args) == 1:
|
|
3854
|
+
parse(args[0])
|
|
3855
|
+
else:
|
|
3856
|
+
usage()
|
|
3857
|
+
|
|
3858
|
+
|
|
3859
|
+
if __name__ == "__main__":
|
|
3860
|
+
# import pdb; pdb.set_trace()
|
|
3861
|
+
main()
|
|
3862
|
+
|
|
3863
|
+
RenameMappings_ = {}
|
|
3864
|
+
|
|
3865
|
+
#
|
|
3866
|
+
# Mapping of namespaces to types defined in them
|
|
3867
|
+
# and the file in which each is defined.
|
|
3868
|
+
# simpleTypes are marked "ST" and complexTypes "CT".
|
|
3869
|
+
NamespaceToDefMappings_ = {
|
|
3870
|
+
"urn:schemas-upnp-org:device-1-0": [
|
|
3871
|
+
("SpecVersionType", "pywemo/ouimeaux_device/api/xsd/device.xsd", "CT"),
|
|
3872
|
+
("DeviceType", "pywemo/ouimeaux_device/api/xsd/device.xsd", "CT"),
|
|
3873
|
+
("IconListType", "pywemo/ouimeaux_device/api/xsd/device.xsd", "CT"),
|
|
3874
|
+
("ServiceListType", "pywemo/ouimeaux_device/api/xsd/device.xsd", "CT"),
|
|
3875
|
+
("DeviceListType", "pywemo/ouimeaux_device/api/xsd/device.xsd", "CT"),
|
|
3876
|
+
]
|
|
3877
|
+
}
|
|
3878
|
+
|
|
3879
|
+
__all__ = [
|
|
3880
|
+
"DeviceListType",
|
|
3881
|
+
"DeviceType",
|
|
3882
|
+
"IconListType",
|
|
3883
|
+
"ServiceListType",
|
|
3884
|
+
"SpecVersionType",
|
|
3885
|
+
"iconType",
|
|
3886
|
+
"root",
|
|
3887
|
+
"serviceType",
|
|
3888
|
+
]
|