How to use gds_validate_string method in autotest

Best Python code snippet using autotest_python

ParameterDatabase.py

Source:ParameterDatabase.py Github

copy

Full Screen

...67except ImportError, exp:68 class GeneratedsSuper(object):69 def gds_format_string(self, input_data, input_name=''):70 return input_data71 def gds_validate_string(self, input_data, node, input_name=''):72 return input_data73 def gds_format_integer(self, input_data, input_name=''):74 return '%d' % input_data75 def gds_validate_integer(self, input_data, node, input_name=''):76 return input_data77 def gds_format_integer_list(self, input_data, input_name=''):78 return '%s' % input_data79 def gds_validate_integer_list(self, input_data, node, input_name=''):80 values = input_data.split()81 for value in values:82 try:83 fvalue = float(value)84 except (TypeError, ValueError), exp:85 raise_parse_error(node, 'Requires sequence of integers')86 return input_data87 def gds_format_float(self, input_data, input_name=''):88 return '%f' % input_data89 def gds_validate_float(self, input_data, node, input_name=''):90 return input_data91 def gds_format_float_list(self, input_data, input_name=''):92 return '%s' % input_data93 def gds_validate_float_list(self, input_data, node, input_name=''):94 values = input_data.split()95 for value in values:96 try:97 fvalue = float(value)98 except (TypeError, ValueError), exp:99 raise_parse_error(node, 'Requires sequence of floats')100 return input_data101 def gds_format_double(self, input_data, input_name=''):102 return '%e' % input_data103 def gds_validate_double(self, input_data, node, input_name=''):104 return input_data105 def gds_format_double_list(self, input_data, input_name=''):106 return '%s' % input_data107 def gds_validate_double_list(self, input_data, node, input_name=''):108 values = input_data.split()109 for value in values:110 try:111 fvalue = float(value)112 except (TypeError, ValueError), exp:113 raise_parse_error(node, 'Requires sequence of doubles')114 return input_data115 def gds_format_boolean(self, input_data, input_name=''):116 return '%s' % input_data117 def gds_validate_boolean(self, input_data, node, input_name=''):118 return input_data119 def gds_format_boolean_list(self, input_data, input_name=''):120 return '%s' % input_data121 def gds_validate_boolean_list(self, input_data, node, input_name=''):122 values = input_data.split()123 for value in values:124 if value not in ('true', '1', 'false', '0', ):125 raise_parse_error(node, 'Requires sequence of booleans ("true", "1", "false", "0")')126 return input_data127 def gds_str_lower(self, instring):128 return instring.lower()129 def get_path_(self, node):130 path_list = []131 self.get_path_list_(node, path_list)132 path_list.reverse()133 path = '/'.join(path_list)134 return path135 Tag_strip_pattern_ = re_.compile(r'\{.*\}')136 def get_path_list_(self, node, path_list):137 if node is None:138 return139 tag = GeneratedsSuper.Tag_strip_pattern_.sub('', node.tag)140 if tag:141 path_list.append(tag)142 self.get_path_list_(node.getparent(), path_list)143 def get_class_obj_(self, node, default_class=None):144 class_obj1 = default_class145 if 'xsi' in node.nsmap:146 classname = node.get('{%s}type' % node.nsmap['xsi'])147 if classname is not None:148 names = classname.split(':')149 if len(names) == 2:150 classname = names[1]151 class_obj2 = globals().get(classname)152 if class_obj2 is not None:153 class_obj1 = class_obj2154 return class_obj1155 def gds_build_any(self, node, type_name=None):156 return None157#158# If you have installed IPython you can uncomment and use the following.159# IPython is available from http://ipython.scipy.org/.160#161## from IPython.Shell import IPShellEmbed162## args = ''163## ipshell = IPShellEmbed(args,164## banner = 'Dropping into IPython',165## exit_msg = 'Leaving Interpreter, back to program.')166# Then use the following line where and when you want to drop into the167# IPython shell:168# ipshell('<some message> -- Entering ipshell.\nHit Ctrl-D to exit')169#170# Globals171#172ExternalEncoding = 'ascii'173Tag_pattern_ = re_.compile(r'({.*})?(.*)')174String_cleanup_pat_ = re_.compile(r"[\n\r\s]+")175Namespace_extract_pat_ = re_.compile(r'{(.*)}(.*)')176#177# Support/utility functions.178#179def showIndent(outfile, level):180 for idx in range(level):181 outfile.write(' ')182def quote_xml(inStr):183 if not inStr:184 return ''185 s1 = (isinstance(inStr, basestring) and inStr or186 '%s' % inStr)187 s1 = s1.replace('&', '&amp;')188 s1 = s1.replace('<', '&lt;')189 s1 = s1.replace('>', '&gt;')190 return s1191def quote_attrib(inStr):192 s1 = (isinstance(inStr, basestring) and inStr or193 '%s' % inStr)194 s1 = s1.replace('&', '&amp;')195 s1 = s1.replace('<', '&lt;')196 s1 = s1.replace('>', '&gt;')197 if '"' in s1:198 if "'" in s1:199 s1 = '"%s"' % s1.replace('"', "&quot;")200 else:201 s1 = "'%s'" % s1202 else:203 s1 = '"%s"' % s1204 return s1205def quote_python(inStr):206 s1 = inStr207 if s1.find("'") == -1:208 if s1.find('\n') == -1:209 return "'%s'" % s1210 else:211 return "'''%s'''" % s1212 else:213 if s1.find('"') != -1:214 s1 = s1.replace('"', '\\"')215 if s1.find('\n') == -1:216 return '"%s"' % s1217 else:218 return '"""%s"""' % s1219def get_all_text_(node):220 if node.text is not None:221 text = node.text222 else:223 text = ''224 for child in node:225 if child.tail is not None:226 text += child.tail227 return text228def find_attr_value_(attr_name, node):229 attrs = node.attrib230 attr_parts = attr_name.split(':')231 value = None232 if len(attr_parts) == 1:233 value = attrs.get(attr_name)234 elif len(attr_parts) == 2:235 prefix, name = attr_parts236 namespace = node.nsmap.get(prefix)237 if namespace is not None:238 value = attrs.get('{%s}%s' % (namespace, name, ))239 return value240class GDSParseError(Exception):241 pass242def raise_parse_error(node, msg):243 if XMLParser_import_library == XMLParser_import_lxml:244 msg = '%s (element %s/line %d)' % (msg, node.tag, node.sourceline, )245 else:246 msg = '%s (element %s)' % (msg, node.tag, )247 raise GDSParseError(msg)248class MixedContainer:249 # Constants for category:250 CategoryNone = 0251 CategoryText = 1252 CategorySimple = 2253 CategoryComplex = 3254 # Constants for content_type:255 TypeNone = 0256 TypeText = 1257 TypeString = 2258 TypeInteger = 3259 TypeFloat = 4260 TypeDecimal = 5261 TypeDouble = 6262 TypeBoolean = 7263 def __init__(self, category, content_type, name, value):264 self.category = category265 self.content_type = content_type266 self.name = name267 self.value = value268 def getCategory(self):269 return self.category270 def getContenttype(self, content_type):271 return self.content_type272 def getValue(self):273 return self.value274 def getName(self):275 return self.name276 def export(self, outfile, level, name, namespace):277 if self.category == MixedContainer.CategoryText:278 # Prevent exporting empty content as empty lines.279 if self.value.strip(): 280 outfile.write(self.value)281 elif self.category == MixedContainer.CategorySimple:282 self.exportSimple(outfile, level, name)283 else: # category == MixedContainer.CategoryComplex284 self.value.export(outfile, level, namespace,name)285 def exportSimple(self, outfile, level, name):286 if self.content_type == MixedContainer.TypeString:287 outfile.write('<%s>%s</%s>' % (self.name, self.value, self.name))288 elif self.content_type == MixedContainer.TypeInteger or \289 self.content_type == MixedContainer.TypeBoolean:290 outfile.write('<%s>%d</%s>' % (self.name, self.value, self.name))291 elif self.content_type == MixedContainer.TypeFloat or \292 self.content_type == MixedContainer.TypeDecimal:293 outfile.write('<%s>%f</%s>' % (self.name, self.value, self.name))294 elif self.content_type == MixedContainer.TypeDouble:295 outfile.write('<%s>%g</%s>' % (self.name, self.value, self.name))296 def exportLiteral(self, outfile, level, name):297 if self.category == MixedContainer.CategoryText:298 showIndent(outfile, level)299 outfile.write('model_.MixedContainer(%d, %d, "%s", "%s"),\n' % \300 (self.category, self.content_type, self.name, self.value))301 elif self.category == MixedContainer.CategorySimple:302 showIndent(outfile, level)303 outfile.write('model_.MixedContainer(%d, %d, "%s", "%s"),\n' % \304 (self.category, self.content_type, self.name, self.value))305 else: # category == MixedContainer.CategoryComplex306 showIndent(outfile, level)307 outfile.write('model_.MixedContainer(%d, %d, "%s",\n' % \308 (self.category, self.content_type, self.name,))309 self.value.exportLiteral(outfile, level + 1)310 showIndent(outfile, level)311 outfile.write(')\n')312class MemberSpec_(object):313 def __init__(self, name='', data_type='', container=0):314 self.name = name315 self.data_type = data_type316 self.container = container317 def set_name(self, name): self.name = name318 def get_name(self): return self.name319 def set_data_type(self, data_type): self.data_type = data_type320 def get_data_type_chain(self): return self.data_type321 def get_data_type(self):322 if isinstance(self.data_type, list):323 if len(self.data_type) > 0:324 return self.data_type[-1]325 else:326 return 'xs:string'327 else:328 return self.data_type329 def set_container(self, container): self.container = container330 def get_container(self): return self.container331def _cast(typ, value):332 if typ is None or value is None:333 return value334 return typ(value)335#336# Data representation classes.337#338class SerialisationFlags(GeneratedsSuper):339 subclass = None340 superclass = None341 def __init__(self, serialisationFlag=None):342 if serialisationFlag is None:343 self.serialisationFlag = []344 else:345 self.serialisationFlag = serialisationFlag346 def factory(*args_, **kwargs_):347 if SerialisationFlags.subclass:348 return SerialisationFlags.subclass(*args_, **kwargs_)349 else:350 return SerialisationFlags(*args_, **kwargs_)351 factory = staticmethod(factory)352 def get_serialisationFlag(self): return self.serialisationFlag353 def set_serialisationFlag(self, serialisationFlag): self.serialisationFlag = serialisationFlag354 def add_serialisationFlag(self, value): self.serialisationFlag.append(value)355 def insert_serialisationFlag(self, index, value): self.serialisationFlag[index] = value356 def export(self, outfile, level, namespace_='', name_='SerialisationFlags', namespacedef_=''):357 showIndent(outfile, level)358 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))359 already_processed = []360 self.exportAttributes(outfile, level, already_processed, namespace_, name_='SerialisationFlags')361 if self.hasContent_():362 outfile.write('>\n')363 self.exportChildren(outfile, level + 1, namespace_, name_)364 showIndent(outfile, level)365 outfile.write('</%s%s>\n' % (namespace_, name_))366 else:367 outfile.write('/>\n')368 def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='SerialisationFlags'):369 pass370 def exportChildren(self, outfile, level, namespace_='', name_='SerialisationFlags', fromsubclass_=False):371 for serialisationFlag_ in self.serialisationFlag:372 showIndent(outfile, level)373 outfile.write('<%sserialisationFlag>%s</%sserialisationFlag>\n' % (namespace_, self.gds_format_string(quote_xml(serialisationFlag_).encode(ExternalEncoding), input_name='serialisationFlag'), namespace_))374 def hasContent_(self):375 if (376 self.serialisationFlag377 ):378 return True379 else:380 return False381 def exportLiteral(self, outfile, level, name_='SerialisationFlags'):382 level += 1383 self.exportLiteralAttributes(outfile, level, [], name_)384 if self.hasContent_():385 self.exportLiteralChildren(outfile, level, name_)386 def exportLiteralAttributes(self, outfile, level, already_processed, name_):387 pass388 def exportLiteralChildren(self, outfile, level, name_):389 showIndent(outfile, level)390 outfile.write('serialisationFlag=[\n')391 level += 1392 for serialisationFlag_ in self.serialisationFlag:393 showIndent(outfile, level)394 outfile.write('%s,\n' % quote_python(serialisationFlag_).encode(ExternalEncoding))395 level -= 1396 showIndent(outfile, level)397 outfile.write('],\n')398 def build(self, node):399 self.buildAttributes(node, node.attrib, [])400 for child in node:401 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]402 self.buildChildren(child, node, nodeName_)403 def buildAttributes(self, node, attrs, already_processed):404 pass405 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):406 if nodeName_ == 'serialisationFlag':407 serialisationFlag_ = child_.text408 serialisationFlag_ = self.gds_validate_string(serialisationFlag_, node, 'serialisationFlag')409 self.serialisationFlag.append(serialisationFlag_)410# end class SerialisationFlags411class UDBType(GeneratedsSuper):412 subclass = None413 superclass = None414 def __init__(self, typeName=None, sendFunction=None, setFunction=None, mavlinkType=None):415 self.typeName = typeName416 self.sendFunction = sendFunction417 self.setFunction = setFunction418 self.mavlinkType = mavlinkType419 def factory(*args_, **kwargs_):420 if UDBType.subclass:421 return UDBType.subclass(*args_, **kwargs_)422 else:423 return UDBType(*args_, **kwargs_)424 factory = staticmethod(factory)425 def get_typeName(self): return self.typeName426 def set_typeName(self, typeName): self.typeName = typeName427 def get_sendFunction(self): return self.sendFunction428 def set_sendFunction(self, sendFunction): self.sendFunction = sendFunction429 def get_setFunction(self): return self.setFunction430 def set_setFunction(self, setFunction): self.setFunction = setFunction431 def get_mavlinkType(self): return self.mavlinkType432 def set_mavlinkType(self, mavlinkType): self.mavlinkType = mavlinkType433 def export(self, outfile, level, namespace_='', name_='UDBType', namespacedef_=''):434 showIndent(outfile, level)435 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))436 already_processed = []437 self.exportAttributes(outfile, level, already_processed, namespace_, name_='UDBType')438 if self.hasContent_():439 outfile.write('>\n')440 self.exportChildren(outfile, level + 1, namespace_, name_)441 showIndent(outfile, level)442 outfile.write('</%s%s>\n' % (namespace_, name_))443 else:444 outfile.write('/>\n')445 def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='UDBType'):446 pass447 def exportChildren(self, outfile, level, namespace_='', name_='UDBType', fromsubclass_=False):448 if self.typeName is not None:449 showIndent(outfile, level)450 outfile.write('<%stypeName>%s</%stypeName>\n' % (namespace_, self.gds_format_string(quote_xml(self.typeName).encode(ExternalEncoding), input_name='typeName'), namespace_))451 if self.sendFunction is not None:452 showIndent(outfile, level)453 outfile.write('<%ssendFunction>%s</%ssendFunction>\n' % (namespace_, self.gds_format_string(quote_xml(self.sendFunction).encode(ExternalEncoding), input_name='sendFunction'), namespace_))454 if self.setFunction is not None:455 showIndent(outfile, level)456 outfile.write('<%ssetFunction>%s</%ssetFunction>\n' % (namespace_, self.gds_format_string(quote_xml(self.setFunction).encode(ExternalEncoding), input_name='setFunction'), namespace_))457 if self.mavlinkType is not None:458 showIndent(outfile, level)459 outfile.write('<%smavlinkType>%s</%smavlinkType>\n' % (namespace_, self.gds_format_string(quote_xml(self.mavlinkType).encode(ExternalEncoding), input_name='mavlinkType'), namespace_))460 def hasContent_(self):461 if (462 self.typeName is not None or463 self.sendFunction is not None or464 self.setFunction is not None or465 self.mavlinkType is not None466 ):467 return True468 else:469 return False470 def exportLiteral(self, outfile, level, name_='UDBType'):471 level += 1472 self.exportLiteralAttributes(outfile, level, [], name_)473 if self.hasContent_():474 self.exportLiteralChildren(outfile, level, name_)475 def exportLiteralAttributes(self, outfile, level, already_processed, name_):476 pass477 def exportLiteralChildren(self, outfile, level, name_):478 if self.typeName is not None:479 showIndent(outfile, level)480 outfile.write('typeName=%s,\n' % quote_python(self.typeName).encode(ExternalEncoding))481 if self.sendFunction is not None:482 showIndent(outfile, level)483 outfile.write('sendFunction=%s,\n' % quote_python(self.sendFunction).encode(ExternalEncoding))484 if self.setFunction is not None:485 showIndent(outfile, level)486 outfile.write('setFunction=%s,\n' % quote_python(self.setFunction).encode(ExternalEncoding))487 if self.mavlinkType is not None:488 showIndent(outfile, level)489 outfile.write('mavlinkType=%s,\n' % quote_python(self.mavlinkType).encode(ExternalEncoding))490 def build(self, node):491 self.buildAttributes(node, node.attrib, [])492 for child in node:493 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]494 self.buildChildren(child, node, nodeName_)495 def buildAttributes(self, node, attrs, already_processed):496 pass497 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):498 if nodeName_ == 'typeName':499 typeName_ = child_.text500 typeName_ = self.gds_validate_string(typeName_, node, 'typeName')501 self.typeName = typeName_502 elif nodeName_ == 'sendFunction':503 sendFunction_ = child_.text504 sendFunction_ = self.gds_validate_string(sendFunction_, node, 'sendFunction')505 self.sendFunction = sendFunction_506 elif nodeName_ == 'setFunction':507 setFunction_ = child_.text508 setFunction_ = self.gds_validate_string(setFunction_, node, 'setFunction')509 self.setFunction = setFunction_510 elif nodeName_ == 'mavlinkType':511 mavlinkType_ = child_.text512 mavlinkType_ = self.gds_validate_string(mavlinkType_, node, 'mavlinkType')513 self.mavlinkType = mavlinkType_514# end class UDBType515class UDBTypes(GeneratedsSuper):516 subclass = None517 superclass = None518 def __init__(self, udbType=None):519 if udbType is None:520 self.udbType = []521 else:522 self.udbType = udbType523 def factory(*args_, **kwargs_):524 if UDBTypes.subclass:525 return UDBTypes.subclass(*args_, **kwargs_)526 else:527 return UDBTypes(*args_, **kwargs_)528 factory = staticmethod(factory)529 def get_udbType(self): return self.udbType530 def set_udbType(self, udbType): self.udbType = udbType531 def add_udbType(self, value): self.udbType.append(value)532 def insert_udbType(self, index, value): self.udbType[index] = value533 def export(self, outfile, level, namespace_='', name_='UDBTypes', namespacedef_=''):534 showIndent(outfile, level)535 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))536 already_processed = []537 self.exportAttributes(outfile, level, already_processed, namespace_, name_='UDBTypes')538 if self.hasContent_():539 outfile.write('>\n')540 self.exportChildren(outfile, level + 1, namespace_, name_)541 showIndent(outfile, level)542 outfile.write('</%s%s>\n' % (namespace_, name_))543 else:544 outfile.write('/>\n')545 def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='UDBTypes'):546 pass547 def exportChildren(self, outfile, level, namespace_='', name_='UDBTypes', fromsubclass_=False):548 for udbType_ in self.udbType:549 udbType_.export(outfile, level, namespace_, name_='udbType')550 def hasContent_(self):551 if (552 self.udbType553 ):554 return True555 else:556 return False557 def exportLiteral(self, outfile, level, name_='UDBTypes'):558 level += 1559 self.exportLiteralAttributes(outfile, level, [], name_)560 if self.hasContent_():561 self.exportLiteralChildren(outfile, level, name_)562 def exportLiteralAttributes(self, outfile, level, already_processed, name_):563 pass564 def exportLiteralChildren(self, outfile, level, name_):565 showIndent(outfile, level)566 outfile.write('udbType=[\n')567 level += 1568 for udbType_ in self.udbType:569 showIndent(outfile, level)570 outfile.write('model_.UDBType(\n')571 udbType_.exportLiteral(outfile, level, name_='UDBType')572 showIndent(outfile, level)573 outfile.write('),\n')574 level -= 1575 showIndent(outfile, level)576 outfile.write('],\n')577 def build(self, node):578 self.buildAttributes(node, node.attrib, [])579 for child in node:580 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]581 self.buildChildren(child, node, nodeName_)582 def buildAttributes(self, node, attrs, already_processed):583 pass584 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):585 if nodeName_ == 'udbType':586 obj_ = UDBType.factory()587 obj_.build(child_)588 self.udbType.append(obj_)589# end class UDBTypes590class Parameter(GeneratedsSuper):591 subclass = None592 superclass = None593 def __init__(self, parameterName=None, udb_param_type=None, variable_name='NULL', description='no description', min='0.0', max='0.0', readonly=True):594 self.parameterName = parameterName595 self.udb_param_type = udb_param_type596 self.variable_name = variable_name597 self.description = description598 self.min = min599 self.max = max600 self.readonly = readonly601 def factory(*args_, **kwargs_):602 if Parameter.subclass:603 return Parameter.subclass(*args_, **kwargs_)604 else:605 return Parameter(*args_, **kwargs_)606 factory = staticmethod(factory)607 def get_parameterName(self): return self.parameterName608 def set_parameterName(self, parameterName): self.parameterName = parameterName609 def validate_ParamIdentifier(self, value):610 # Validate type ParamIdentifier, a restriction on xs:string.611 pass612 def get_udb_param_type(self): return self.udb_param_type613 def set_udb_param_type(self, udb_param_type): self.udb_param_type = udb_param_type614 def get_variable_name(self): return self.variable_name615 def set_variable_name(self, variable_name): self.variable_name = variable_name616 def get_description(self): return self.description617 def set_description(self, description): self.description = description618 def get_min(self): return self.min619 def set_min(self, min): self.min = min620 def get_max(self): return self.max621 def set_max(self, max): self.max = max622 def get_readonly(self): return self.readonly623 def set_readonly(self, readonly): self.readonly = readonly624 def export(self, outfile, level, namespace_='', name_='Parameter', namespacedef_=''):625 showIndent(outfile, level)626 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))627 already_processed = []628 self.exportAttributes(outfile, level, already_processed, namespace_, name_='Parameter')629 if self.hasContent_():630 outfile.write('>\n')631 self.exportChildren(outfile, level + 1, namespace_, name_)632 showIndent(outfile, level)633 outfile.write('</%s%s>\n' % (namespace_, name_))634 else:635 outfile.write('/>\n')636 def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='Parameter'):637 pass638 def exportChildren(self, outfile, level, namespace_='', name_='Parameter', fromsubclass_=False):639 if self.parameterName is not None:640 showIndent(outfile, level)641 outfile.write('<%sparameterName>%s</%sparameterName>\n' % (namespace_, self.gds_format_string(quote_xml(self.parameterName).encode(ExternalEncoding), input_name='parameterName'), namespace_))642 if self.udb_param_type is not None:643 showIndent(outfile, level)644 outfile.write('<%sudb_param_type>%s</%sudb_param_type>\n' % (namespace_, self.gds_format_string(quote_xml(self.udb_param_type).encode(ExternalEncoding), input_name='udb_param_type'), namespace_))645 if self.variable_name is not None:646 showIndent(outfile, level)647 outfile.write('<%svariable_name>%s</%svariable_name>\n' % (namespace_, self.gds_format_string(quote_xml(self.variable_name).encode(ExternalEncoding), input_name='variable_name'), namespace_))648 if self.description is not None:649 showIndent(outfile, level)650 outfile.write('<%sdescription>%s</%sdescription>\n' % (namespace_, self.gds_format_string(quote_xml(self.description).encode(ExternalEncoding), input_name='description'), namespace_))651 if self.min is not None:652 showIndent(outfile, level)653 outfile.write('<%smin>%s</%smin>\n' % (namespace_, self.gds_format_string(quote_xml(self.min).encode(ExternalEncoding), input_name='min'), namespace_))654 if self.max is not None:655 showIndent(outfile, level)656 outfile.write('<%smax>%s</%smax>\n' % (namespace_, self.gds_format_string(quote_xml(self.max).encode(ExternalEncoding), input_name='max'), namespace_))657 if self.readonly is not None:658 showIndent(outfile, level)659 outfile.write('<%sreadonly>%s</%sreadonly>\n' % (namespace_, self.gds_format_boolean(self.gds_str_lower(str(self.readonly)), input_name='readonly'), namespace_))660 def hasContent_(self):661 if (662 self.parameterName is not None or663 self.udb_param_type is not None or664 self.variable_name is not None or665 self.description is not None or666 self.min is not None or667 self.max is not None or668 self.readonly is not None669 ):670 return True671 else:672 return False673 def exportLiteral(self, outfile, level, name_='Parameter'):674 level += 1675 self.exportLiteralAttributes(outfile, level, [], name_)676 if self.hasContent_():677 self.exportLiteralChildren(outfile, level, name_)678 def exportLiteralAttributes(self, outfile, level, already_processed, name_):679 pass680 def exportLiteralChildren(self, outfile, level, name_):681 if self.parameterName is not None:682 showIndent(outfile, level)683 outfile.write('parameterName=%s,\n' % quote_python(self.parameterName).encode(ExternalEncoding))684 if self.udb_param_type is not None:685 showIndent(outfile, level)686 outfile.write('udb_param_type=%s,\n' % quote_python(self.udb_param_type).encode(ExternalEncoding))687 if self.variable_name is not None:688 showIndent(outfile, level)689 outfile.write('variable_name=%s,\n' % quote_python(self.variable_name).encode(ExternalEncoding))690 if self.description is not None:691 showIndent(outfile, level)692 outfile.write('description=%s,\n' % quote_python(self.description).encode(ExternalEncoding))693 if self.min is not None:694 showIndent(outfile, level)695 outfile.write('min=%s,\n' % quote_python(self.min).encode(ExternalEncoding))696 if self.max is not None:697 showIndent(outfile, level)698 outfile.write('max=%s,\n' % quote_python(self.max).encode(ExternalEncoding))699 if self.readonly is not None:700 showIndent(outfile, level)701 outfile.write('readonly=%s,\n' % self.readonly)702 def build(self, node):703 self.buildAttributes(node, node.attrib, [])704 for child in node:705 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]706 self.buildChildren(child, node, nodeName_)707 def buildAttributes(self, node, attrs, already_processed):708 pass709 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):710 if nodeName_ == 'parameterName':711 parameterName_ = child_.text712 parameterName_ = self.gds_validate_string(parameterName_, node, 'parameterName')713 self.parameterName = parameterName_714 self.validate_ParamIdentifier(self.parameterName) # validate type ParamIdentifier715 elif nodeName_ == 'udb_param_type':716 udb_param_type_ = child_.text717 udb_param_type_ = self.gds_validate_string(udb_param_type_, node, 'udb_param_type')718 self.udb_param_type = udb_param_type_719 elif nodeName_ == 'variable_name':720 variable_name_ = child_.text721 variable_name_ = self.gds_validate_string(variable_name_, node, 'variable_name')722 self.variable_name = variable_name_723 elif nodeName_ == 'description':724 description_ = child_.text725 description_ = self.gds_validate_string(description_, node, 'description')726 self.description = description_727 elif nodeName_ == 'min':728 min_ = child_.text729 min_ = self.gds_validate_string(min_, node, 'min')730 self.min = min_731 elif nodeName_ == 'max':732 max_ = child_.text733 max_ = self.gds_validate_string(max_, node, 'max')734 self.max = max_735 elif nodeName_ == 'readonly':736 sval_ = child_.text737 if sval_ in ('true', '1'):738 ival_ = True739 elif sval_ in ('false', '0'):740 ival_ = False741 else:742 raise_parse_error(child_, 'requires boolean')743 ival_ = self.gds_validate_boolean(ival_, node, 'readonly')744 self.readonly = ival_745# end class Parameter746class Parameters(GeneratedsSuper):747 subclass = None748 superclass = None749 def __init__(self, parameter=None):750 if parameter is None:751 self.parameter = []752 else:753 self.parameter = parameter754 def factory(*args_, **kwargs_):755 if Parameters.subclass:756 return Parameters.subclass(*args_, **kwargs_)757 else:758 return Parameters(*args_, **kwargs_)759 factory = staticmethod(factory)760 def get_parameter(self): return self.parameter761 def set_parameter(self, parameter): self.parameter = parameter762 def add_parameter(self, value): self.parameter.append(value)763 def insert_parameter(self, index, value): self.parameter[index] = value764 def export(self, outfile, level, namespace_='', name_='Parameters', namespacedef_=''):765 showIndent(outfile, level)766 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))767 already_processed = []768 self.exportAttributes(outfile, level, already_processed, namespace_, name_='Parameters')769 if self.hasContent_():770 outfile.write('>\n')771 self.exportChildren(outfile, level + 1, namespace_, name_)772 showIndent(outfile, level)773 outfile.write('</%s%s>\n' % (namespace_, name_))774 else:775 outfile.write('/>\n')776 def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='Parameters'):777 pass778 def exportChildren(self, outfile, level, namespace_='', name_='Parameters', fromsubclass_=False):779 for parameter_ in self.parameter:780 parameter_.export(outfile, level, namespace_, name_='parameter')781 def hasContent_(self):782 if (783 self.parameter784 ):785 return True786 else:787 return False788 def exportLiteral(self, outfile, level, name_='Parameters'):789 level += 1790 self.exportLiteralAttributes(outfile, level, [], name_)791 if self.hasContent_():792 self.exportLiteralChildren(outfile, level, name_)793 def exportLiteralAttributes(self, outfile, level, already_processed, name_):794 pass795 def exportLiteralChildren(self, outfile, level, name_):796 showIndent(outfile, level)797 outfile.write('parameter=[\n')798 level += 1799 for parameter_ in self.parameter:800 showIndent(outfile, level)801 outfile.write('model_.Parameter(\n')802 parameter_.exportLiteral(outfile, level, name_='Parameter')803 showIndent(outfile, level)804 outfile.write('),\n')805 level -= 1806 showIndent(outfile, level)807 outfile.write('],\n')808 def build(self, node):809 self.buildAttributes(node, node.attrib, [])810 for child in node:811 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]812 self.buildChildren(child, node, nodeName_)813 def buildAttributes(self, node, attrs, already_processed):814 pass815 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):816 if nodeName_ == 'parameter':817 obj_ = Parameter.factory()818 obj_.build(child_)819 self.parameter.append(obj_)820# end class Parameters821class ParameterBlock(GeneratedsSuper):822 subclass = None823 superclass = None824 def __init__(self, blockName=None, storage_area='None', serialisationFlags=None, externs=None, load_callback=None, in_mavlink_parameters=None, parameters=None, description='no description'):825 self.blockName = blockName826 self.storage_area = storage_area827 self.serialisationFlags = serialisationFlags828 self.externs = externs829 self.load_callback = load_callback830 self.in_mavlink_parameters = in_mavlink_parameters831 self.parameters = parameters832 self.description = description833 def factory(*args_, **kwargs_):834 if ParameterBlock.subclass:835 return ParameterBlock.subclass(*args_, **kwargs_)836 else:837 return ParameterBlock(*args_, **kwargs_)838 factory = staticmethod(factory)839 def get_blockName(self): return self.blockName840 def set_blockName(self, blockName): self.blockName = blockName841 def get_storage_area(self): return self.storage_area842 def set_storage_area(self, storage_area): self.storage_area = storage_area843 def get_serialisationFlags(self): return self.serialisationFlags844 def set_serialisationFlags(self, serialisationFlags): self.serialisationFlags = serialisationFlags845 def get_externs(self): return self.externs846 def set_externs(self, externs): self.externs = externs847 def get_load_callback(self): return self.load_callback848 def set_load_callback(self, load_callback): self.load_callback = load_callback849 def get_in_mavlink_parameters(self): return self.in_mavlink_parameters850 def set_in_mavlink_parameters(self, in_mavlink_parameters): self.in_mavlink_parameters = in_mavlink_parameters851 def get_parameters(self): return self.parameters852 def set_parameters(self, parameters): self.parameters = parameters853 def get_description(self): return self.description854 def set_description(self, description): self.description = description855 def export(self, outfile, level, namespace_='', name_='ParameterBlock', namespacedef_=''):856 showIndent(outfile, level)857 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))858 already_processed = []859 self.exportAttributes(outfile, level, already_processed, namespace_, name_='ParameterBlock')860 if self.hasContent_():861 outfile.write('>\n')862 self.exportChildren(outfile, level + 1, namespace_, name_)863 showIndent(outfile, level)864 outfile.write('</%s%s>\n' % (namespace_, name_))865 else:866 outfile.write('/>\n')867 def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='ParameterBlock'):868 pass869 def exportChildren(self, outfile, level, namespace_='', name_='ParameterBlock', fromsubclass_=False):870 if self.blockName is not None:871 showIndent(outfile, level)872 outfile.write('<%sblockName>%s</%sblockName>\n' % (namespace_, self.gds_format_string(quote_xml(self.blockName).encode(ExternalEncoding), input_name='blockName'), namespace_))873 if self.storage_area is not None:874 showIndent(outfile, level)875 outfile.write('<%sstorage_area>%s</%sstorage_area>\n' % (namespace_, self.gds_format_string(quote_xml(self.storage_area).encode(ExternalEncoding), input_name='storage_area'), namespace_))876 if self.serialisationFlags is not None:877 self.serialisationFlags.export(outfile, level, namespace_, name_='serialisationFlags', )878 if self.externs is not None:879 self.externs.export(outfile, level, namespace_, name_='externs')880 if self.load_callback is not None:881 showIndent(outfile, level)882 outfile.write('<%sload_callback>%s</%sload_callback>\n' % (namespace_, self.gds_format_string(quote_xml(self.load_callback).encode(ExternalEncoding), input_name='load_callback'), namespace_))883 if self.in_mavlink_parameters is not None:884 showIndent(outfile, level)885 outfile.write('<%sin_mavlink_parameters>%s</%sin_mavlink_parameters>\n' % (namespace_, self.gds_format_boolean(self.gds_str_lower(str(self.in_mavlink_parameters)), input_name='in_mavlink_parameters'), namespace_))886 if self.parameters is not None:887 self.parameters.export(outfile, level, namespace_, name_='parameters', )888 if self.description is not None:889 showIndent(outfile, level)890 outfile.write('<%sdescription>%s</%sdescription>\n' % (namespace_, self.gds_format_string(quote_xml(self.description).encode(ExternalEncoding), input_name='description'), namespace_))891 def hasContent_(self):892 if (893 self.blockName is not None or894 self.storage_area is not None or895 self.serialisationFlags is not None or896 self.externs is not None or897 self.load_callback is not None or898 self.in_mavlink_parameters is not None or899 self.parameters is not None or900 self.description is not None901 ):902 return True903 else:904 return False905 def exportLiteral(self, outfile, level, name_='ParameterBlock'):906 level += 1907 self.exportLiteralAttributes(outfile, level, [], name_)908 if self.hasContent_():909 self.exportLiteralChildren(outfile, level, name_)910 def exportLiteralAttributes(self, outfile, level, already_processed, name_):911 pass912 def exportLiteralChildren(self, outfile, level, name_):913 if self.blockName is not None:914 showIndent(outfile, level)915 outfile.write('blockName=%s,\n' % quote_python(self.blockName).encode(ExternalEncoding))916 if self.storage_area is not None:917 showIndent(outfile, level)918 outfile.write('storage_area=%s,\n' % quote_python(self.storage_area).encode(ExternalEncoding))919 if self.serialisationFlags is not None:920 showIndent(outfile, level)921 outfile.write('serialisationFlags=model_.SerialisationFlags(\n')922 self.serialisationFlags.exportLiteral(outfile, level, name_='serialisationFlags')923 showIndent(outfile, level)924 outfile.write('),\n')925 if self.externs is not None:926 showIndent(outfile, level)927 outfile.write('externs=model_.Externs(\n')928 self.externs.exportLiteral(outfile, level, name_='externs')929 showIndent(outfile, level)930 outfile.write('),\n')931 if self.load_callback is not None:932 showIndent(outfile, level)933 outfile.write('load_callback=%s,\n' % quote_python(self.load_callback).encode(ExternalEncoding))934 if self.in_mavlink_parameters is not None:935 showIndent(outfile, level)936 outfile.write('in_mavlink_parameters=%s,\n' % self.in_mavlink_parameters)937 if self.parameters is not None:938 showIndent(outfile, level)939 outfile.write('parameters=model_.Parameters(\n')940 self.parameters.exportLiteral(outfile, level, name_='parameters')941 showIndent(outfile, level)942 outfile.write('),\n')943 if self.description is not None:944 showIndent(outfile, level)945 outfile.write('description=%s,\n' % quote_python(self.description).encode(ExternalEncoding))946 def build(self, node):947 self.buildAttributes(node, node.attrib, [])948 for child in node:949 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]950 self.buildChildren(child, node, nodeName_)951 def buildAttributes(self, node, attrs, already_processed):952 pass953 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):954 if nodeName_ == 'blockName':955 blockName_ = child_.text956 blockName_ = self.gds_validate_string(blockName_, node, 'blockName')957 self.blockName = blockName_958 elif nodeName_ == 'storage_area':959 storage_area_ = child_.text960 storage_area_ = self.gds_validate_string(storage_area_, node, 'storage_area')961 self.storage_area = storage_area_962 elif nodeName_ == 'serialisationFlags':963 obj_ = SerialisationFlags.factory()964 obj_.build(child_)965 self.set_serialisationFlags(obj_)966 elif nodeName_ == 'externs':967 obj_ = Externs.factory()968 obj_.build(child_)969 self.set_externs(obj_)970 elif nodeName_ == 'load_callback':971 load_callback_ = child_.text972 load_callback_ = self.gds_validate_string(load_callback_, node, 'load_callback')973 self.load_callback = load_callback_974 elif nodeName_ == 'in_mavlink_parameters':975 sval_ = child_.text976 if sval_ in ('true', '1'):977 ival_ = True978 elif sval_ in ('false', '0'):979 ival_ = False980 else:981 raise_parse_error(child_, 'requires boolean')982 ival_ = self.gds_validate_boolean(ival_, node, 'in_mavlink_parameters')983 self.in_mavlink_parameters = ival_984 elif nodeName_ == 'parameters':985 obj_ = Parameters.factory()986 obj_.build(child_)987 self.set_parameters(obj_)988 elif nodeName_ == 'description':989 description_ = child_.text990 description_ = self.gds_validate_string(description_, node, 'description')991 self.description = description_992# end class ParameterBlock993class ParameterBlocks(GeneratedsSuper):994 subclass = None995 superclass = None996 def __init__(self, parameterBlock=None):997 if parameterBlock is None:998 self.parameterBlock = []999 else:1000 self.parameterBlock = parameterBlock1001 def factory(*args_, **kwargs_):1002 if ParameterBlocks.subclass:1003 return ParameterBlocks.subclass(*args_, **kwargs_)1004 else:1005 return ParameterBlocks(*args_, **kwargs_)1006 factory = staticmethod(factory)1007 def get_parameterBlock(self): return self.parameterBlock1008 def set_parameterBlock(self, parameterBlock): self.parameterBlock = parameterBlock1009 def add_parameterBlock(self, value): self.parameterBlock.append(value)1010 def insert_parameterBlock(self, index, value): self.parameterBlock[index] = value1011 def export(self, outfile, level, namespace_='', name_='ParameterBlocks', namespacedef_=''):1012 showIndent(outfile, level)1013 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))1014 already_processed = []1015 self.exportAttributes(outfile, level, already_processed, namespace_, name_='ParameterBlocks')1016 if self.hasContent_():1017 outfile.write('>\n')1018 self.exportChildren(outfile, level + 1, namespace_, name_)1019 showIndent(outfile, level)1020 outfile.write('</%s%s>\n' % (namespace_, name_))1021 else:1022 outfile.write('/>\n')1023 def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='ParameterBlocks'):1024 pass1025 def exportChildren(self, outfile, level, namespace_='', name_='ParameterBlocks', fromsubclass_=False):1026 for parameterBlock_ in self.parameterBlock:1027 parameterBlock_.export(outfile, level, namespace_, name_='parameterBlock')1028 def hasContent_(self):1029 if (1030 self.parameterBlock1031 ):1032 return True1033 else:1034 return False1035 def exportLiteral(self, outfile, level, name_='ParameterBlocks'):1036 level += 11037 self.exportLiteralAttributes(outfile, level, [], name_)1038 if self.hasContent_():1039 self.exportLiteralChildren(outfile, level, name_)1040 def exportLiteralAttributes(self, outfile, level, already_processed, name_):1041 pass1042 def exportLiteralChildren(self, outfile, level, name_):1043 showIndent(outfile, level)1044 outfile.write('parameterBlock=[\n')1045 level += 11046 for parameterBlock_ in self.parameterBlock:1047 showIndent(outfile, level)1048 outfile.write('model_.ParameterBlock(\n')1049 parameterBlock_.exportLiteral(outfile, level, name_='ParameterBlock')1050 showIndent(outfile, level)1051 outfile.write('),\n')1052 level -= 11053 showIndent(outfile, level)1054 outfile.write('],\n')1055 def build(self, node):1056 self.buildAttributes(node, node.attrib, [])1057 for child in node:1058 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]1059 self.buildChildren(child, node, nodeName_)1060 def buildAttributes(self, node, attrs, already_processed):1061 pass1062 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):1063 if nodeName_ == 'parameterBlock':1064 obj_ = ParameterBlock.factory()1065 obj_.build(child_)1066 self.parameterBlock.append(obj_)1067# end class ParameterBlocks1068class ParameterDatabase(GeneratedsSuper):1069 subclass = None1070 superclass = None1071 def __init__(self, dataStorageAreas=None, serialisationFlags=None, udbTypes=None, parameterBlocks=None):1072 self.dataStorageAreas = dataStorageAreas1073 self.serialisationFlags = serialisationFlags1074 self.udbTypes = udbTypes1075 self.parameterBlocks = parameterBlocks1076 def factory(*args_, **kwargs_):1077 if ParameterDatabase.subclass:1078 return ParameterDatabase.subclass(*args_, **kwargs_)1079 else:1080 return ParameterDatabase(*args_, **kwargs_)1081 factory = staticmethod(factory)1082 def get_dataStorageAreas(self): return self.dataStorageAreas1083 def set_dataStorageAreas(self, dataStorageAreas): self.dataStorageAreas = dataStorageAreas1084 def get_serialisationFlags(self): return self.serialisationFlags1085 def set_serialisationFlags(self, serialisationFlags): self.serialisationFlags = serialisationFlags1086 def get_udbTypes(self): return self.udbTypes1087 def set_udbTypes(self, udbTypes): self.udbTypes = udbTypes1088 def get_parameterBlocks(self): return self.parameterBlocks1089 def set_parameterBlocks(self, parameterBlocks): self.parameterBlocks = parameterBlocks1090 def export(self, outfile, level, namespace_='', name_='ParameterDatabase', namespacedef_=''):1091 showIndent(outfile, level)1092 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))1093 already_processed = []1094 self.exportAttributes(outfile, level, already_processed, namespace_, name_='ParameterDatabase')1095 if self.hasContent_():1096 outfile.write('>\n')1097 self.exportChildren(outfile, level + 1, namespace_, name_)1098 showIndent(outfile, level)1099 outfile.write('</%s%s>\n' % (namespace_, name_))1100 else:1101 outfile.write('/>\n')1102 def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='ParameterDatabase'):1103 pass1104 def exportChildren(self, outfile, level, namespace_='', name_='ParameterDatabase', fromsubclass_=False):1105 if self.dataStorageAreas is not None:1106 self.dataStorageAreas.export(outfile, level, namespace_, name_='dataStorageAreas', )1107 if self.serialisationFlags is not None:1108 self.serialisationFlags.export(outfile, level, namespace_, name_='serialisationFlags', )1109 if self.udbTypes is not None:1110 self.udbTypes.export(outfile, level, namespace_, name_='udbTypes', )1111 if self.parameterBlocks is not None:1112 self.parameterBlocks.export(outfile, level, namespace_, name_='parameterBlocks', )1113 def hasContent_(self):1114 if (1115 self.dataStorageAreas is not None or1116 self.serialisationFlags is not None or1117 self.udbTypes is not None or1118 self.parameterBlocks is not None1119 ):1120 return True1121 else:1122 return False1123 def exportLiteral(self, outfile, level, name_='ParameterDatabase'):1124 level += 11125 self.exportLiteralAttributes(outfile, level, [], name_)1126 if self.hasContent_():1127 self.exportLiteralChildren(outfile, level, name_)1128 def exportLiteralAttributes(self, outfile, level, already_processed, name_):1129 pass1130 def exportLiteralChildren(self, outfile, level, name_):1131 if self.dataStorageAreas is not None:1132 showIndent(outfile, level)1133 outfile.write('dataStorageAreas=model_.DataStorageAreas(\n')1134 self.dataStorageAreas.exportLiteral(outfile, level, name_='dataStorageAreas')1135 showIndent(outfile, level)1136 outfile.write('),\n')1137 if self.serialisationFlags is not None:1138 showIndent(outfile, level)1139 outfile.write('serialisationFlags=model_.SerialisationFlags(\n')1140 self.serialisationFlags.exportLiteral(outfile, level, name_='serialisationFlags')1141 showIndent(outfile, level)1142 outfile.write('),\n')1143 if self.udbTypes is not None:1144 showIndent(outfile, level)1145 outfile.write('udbTypes=model_.UDBTypes(\n')1146 self.udbTypes.exportLiteral(outfile, level, name_='udbTypes')1147 showIndent(outfile, level)1148 outfile.write('),\n')1149 if self.parameterBlocks is not None:1150 showIndent(outfile, level)1151 outfile.write('parameterBlocks=model_.ParameterBlocks(\n')1152 self.parameterBlocks.exportLiteral(outfile, level, name_='parameterBlocks')1153 showIndent(outfile, level)1154 outfile.write('),\n')1155 def build(self, node):1156 self.buildAttributes(node, node.attrib, [])1157 for child in node:1158 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]1159 self.buildChildren(child, node, nodeName_)1160 def buildAttributes(self, node, attrs, already_processed):1161 pass1162 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):1163 if nodeName_ == 'dataStorageAreas':1164 obj_ = DataStorageAreas.factory()1165 obj_.build(child_)1166 self.set_dataStorageAreas(obj_)1167 elif nodeName_ == 'serialisationFlags':1168 obj_ = SerialisationFlags.factory()1169 obj_.build(child_)1170 self.set_serialisationFlags(obj_)1171 elif nodeName_ == 'udbTypes':1172 obj_ = UDBTypes.factory()1173 obj_.build(child_)1174 self.set_udbTypes(obj_)1175 elif nodeName_ == 'parameterBlocks':1176 obj_ = ParameterBlocks.factory()1177 obj_.build(child_)1178 self.set_parameterBlocks(obj_)1179# end class ParameterDatabase1180class Externs(GeneratedsSuper):1181 subclass = None1182 superclass = None1183 def __init__(self, externString=None):1184 if externString is None:1185 self.externString = []1186 else:1187 self.externString = externString1188 def factory(*args_, **kwargs_):1189 if Externs.subclass:1190 return Externs.subclass(*args_, **kwargs_)1191 else:1192 return Externs(*args_, **kwargs_)1193 factory = staticmethod(factory)1194 def get_externString(self): return self.externString1195 def set_externString(self, externString): self.externString = externString1196 def add_externString(self, value): self.externString.append(value)1197 def insert_externString(self, index, value): self.externString[index] = value1198 def export(self, outfile, level, namespace_='', name_='Externs', namespacedef_=''):1199 showIndent(outfile, level)1200 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))1201 already_processed = []1202 self.exportAttributes(outfile, level, already_processed, namespace_, name_='Externs')1203 if self.hasContent_():1204 outfile.write('>\n')1205 self.exportChildren(outfile, level + 1, namespace_, name_)1206 showIndent(outfile, level)1207 outfile.write('</%s%s>\n' % (namespace_, name_))1208 else:1209 outfile.write('/>\n')1210 def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='Externs'):1211 pass1212 def exportChildren(self, outfile, level, namespace_='', name_='Externs', fromsubclass_=False):1213 for externString_ in self.externString:1214 showIndent(outfile, level)1215 outfile.write('<%sexternString>%s</%sexternString>\n' % (namespace_, self.gds_format_string(quote_xml(externString_).encode(ExternalEncoding), input_name='externString'), namespace_))1216 def hasContent_(self):1217 if (1218 self.externString1219 ):1220 return True1221 else:1222 return False1223 def exportLiteral(self, outfile, level, name_='Externs'):1224 level += 11225 self.exportLiteralAttributes(outfile, level, [], name_)1226 if self.hasContent_():1227 self.exportLiteralChildren(outfile, level, name_)1228 def exportLiteralAttributes(self, outfile, level, already_processed, name_):1229 pass1230 def exportLiteralChildren(self, outfile, level, name_):1231 showIndent(outfile, level)1232 outfile.write('externString=[\n')1233 level += 11234 for externString_ in self.externString:1235 showIndent(outfile, level)1236 outfile.write('%s,\n' % quote_python(externString_).encode(ExternalEncoding))1237 level -= 11238 showIndent(outfile, level)1239 outfile.write('],\n')1240 def build(self, node):1241 self.buildAttributes(node, node.attrib, [])1242 for child in node:1243 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]1244 self.buildChildren(child, node, nodeName_)1245 def buildAttributes(self, node, attrs, already_processed):1246 pass1247 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):1248 if nodeName_ == 'externString':1249 externString_ = child_.text1250 externString_ = self.gds_validate_string(externString_, node, 'externString')1251 self.externString.append(externString_)1252# end class Externs1253class DataStorageAreas(GeneratedsSuper):1254 subclass = None1255 superclass = None1256 def __init__(self, dataStorageArea=None):1257 if dataStorageArea is None:1258 self.dataStorageArea = []1259 else:1260 self.dataStorageArea = dataStorageArea1261 def factory(*args_, **kwargs_):1262 if DataStorageAreas.subclass:1263 return DataStorageAreas.subclass(*args_, **kwargs_)1264 else:1265 return DataStorageAreas(*args_, **kwargs_)1266 factory = staticmethod(factory)1267 def get_dataStorageArea(self): return self.dataStorageArea1268 def set_dataStorageArea(self, dataStorageArea): self.dataStorageArea = dataStorageArea1269 def add_dataStorageArea(self, value): self.dataStorageArea.append(value)1270 def insert_dataStorageArea(self, index, value): self.dataStorageArea[index] = value1271 def export(self, outfile, level, namespace_='', name_='DataStorageAreas', namespacedef_=''):1272 showIndent(outfile, level)1273 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))1274 already_processed = []1275 self.exportAttributes(outfile, level, already_processed, namespace_, name_='DataStorageAreas')1276 if self.hasContent_():1277 outfile.write('>\n')1278 self.exportChildren(outfile, level + 1, namespace_, name_)1279 showIndent(outfile, level)1280 outfile.write('</%s%s>\n' % (namespace_, name_))1281 else:1282 outfile.write('/>\n')1283 def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='DataStorageAreas'):1284 pass1285 def exportChildren(self, outfile, level, namespace_='', name_='DataStorageAreas', fromsubclass_=False):1286 for dataStorageArea_ in self.dataStorageArea:1287 showIndent(outfile, level)1288 outfile.write('<%sdataStorageArea>%s</%sdataStorageArea>\n' % (namespace_, self.gds_format_string(quote_xml(dataStorageArea_).encode(ExternalEncoding), input_name='dataStorageArea'), namespace_))1289 def hasContent_(self):1290 if (1291 self.dataStorageArea1292 ):1293 return True1294 else:1295 return False1296 def exportLiteral(self, outfile, level, name_='DataStorageAreas'):1297 level += 11298 self.exportLiteralAttributes(outfile, level, [], name_)1299 if self.hasContent_():1300 self.exportLiteralChildren(outfile, level, name_)1301 def exportLiteralAttributes(self, outfile, level, already_processed, name_):1302 pass1303 def exportLiteralChildren(self, outfile, level, name_):1304 showIndent(outfile, level)1305 outfile.write('dataStorageArea=[\n')1306 level += 11307 for dataStorageArea_ in self.dataStorageArea:1308 showIndent(outfile, level)1309 outfile.write('%s,\n' % quote_python(dataStorageArea_).encode(ExternalEncoding))1310 level -= 11311 showIndent(outfile, level)1312 outfile.write('],\n')1313 def build(self, node):1314 self.buildAttributes(node, node.attrib, [])1315 for child in node:1316 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]1317 self.buildChildren(child, node, nodeName_)1318 def buildAttributes(self, node, attrs, already_processed):1319 pass1320 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):1321 if nodeName_ == 'dataStorageArea':1322 dataStorageArea_ = child_.text1323 dataStorageArea_ = self.gds_validate_string(dataStorageArea_, node, 'dataStorageArea')1324 self.dataStorageArea.append(dataStorageArea_)1325# end class DataStorageAreas1326USAGE_TEXT = """1327Usage: python <Parser>.py [ -s ] <in_xml_file>1328"""1329def usage():1330 print USAGE_TEXT1331 sys.exit(1)1332def get_root_tag(node):1333 tag = Tag_pattern_.match(node.tag).groups()[-1]1334 rootClass = globals().get(tag)1335 return tag, rootClass1336def parse(inFileName):1337 doc = parsexml_(inFileName)...

