Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def gds_parse_datetime(self, input_data, node, input_name=''):
tz = None
if input_data[-1] == 'Z':
tz = GeneratedsSuper._FixedOffsetTZ(0, 'GMT')
input_data = input_data[:-1]
else:
results = GeneratedsSuper.tzoff_pattern.search(input_data)
if results is not None:
tzoff_parts = results.group(2).split(':')
tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1])
if results.group(1) == '-':
tzoff *= -1
tz = GeneratedsSuper._FixedOffsetTZ(
tzoff, results.group(0))
input_data = input_data[:-6]
if len(input_data.split('.')) > 1:
dt = datetime.strptime(
input_data, '%Y-%m-%dT%H:%M:%S.%f')
else:
dt = datetime.strptime(
input_data, '%Y-%m-%dT%H:%M:%S')
return dt.replace(tzinfo = tz)
def gds_parse_date(self, input_data, node, input_name=''):
tz = None
if input_data[-1] == 'Z':
tz = GeneratedsSuper._FixedOffsetTZ(0, 'GMT')
input_data = input_data[:-1]
else:
results = GeneratedsSuper.tzoff_pattern.search(input_data)
if results is not None:
tzoff_parts = results.group(2).split(':')
tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1])
if results.group(1) == '-':
tzoff *= -1
tz = GeneratedsSuper._FixedOffsetTZ(
tzoff, results.group(0))
input_data = input_data[:-6]
return datetime.strptime(input_data,
'%Y-%m-%d').replace(tzinfo = tz)
def gds_str_lower(self, instring):
def build(self, node):
self.buildAttributes(node, node.attrib, [])
for child in node:
nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
self.buildChildren(child, node, nodeName_)
def buildAttributes(self, node, attrs, already_processed):
pass
def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
if nodeName_ == 'action':
obj_ = ActionType.factory()
obj_.build(child_)
self.action.append(obj_)
# end class ActionListType
class ActionType(GeneratedsSuper):
subclass = None
superclass = None
def __init__(self, name=None, argumentList=None):
self.name = name
self.argumentList = argumentList
def factory(*args_, **kwargs_):
if ActionType.subclass:
return ActionType.subclass(*args_, **kwargs_)
else:
return ActionType(*args_, **kwargs_)
factory = staticmethod(factory)
def get_name(self): return self.name
def set_name(self, name): self.name = name
def get_argumentList(self): return self.argumentList
def set_argumentList(self, argumentList): self.argumentList = argumentList
def export(self, outfile, level, namespace_='', name_='ActionType', namespacedef_='', pretty_print=True):
return 'xs:string'
else:
return self.data_type
def set_container(self, container): self.container = container
def get_container(self): return self.container
def _cast(typ, value):
if typ is None or value is None:
return value
return typ(value)
#
# Data representation classes.
#
class scpd(GeneratedsSuper):
subclass = None
superclass = None
def __init__(self, specVersion=None, actionList=None, serviceStateTable=None):
self.specVersion = specVersion
self.actionList = actionList
self.serviceStateTable = serviceStateTable
def factory(*args_, **kwargs_):
if scpd.subclass:
return scpd.subclass(*args_, **kwargs_)
else:
return scpd(*args_, **kwargs_)
factory = staticmethod(factory)
def get_specVersion(self): return self.specVersion
def set_specVersion(self, specVersion): self.specVersion = specVersion
def get_actionList(self): return self.actionList
def set_actionList(self, actionList): self.actionList = actionList
def build(self, node):
self.buildAttributes(node, node.attrib, [])
for child in node:
nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
self.buildChildren(child, node, nodeName_)
def buildAttributes(self, node, attrs, already_processed):
pass
def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
if nodeName_ == 'allowedValue':
allowedValue_ = child_.text
allowedValue_ = self.gds_validate_string(allowedValue_, node, 'allowedValue')
self.allowedValue.append(allowedValue_)
# end class AllowedValueListType
class AllowedValueRangeType(GeneratedsSuper):
subclass = None
superclass = None
def __init__(self, minimum=None, maximum=None, step=None):
self.minimum = minimum
self.maximum = maximum
self.step = step
def factory(*args_, **kwargs_):
if AllowedValueRangeType.subclass:
return AllowedValueRangeType.subclass(*args_, **kwargs_)
else:
return AllowedValueRangeType(*args_, **kwargs_)
factory = staticmethod(factory)
def get_minimum(self): return self.minimum
def set_minimum(self, minimum): self.minimum = minimum
def get_maximum(self): return self.maximum
def set_maximum(self, maximum): self.maximum = maximum
def build(self, node):
self.buildAttributes(node, node.attrib, [])
for child in node:
nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
self.buildChildren(child, node, nodeName_)
def buildAttributes(self, node, attrs, already_processed):
pass
def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
if nodeName_ == 'argument':
obj_ = ArgumentType.factory()
obj_.build(child_)
self.argument.append(obj_)
# end class ArgumentListType
class ArgumentType(GeneratedsSuper):
subclass = None
superclass = None
def __init__(self, name=None, direction=None, relatedStateVariable=None, retval=None):
self.name = name
self.direction = direction
self.relatedStateVariable = relatedStateVariable
self.retval = retval
def factory(*args_, **kwargs_):
if ArgumentType.subclass:
return ArgumentType.subclass(*args_, **kwargs_)
else:
return ArgumentType(*args_, **kwargs_)
factory = staticmethod(factory)
def get_name(self): return self.name
def set_name(self, name): self.name = name
def get_direction(self): return self.direction
elif nodeName_ == 'direction':
direction_ = child_.text
direction_ = self.gds_validate_string(direction_, node, 'direction')
self.direction = direction_
elif nodeName_ == 'relatedStateVariable':
relatedStateVariable_ = child_.text
relatedStateVariable_ = self.gds_validate_string(relatedStateVariable_, node, 'relatedStateVariable')
self.relatedStateVariable = relatedStateVariable_
elif nodeName_ == 'retval':
obj_ = retvalType.factory()
obj_.build(child_)
self.set_retval(obj_)
# end class ArgumentType
class ServiceStateTableType(GeneratedsSuper):
subclass = None
superclass = None
def __init__(self, stateVariable=None):
if stateVariable is None:
self.stateVariable = []
else:
self.stateVariable = stateVariable
def factory(*args_, **kwargs_):
if ServiceStateTableType.subclass:
return ServiceStateTableType.subclass(*args_, **kwargs_)
else:
return ServiceStateTableType(*args_, **kwargs_)
factory = staticmethod(factory)
def get_stateVariable(self): return self.stateVariable
def set_stateVariable(self, stateVariable): self.stateVariable = stateVariable
def add_stateVariable(self, value): self.stateVariable.append(value)
elif nodeName_ == 'defaultValue':
defaultValue_ = child_.text
defaultValue_ = self.gds_validate_string(defaultValue_, node, 'defaultValue')
self.defaultValue = defaultValue_
elif nodeName_ == 'allowedValueList':
obj_ = AllowedValueListType.factory()
obj_.build(child_)
self.set_allowedValueList(obj_)
elif nodeName_ == 'allowedValueRange':
obj_ = AllowedValueRangeType.factory()
obj_.build(child_)
self.set_allowedValueRange(obj_)
# end class StateVariableType
class AllowedValueListType(GeneratedsSuper):
subclass = None
superclass = None
def __init__(self, allowedValue=None):
if allowedValue is None:
self.allowedValue = []
else:
self.allowedValue = allowedValue
def factory(*args_, **kwargs_):
if AllowedValueListType.subclass:
return AllowedValueListType.subclass(*args_, **kwargs_)
else:
return AllowedValueListType(*args_, **kwargs_)
factory = staticmethod(factory)
def get_allowedValue(self): return self.allowedValue
def set_allowedValue(self, allowedValue): self.allowedValue = allowedValue
def add_allowedValue(self, value): self.allowedValue.append(value)
except (TypeError, ValueError) as exp:
raise_parse_error(child_, 'requires float or double: %s' % exp)
fval_ = self.gds_validate_float(fval_, node, 'maximum')
self.maximum = fval_
elif nodeName_ == 'step':
sval_ = child_.text
try:
fval_ = float(sval_)
except (TypeError, ValueError) as exp:
raise_parse_error(child_, 'requires float or double: %s' % exp)
fval_ = self.gds_validate_float(fval_, node, 'step')
self.step = fval_
# end class AllowedValueRangeType
class retvalType(GeneratedsSuper):
subclass = None
superclass = None
def __init__(self):
pass
def factory(*args_, **kwargs_):
if retvalType.subclass:
return retvalType.subclass(*args_, **kwargs_)
else:
return retvalType(*args_, **kwargs_)
factory = staticmethod(factory)
def export(self, outfile, level, namespace_='', name_='retvalType', namespacedef_='', pretty_print=True):
if pretty_print:
eol_ = '\n'
else:
eol_ = ''
showIndent(outfile, level, pretty_print)
def get_path_list_(self, node, path_list):
if node is None:
return
tag = GeneratedsSuper.Tag_strip_pattern_.sub('', node.tag)
if tag:
path_list.append(tag)
self.get_path_list_(node.getparent(), path_list)
def get_class_obj_(self, node, default_class=None):