Best Python code snippet using autotest_python
generateds_gui_session.py
Source:generateds_gui_session.py
...113 raise_parse_error(node, 'Requires sequence of doubles')114 return values115 def gds_format_boolean(self, input_data, input_name=''):116 return ('%s' % input_data).lower()117 def gds_validate_boolean(self, input_data, node=None, input_name=''):118 return input_data119 def gds_format_boolean_list(self, input_data, input_name=''):120 return '%s' % ' '.join(input_data)121 def gds_validate_boolean_list(122 self, input_data, node=None, input_name=''):123 values = input_data.split()124 for value in values:125 if value not in ('true', '1', 'false', '0', ):126 raise_parse_error(127 node,128 'Requires sequence of booleans '129 '("true", "1", "false", "0")')130 return values131 def gds_validate_datetime(self, input_data, node=None, input_name=''):132 return input_data133 def gds_format_datetime(self, input_data, input_name=''):134 if input_data.microsecond == 0:135 _svalue = '%04d-%02d-%02dT%02d:%02d:%02d' % (136 input_data.year,137 input_data.month,138 input_data.day,139 input_data.hour,140 input_data.minute,141 input_data.second,142 )143 else:144 _svalue = '%04d-%02d-%02dT%02d:%02d:%02d.%s' % (145 input_data.year,146 input_data.month,147 input_data.day,148 input_data.hour,149 input_data.minute,150 input_data.second,151 ('%f' % (float(input_data.microsecond) / 1000000))[2:],152 )153 if input_data.tzinfo is not None:154 tzoff = input_data.tzinfo.utcoffset(input_data)155 if tzoff is not None:156 total_seconds = tzoff.seconds + (86400 * tzoff.days)157 if total_seconds == 0:158 _svalue += 'Z'159 else:160 if total_seconds < 0:161 _svalue += '-'162 total_seconds *= -1163 else:164 _svalue += '+'165 hours = total_seconds // 3600166 minutes = (total_seconds - (hours * 3600)) // 60167 _svalue += '{0:02d}:{1:02d}'.format(hours, minutes)168 return _svalue169 @classmethod170 def gds_parse_datetime(cls, input_data):171 tz = None172 if input_data[-1] == 'Z':173 tz = GeneratedsSuper._FixedOffsetTZ(0, 'UTC')174 input_data = input_data[:-1]175 else:176 results = GeneratedsSuper.tzoff_pattern.search(input_data)177 if results is not None:178 tzoff_parts = results.group(2).split(':')179 tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1])180 if results.group(1) == '-':181 tzoff *= -1182 tz = GeneratedsSuper._FixedOffsetTZ(183 tzoff, results.group(0))184 input_data = input_data[:-6]185 time_parts = input_data.split('.')186 if len(time_parts) > 1:187 micro_seconds = int(float('0.' + time_parts[1]) * 1000000)188 input_data = '%s.%s' % (time_parts[0], micro_seconds, )189 dt = datetime_.datetime.strptime(190 input_data, '%Y-%m-%dT%H:%M:%S.%f')191 else:192 dt = datetime_.datetime.strptime(193 input_data, '%Y-%m-%dT%H:%M:%S')194 dt = dt.replace(tzinfo=tz)195 return dt196 def gds_validate_date(self, input_data, node=None, input_name=''):197 return input_data198 def gds_format_date(self, input_data, input_name=''):199 _svalue = '%04d-%02d-%02d' % (200 input_data.year,201 input_data.month,202 input_data.day,203 )204 try:205 if input_data.tzinfo is not None:206 tzoff = input_data.tzinfo.utcoffset(input_data)207 if tzoff is not None:208 total_seconds = tzoff.seconds + (86400 * tzoff.days)209 if total_seconds == 0:210 _svalue += 'Z'211 else:212 if total_seconds < 0:213 _svalue += '-'214 total_seconds *= -1215 else:216 _svalue += '+'217 hours = total_seconds // 3600218 minutes = (total_seconds - (hours * 3600)) // 60219 _svalue += '{0:02d}:{1:02d}'.format(220 hours, minutes)221 except AttributeError:222 pass223 return _svalue224 @classmethod225 def gds_parse_date(cls, input_data):226 tz = None227 if input_data[-1] == 'Z':228 tz = GeneratedsSuper._FixedOffsetTZ(0, 'UTC')229 input_data = input_data[:-1]230 else:231 results = GeneratedsSuper.tzoff_pattern.search(input_data)232 if results is not None:233 tzoff_parts = results.group(2).split(':')234 tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1])235 if results.group(1) == '-':236 tzoff *= -1237 tz = GeneratedsSuper._FixedOffsetTZ(238 tzoff, results.group(0))239 input_data = input_data[:-6]240 dt = datetime_.datetime.strptime(input_data, '%Y-%m-%d')241 dt = dt.replace(tzinfo=tz)242 return dt.date()243 def gds_validate_time(self, input_data, node=None, input_name=''):244 return input_data245 def gds_format_time(self, input_data, input_name=''):246 if input_data.microsecond == 0:247 _svalue = '%02d:%02d:%02d' % (248 input_data.hour,249 input_data.minute,250 input_data.second,251 )252 else:253 _svalue = '%02d:%02d:%02d.%s' % (254 input_data.hour,255 input_data.minute,256 input_data.second,257 ('%f' % (float(input_data.microsecond) / 1000000))[2:],258 )259 if input_data.tzinfo is not None:260 tzoff = input_data.tzinfo.utcoffset(input_data)261 if tzoff is not None:262 total_seconds = tzoff.seconds + (86400 * tzoff.days)263 if total_seconds == 0:264 _svalue += 'Z'265 else:266 if total_seconds < 0:267 _svalue += '-'268 total_seconds *= -1269 else:270 _svalue += '+'271 hours = total_seconds // 3600272 minutes = (total_seconds - (hours * 3600)) // 60273 _svalue += '{0:02d}:{1:02d}'.format(hours, minutes)274 return _svalue275 def gds_validate_simple_patterns(self, patterns, target):276 # pat is a list of lists of strings/patterns. We should:277 # - AND the outer elements278 # - OR the inner elements279 found1 = True280 for patterns1 in patterns:281 found2 = False282 for patterns2 in patterns1:283 if re_.search(patterns2, target) is not None:284 found2 = True285 break286 if not found2:287 found1 = False288 break289 return found1290 @classmethod291 def gds_parse_time(cls, input_data):292 tz = None293 if input_data[-1] == 'Z':294 tz = GeneratedsSuper._FixedOffsetTZ(0, 'UTC')295 input_data = input_data[:-1]296 else:297 results = GeneratedsSuper.tzoff_pattern.search(input_data)298 if results is not None:299 tzoff_parts = results.group(2).split(':')300 tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1])301 if results.group(1) == '-':302 tzoff *= -1303 tz = GeneratedsSuper._FixedOffsetTZ(304 tzoff, results.group(0))305 input_data = input_data[:-6]306 if len(input_data.split('.')) > 1:307 dt = datetime_.datetime.strptime(input_data, '%H:%M:%S.%f')308 else:309 dt = datetime_.datetime.strptime(input_data, '%H:%M:%S')310 dt = dt.replace(tzinfo=tz)311 return dt.time()312 def gds_str_lower(self, instring):313 return instring.lower()314 def get_path_(self, node):315 path_list = []316 self.get_path_list_(node, path_list)317 path_list.reverse()318 path = '/'.join(path_list)319 return path320 Tag_strip_pattern_ = re_.compile(r'\{.*\}')321 def get_path_list_(self, node, path_list):322 if node is None:323 return324 tag = GeneratedsSuper.Tag_strip_pattern_.sub('', node.tag)325 if tag:326 path_list.append(tag)327 self.get_path_list_(node.getparent(), path_list)328 def get_class_obj_(self, node, default_class=None):329 class_obj1 = default_class330 if 'xsi' in node.nsmap:331 classname = node.get('{%s}type' % node.nsmap['xsi'])332 if classname is not None:333 names = classname.split(':')334 if len(names) == 2:335 classname = names[1]336 class_obj2 = globals().get(classname)337 if class_obj2 is not None:338 class_obj1 = class_obj2339 return class_obj1340 def gds_build_any(self, node, type_name=None):341 return None342 @classmethod343 def gds_reverse_node_mapping(cls, mapping):344 return dict(((v, k) for k, v in mapping.iteritems()))345 @staticmethod346 def gds_encode(instring):347 if sys.version_info.major == 2:348 return instring.encode(ExternalEncoding)349 else:350 return instring351 def getSubclassFromModule_(module, class_):352 '''Get the subclass of a class from a specific module.'''353 name = class_.__name__ + 'Sub'354 if hasattr(module, name):355 return getattr(module, name)356 else:357 return None358#359# If you have installed IPython you can uncomment and use the following.360# IPython is available from http://ipython.scipy.org/.361#362## from IPython.Shell import IPShellEmbed363## args = ''364## ipshell = IPShellEmbed(args,365## banner = 'Dropping into IPython',366## exit_msg = 'Leaving Interpreter, back to program.')367# Then use the following line where and when you want to drop into the368# IPython shell:369# ipshell('<some message> -- Entering ipshell.\nHit Ctrl-D to exit')370#371# Globals372#373ExternalEncoding = 'ascii'374Tag_pattern_ = re_.compile(r'({.*})?(.*)')375String_cleanup_pat_ = re_.compile(r"[\n\r\s]+")376Namespace_extract_pat_ = re_.compile(r'{(.*)}(.*)')377CDATA_pattern_ = re_.compile(r"<!\[CDATA\[.*?\]\]>", re_.DOTALL)378# Change this to redirect the generated superclass module to use a379# specific subclass module.380CurrentSubclassModule_ = None381#382# Support/utility functions.383#384def showIndent(outfile, level, pretty_print=True):385 if pretty_print:386 for idx in range(level):387 outfile.write(' ')388def quote_xml(inStr):389 "Escape markup chars, but do not modify CDATA sections."390 if not inStr:391 return ''392 s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr)393 s2 = ''394 pos = 0395 matchobjects = CDATA_pattern_.finditer(s1)396 for mo in matchobjects:397 s3 = s1[pos:mo.start()]398 s2 += quote_xml_aux(s3)399 s2 += s1[mo.start():mo.end()]400 pos = mo.end()401 s3 = s1[pos:]402 s2 += quote_xml_aux(s3)403 return s2404def quote_xml_aux(inStr):405 s1 = inStr.replace('&', '&')406 s1 = s1.replace('<', '<')407 s1 = s1.replace('>', '>')408 return s1409def quote_attrib(inStr):410 s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr)411 s1 = s1.replace('&', '&')412 s1 = s1.replace('<', '<')413 s1 = s1.replace('>', '>')414 if '"' in s1:415 if "'" in s1:416 s1 = '"%s"' % s1.replace('"', """)417 else:418 s1 = "'%s'" % s1419 else:420 s1 = '"%s"' % s1421 return s1422def quote_python(inStr):423 s1 = inStr424 if s1.find("'") == -1:425 if s1.find('\n') == -1:426 return "'%s'" % s1427 else:428 return "'''%s'''" % s1429 else:430 if s1.find('"') != -1:431 s1 = s1.replace('"', '\\"')432 if s1.find('\n') == -1:433 return '"%s"' % s1434 else:435 return '"""%s"""' % s1436def get_all_text_(node):437 if node.text is not None:438 text = node.text439 else:440 text = ''441 for child in node:442 if child.tail is not None:443 text += child.tail444 return text445def find_attr_value_(attr_name, node):446 attrs = node.attrib447 attr_parts = attr_name.split(':')448 value = None449 if len(attr_parts) == 1:450 value = attrs.get(attr_name)451 elif len(attr_parts) == 2:452 prefix, name = attr_parts453 namespace = node.nsmap.get(prefix)454 if namespace is not None:455 value = attrs.get('{%s}%s' % (namespace, name, ))456 return value457class GDSParseError(Exception):458 pass459def raise_parse_error(node, msg):460 msg = '%s (element %s/line %d)' % (msg, node.tag, node.sourceline, )461 raise GDSParseError(msg)462class MixedContainer:463 # Constants for category:464 CategoryNone = 0465 CategoryText = 1466 CategorySimple = 2467 CategoryComplex = 3468 # Constants for content_type:469 TypeNone = 0470 TypeText = 1471 TypeString = 2472 TypeInteger = 3473 TypeFloat = 4474 TypeDecimal = 5475 TypeDouble = 6476 TypeBoolean = 7477 TypeBase64 = 8478 def __init__(self, category, content_type, name, value):479 self.category = category480 self.content_type = content_type481 self.name = name482 self.value = value483 def getCategory(self):484 return self.category485 def getContenttype(self, content_type):486 return self.content_type487 def getValue(self):488 return self.value489 def getName(self):490 return self.name491 def export(self, outfile, level, name, namespace, pretty_print=True):492 if self.category == MixedContainer.CategoryText:493 # Prevent exporting empty content as empty lines.494 if self.value.strip():495 outfile.write(self.value)496 elif self.category == MixedContainer.CategorySimple:497 self.exportSimple(outfile, level, name)498 else: # category == MixedContainer.CategoryComplex499 self.value.export(outfile, level, namespace, name, pretty_print)500 def exportSimple(self, outfile, level, name):501 if self.content_type == MixedContainer.TypeString:502 outfile.write('<%s>%s</%s>' % (503 self.name, self.value, self.name))504 elif self.content_type == MixedContainer.TypeInteger or \505 self.content_type == MixedContainer.TypeBoolean:506 outfile.write('<%s>%d</%s>' % (507 self.name, self.value, self.name))508 elif self.content_type == MixedContainer.TypeFloat or \509 self.content_type == MixedContainer.TypeDecimal:510 outfile.write('<%s>%f</%s>' % (511 self.name, self.value, self.name))512 elif self.content_type == MixedContainer.TypeDouble:513 outfile.write('<%s>%g</%s>' % (514 self.name, self.value, self.name))515 elif self.content_type == MixedContainer.TypeBase64:516 outfile.write('<%s>%s</%s>' % (517 self.name, base64.b64encode(self.value), self.name))518 def to_etree(self, element):519 if self.category == MixedContainer.CategoryText:520 # Prevent exporting empty content as empty lines.521 if self.value.strip():522 if len(element) > 0:523 if element[-1].tail is None:524 element[-1].tail = self.value525 else:526 element[-1].tail += self.value527 else:528 if element.text is None:529 element.text = self.value530 else:531 element.text += self.value532 elif self.category == MixedContainer.CategorySimple:533 subelement = etree_.SubElement(element, '%s' % self.name)534 subelement.text = self.to_etree_simple()535 else: # category == MixedContainer.CategoryComplex536 self.value.to_etree(element)537 def to_etree_simple(self):538 if self.content_type == MixedContainer.TypeString:539 text = self.value540 elif (self.content_type == MixedContainer.TypeInteger or541 self.content_type == MixedContainer.TypeBoolean):542 text = '%d' % self.value543 elif (self.content_type == MixedContainer.TypeFloat or544 self.content_type == MixedContainer.TypeDecimal):545 text = '%f' % self.value546 elif self.content_type == MixedContainer.TypeDouble:547 text = '%g' % self.value548 elif self.content_type == MixedContainer.TypeBase64:549 text = '%s' % base64.b64encode(self.value)550 return text551 def exportLiteral(self, outfile, level, name):552 if self.category == MixedContainer.CategoryText:553 showIndent(outfile, level)554 outfile.write(555 'model_.MixedContainer(%d, %d, "%s", "%s"),\n' % (556 self.category, self.content_type, self.name, self.value))557 elif self.category == MixedContainer.CategorySimple:558 showIndent(outfile, level)559 outfile.write(560 'model_.MixedContainer(%d, %d, "%s", "%s"),\n' % (561 self.category, self.content_type, self.name, self.value))562 else: # category == MixedContainer.CategoryComplex563 showIndent(outfile, level)564 outfile.write(565 'model_.MixedContainer(%d, %d, "%s",\n' % (566 self.category, self.content_type, self.name,))567 self.value.exportLiteral(outfile, level + 1)568 showIndent(outfile, level)569 outfile.write(')\n')570class MemberSpec_(object):571 def __init__(self, name='', data_type='', container=0):572 self.name = name573 self.data_type = data_type574 self.container = container575 def set_name(self, name): self.name = name576 def get_name(self): return self.name577 def set_data_type(self, data_type): self.data_type = data_type578 def get_data_type_chain(self): return self.data_type579 def get_data_type(self):580 if isinstance(self.data_type, list):581 if len(self.data_type) > 0:582 return self.data_type[-1]583 else:584 return 'xs:string'585 else:586 return self.data_type587 def set_container(self, container): self.container = container588 def get_container(self): return self.container589def _cast(typ, value):590 if typ is None or value is None:591 return value592 return typ(value)593#594# Mixin class for additional behaviors.595#596class SessionTypeMixin(object):597 def copy(self):598 """Produce a copy of myself.599 """600 new_session = sessionType(601 input_schema=self.input_schema,602 output_superclass=self.output_superclass,603 output_subclass=self.output_subclass,604 force=self.force,605 prefix=self.prefix,606 namespace_prefix=self.namespace_prefix,607 empty_namespace_prefix=self.empty_namespace_prefix,608 behavior_filename=self.behavior_filename,609 properties=self.properties,610 subclass_suffix=self.subclass_suffix,611 root_element=self.root_element,612 superclass_module=self.superclass_module,613 auto_super=self.auto_super,614 old_getters_setters=self.old_getters_setters,615 validator_bodies=self.validator_bodies,616 user_methods=self.user_methods,617 no_dates=self.no_dates,618 no_versions=self.no_versions,619 no_process_includes=self.no_process_includes,620 silence=self.silence,621 namespace_defs=self.namespace_defs,622 external_encoding=self.external_encoding,623 member_specs=self.member_specs,624 export_spec=self.export_spec,625 one_file_per_xsd=self.one_file_per_xsd,626 output_directory=self.output_directory,627 module_suffix=self.module_suffix,628 preserve_cdata_tags=self.preserve_cdata_tags,629 cleanup_name_list=self.cleanup_name_list,630 )631 return new_session632 def __eq__(self, obj):633 """Implement the == operator.634 """635 if (636 obj.input_schema == self.input_schema and637 obj.output_superclass == self.output_superclass and638 obj.output_subclass == self.output_subclass and639 obj.force == self.force and640 obj.prefix == self.prefix and641 obj.namespace_prefix == self.namespace_prefix and642 obj.empty_namespace_prefix == self.empty_namespace_prefix and643 obj.behavior_filename == self.behavior_filename and644 obj.properties == self.properties and645 obj.subclass_suffix == self.subclass_suffix and646 obj.root_element == self.root_element and647 obj.superclass_module == self.superclass_module and648 obj.auto_super == self.auto_super and649 obj.old_getters_setters == self.old_getters_setters and650 obj.validator_bodies == self.validator_bodies and651 obj.user_methods == self.user_methods and652 obj.no_dates == self.no_dates and653 obj.no_versions == self.no_versions and654 obj.no_process_includes == self.no_process_includes and655 obj.silence == self.silence and656 obj.namespace_defs == self.namespace_defs and657 obj.external_encoding == self.external_encoding and658 obj.member_specs == self.member_specs and659 obj.export_spec == self.export_spec and660 obj.one_file_per_xsd == self.one_file_per_xsd and661 obj.output_directory == self.output_directory and662 obj.module_suffix == self.module_suffix and663 obj.preserve_cdata_tags == self.preserve_cdata_tags and664 obj.cleanup_name_list == self.cleanup_name_list):665 return True666 else:667 return False668 def __ne__(self, obj):669 """Implement the != operator.670 """671 return not self.__eq__(obj)672#673# Data representation classes.674#675class sessionType(GeneratedsSuper, SessionTypeMixin):676 member_data_items_ = [677 MemberSpec_('input_schema', 'xs:string', 0),678 MemberSpec_('output_superclass', 'xs:string', 0),679 MemberSpec_('output_subclass', 'xs:string', 0),680 MemberSpec_('force', 'xs:boolean', 0),681 MemberSpec_('prefix', 'xs:string', 0),682 MemberSpec_('namespace_prefix', 'xs:string', 0),683 MemberSpec_('empty_namespace_prefix', 'xs:boolean', 0),684 MemberSpec_('behavior_filename', 'xs:string', 0),685 MemberSpec_('properties', 'xs:boolean', 0),686 MemberSpec_('subclass_suffix', 'xs:string', 0),687 MemberSpec_('root_element', 'xs:string', 0),688 MemberSpec_('superclass_module', 'xs:string', 0),689 MemberSpec_('auto_super', 'xs:boolean', 0),690 MemberSpec_('old_getters_setters', 'xs:boolean', 0),691 MemberSpec_('validator_bodies', 'xs:string', 0),692 MemberSpec_('user_methods', 'xs:string', 0),693 MemberSpec_('no_dates', 'xs:boolean', 0),694 MemberSpec_('no_versions', 'xs:boolean', 0),695 MemberSpec_('no_process_includes', 'xs:boolean', 0),696 MemberSpec_('silence', 'xs:boolean', 0),697 MemberSpec_('namespace_defs', 'xs:string', 0),698 MemberSpec_('external_encoding', 'xs:string', 0),699 MemberSpec_('get_encoded', 'xs:boolean', 0),700 MemberSpec_('member_specs', 'xs:string', 0),701 MemberSpec_('export_spec', 'xs:string', 0),702 MemberSpec_('one_file_per_xsd', 'xs:boolean', 0),703 MemberSpec_('output_directory', 'xs:string', 0),704 MemberSpec_('module_suffix', 'xs:string', 0),705 MemberSpec_('preserve_cdata_tags', 'xs:boolean', 0),706 MemberSpec_('cleanup_name_list', 'xs:string', 0),707 ]708 subclass = None709 superclass = None710 def __init__(self, input_schema=None, output_superclass=None, output_subclass=None, force=None, prefix=None, namespace_prefix=None, empty_namespace_prefix=None, behavior_filename=None, properties=None, subclass_suffix=None, root_element=None, superclass_module=None, auto_super=None, old_getters_setters=None, validator_bodies=None, user_methods=None, no_dates=None, no_versions=None, no_process_includes=None, silence=None, namespace_defs=None, external_encoding=None, get_encoded=None, member_specs=None, export_spec=None, one_file_per_xsd=None, output_directory=None, module_suffix=None, preserve_cdata_tags=None, cleanup_name_list=None):711 self.original_tagname_ = None712 self.input_schema = input_schema713 self.output_superclass = output_superclass714 self.output_subclass = output_subclass715 self.force = force716 self.prefix = prefix717 self.namespace_prefix = namespace_prefix718 self.empty_namespace_prefix = empty_namespace_prefix719 self.behavior_filename = behavior_filename720 self.properties = properties721 self.subclass_suffix = subclass_suffix722 self.root_element = root_element723 self.superclass_module = superclass_module724 self.auto_super = auto_super725 self.old_getters_setters = old_getters_setters726 self.validator_bodies = validator_bodies727 self.user_methods = user_methods728 self.no_dates = no_dates729 self.no_versions = no_versions730 self.no_process_includes = no_process_includes731 self.silence = silence732 self.namespace_defs = namespace_defs733 self.external_encoding = external_encoding734 self.get_encoded = get_encoded735 self.member_specs = member_specs736 self.export_spec = export_spec737 self.one_file_per_xsd = one_file_per_xsd738 self.output_directory = output_directory739 self.module_suffix = module_suffix740 self.preserve_cdata_tags = preserve_cdata_tags741 self.cleanup_name_list = cleanup_name_list742 def factory(*args_, **kwargs_):743 if CurrentSubclassModule_ is not None:744 subclass = getSubclassFromModule_(745 CurrentSubclassModule_, sessionType)746 if subclass is not None:747 return subclass(*args_, **kwargs_)748 if sessionType.subclass:749 return sessionType.subclass(*args_, **kwargs_)750 else:751 return sessionType(*args_, **kwargs_)752 factory = staticmethod(factory)753 def get_input_schema(self): return self.input_schema754 def set_input_schema(self, input_schema): self.input_schema = input_schema755 def get_output_superclass(self): return self.output_superclass756 def set_output_superclass(self, output_superclass): self.output_superclass = output_superclass757 def get_output_subclass(self): return self.output_subclass758 def set_output_subclass(self, output_subclass): self.output_subclass = output_subclass759 def get_force(self): return self.force760 def set_force(self, force): self.force = force761 def get_prefix(self): return self.prefix762 def set_prefix(self, prefix): self.prefix = prefix763 def get_namespace_prefix(self): return self.namespace_prefix764 def set_namespace_prefix(self, namespace_prefix): self.namespace_prefix = namespace_prefix765 def get_empty_namespace_prefix(self): return self.empty_namespace_prefix766 def set_empty_namespace_prefix(self, empty_namespace_prefix): self.empty_namespace_prefix = empty_namespace_prefix767 def get_behavior_filename(self): return self.behavior_filename768 def set_behavior_filename(self, behavior_filename): self.behavior_filename = behavior_filename769 def get_properties(self): return self.properties770 def set_properties(self, properties): self.properties = properties771 def get_subclass_suffix(self): return self.subclass_suffix772 def set_subclass_suffix(self, subclass_suffix): self.subclass_suffix = subclass_suffix773 def get_root_element(self): return self.root_element774 def set_root_element(self, root_element): self.root_element = root_element775 def get_superclass_module(self): return self.superclass_module776 def set_superclass_module(self, superclass_module): self.superclass_module = superclass_module777 def get_auto_super(self): return self.auto_super778 def set_auto_super(self, auto_super): self.auto_super = auto_super779 def get_old_getters_setters(self): return self.old_getters_setters780 def set_old_getters_setters(self, old_getters_setters): self.old_getters_setters = old_getters_setters781 def get_validator_bodies(self): return self.validator_bodies782 def set_validator_bodies(self, validator_bodies): self.validator_bodies = validator_bodies783 def get_user_methods(self): return self.user_methods784 def set_user_methods(self, user_methods): self.user_methods = user_methods785 def get_no_dates(self): return self.no_dates786 def set_no_dates(self, no_dates): self.no_dates = no_dates787 def get_no_versions(self): return self.no_versions788 def set_no_versions(self, no_versions): self.no_versions = no_versions789 def get_no_process_includes(self): return self.no_process_includes790 def set_no_process_includes(self, no_process_includes): self.no_process_includes = no_process_includes791 def get_silence(self): return self.silence792 def set_silence(self, silence): self.silence = silence793 def get_namespace_defs(self): return self.namespace_defs794 def set_namespace_defs(self, namespace_defs): self.namespace_defs = namespace_defs795 def get_external_encoding(self): return self.external_encoding796 def set_external_encoding(self, external_encoding): self.external_encoding = external_encoding797 def get_get_encoded(self): return self.get_encoded798 def set_get_encoded(self, get_encoded): self.get_encoded = get_encoded799 def get_member_specs(self): return self.member_specs800 def set_member_specs(self, member_specs): self.member_specs = member_specs801 def get_export_spec(self): return self.export_spec802 def set_export_spec(self, export_spec): self.export_spec = export_spec803 def get_one_file_per_xsd(self): return self.one_file_per_xsd804 def set_one_file_per_xsd(self, one_file_per_xsd): self.one_file_per_xsd = one_file_per_xsd805 def get_output_directory(self): return self.output_directory806 def set_output_directory(self, output_directory): self.output_directory = output_directory807 def get_module_suffix(self): return self.module_suffix808 def set_module_suffix(self, module_suffix): self.module_suffix = module_suffix809 def get_preserve_cdata_tags(self): return self.preserve_cdata_tags810 def set_preserve_cdata_tags(self, preserve_cdata_tags): self.preserve_cdata_tags = preserve_cdata_tags811 def get_cleanup_name_list(self): return self.cleanup_name_list812 def set_cleanup_name_list(self, cleanup_name_list): self.cleanup_name_list = cleanup_name_list813 def hasContent_(self):814 if (815 self.input_schema is not None or816 self.output_superclass is not None or817 self.output_subclass is not None or818 self.force is not None or819 self.prefix is not None or820 self.namespace_prefix is not None or821 self.empty_namespace_prefix is not None or822 self.behavior_filename is not None or823 self.properties is not None or824 self.subclass_suffix is not None or825 self.root_element is not None or826 self.superclass_module is not None or827 self.auto_super is not None or828 self.old_getters_setters is not None or829 self.validator_bodies is not None or830 self.user_methods is not None or831 self.no_dates is not None or832 self.no_versions is not None or833 self.no_process_includes is not None or834 self.silence is not None or835 self.namespace_defs is not None or836 self.external_encoding is not None or837 self.get_encoded is not None or838 self.member_specs is not None or839 self.export_spec is not None or840 self.one_file_per_xsd is not None or841 self.output_directory is not None or842 self.module_suffix is not None or843 self.preserve_cdata_tags is not None or844 self.cleanup_name_list is not None845 ):846 return True847 else:848 return False849 def export(self, outfile, level, namespace_='', name_='sessionType', namespacedef_='', pretty_print=True):850 if pretty_print:851 eol_ = '\n'852 else:853 eol_ = ''854 if self.original_tagname_ is not None:855 name_ = self.original_tagname_856 showIndent(outfile, level, pretty_print)857 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))858 already_processed = set()859 self.exportAttributes(outfile, level, already_processed, namespace_, name_='sessionType')860 if self.hasContent_():861 outfile.write('>%s' % (eol_, ))862 self.exportChildren(outfile, level + 1, namespace_='', name_='sessionType', pretty_print=pretty_print)863 showIndent(outfile, level, pretty_print)864 outfile.write('</%s%s>%s' % (namespace_, name_, eol_))865 else:866 outfile.write('/>%s' % (eol_, ))867 def exportAttributes(self, outfile, level, already_processed, namespace_='', name_='sessionType'):868 pass869 def exportChildren(self, outfile, level, namespace_='', name_='sessionType', fromsubclass_=False, pretty_print=True):870 if pretty_print:871 eol_ = '\n'872 else:873 eol_ = ''874 if self.input_schema is not None:875 showIndent(outfile, level, pretty_print)876 outfile.write('<%sinput_schema>%s</%sinput_schema>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.input_schema), input_name='input_schema')), namespace_, eol_))877 if self.output_superclass is not None:878 showIndent(outfile, level, pretty_print)879 outfile.write('<%soutput_superclass>%s</%soutput_superclass>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.output_superclass), input_name='output_superclass')), namespace_, eol_))880 if self.output_subclass is not None:881 showIndent(outfile, level, pretty_print)882 outfile.write('<%soutput_subclass>%s</%soutput_subclass>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.output_subclass), input_name='output_subclass')), namespace_, eol_))883 if self.force is not None:884 showIndent(outfile, level, pretty_print)885 outfile.write('<%sforce>%s</%sforce>%s' % (namespace_, self.gds_format_boolean(self.force, input_name='force'), namespace_, eol_))886 if self.prefix is not None:887 showIndent(outfile, level, pretty_print)888 outfile.write('<%sprefix>%s</%sprefix>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.prefix), input_name='prefix')), namespace_, eol_))889 if self.namespace_prefix is not None:890 showIndent(outfile, level, pretty_print)891 outfile.write('<%snamespace_prefix>%s</%snamespace_prefix>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.namespace_prefix), input_name='namespace_prefix')), namespace_, eol_))892 if self.empty_namespace_prefix is not None:893 showIndent(outfile, level, pretty_print)894 outfile.write('<%sempty_namespace_prefix>%s</%sempty_namespace_prefix>%s' % (namespace_, self.gds_format_boolean(self.empty_namespace_prefix, input_name='empty_namespace_prefix'), namespace_, eol_))895 if self.behavior_filename is not None:896 showIndent(outfile, level, pretty_print)897 outfile.write('<%sbehavior_filename>%s</%sbehavior_filename>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.behavior_filename), input_name='behavior_filename')), namespace_, eol_))898 if self.properties is not None:899 showIndent(outfile, level, pretty_print)900 outfile.write('<%sproperties>%s</%sproperties>%s' % (namespace_, self.gds_format_boolean(self.properties, input_name='properties'), namespace_, eol_))901 if self.subclass_suffix is not None:902 showIndent(outfile, level, pretty_print)903 outfile.write('<%ssubclass_suffix>%s</%ssubclass_suffix>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.subclass_suffix), input_name='subclass_suffix')), namespace_, eol_))904 if self.root_element is not None:905 showIndent(outfile, level, pretty_print)906 outfile.write('<%sroot_element>%s</%sroot_element>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.root_element), input_name='root_element')), namespace_, eol_))907 if self.superclass_module is not None:908 showIndent(outfile, level, pretty_print)909 outfile.write('<%ssuperclass_module>%s</%ssuperclass_module>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.superclass_module), input_name='superclass_module')), namespace_, eol_))910 if self.auto_super is not None:911 showIndent(outfile, level, pretty_print)912 outfile.write('<%sauto_super>%s</%sauto_super>%s' % (namespace_, self.gds_format_boolean(self.auto_super, input_name='auto_super'), namespace_, eol_))913 if self.old_getters_setters is not None:914 showIndent(outfile, level, pretty_print)915 outfile.write('<%sold_getters_setters>%s</%sold_getters_setters>%s' % (namespace_, self.gds_format_boolean(self.old_getters_setters, input_name='old_getters_setters'), namespace_, eol_))916 if self.validator_bodies is not None:917 showIndent(outfile, level, pretty_print)918 outfile.write('<%svalidator_bodies>%s</%svalidator_bodies>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.validator_bodies), input_name='validator_bodies')), namespace_, eol_))919 if self.user_methods is not None:920 showIndent(outfile, level, pretty_print)921 outfile.write('<%suser_methods>%s</%suser_methods>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.user_methods), input_name='user_methods')), namespace_, eol_))922 if self.no_dates is not None:923 showIndent(outfile, level, pretty_print)924 outfile.write('<%sno_dates>%s</%sno_dates>%s' % (namespace_, self.gds_format_boolean(self.no_dates, input_name='no_dates'), namespace_, eol_))925 if self.no_versions is not None:926 showIndent(outfile, level, pretty_print)927 outfile.write('<%sno_versions>%s</%sno_versions>%s' % (namespace_, self.gds_format_boolean(self.no_versions, input_name='no_versions'), namespace_, eol_))928 if self.no_process_includes is not None:929 showIndent(outfile, level, pretty_print)930 outfile.write('<%sno_process_includes>%s</%sno_process_includes>%s' % (namespace_, self.gds_format_boolean(self.no_process_includes, input_name='no_process_includes'), namespace_, eol_))931 if self.silence is not None:932 showIndent(outfile, level, pretty_print)933 outfile.write('<%ssilence>%s</%ssilence>%s' % (namespace_, self.gds_format_boolean(self.silence, input_name='silence'), namespace_, eol_))934 if self.namespace_defs is not None:935 showIndent(outfile, level, pretty_print)936 outfile.write('<%snamespace_defs>%s</%snamespace_defs>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.namespace_defs), input_name='namespace_defs')), namespace_, eol_))937 if self.external_encoding is not None:938 showIndent(outfile, level, pretty_print)939 outfile.write('<%sexternal_encoding>%s</%sexternal_encoding>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.external_encoding), input_name='external_encoding')), namespace_, eol_))940 if self.get_encoded is not None:941 showIndent(outfile, level, pretty_print)942 outfile.write('<%sget_encoded>%s</%sget_encoded>%s' % (namespace_, self.gds_format_boolean(self.get_encoded, input_name='get_encoded'), namespace_, eol_))943 if self.member_specs is not None:944 showIndent(outfile, level, pretty_print)945 outfile.write('<%smember_specs>%s</%smember_specs>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.member_specs), input_name='member_specs')), namespace_, eol_))946 if self.export_spec is not None:947 showIndent(outfile, level, pretty_print)948 outfile.write('<%sexport_spec>%s</%sexport_spec>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.export_spec), input_name='export_spec')), namespace_, eol_))949 if self.one_file_per_xsd is not None:950 showIndent(outfile, level, pretty_print)951 outfile.write('<%sone_file_per_xsd>%s</%sone_file_per_xsd>%s' % (namespace_, self.gds_format_boolean(self.one_file_per_xsd, input_name='one_file_per_xsd'), namespace_, eol_))952 if self.output_directory is not None:953 showIndent(outfile, level, pretty_print)954 outfile.write('<%soutput_directory>%s</%soutput_directory>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.output_directory), input_name='output_directory')), namespace_, eol_))955 if self.module_suffix is not None:956 showIndent(outfile, level, pretty_print)957 outfile.write('<%smodule_suffix>%s</%smodule_suffix>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.module_suffix), input_name='module_suffix')), namespace_, eol_))958 if self.preserve_cdata_tags is not None:959 showIndent(outfile, level, pretty_print)960 outfile.write('<%spreserve_cdata_tags>%s</%spreserve_cdata_tags>%s' % (namespace_, self.gds_format_boolean(self.preserve_cdata_tags, input_name='preserve_cdata_tags'), namespace_, eol_))961 if self.cleanup_name_list is not None:962 showIndent(outfile, level, pretty_print)963 outfile.write('<%scleanup_name_list>%s</%scleanup_name_list>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.cleanup_name_list), input_name='cleanup_name_list')), namespace_, eol_))964 def build(self, node):965 already_processed = set()966 self.buildAttributes(node, node.attrib, already_processed)967 for child in node:968 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]969 self.buildChildren(child, node, nodeName_)970 return self971 def buildAttributes(self, node, attrs, already_processed):972 pass973 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):974 if nodeName_ == 'input_schema':975 input_schema_ = child_.text976 input_schema_ = self.gds_validate_string(input_schema_, node, 'input_schema')977 self.input_schema = input_schema_978 elif nodeName_ == 'output_superclass':979 output_superclass_ = child_.text980 output_superclass_ = self.gds_validate_string(output_superclass_, node, 'output_superclass')981 self.output_superclass = output_superclass_982 elif nodeName_ == 'output_subclass':983 output_subclass_ = child_.text984 output_subclass_ = self.gds_validate_string(output_subclass_, node, 'output_subclass')985 self.output_subclass = output_subclass_986 elif nodeName_ == 'force':987 sval_ = child_.text988 if sval_ in ('true', '1'):989 ival_ = True990 elif sval_ in ('false', '0'):991 ival_ = False992 else:993 raise_parse_error(child_, 'requires boolean')994 ival_ = self.gds_validate_boolean(ival_, node, 'force')995 self.force = ival_996 elif nodeName_ == 'prefix':997 prefix_ = child_.text998 prefix_ = self.gds_validate_string(prefix_, node, 'prefix')999 self.prefix = prefix_1000 elif nodeName_ == 'namespace_prefix':1001 namespace_prefix_ = child_.text1002 namespace_prefix_ = self.gds_validate_string(namespace_prefix_, node, 'namespace_prefix')1003 self.namespace_prefix = namespace_prefix_1004 elif nodeName_ == 'empty_namespace_prefix':1005 sval_ = child_.text1006 if sval_ in ('true', '1'):1007 ival_ = True1008 elif sval_ in ('false', '0'):1009 ival_ = False1010 else:1011 raise_parse_error(child_, 'requires boolean')1012 ival_ = self.gds_validate_boolean(ival_, node, 'empty_namespace_prefix')1013 self.empty_namespace_prefix = ival_1014 elif nodeName_ == 'behavior_filename':1015 behavior_filename_ = child_.text1016 behavior_filename_ = self.gds_validate_string(behavior_filename_, node, 'behavior_filename')1017 self.behavior_filename = behavior_filename_1018 elif nodeName_ == 'properties':1019 sval_ = child_.text1020 if sval_ in ('true', '1'):1021 ival_ = True1022 elif sval_ in ('false', '0'):1023 ival_ = False1024 else:1025 raise_parse_error(child_, 'requires boolean')1026 ival_ = self.gds_validate_boolean(ival_, node, 'properties')1027 self.properties = ival_1028 elif nodeName_ == 'subclass_suffix':1029 subclass_suffix_ = child_.text1030 subclass_suffix_ = self.gds_validate_string(subclass_suffix_, node, 'subclass_suffix')1031 self.subclass_suffix = subclass_suffix_1032 elif nodeName_ == 'root_element':1033 root_element_ = child_.text1034 root_element_ = self.gds_validate_string(root_element_, node, 'root_element')1035 self.root_element = root_element_1036 elif nodeName_ == 'superclass_module':1037 superclass_module_ = child_.text1038 superclass_module_ = self.gds_validate_string(superclass_module_, node, 'superclass_module')1039 self.superclass_module = superclass_module_1040 elif nodeName_ == 'auto_super':1041 sval_ = child_.text1042 if sval_ in ('true', '1'):1043 ival_ = True1044 elif sval_ in ('false', '0'):1045 ival_ = False1046 else:1047 raise_parse_error(child_, 'requires boolean')1048 ival_ = self.gds_validate_boolean(ival_, node, 'auto_super')1049 self.auto_super = ival_1050 elif nodeName_ == 'old_getters_setters':1051 sval_ = child_.text1052 if sval_ in ('true', '1'):1053 ival_ = True1054 elif sval_ in ('false', '0'):1055 ival_ = False1056 else:1057 raise_parse_error(child_, 'requires boolean')1058 ival_ = self.gds_validate_boolean(ival_, node, 'old_getters_setters')1059 self.old_getters_setters = ival_1060 elif nodeName_ == 'validator_bodies':1061 validator_bodies_ = child_.text1062 validator_bodies_ = self.gds_validate_string(validator_bodies_, node, 'validator_bodies')1063 self.validator_bodies = validator_bodies_1064 elif nodeName_ == 'user_methods':1065 user_methods_ = child_.text1066 user_methods_ = self.gds_validate_string(user_methods_, node, 'user_methods')1067 self.user_methods = user_methods_1068 elif nodeName_ == 'no_dates':1069 sval_ = child_.text1070 if sval_ in ('true', '1'):1071 ival_ = True1072 elif sval_ in ('false', '0'):1073 ival_ = False1074 else:1075 raise_parse_error(child_, 'requires boolean')1076 ival_ = self.gds_validate_boolean(ival_, node, 'no_dates')1077 self.no_dates = ival_1078 elif nodeName_ == 'no_versions':1079 sval_ = child_.text1080 if sval_ in ('true', '1'):1081 ival_ = True1082 elif sval_ in ('false', '0'):1083 ival_ = False1084 else:1085 raise_parse_error(child_, 'requires boolean')1086 ival_ = self.gds_validate_boolean(ival_, node, 'no_versions')1087 self.no_versions = ival_1088 elif nodeName_ == 'no_process_includes':1089 sval_ = child_.text1090 if sval_ in ('true', '1'):1091 ival_ = True1092 elif sval_ in ('false', '0'):1093 ival_ = False1094 else:1095 raise_parse_error(child_, 'requires boolean')1096 ival_ = self.gds_validate_boolean(ival_, node, 'no_process_includes')1097 self.no_process_includes = ival_1098 elif nodeName_ == 'silence':1099 sval_ = child_.text1100 if sval_ in ('true', '1'):1101 ival_ = True1102 elif sval_ in ('false', '0'):1103 ival_ = False1104 else:1105 raise_parse_error(child_, 'requires boolean')1106 ival_ = self.gds_validate_boolean(ival_, node, 'silence')1107 self.silence = ival_1108 elif nodeName_ == 'namespace_defs':1109 namespace_defs_ = child_.text1110 namespace_defs_ = self.gds_validate_string(namespace_defs_, node, 'namespace_defs')1111 self.namespace_defs = namespace_defs_1112 elif nodeName_ == 'external_encoding':1113 external_encoding_ = child_.text1114 external_encoding_ = self.gds_validate_string(external_encoding_, node, 'external_encoding')1115 self.external_encoding = external_encoding_1116 elif nodeName_ == 'get_encoded':1117 sval_ = child_.text1118 if sval_ in ('true', '1'):1119 ival_ = True1120 elif sval_ in ('false', '0'):1121 ival_ = False1122 else:1123 raise_parse_error(child_, 'requires boolean')1124 ival_ = self.gds_validate_boolean(ival_, node, 'get_encoded')1125 self.get_encoded = ival_1126 elif nodeName_ == 'member_specs':1127 member_specs_ = child_.text1128 member_specs_ = self.gds_validate_string(member_specs_, node, 'member_specs')1129 self.member_specs = member_specs_1130 elif nodeName_ == 'export_spec':1131 export_spec_ = child_.text1132 export_spec_ = self.gds_validate_string(export_spec_, node, 'export_spec')1133 self.export_spec = export_spec_1134 elif nodeName_ == 'one_file_per_xsd':1135 sval_ = child_.text1136 if sval_ in ('true', '1'):1137 ival_ = True1138 elif sval_ in ('false', '0'):1139 ival_ = False1140 else:1141 raise_parse_error(child_, 'requires boolean')1142 ival_ = self.gds_validate_boolean(ival_, node, 'one_file_per_xsd')1143 self.one_file_per_xsd = ival_1144 elif nodeName_ == 'output_directory':1145 output_directory_ = child_.text1146 output_directory_ = self.gds_validate_string(output_directory_, node, 'output_directory')1147 self.output_directory = output_directory_1148 elif nodeName_ == 'module_suffix':1149 module_suffix_ = child_.text1150 module_suffix_ = self.gds_validate_string(module_suffix_, node, 'module_suffix')1151 self.module_suffix = module_suffix_1152 elif nodeName_ == 'preserve_cdata_tags':1153 sval_ = child_.text1154 if sval_ in ('true', '1'):1155 ival_ = True1156 elif sval_ in ('false', '0'):1157 ival_ = False1158 else:1159 raise_parse_error(child_, 'requires boolean')1160 ival_ = self.gds_validate_boolean(ival_, node, 'preserve_cdata_tags')1161 self.preserve_cdata_tags = ival_1162 elif nodeName_ == 'cleanup_name_list':1163 cleanup_name_list_ = child_.text1164 cleanup_name_list_ = self.gds_validate_string(cleanup_name_list_, node, 'cleanup_name_list')1165 self.cleanup_name_list = cleanup_name_list_1166# end class sessionType1167GDSClassesMapping = {1168 'session': sessionType,1169}1170USAGE_TEXT = """1171Usage: python <Parser>.py [ -s ] <in_xml_file>1172"""1173def usage():1174 print(USAGE_TEXT)...
network_socket_object.py
Source:network_socket_object.py
...213 elif sval_ in ('false', '0'):214 ival_ = False215 else:216 raise_parse_error(child_, 'requires boolean')217 ival_ = self.gds_validate_boolean(ival_, node, 'IP_MULTICAST_LOOP')218 self.IP_MULTICAST_LOOP = ival_219 elif nodeName_ == 'IP_TOS':220 obj_ = cybox_common.StringObjectPropertyType.factory()221 obj_.build(child_)222 self.set_IP_TOS(obj_)223 elif nodeName_ == 'SO_BROADCAST':224 sval_ = child_.text225 if sval_ in ('true', '1'):226 ival_ = True227 elif sval_ in ('false', '0'):228 ival_ = False229 else:230 raise_parse_error(child_, 'requires boolean')231 ival_ = self.gds_validate_boolean(ival_, node, 'SO_BROADCAST')232 self.SO_BROADCAST = ival_233 elif nodeName_ == 'SO_CONDITIONAL_ACCEPT':234 sval_ = child_.text235 if sval_ in ('true', '1'):236 ival_ = True237 elif sval_ in ('false', '0'):238 ival_ = False239 else:240 raise_parse_error(child_, 'requires boolean')241 ival_ = self.gds_validate_boolean(ival_, node, 'SO_CONDITIONAL_ACCEPT')242 self.SO_CONDITIONAL_ACCEPT = ival_243 elif nodeName_ == 'SO_KEEPALIVE':244 sval_ = child_.text245 if sval_ in ('true', '1'):246 ival_ = True247 elif sval_ in ('false', '0'):248 ival_ = False249 else:250 raise_parse_error(child_, 'requires boolean')251 ival_ = self.gds_validate_boolean(ival_, node, 'SO_KEEPALIVE')252 self.SO_KEEPALIVE = ival_253 elif nodeName_ == 'SO_DONTROUTE':254 sval_ = child_.text255 if sval_ in ('true', '1'):256 ival_ = True257 elif sval_ in ('false', '0'):258 ival_ = False259 else:260 raise_parse_error(child_, 'requires boolean')261 ival_ = self.gds_validate_boolean(ival_, node, 'SO_DONTROUTE')262 self.SO_DONTROUTE = ival_263 elif nodeName_ == 'SO_LINGER':264 obj_ = cybox_common.UnsignedIntegerObjectPropertyType.factory()265 obj_.build(child_)266 self.set_SO_LINGER(obj_)267 elif nodeName_ == 'SO_DONTLINGER':268 sval_ = child_.text269 if sval_ in ('true', '1'):270 ival_ = True271 elif sval_ in ('false', '0'):272 ival_ = False273 else:274 raise_parse_error(child_, 'requires boolean')275 ival_ = self.gds_validate_boolean(ival_, node, 'SO_DONTLINGER')276 self.SO_DONTLINGER = ival_277 elif nodeName_ == 'SO_OOBINLINE':278 sval_ = child_.text279 if sval_ in ('true', '1'):280 ival_ = True281 elif sval_ in ('false', '0'):282 ival_ = False283 else:284 raise_parse_error(child_, 'requires boolean')285 ival_ = self.gds_validate_boolean(ival_, node, 'SO_OOBINLINE')286 self.SO_OOBINLINE = ival_287 elif nodeName_ == 'SO_RCVBUF':288 obj_ = cybox_common.UnsignedIntegerObjectPropertyType.factory()289 obj_.build(child_)290 self.set_SO_RCVBUF(obj_)291 elif nodeName_ == 'SO_GROUP_PRIORITY':292 obj_ = cybox_common.UnsignedIntegerObjectPropertyType.factory()293 obj_.build(child_)294 self.set_SO_GROUP_PRIORITY(obj_)295 elif nodeName_ == 'SO_REUSEADDR':296 sval_ = child_.text297 if sval_ in ('true', '1'):298 ival_ = True299 elif sval_ in ('false', '0'):300 ival_ = False301 else:302 raise_parse_error(child_, 'requires boolean')303 ival_ = self.gds_validate_boolean(ival_, node, 'SO_REUSEADDR')304 self.SO_REUSEADDR = ival_305 elif nodeName_ == 'SO_DEBUG':306 sval_ = child_.text307 if sval_ in ('true', '1'):308 ival_ = True309 elif sval_ in ('false', '0'):310 ival_ = False311 else:312 raise_parse_error(child_, 'requires boolean')313 ival_ = self.gds_validate_boolean(ival_, node, 'SO_DEBUG')314 self.SO_DEBUG = ival_315 elif nodeName_ == 'SO_RCVTIMEO':316 obj_ = cybox_common.UnsignedIntegerObjectPropertyType.factory()317 obj_.build(child_)318 self.set_SO_RCVTIMEO(obj_)319 elif nodeName_ == 'SO_SNDBUF':320 obj_ = cybox_common.UnsignedIntegerObjectPropertyType.factory()321 obj_.build(child_)322 self.set_SO_SNDBUF(obj_)323 elif nodeName_ == 'SO_SNDTIMEO':324 obj_ = cybox_common.UnsignedIntegerObjectPropertyType.factory()325 obj_.build(child_)326 self.set_SO_SNDTIMEO(obj_)327 elif nodeName_ == 'SO_UPDATE_ACCEPT_CONTEXT':328 obj_ = cybox_common.UnsignedIntegerObjectPropertyType.factory()329 obj_.build(child_)330 self.set_SO_UPDATE_ACCEPT_CONTEXT(obj_)331 elif nodeName_ == 'SO_TIMEOUT':332 obj_ = cybox_common.UnsignedIntegerObjectPropertyType.factory()333 obj_.build(child_)334 self.set_SO_TIMEOUT(obj_)335 elif nodeName_ == 'TCP_NODELAY':336 sval_ = child_.text337 if sval_ in ('true', '1'):338 ival_ = True339 elif sval_ in ('false', '0'):340 ival_ = False341 else:342 raise_parse_error(child_, 'requires boolean')343 ival_ = self.gds_validate_boolean(ival_, node, 'TCP_NODELAY')344 self.TCP_NODELAY = ival_345# end class SocketOptionsType346class ProtocolType(cybox_common.BaseObjectPropertyType):347 """ProtocolType specifies protocol types, via a union of the348 ProtocolTypeEnum type and the atomic xs:string type. Its base349 type is the CybOX Core cybox_common.BaseObjectPropertyType, for permitting350 complex (i.e. regular-expression based) specifications.This351 attribute is optional and specifies the expected type for the352 value of the specified property."""353 354 subclass = None355 superclass = cybox_common.BaseObjectPropertyType356 def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None):357 super(ProtocolType, self).__init__(obfuscation_algorithm_ref, refanging_transform_type, has_changed, delimiter, pattern_type, datatype, refanging_transform, is_case_sensitive, bit_mask, appears_random, observed_encoding, defanging_algorithm_ref, is_obfuscated, regex_syntax, apply_condition, trend, idref, is_defanged, id, condition, valueOf_)...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!