Full Screen

Full Screen

jbossds.py

Source:jbossds.py Github

copy

Full Screen

...67except ImportError, exp:68 class GeneratedsSuper(object):69 def gds_format_string(self, input_data, input_name=''):70 return input_data71 def gds_validate_string(self, input_data, node, input_name=''):72 return input_data73 def gds_format_integer(self, input_data, input_name=''):74 return '%d' % input_data75 def gds_validate_integer(self, input_data, node, input_name=''):76 return input_data77 def gds_format_integer_list(self, input_data, input_name=''):78 return '%s' % input_data79 def gds_validate_integer_list(self, input_data, node, input_name=''):80 values = input_data.split()81 for value in values:82 try:83 fvalue = float(value)84 except (TypeError, ValueError), exp:85 raise_parse_error(node, 'Requires sequence of integers')86 return input_data87 def gds_format_float(self, input_data, input_name=''):88 return '%f' % input_data89 def gds_validate_float(self, input_data, node, input_name=''):90 return input_data91 def gds_format_float_list(self, input_data, input_name=''):92 return '%s' % input_data93 def gds_validate_float_list(self, input_data, node, input_name=''):94 values = input_data.split()95 for value in values:96 try:97 fvalue = float(value)98 except (TypeError, ValueError), exp:99 raise_parse_error(node, 'Requires sequence of floats')100 return input_data101 def gds_format_double(self, input_data, input_name=''):102 return '%e' % input_data103 def gds_validate_double(self, input_data, node, input_name=''):104 return input_data105 def gds_format_double_list(self, input_data, input_name=''):106 return '%s' % input_data107 def gds_validate_double_list(self, input_data, node, input_name=''):108 values = input_data.split()109 for value in values:110 try:111 fvalue = float(value)112 except (TypeError, ValueError), exp:113 raise_parse_error(node, 'Requires sequence of doubles')114 return input_data115 def gds_format_boolean(self, input_data, input_name=''):116 return '%s' % input_data117 def gds_validate_boolean(self, input_data, node, input_name=''):118 return input_data119 def gds_format_boolean_list(self, input_data, input_name=''):120 return '%s' % input_data121 def gds_validate_boolean_list(self, input_data, node, input_name=''):122 values = input_data.split()123 for value in values:124 if value not in ('true', '1', 'false', '0', ):125 raise_parse_error(node, 'Requires sequence of booleans ("true", "1", "false", "0")')126 return input_data127 def gds_str_lower(self, instring):128 return instring.lower()129 def get_path_(self, node):130 path_list = []131 self.get_path_list_(node, path_list)132 path_list.reverse()133 path = '/'.join(path_list)134 return path135 Tag_strip_pattern_ = re_.compile(r'\{.*\}')136 def get_path_list_(self, node, path_list):137 if node is None:138 return139 tag = GeneratedsSuper.Tag_strip_pattern_.sub('', node.tag)140 if tag:141 path_list.append(tag)142 self.get_path_list_(node.getparent(), path_list)143#144# If you have installed IPython you can uncomment and use the following.145# IPython is available from http://ipython.scipy.org/.146#147## from IPython.Shell import IPShellEmbed148## args = ''149## ipshell = IPShellEmbed(args,150## banner = 'Dropping into IPython',151## exit_msg = 'Leaving Interpreter, back to program.')152# Then use the following line where and when you want to drop into the153# IPython shell:154# ipshell('<some message> -- Entering ipshell.\nHit Ctrl-D to exit')155#156# Globals157#158ExternalEncoding = 'ascii'159Tag_pattern_ = re_.compile(r'({.*})?(.*)')160STRING_CLEANUP_PAT = re_.compile(r"[\n\r\s]+")161#162# Support/utility functions.163#164def showIndent(outfile, level):165 for idx in range(level):166 outfile.write(' ')167def quote_xml(inStr):168 if not inStr:169 return ''170 s1 = (isinstance(inStr, basestring) and inStr or171 '%s' % inStr)172 s1 = s1.replace('&', '&amp;')173 s1 = s1.replace('<', '&lt;')174 s1 = s1.replace('>', '&gt;')175 return s1176def quote_attrib(inStr):177 s1 = (isinstance(inStr, basestring) and inStr or178 '%s' % inStr)179 s1 = s1.replace('&', '&amp;')180 s1 = s1.replace('<', '&lt;')181 s1 = s1.replace('>', '&gt;')182 if '"' in s1:183 if "'" in s1:184 s1 = '"%s"' % s1.replace('"', "&quot;")185 else:186 s1 = "'%s'" % s1187 else:188 s1 = '"%s"' % s1189 return s1190def quote_python(inStr):191 s1 = inStr192 if s1.find("'") == -1:193 if s1.find('\n') == -1:194 return "'%s'" % s1195 else:196 return "'''%s'''" % s1197 else:198 if s1.find('"') != -1:199 s1 = s1.replace('"', '\\"')200 if s1.find('\n') == -1:201 return '"%s"' % s1202 else:203 return '"""%s"""' % s1204def get_all_text_(node):205 if node.text is not None:206 text = node.text207 else:208 text = ''209 for child in node:210 if child.tail is not None:211 text += child.tail212 return text213class GDSParseError(Exception):214 pass215def raise_parse_error(node, msg):216 if XMLParser_import_library == XMLParser_import_lxml:217 msg = '%s (element %s/line %d)' % (msg, node.tag, node.sourceline, )218 else:219 msg = '%s (element %s)' % (msg, node.tag, )220 raise GDSParseError(msg)221class MixedContainer:222 # Constants for category:223 CategoryNone = 0224 CategoryText = 1225 CategorySimple = 2226 CategoryComplex = 3227 # Constants for content_type:228 TypeNone = 0229 TypeText = 1230 TypeString = 2231 TypeInteger = 3232 TypeFloat = 4233 TypeDecimal = 5234 TypeDouble = 6235 TypeBoolean = 7236 def __init__(self, category, content_type, name, value):237 self.category = category238 self.content_type = content_type239 self.name = name240 self.value = value241 def getCategory(self):242 return self.category243 def getContenttype(self, content_type):244 return self.content_type245 def getValue(self):246 return self.value247 def getName(self):248 return self.name249 def export(self, outfile, level, name, namespace):250 if self.category == MixedContainer.CategoryText:251 # Prevent exporting empty content as empty lines.252 if self.value.strip(): 253 outfile.write(self.value)254 elif self.category == MixedContainer.CategorySimple:255 self.exportSimple(outfile, level, name)256 else: # category == MixedContainer.CategoryComplex257 self.value.export(outfile, level, namespace,name)258 def exportSimple(self, outfile, level, name):259 if self.content_type == MixedContainer.TypeString:260 outfile.write('<%s>%s</%s>' % (self.name, self.value, self.name))261 elif self.content_type == MixedContainer.TypeInteger or \262 self.content_type == MixedContainer.TypeBoolean:263 outfile.write('<%s>%d</%s>' % (self.name, self.value, self.name))264 elif self.content_type == MixedContainer.TypeFloat or \265 self.content_type == MixedContainer.TypeDecimal:266 outfile.write('<%s>%f</%s>' % (self.name, self.value, self.name))267 elif self.content_type == MixedContainer.TypeDouble:268 outfile.write('<%s>%g</%s>' % (self.name, self.value, self.name))269 def exportLiteral(self, outfile, level, name):270 if self.category == MixedContainer.CategoryText:271 showIndent(outfile, level)272 outfile.write('model_.MixedContainer(%d, %d, "%s", "%s"),\n' % \273 (self.category, self.content_type, self.name, self.value))274 elif self.category == MixedContainer.CategorySimple:275 showIndent(outfile, level)276 outfile.write('model_.MixedContainer(%d, %d, "%s", "%s"),\n' % \277 (self.category, self.content_type, self.name, self.value))278 else: # category == MixedContainer.CategoryComplex279 showIndent(outfile, level)280 outfile.write('model_.MixedContainer(%d, %d, "%s",\n' % \281 (self.category, self.content_type, self.name,))282 self.value.exportLiteral(outfile, level + 1)283 showIndent(outfile, level)284 outfile.write(')\n')285class MemberSpec_(object):286 def __init__(self, name='', data_type='', container=0):287 self.name = name288 self.data_type = data_type289 self.container = container290 def set_name(self, name): self.name = name291 def get_name(self): return self.name292 def set_data_type(self, data_type): self.data_type = data_type293 def get_data_type_chain(self): return self.data_type294 def get_data_type(self):295 if isinstance(self.data_type, list):296 if len(self.data_type) > 0:297 return self.data_type[-1]298 else:299 return 'xs:string'300 else:301 return self.data_type302 def set_container(self, container): self.container = container303 def get_container(self): return self.container304def _cast(typ, value):305 if typ is None or value is None:306 return value307 return typ(value)308#309# Data representation classes.310#311class datasources(GeneratedsSuper):312 subclass = None313 superclass = None314 def __init__(self, local_tx_datasource=None):315 if local_tx_datasource is None:316 self.local_tx_datasource = []317 else:318 self.local_tx_datasource = local_tx_datasource319 def factory(*args_, **kwargs_):320 if datasources.subclass:321 return datasources.subclass(*args_, **kwargs_)322 else:323 return datasources(*args_, **kwargs_)324 factory = staticmethod(factory)325 def get_local_tx_datasource(self): return self.local_tx_datasource326 def set_local_tx_datasource(self, local_tx_datasource): self.local_tx_datasource = local_tx_datasource327 def add_local_tx_datasource(self, value): self.local_tx_datasource.append(value)328 def insert_local_tx_datasource(self, index, value): self.local_tx_datasource[index] = value329 def export(self, outfile, level, namespace_='tns:', name_='datasources', namespacedef_=''):330 showIndent(outfile, level)331 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))332 self.exportAttributes(outfile, level, [], namespace_, name_='datasources')333 if self.hasContent_():334 outfile.write('>\n')335 self.exportChildren(outfile, level + 1, namespace_, name_)336 showIndent(outfile, level)337 outfile.write('</%s%s>\n' % (namespace_, name_))338 else:339 outfile.write('/>\n')340 def exportAttributes(self, outfile, level, already_processed, namespace_='tns:', name_='datasources'):341 pass342 def exportChildren(self, outfile, level, namespace_='tns:', name_='datasources', fromsubclass_=False):343 for local_tx_datasource_ in self.local_tx_datasource:344 local_tx_datasource_.export(outfile, level, namespace_, name_='local-tx-datasource')345 def hasContent_(self):346 if (347 self.local_tx_datasource348 ):349 return True350 else:351 return False352 def exportLiteral(self, outfile, level, name_='datasources'):353 level += 1354 self.exportLiteralAttributes(outfile, level, [], name_)355 if self.hasContent_():356 self.exportLiteralChildren(outfile, level, name_)357 def exportLiteralAttributes(self, outfile, level, already_processed, name_):358 pass359 def exportLiteralChildren(self, outfile, level, name_):360 showIndent(outfile, level)361 outfile.write('local_tx_datasource=[\n')362 level += 1363 for local_tx_datasource_ in self.local_tx_datasource:364 showIndent(outfile, level)365 outfile.write('model_.local_tx_datasource(\n')366 local_tx_datasource_.exportLiteral(outfile, level, name_='local-tx-datasource')367 showIndent(outfile, level)368 outfile.write('),\n')369 level -= 1370 showIndent(outfile, level)371 outfile.write('],\n')372 def build(self, node):373 self.buildAttributes(node, node.attrib, [])374 for child in node:375 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]376 self.buildChildren(child, node, nodeName_)377 def buildAttributes(self, node, attrs, already_processed):378 pass379 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):380 if nodeName_ == 'local-tx-datasource': 381 obj_ = local_tx_datasource.factory()382 obj_.build(child_)383 self.local_tx_datasource.append(obj_)384# end class datasources385class local_tx_datasource(GeneratedsSuper):386 subclass = None387 superclass = None388 def __init__(self, jndi_name=None, connection_url=None, driver_class=None, max_pool_size=None, check_valid_connection_sql=None, security_domain=None, user_name=None, password=None):389 self.jndi_name = jndi_name390 self.connection_url = connection_url391 self.driver_class = driver_class392 self.max_pool_size = max_pool_size393 self.check_valid_connection_sql = check_valid_connection_sql394 self.security_domain = security_domain395 self.user_name = user_name396 self.password = password397 def factory(*args_, **kwargs_):398 if local_tx_datasource.subclass:399 return local_tx_datasource.subclass(*args_, **kwargs_)400 else:401 return local_tx_datasource(*args_, **kwargs_)402 factory = staticmethod(factory)403 def get_jndi_name(self): return self.jndi_name404 def set_jndi_name(self, jndi_name): self.jndi_name = jndi_name405 def get_connection_url(self): return self.connection_url406 def set_connection_url(self, connection_url): self.connection_url = connection_url407 def get_driver_class(self): return self.driver_class408 def set_driver_class(self, driver_class): self.driver_class = driver_class409 def get_max_pool_size(self): return self.max_pool_size410 def set_max_pool_size(self, max_pool_size): self.max_pool_size = max_pool_size411 def get_check_valid_connection_sql(self): return self.check_valid_connection_sql412 def set_check_valid_connection_sql(self, check_valid_connection_sql): self.check_valid_connection_sql = check_valid_connection_sql413 def get_security_domain(self): return self.security_domain414 def set_security_domain(self, security_domain): self.security_domain = security_domain415 def get_user_name(self): return self.user_name416 def set_user_name(self, user_name): self.user_name = user_name417 def get_password(self): return self.password418 def set_password(self, password): self.password = password419 def export(self, outfile, level, namespace_='tns:', name_='local-tx-datasource', namespacedef_=''):420 showIndent(outfile, level)421 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))422 self.exportAttributes(outfile, level, [], namespace_, name_='local-tx-datasource')423 if self.hasContent_():424 outfile.write('>\n')425 self.exportChildren(outfile, level + 1, namespace_, name_)426 showIndent(outfile, level)427 outfile.write('</%s%s>\n' % (namespace_, name_))428 else:429 outfile.write('/>\n')430 def exportAttributes(self, outfile, level, already_processed, namespace_='tns:', name_='local-tx-datasource'):431 pass432 def exportChildren(self, outfile, level, namespace_='tns:', name_='local-tx-datasource', fromsubclass_=False):433 if self.jndi_name is not None:434 showIndent(outfile, level)435 outfile.write('<%sjndi-name>%s</%sjndi-name>\n' % (namespace_, self.gds_format_string(quote_xml(self.jndi_name).encode(ExternalEncoding), input_name='jndi-name'), namespace_))436 if self.connection_url is not None:437 showIndent(outfile, level)438 outfile.write('<%sconnection-url>%s</%sconnection-url>\n' % (namespace_, self.gds_format_string(quote_xml(self.connection_url).encode(ExternalEncoding), input_name='connection-url'), namespace_))439 if self.driver_class is not None:440 showIndent(outfile, level)441 outfile.write('<%sdriver-class>%s</%sdriver-class>\n' % (namespace_, self.gds_format_string(quote_xml(self.driver_class).encode(ExternalEncoding), input_name='driver-class'), namespace_))442 if self.max_pool_size is not None:443 showIndent(outfile, level)444 outfile.write('<%smax-pool-size>%s</%smax-pool-size>\n' % (namespace_, self.gds_format_string(quote_xml(self.max_pool_size).encode(ExternalEncoding), input_name='max-pool-size'), namespace_))445 if self.check_valid_connection_sql is not None:446 showIndent(outfile, level)447 outfile.write('<%scheck-valid-connection-sql>%s</%scheck-valid-connection-sql>\n' % (namespace_, self.gds_format_string(quote_xml(self.check_valid_connection_sql).encode(ExternalEncoding), input_name='check-valid-connection-sql'), namespace_))448 if self.security_domain is not None:449 showIndent(outfile, level)450 outfile.write('<%ssecurity-domain>%s</%ssecurity-domain>\n' % (namespace_, self.gds_format_string(quote_xml(self.security_domain).encode(ExternalEncoding), input_name='security-domain'), namespace_))451 if self.user_name is not None:452 showIndent(outfile, level)453 outfile.write('<%suser-name>%s</%suser-name>\n' % (namespace_, self.gds_format_string(quote_xml(self.user_name).encode(ExternalEncoding), input_name='user-name'), namespace_))454 if self.password is not None:455 showIndent(outfile, level)456 outfile.write('<%spassword>%s</%spassword>\n' % (namespace_, self.gds_format_string(quote_xml(self.password).encode(ExternalEncoding), input_name='password'), namespace_))457 def hasContent_(self):458 if (459 self.jndi_name is not None or460 self.connection_url is not None or461 self.driver_class is not None or462 self.max_pool_size is not None or463 self.check_valid_connection_sql is not None or464 self.security_domain is not None or465 self.user_name is not None or466 self.password is not None467 ):468 return True469 else:470 return False471 def exportLiteral(self, outfile, level, name_='local-tx-datasource'):472 level += 1473 self.exportLiteralAttributes(outfile, level, [], name_)474 if self.hasContent_():475 self.exportLiteralChildren(outfile, level, name_)476 def exportLiteralAttributes(self, outfile, level, already_processed, name_):477 pass478 def exportLiteralChildren(self, outfile, level, name_):479 if self.jndi_name is not None:480 showIndent(outfile, level)481 outfile.write('jndi_name=%s,\n' % quote_python(self.jndi_name).encode(ExternalEncoding))482 if self.connection_url is not None:483 showIndent(outfile, level)484 outfile.write('connection_url=%s,\n' % quote_python(self.connection_url).encode(ExternalEncoding))485 if self.driver_class is not None:486 showIndent(outfile, level)487 outfile.write('driver_class=%s,\n' % quote_python(self.driver_class).encode(ExternalEncoding))488 if self.max_pool_size is not None:489 showIndent(outfile, level)490 outfile.write('max_pool_size=%s,\n' % quote_python(self.max_pool_size).encode(ExternalEncoding))491 if self.check_valid_connection_sql is not None:492 showIndent(outfile, level)493 outfile.write('check_valid_connection_sql=%s,\n' % quote_python(self.check_valid_connection_sql).encode(ExternalEncoding))494 if self.security_domain is not None:495 showIndent(outfile, level)496 outfile.write('security_domain=%s,\n' % quote_python(self.security_domain).encode(ExternalEncoding))497 if self.user_name is not None:498 showIndent(outfile, level)499 outfile.write('user_name=%s,\n' % quote_python(self.user_name).encode(ExternalEncoding))500 if self.password is not None:501 showIndent(outfile, level)502 outfile.write('password=%s,\n' % quote_python(self.password).encode(ExternalEncoding))503 def build(self, node):504 self.buildAttributes(node, node.attrib, [])505 for child in node:506 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]507 self.buildChildren(child, node, nodeName_)508 def buildAttributes(self, node, attrs, already_processed):509 pass510 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):511 if nodeName_ == 'jndi-name':512 jndi_name_ = child_.text513 jndi_name_ = self.gds_validate_string(jndi_name_, node, 'jndi_name')514 self.jndi_name = jndi_name_515 elif nodeName_ == 'connection-url':516 connection_url_ = child_.text517 connection_url_ = self.gds_validate_string(connection_url_, node, 'connection_url')518 self.connection_url = connection_url_519 elif nodeName_ == 'driver-class':520 driver_class_ = child_.text521 driver_class_ = self.gds_validate_string(driver_class_, node, 'driver_class')522 self.driver_class = driver_class_523 elif nodeName_ == 'max-pool-size':524 max_pool_size_ = child_.text525 max_pool_size_ = self.gds_validate_string(max_pool_size_, node, 'max_pool_size')526 self.max_pool_size = max_pool_size_527 elif nodeName_ == 'check-valid-connection-sql':528 check_valid_connection_sql_ = child_.text529 check_valid_connection_sql_ = self.gds_validate_string(check_valid_connection_sql_, node, 'check_valid_connection_sql')530 self.check_valid_connection_sql = check_valid_connection_sql_531 elif nodeName_ == 'security-domain':532 security_domain_ = child_.text533 security_domain_ = self.gds_validate_string(security_domain_, node, 'security_domain')534 self.security_domain = security_domain_535 elif nodeName_ == 'user-name':536 user_name_ = child_.text537 user_name_ = self.gds_validate_string(user_name_, node, 'user_name')538 self.user_name = user_name_539 elif nodeName_ == 'password':540 password_ = child_.text541 password_ = self.gds_validate_string(password_, node, 'password')542 self.password = password_543# end class local_tx_datasource544USAGE_TEXT = """545Usage: python <Parser>.py [ -s ] <in_xml_file>546"""547def usage():548 print USAGE_TEXT549 sys.exit(1)550def get_root_tag(node):551 tag = Tag_pattern_.match(node.tag).groups()[-1]552 rootClass = globals().get(tag)553 return tag, rootClass554def parse(inFileName):555 doc = parsexml_(inFileName)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful