Coverage for python/lsst/sims/alertsim/VOEventLib/VOEventClasses.py : 24%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
#!/usr/bin/env python
# # Generated Fri Mar 4 13:10:52 2011 by generateDS.py version 2.1a. #
from StringIO import StringIO else:
"EventIVORN", "Group", "Param", "showIndent", "parsexml_", "get_root_tag", "AstroCoords", "Time", "TimeInstant", "Position2D", "Value2", "AstroCoordSystem", "ObservationLocation", "ObservatoryLocation", "ObsDataLocation", "WhereWhen", "Table", "Data", "TR"]
XMLParser_import_elementtree ) = list(range(3)) # lxml XMLParser_import_library = XMLParser_import_lxml if Verbose_import_: print("running with lxml.etree") # cElementTree from Python 2.5+ print("running with cElementTree on Python 2.5+") except ImportError: try: # ElementTree from Python 2.5+ import xml.etree.ElementTree as etree_ XMLParser_import_library = XMLParser_import_elementtree if Verbose_import_: print("running with ElementTree on Python 2.5+") except ImportError: try: # normal cElementTree install import cElementTree as etree_ XMLParser_import_library = XMLParser_import_elementtree if Verbose_import_: print("running with cElementTree") except ImportError: try: # normal ElementTree install import elementtree.ElementTree as etree_ XMLParser_import_library = XMLParser_import_elementtree if Verbose_import_: print("running with ElementTree") except ImportError: raise ImportError("Failed to import ElementTree from any known place")
if (XMLParser_import_library == XMLParser_import_lxml and 'parser' not in kwargs): # Use the lxml ElementTree compatible parser so that, e.g., # we ignore comments. kwargs['parser'] = etree_.ETCompatXMLParser() doc = etree_.parse(*args, **kwargs) return doc
# # User methods # # Calls to the methods in these classes are generated by generateDS.py. # You can replace these methods by re-implementing the following class # in a module named generatedssuper.py.
return input_data.decode(encoding='ascii') return '%d' % input_data return '%f' % input_data return '%e' % input_data return '%s' % input_data
# # If you have installed IPython you can uncomment and use the following. # IPython is available from http://ipython.scipy.org/. #
## from IPython.Shell import IPShellEmbed ## args = '' ## ipshell = IPShellEmbed(args, ## banner = 'Dropping into IPython', ## exit_msg = 'Leaving Interpreter, back to program.')
# Then use the following line where and when you want to drop into the # IPython shell: # ipshell('<some message> -- Entering ipshell.\nHit Ctrl-D to exit')
# # Globals #
# # Support/utility functions. #
for idx in range(level): outfile.write(' ')
s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') return s1
s1 = (isinstance(inStr, basestring) and inStr or '%s' % inStr) s1 = s1.replace('&', '&') s1 = s1.replace('<', '<') s1 = s1.replace('>', '>') if '"' in s1: if "'" in s1: s1 = '"%s"' % s1.replace('"', """) else: s1 = "'%s'" % s1 else: s1 = '"%s"' % s1 return s1
s1 = inStr if s1.find("'") == -1: if s1.find('\n') == -1: return "'%s'" % s1 else: return "'''%s'''" % s1 else: if s1.find('"') != -1: s1 = s1.replace('"', '\\"') if s1.find('\n') == -1: return '"%s"' % s1 else: return '"""%s"""' % s1
if node.text is not None: text = node.text else: text = '' for child in node: if child.tail is not None: text += child.tail return text
if XMLParser_import_library == XMLParser_import_lxml: msg = '%s (element %s/line %d)' % (msg, node.tag, node.sourceline, ) else: msg = '%s (element %s)' % (msg, node.tag, ) raise GDSParseError(msg)
# Constants for category: # Constants for content_type: self.category = category self.content_type = content_type self.name = name self.value = value return self.category return self.content_type return self.value return self.name if self.category == MixedContainer.CategoryText: outfile.write(self.value) elif self.category == MixedContainer.CategorySimple: self.exportSimple(outfile, level, name) else: # category == MixedContainer.CategoryComplex self.value.export(outfile, level, namespace,name) if self.content_type == MixedContainer.TypeString: outfile.write('<%s>%s</%s>' % (self.name, self.value, self.name)) elif self.content_type == MixedContainer.TypeInteger or \ self.content_type == MixedContainer.TypeBoolean: outfile.write('<%s>%d</%s>' % (self.name, self.value, self.name)) elif self.content_type == MixedContainer.TypeFloat or \ self.content_type == MixedContainer.TypeDecimal: outfile.write('<%s>%f</%s>' % (self.name, self.value, self.name)) elif self.content_type == MixedContainer.TypeDouble: outfile.write('<%s>%g</%s>' % (self.name, self.value, self.name)) if self.category == MixedContainer.CategoryText: showIndent(outfile, level) outfile.write('model_.MixedContainer(%d, %d, "%s", "%s"),\n' % \ (self.category, self.content_type, self.name, self.value)) elif self.category == MixedContainer.CategorySimple: showIndent(outfile, level) outfile.write('model_.MixedContainer(%d, %d, "%s", "%s"),\n' % \ (self.category, self.content_type, self.name, self.value)) else: # category == MixedContainer.CategoryComplex showIndent(outfile, level) outfile.write('model_.MixedContainer(%d, %d, "%s",\n' % \ (self.category, self.content_type, self.name,)) self.value.exportLiteral(outfile, level + 1) showIndent(outfile, level) outfile.write(')\n')
self.name = name self.data_type = data_type self.container = container if isinstance(self.data_type, list): if len(self.data_type) > 0: return self.data_type[-1] else: return 'xs:string' else: return self.data_type
if typ is None or value is None: return value return typ(value)
# # Data representation classes. #
if name_ is None: name_ = self.export_name showIndent(outfile, level) outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) self.exportAttributes(outfile, level, namespace_, name_=self.export_name) if self.hasContent_(): outfile.write('>\n') self.exportChildren(outfile, level + 1, namespace_, name_) showIndent(outfile, level) outfile.write('</%s%s>\n' % (namespace_, name_)) else: outfile.write('/>\n')
"""VOEvent is the root element for describing observations of immediate astronomical events. For more information, see http://www.ivoa.net/twiki/bin/view/IVOA/IvoaVOEvent. The event consists of at most one of each of: Who, What, WhereWhen, How, Why, Citations, Description, and Reference.""" self.version = _cast(None, version) self.role = _cast(None, role) self.ivorn = _cast(None, ivorn) self.Who = Who self.What = What self.WhereWhen = WhereWhen self.How = How self.Why = Why self.Citations = Citations self.Description = Description self.Reference = Reference self.export_name = 'VOEvent' if VOEvent.subclass: return VOEvent.subclass(*args_, **kwargs_) else: return VOEvent(*args_, **kwargs_) # Validate type roleValues, a restriction on xs:string. pass
outfile.write(' version=%s' % (self.format_string(quote_attrib(self.version).encode(ExternalEncoding), input_name='version'), )) if self.role is not None: outfile.write(' role=%s' % (quote_attrib(self.role), )) outfile.write(' ivorn=%s' % (self.format_string(quote_attrib(self.ivorn).encode(ExternalEncoding), input_name='ivorn'), )) if self.Who: self.Who.export(outfile, level, namespace_, name_='Who') if self.What: self.What.export(outfile, level, namespace_, name_='What') if self.WhereWhen: self.WhereWhen.export(outfile, level, namespace_, name_='WhereWhen') if self.How: self.How.export(outfile, level, namespace_, name_='How') if self.Why: self.Why.export(outfile, level, namespace_, name_='Why') if self.Citations: self.Citations.export(outfile, level, namespace_, name_='Citations') if self.Description is not None: showIndent(outfile, level) outfile.write('<%sDescription>%s</%sDescription>\n' % (namespace_, self.format_string(quote_xml(self.Description).encode(ExternalEncoding), input_name='Description'), namespace_)) if self.Reference: self.Reference.export(outfile, level, namespace_, name_='Reference') if ( self.Who is not None or self.What is not None or self.WhereWhen is not None or self.How is not None or self.Why is not None or self.Citations is not None or self.Description is not None or self.Reference is not None ): return True else: return False level += 1 self.exportLiteralAttributes(outfile, level, name_) if self.hasContent_(): self.exportLiteralChildren(outfile, level, name_) if self.version is not None: showIndent(outfile, level) outfile.write('version = "%s",\n' % (self.version,)) if self.role is not None: showIndent(outfile, level) outfile.write('role = "%s",\n' % (self.role,)) if self.ivorn is not None: showIndent(outfile, level) outfile.write('ivorn = "%s",\n' % (self.ivorn,)) if self.Who is not None: showIndent(outfile, level) outfile.write('Who=model_.Who(\n') self.Who.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') if self.What is not None: showIndent(outfile, level) outfile.write('What=model_.What(\n') self.What.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') if self.WhereWhen is not None: showIndent(outfile, level) outfile.write('WhereWhen=model_.WhereWhen(\n') self.WhereWhen.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') if self.How is not None: showIndent(outfile, level) outfile.write('How=model_.How(\n') self.How.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') if self.Why is not None: showIndent(outfile, level) outfile.write('Why=model_.Why(\n') self.Why.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') if self.Citations is not None: showIndent(outfile, level) outfile.write('Citations=model_.Citations(\n') self.Citations.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') if self.Description is not None: showIndent(outfile, level) outfile.write('Description=%s,\n' % quote_python(self.Description).encode(ExternalEncoding)) if self.Reference is not None: showIndent(outfile, level) outfile.write('Reference=model_.Reference(\n') self.Reference.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') self.buildAttributes(node, node.attrib) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] self.buildChildren(child, nodeName_) value = attrs.get('version') if value is not None: self.version = value self.version = ' '.join(self.version.split()) value = attrs.get('role') if value is not None: self.role = value self.validate_roleValues(self.role) # validate type roleValues value = attrs.get('ivorn') if value is not None: self.ivorn = value if nodeName_ == 'Who': obj_ = Who.factory() obj_.build(child_) self.set_Who(obj_) elif nodeName_ == 'What': obj_ = What.factory() obj_.build(child_) self.set_What(obj_) elif nodeName_ == 'WhereWhen': obj_ = WhereWhen.factory() obj_.build(child_) self.set_WhereWhen(obj_) elif nodeName_ == 'How': obj_ = How.factory() obj_.build(child_) self.set_How(obj_) elif nodeName_ == 'Why': obj_ = Why.factory() obj_.build(child_) self.set_Why(obj_) elif nodeName_ == 'Citations': obj_ = Citations.factory() obj_.build(child_) self.set_Citations(obj_) elif nodeName_ == 'Description': Description_ = child_.text self.Description = Description_ elif nodeName_ == 'Reference': obj_ = Reference.factory() obj_.build(child_) self.set_Reference(obj_) # end class VOEvent
"""Who: Curation Metadata""" self.AuthorIVORN = AuthorIVORN self.Date = Date self.Description = Description self.Reference = Reference self.Author = Author self.export_name = 'Who' if Who.subclass: return Who.subclass(*args_, **kwargs_) else: return Who(*args_, **kwargs_)
pass if self.AuthorIVORN is not None: showIndent(outfile, level) outfile.write('<%sAuthorIVORN>%s</%sAuthorIVORN>\n' % (namespace_, self.format_string(quote_xml(self.AuthorIVORN).encode(ExternalEncoding), input_name='AuthorIVORN'), namespace_)) if self.Date is not None: showIndent(outfile, level) outfile.write('<%sDate>%s</%sDate>\n' % (namespace_, self.format_string(quote_xml(self.Date).encode(ExternalEncoding), input_name='Date'), namespace_)) if self.Description is not None: showIndent(outfile, level) outfile.write('<%sDescription>%s</%sDescription>\n' % (namespace_, self.format_string(quote_xml(self.Description).encode(ExternalEncoding), input_name='Description'), namespace_)) if self.Reference: self.Reference.export(outfile, level, namespace_, name_='Reference') if self.Author: self.Author.export(outfile, level, namespace_, name_='Author') if ( self.AuthorIVORN is not None or self.Date is not None or self.Description is not None or self.Reference is not None or self.Author is not None ): return True else: return False level += 1 self.exportLiteralAttributes(outfile, level, name_) if self.hasContent_(): self.exportLiteralChildren(outfile, level, name_) pass if self.AuthorIVORN is not None: showIndent(outfile, level) outfile.write('AuthorIVORN=%s,\n' % quote_python(self.AuthorIVORN).encode(ExternalEncoding)) if self.Date is not None: showIndent(outfile, level) outfile.write('Date=%s,\n' % quote_python(self.Date).encode(ExternalEncoding)) if self.Description is not None: showIndent(outfile, level) outfile.write('Description=%s,\n' % quote_python(self.Description).encode(ExternalEncoding)) if self.Reference is not None: showIndent(outfile, level) outfile.write('Reference=model_.Reference(\n') self.Reference.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') if self.Author is not None: showIndent(outfile, level) outfile.write('Author=model_.Author(\n') self.Author.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') self.buildAttributes(node, node.attrib) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] self.buildChildren(child, nodeName_) pass if nodeName_ == 'AuthorIVORN': AuthorIVORN_ = child_.text self.AuthorIVORN = AuthorIVORN_ elif nodeName_ == 'Date': Date_ = child_.text self.Date = Date_ elif nodeName_ == 'Description': Description_ = child_.text self.Description = Description_ elif nodeName_ == 'Reference': obj_ = Reference.factory() obj_.build(child_) self.set_Reference(obj_) elif nodeName_ == 'Author': obj_ = Author.factory() obj_.build(child_) self.set_Author(obj_) # end class Who
"""Author information follows the IVOA curation information schema: the organization responsible for the packet can have a title, short name or acronym, and a logo. A contact person has a name, email, and phone number. Other contributors can also be noted.""" if title is None: self.title = [] else: self.title = title if shortName is None: self.shortName = [] else: self.shortName = shortName if logoURL is None: self.logoURL = [] else: self.logoURL = logoURL if contactName is None: self.contactName = [] else: self.contactName = contactName if contactEmail is None: self.contactEmail = [] else: self.contactEmail = contactEmail if contactPhone is None: self.contactPhone = [] else: self.contactPhone = contactPhone if contributor is None: self.contributor = [] else: self.contributor = contributor
self.export_name = 'Author'
if Author.subclass: return Author.subclass(*args_, **kwargs_) else: return Author(*args_, **kwargs_)
pass for title_ in self.title: showIndent(outfile, level) outfile.write('<%stitle>%s</%stitle>\n' % (namespace_, self.format_string(quote_xml(title_).encode(ExternalEncoding), input_name='title'), namespace_)) for shortName_ in self.shortName: showIndent(outfile, level) outfile.write('<%sshortName>%s</%sshortName>\n' % (namespace_, self.format_string(quote_xml(shortName_).encode(ExternalEncoding), input_name='shortName'), namespace_)) for logoURL_ in self.logoURL: showIndent(outfile, level) outfile.write('<%slogoURL>%s</%slogoURL>\n' % (namespace_, self.format_string(quote_xml(logoURL_).encode(ExternalEncoding), input_name='logoURL'), namespace_)) for contactName_ in self.contactName: showIndent(outfile, level) outfile.write('<%scontactName>%s</%scontactName>\n' % (namespace_, self.format_string(quote_xml(contactName_).encode(ExternalEncoding), input_name='contactName'), namespace_)) for contactEmail_ in self.contactEmail: showIndent(outfile, level) outfile.write('<%scontactEmail>%s</%scontactEmail>\n' % (namespace_, self.format_string(quote_xml(contactEmail_).encode(ExternalEncoding), input_name='contactEmail'), namespace_)) for contactPhone_ in self.contactPhone: showIndent(outfile, level) outfile.write('<%scontactPhone>%s</%scontactPhone>\n' % (namespace_, self.format_string(quote_xml(contactPhone_).encode(ExternalEncoding), input_name='contactPhone'), namespace_)) for contributor_ in self.contributor: showIndent(outfile, level) outfile.write('<%scontributor>%s</%scontributor>\n' % (namespace_, self.format_string(quote_xml(contributor_).encode(ExternalEncoding), input_name='contributor'), namespace_)) if ( self.title or self.shortName or self.logoURL or self.contactName or self.contactEmail or self.contactPhone or self.contributor ): return True else: return False level += 1 self.exportLiteralAttributes(outfile, level, name_) if self.hasContent_(): self.exportLiteralChildren(outfile, level, name_) pass showIndent(outfile, level) outfile.write('title=[\n') level += 1 for title_ in self.title: showIndent(outfile, level) outfile.write('%s,\n' % quote_python(title_).encode(ExternalEncoding)) level -= 1 showIndent(outfile, level) outfile.write('],\n') showIndent(outfile, level) outfile.write('shortName=[\n') level += 1 for shortName_ in self.shortName: showIndent(outfile, level) outfile.write('%s,\n' % quote_python(shortName_).encode(ExternalEncoding)) level -= 1 showIndent(outfile, level) outfile.write('],\n') showIndent(outfile, level) outfile.write('logoURL=[\n') level += 1 for logoURL_ in self.logoURL: showIndent(outfile, level) outfile.write('%s,\n' % quote_python(logoURL_).encode(ExternalEncoding)) level -= 1 showIndent(outfile, level) outfile.write('],\n') showIndent(outfile, level) outfile.write('contactName=[\n') level += 1 for contactName_ in self.contactName: showIndent(outfile, level) outfile.write('%s,\n' % quote_python(contactName_).encode(ExternalEncoding)) level -= 1 showIndent(outfile, level) outfile.write('],\n') showIndent(outfile, level) outfile.write('contactEmail=[\n') level += 1 for contactEmail_ in self.contactEmail: showIndent(outfile, level) outfile.write('%s,\n' % quote_python(contactEmail_).encode(ExternalEncoding)) level -= 1 showIndent(outfile, level) outfile.write('],\n') showIndent(outfile, level) outfile.write('contactPhone=[\n') level += 1 for contactPhone_ in self.contactPhone: showIndent(outfile, level) outfile.write('%s,\n' % quote_python(contactPhone_).encode(ExternalEncoding)) level -= 1 showIndent(outfile, level) outfile.write('],\n') showIndent(outfile, level) outfile.write('contributor=[\n') level += 1 for contributor_ in self.contributor: showIndent(outfile, level) outfile.write('%s,\n' % quote_python(contributor_).encode(ExternalEncoding)) level -= 1 showIndent(outfile, level) outfile.write('],\n') self.buildAttributes(node, node.attrib) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] self.buildChildren(child, nodeName_) pass if nodeName_ == 'title': title_ = child_.text self.title.append(title_) elif nodeName_ == 'shortName': shortName_ = child_.text self.shortName.append(shortName_) elif nodeName_ == 'logoURL': logoURL_ = child_.text self.logoURL.append(logoURL_) elif nodeName_ == 'contactName': contactName_ = child_.text self.contactName.append(contactName_) elif nodeName_ == 'contactEmail': contactEmail_ = child_.text self.contactEmail.append(contactEmail_) elif nodeName_ == 'contactPhone': contactPhone_ = child_.text self.contactPhone.append(contactPhone_) elif nodeName_ == 'contributor': contributor_ = child_.text self.contributor.append(contributor_) # end class Author
"""What: Event Characterization. This is the part of the data model that is chosen by the Authoer of the event rather than the IVOA. There can be Params, that may be in Groups, and Tables, and simpleTimeSeries. There can also be Description and Reference as with most VOEvent elements.""" if Param is None: self.Param = [] else: self.Param = Param if Group is None: self.Group = [] else: self.Group = Group if Table is None: self.Table = [] else: self.Table = Table if Description is None: self.Description = [] else: self.Description = Description if Reference is None: self.Reference = [] else: self.Reference = Reference
self.export_name = 'What'
if What.subclass: return What.subclass(*args_, **kwargs_) else: return What(*args_, **kwargs_)
pass for Param_ in self.Param: Param_.export(outfile, level, namespace_, name_='Param') for Group_ in self.Group: Group_.export(outfile, level, namespace_, name_='Group') for Table_ in self.Table: Table_.export(outfile, level, namespace_, name_='Table') for Description_ in self.Description: showIndent(outfile, level) outfile.write('<%sDescription>%s</%sDescription>\n' % (namespace_, self.format_string(quote_xml(Description_).encode(ExternalEncoding), input_name='Description'), namespace_)) for Reference_ in self.Reference: Reference_.export(outfile, level, namespace_, name_='Reference') if ( self.Param or self.Group or self.Table or self.Description or self.Reference ): return True else: return False level += 1 self.exportLiteralAttributes(outfile, level, name_) if self.hasContent_(): self.exportLiteralChildren(outfile, level, name_) pass showIndent(outfile, level) outfile.write('Param=[\n') level += 1 for Param_ in self.Param: showIndent(outfile, level) outfile.write('model_.Param(\n') Param_.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') level -= 1 showIndent(outfile, level) outfile.write('],\n') showIndent(outfile, level) outfile.write('Group=[\n') level += 1 for Group_ in self.Group: showIndent(outfile, level) outfile.write('model_.Group(\n') Group_.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') level -= 1 showIndent(outfile, level) outfile.write('],\n') showIndent(outfile, level) outfile.write('Table=[\n') level += 1 for Table_ in self.Table: showIndent(outfile, level) outfile.write('model_.Table(\n') Table_.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') level -= 1 showIndent(outfile, level) outfile.write('],\n') showIndent(outfile, level) outfile.write('Description=[\n') level += 1 for Description_ in self.Description: showIndent(outfile, level) outfile.write('%s,\n' % quote_python(Description_).encode(ExternalEncoding)) level -= 1 showIndent(outfile, level) outfile.write('],\n') showIndent(outfile, level) outfile.write('Reference=[\n') level += 1 for Reference_ in self.Reference: showIndent(outfile, level) outfile.write('model_.Reference(\n') Reference_.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') level -= 1 showIndent(outfile, level) outfile.write('],\n') self.buildAttributes(node, node.attrib) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] self.buildChildren(child, nodeName_) pass if nodeName_ == 'Param': obj_ = Param.factory() obj_.build(child_) self.Param.append(obj_) elif nodeName_ == 'Group': obj_ = Group.factory() obj_.build(child_) self.Group.append(obj_) elif nodeName_ == 'Table': obj_ = Table.factory() obj_.build(child_) self.Table.append(obj_) elif nodeName_ == 'Description': Description_ = child_.text self.Description.append(Description_) elif nodeName_ == 'Reference': obj_ = Reference.factory() obj_.build(child_) self.Reference.append(obj_) # end class What
"""What/Param definition. A Param has name, value, ucd, unit, dataType; and may have Description and Reference.""" self.name = _cast(None, name) self.dataType = _cast(None, dataType) self.value = _cast(None, value) self.utype = _cast(None, utype) self.ucd = _cast(None, ucd) self.unit = _cast(None, unit) if Description is None: self.Description = [] else: self.Description = Description if Reference is None: self.Reference = [] else: self.Reference = Reference self.Value = Value self.export_name = 'Param' if Param.subclass: return Param.subclass(*args_, **kwargs_) else: return Param(*args_, **kwargs_) # Validate type dataType, a restriction on xs:string. pass
if self.name is not None: outfile.write(' name=%s' % (self.format_string(quote_attrib(self.name).encode(ExternalEncoding), input_name='name'), )) if self.dataType is not None: outfile.write(' dataType=%s' % (quote_attrib(self.dataType), )) if self.value is not None: outfile.write(' value=%s' % (self.format_string(quote_attrib(self.value).encode(ExternalEncoding), input_name='value'), )) if self.utype is not None: outfile.write(' utype=%s' % (self.format_string(quote_attrib(self.utype).encode(ExternalEncoding), input_name='utype'), )) if self.ucd is not None: outfile.write(' ucd=%s' % (self.format_string(quote_attrib(self.ucd).encode(ExternalEncoding), input_name='ucd'), )) if self.unit is not None: outfile.write(' unit=%s' % (self.format_string(quote_attrib(self.unit).encode(ExternalEncoding), input_name='unit'), )) for Description_ in self.Description: showIndent(outfile, level) outfile.write('<%sDescription>%s</%sDescription>\n' % (namespace_, self.format_string(quote_xml(Description_).encode(ExternalEncoding), input_name='Description'), namespace_)) for Reference_ in self.Reference: Reference_.export(outfile, level, namespace_, name_='Reference') if self.Value is not None: showIndent(outfile, level) outfile.write('<%sValue>%s</%sValue>\n' % (namespace_, self.format_string(quote_xml(self.Value).encode(ExternalEncoding), input_name='Value'), namespace_)) if ( self.Description or self.Reference or self.Value is not None ): return True else: return False level += 1 self.exportLiteralAttributes(outfile, level, name_) if self.hasContent_(): self.exportLiteralChildren(outfile, level, name_) if self.name is not None: showIndent(outfile, level) outfile.write('name = "%s",\n' % (self.name,)) if self.dataType is not None: showIndent(outfile, level) outfile.write('dataType = "%s",\n' % (self.dataType,)) if self.value is not None: showIndent(outfile, level) outfile.write('value = "%s",\n' % (self.value,)) if self.utype is not None: showIndent(outfile, level) outfile.write('utype = "%s",\n' % (self.utype,)) if self.ucd is not None: showIndent(outfile, level) outfile.write('ucd = "%s",\n' % (self.ucd,)) if self.unit is not None: showIndent(outfile, level) outfile.write('unit = "%s",\n' % (self.unit,)) showIndent(outfile, level) outfile.write('Description=[\n') level += 1 for Description_ in self.Description: showIndent(outfile, level) outfile.write('%s,\n' % quote_python(Description_).encode(ExternalEncoding)) level -= 1 showIndent(outfile, level) outfile.write('],\n') showIndent(outfile, level) outfile.write('Reference=[\n') level += 1 for Reference_ in self.Reference: showIndent(outfile, level) outfile.write('model_.Reference(\n') Reference_.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') level -= 1 showIndent(outfile, level) outfile.write('],\n') if self.Value is not None: showIndent(outfile, level) outfile.write('Value=%s,\n' % quote_python(self.Value).encode(ExternalEncoding)) self.buildAttributes(node, node.attrib) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] self.buildChildren(child, nodeName_) value = attrs.get('name') if value is not None: self.name = value value = attrs.get('dataType') if value is not None: self.dataType = value self.validate_dataType(self.dataType) # validate type dataType value = attrs.get('value') if value is not None: self.value = value value = attrs.get('utype') if value is not None: self.utype = value value = attrs.get('ucd') if value is not None: self.ucd = value value = attrs.get('unit') if value is not None: self.unit = value if nodeName_ == 'Description': Description_ = child_.text self.Description.append(Description_) elif nodeName_ == 'Reference': obj_ = Reference.factory() obj_.build(child_) self.Reference.append(obj_) elif nodeName_ == 'Value': Value_ = child_.text self.Value = Value_ # end class Param
"""What/Group definition: A group is a collection of Params, with name and type attributes.""" self.type_ = _cast(None, type_) self.name = _cast(None, name) if Param is None: self.Param = [] else: self.Param = Param if Description is None: self.Description = [] else: self.Description = Description if Reference is None: self.Reference = [] else: self.Reference = Reference self.export_name = 'Group'
if Group.subclass: return Group.subclass(*args_, **kwargs_) else: return Group(*args_, **kwargs_)
if self.type_ is not None: outfile.write(' type=%s' % (self.format_string(quote_attrib(self.type_).encode(ExternalEncoding), input_name='type'), )) if self.name is not None: outfile.write(' name=%s' % (self.format_string(quote_attrib(self.name).encode(ExternalEncoding), input_name='name'), )) for Param_ in self.Param: Param_.export(outfile, level, namespace_, name_='Param') for Description_ in self.Description: showIndent(outfile, level) outfile.write('<%sDescription>%s</%sDescription>\n' % (namespace_, self.format_string(quote_xml(Description_).encode(ExternalEncoding), input_name='Description'), namespace_)) for Reference_ in self.Reference: Reference_.export(outfile, level, namespace_, name_='Reference') if ( self.Param or self.Description or self.Reference ): return True else: return False level += 1 self.exportLiteralAttributes(outfile, level, name_) if self.hasContent_(): self.exportLiteralChildren(outfile, level, name_) if self.type_ is not None: showIndent(outfile, level) outfile.write('type_ = "%s",\n' % (self.type_,)) if self.name is not None: showIndent(outfile, level) outfile.write('name = "%s",\n' % (self.name,)) showIndent(outfile, level) outfile.write('Param=[\n') level += 1 for Param_ in self.Param: showIndent(outfile, level) outfile.write('model_.Param(\n') Param_.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') level -= 1 showIndent(outfile, level) outfile.write('],\n') showIndent(outfile, level) outfile.write('Description=[\n') level += 1 for Description_ in self.Description: showIndent(outfile, level) outfile.write('%s,\n' % quote_python(Description_).encode(ExternalEncoding)) level -= 1 showIndent(outfile, level) outfile.write('],\n') showIndent(outfile, level) outfile.write('Reference=[\n') level += 1 for Reference_ in self.Reference: showIndent(outfile, level) outfile.write('model_.Reference(\n') Reference_.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') level -= 1 showIndent(outfile, level) outfile.write('],\n') self.buildAttributes(node, node.attrib) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] self.buildChildren(child, nodeName_) value = attrs.get('type') if value is not None: self.type_ = value value = attrs.get('name') if value is not None: self.name = value if nodeName_ == 'Param': obj_ = Param.factory() obj_.build(child_) self.Param.append(obj_) elif nodeName_ == 'Description': Description_ = child_.text self.Description.append(Description_) elif nodeName_ == 'Reference': obj_ = Reference.factory() obj_.build(child_) self.Reference.append(obj_) # end class Group
"""What/Table definition. This small Table has Fields for the column definitions, and Data to hold the table data, with TR for row and TD for value of a table cell.""" self.type_ = _cast(None, type_) self.name = _cast(None, name) if Description is None: self.Description = [] else: self.Description = Description if Reference is None: self.Reference = [] else: self.Reference = Reference if Param is None: self.Param = [] else: self.Param = Param if Field is None: self.Field = [] else: self.Field = Field self.Data = Data self.export_name = 'Table' if Table.subclass: return Table.subclass(*args_, **kwargs_) else: return Table(*args_, **kwargs_)
if self.type_ is not None: outfile.write(' type=%s' % (self.format_string(quote_attrib(self.type_).encode(ExternalEncoding), input_name='type'), )) if self.name is not None: outfile.write(' name=%s' % (self.format_string(quote_attrib(self.name).encode(ExternalEncoding), input_name='name'), )) for Description_ in self.Description: showIndent(outfile, level) outfile.write('<%sDescription>%s</%sDescription>\n' % (namespace_, self.format_string(quote_xml(Description_).encode(ExternalEncoding), input_name='Description'), namespace_)) for Reference_ in self.Reference: Reference_.export(outfile, level, namespace_, name_='Reference') for Param_ in self.Param: Param_.export(outfile, level, namespace_, name_='Param') for Field_ in self.Field: Field_.export(outfile, level, namespace_, name_='Field') if self.Data: self.Data.export(outfile, level, namespace_, name_='Data', ) if ( self.Description or self.Reference or self.Param or self.Field or self.Data is not None ): return True else: return False level += 1 self.exportLiteralAttributes(outfile, level, name_) if self.hasContent_(): self.exportLiteralChildren(outfile, level, name_) if self.type_ is not None: showIndent(outfile, level) outfile.write('type_ = "%s",\n' % (self.type_,)) if self.name is not None: showIndent(outfile, level) outfile.write('name = "%s",\n' % (self.name,)) showIndent(outfile, level) outfile.write('Description=[\n') level += 1 for Description_ in self.Description: showIndent(outfile, level) outfile.write('%s,\n' % quote_python(Description_).encode(ExternalEncoding)) level -= 1 showIndent(outfile, level) outfile.write('],\n') showIndent(outfile, level) outfile.write('Reference=[\n') level += 1 for Reference_ in self.Reference: showIndent(outfile, level) outfile.write('model_.Reference(\n') Reference_.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') level -= 1 showIndent(outfile, level) outfile.write('],\n') showIndent(outfile, level) outfile.write('Param=[\n') level += 1 for Param_ in self.Param: showIndent(outfile, level) outfile.write('model_.Param(\n') Param_.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') level -= 1 showIndent(outfile, level) outfile.write('],\n') showIndent(outfile, level) outfile.write('Field=[\n') level += 1 for Field_ in self.Field: showIndent(outfile, level) outfile.write('model_.Field(\n') Field_.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') level -= 1 showIndent(outfile, level) outfile.write('],\n') if self.Data is not None: showIndent(outfile, level) outfile.write('Data=model_.Data(\n') self.Data.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') self.buildAttributes(node, node.attrib) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] self.buildChildren(child, nodeName_) value = attrs.get('type') if value is not None: self.type_ = value value = attrs.get('name') if value is not None: self.name = value if nodeName_ == 'Description': Description_ = child_.text self.Description.append(Description_) elif nodeName_ == 'Reference': obj_ = Reference.factory() obj_.build(child_) self.Reference.append(obj_) elif nodeName_ == 'Param': obj_ = Param.factory() obj_.build(child_) self.Param.append(obj_) elif nodeName_ == 'Field': obj_ = Field.factory() obj_.build(child_) self.Field.append(obj_) elif nodeName_ == 'Data': obj_ = Data.factory() obj_.build(child_) self.set_Data(obj_) # end class Table
self.dataType = _cast(None, dataType) self.utype = _cast(None, utype) self.ucd = _cast(None, ucd) self.name = _cast(None, name) self.unit = _cast(None, unit) if Description is None: self.Description = [] else: self.Description = Description if Reference is None: self.Reference = [] else: self.Reference = Reference self.export_name = 'Field' if Field.subclass: return Field.subclass(*args_, **kwargs_) else: return Field(*args_, **kwargs_) # Validate type dataType, a restriction on xs:string. pass
if self.dataType is not None: outfile.write(' dataType=%s' % (quote_attrib(self.dataType), )) if self.utype is not None: outfile.write(' utype=%s' % (self.format_string(quote_attrib(self.utype).encode(ExternalEncoding), input_name='utype'), )) if self.ucd is not None: outfile.write(' ucd=%s' % (self.format_string(quote_attrib(self.ucd).encode(ExternalEncoding), input_name='ucd'), )) if self.name is not None: outfile.write(' name=%s' % (self.format_string(quote_attrib(self.name).encode(ExternalEncoding), input_name='name'), )) if self.unit is not None: outfile.write(' unit=%s' % (self.format_string(quote_attrib(self.unit).encode(ExternalEncoding), input_name='unit'), )) for Description_ in self.Description: showIndent(outfile, level) outfile.write('<%sDescription>%s</%sDescription>\n' % (namespace_, self.format_string(quote_xml(Description_).encode(ExternalEncoding), input_name='Description'), namespace_)) for Reference_ in self.Reference: Reference_.export(outfile, level, namespace_, name_='Reference') if ( self.Description or self.Reference ): return True else: return False level += 1 self.exportLiteralAttributes(outfile, level, name_) if self.hasContent_(): self.exportLiteralChildren(outfile, level, name_) if self.dataType is not None: showIndent(outfile, level) outfile.write('dataType = "%s",\n' % (self.dataType,)) if self.utype is not None: showIndent(outfile, level) outfile.write('utype = "%s",\n' % (self.utype,)) if self.ucd is not None: showIndent(outfile, level) outfile.write('ucd = "%s",\n' % (self.ucd,)) if self.name is not None: showIndent(outfile, level) outfile.write('name = "%s",\n' % (self.name,)) if self.unit is not None: showIndent(outfile, level) outfile.write('unit = "%s",\n' % (self.unit,)) showIndent(outfile, level) outfile.write('Description=[\n') level += 1 for Description_ in self.Description: showIndent(outfile, level) outfile.write('%s,\n' % quote_python(Description_).encode(ExternalEncoding)) level -= 1 showIndent(outfile, level) outfile.write('],\n') showIndent(outfile, level) outfile.write('Reference=[\n') level += 1 for Reference_ in self.Reference: showIndent(outfile, level) outfile.write('model_.Reference(\n') Reference_.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') level -= 1 showIndent(outfile, level) outfile.write('],\n') self.buildAttributes(node, node.attrib) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] self.buildChildren(child, nodeName_) value = attrs.get('dataType') if value is not None: self.dataType = value self.validate_dataType(self.dataType) # validate type dataType value = attrs.get('utype') if value is not None: self.utype = value value = attrs.get('ucd') if value is not None: self.ucd = value value = attrs.get('name') if value is not None: self.name = value value = attrs.get('unit') if value is not None: self.unit = value if nodeName_ == 'Description': Description_ = child_.text self.Description.append(Description_) elif nodeName_ == 'Reference': obj_ = Reference.factory() obj_.build(child_) self.Reference.append(obj_) # end class Field
if TR is None: self.TR = [] else: self.TR = TR self.export_name = 'Data'
if Data.subclass: return Data.subclass(*args_, **kwargs_) else: return Data(*args_, **kwargs_)
pass for TR_ in self.TR: TR_.export(outfile, level, namespace_, name_='TR') if ( self.TR ): return True else: return False level += 1 self.exportLiteralAttributes(outfile, level, name_) if self.hasContent_(): self.exportLiteralChildren(outfile, level, name_) pass showIndent(outfile, level) outfile.write('TR=[\n') level += 1 for TR_ in self.TR: showIndent(outfile, level) outfile.write('model_.TR(\n') TR_.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') level -= 1 showIndent(outfile, level) outfile.write('],\n') self.buildAttributes(node, node.attrib) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] self.buildChildren(child, nodeName_) pass if nodeName_ == 'TR': obj_ = TR.factory() obj_.build(child_) self.TR.append(obj_) # end class Data
if TD is None: self.TD = [] else: self.TD = TD self.export_name = 'TR' if TR.subclass: return TR.subclass(*args_, **kwargs_) else: return TR(*args_, **kwargs_)
pass for TD_ in self.TD: showIndent(outfile, level) outfile.write('<%sTD>%s</%sTD>\n' % (namespace_, self.format_string(quote_xml(TD_).encode(ExternalEncoding), input_name='TD'), namespace_)) if ( self.TD ): return True else: return False level += 1 self.exportLiteralAttributes(outfile, level, name_) if self.hasContent_(): self.exportLiteralChildren(outfile, level, name_) pass showIndent(outfile, level) outfile.write('TD=[\n') level += 1 for TD_ in self.TD: showIndent(outfile, level) outfile.write('%s,\n' % quote_python(TD_).encode(ExternalEncoding)) level -= 1 showIndent(outfile, level) outfile.write('],\n') self.buildAttributes(node, node.attrib) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] self.buildChildren(child, nodeName_) pass if nodeName_ == 'TD': TD_ = child_.text self.TD.append(TD_) # end class TR
"""WhereWhen: Space-Time Coordinates. Lots and lots of elements here, but the import is that each event has these: observatory, coord_system, time, timeError, longitude, latitude, posError.""" self.id = _cast(None, id) self.ObsDataLocation = ObsDataLocation if Description is None: self.Description = [] else: self.Description = Description if Reference is None: self.Reference = [] else: self.Reference = Reference self.export_name = 'WhereWhen'
if WhereWhen.subclass: return WhereWhen.subclass(*args_, **kwargs_) else: return WhereWhen(*args_, **kwargs_)
if self.id is not None: outfile.write(' id=%s' % (self.format_string(quote_attrib(self.id).encode(ExternalEncoding), input_name='id'), )) if self.ObsDataLocation: self.ObsDataLocation.export(outfile, level, namespace_, name_='ObsDataLocation', ) for Description_ in self.Description: showIndent(outfile, level) outfile.write('<%sDescription>%s</%sDescription>\n' % (namespace_, self.format_string(quote_xml(Description_).encode(ExternalEncoding), input_name='Description'), namespace_)) for Reference_ in self.Reference: Reference_.export(outfile, level, namespace_, name_='Reference') if ( self.ObsDataLocation is not None or self.Description or self.Reference ): return True else: return False level += 1 self.exportLiteralAttributes(outfile, level, name_) if self.hasContent_(): self.exportLiteralChildren(outfile, level, name_) if self.id is not None: showIndent(outfile, level) outfile.write('id = "%s",\n' % (self.id,)) if self.ObsDataLocation is not None: showIndent(outfile, level) outfile.write('ObsDataLocation=model_.ObsDataLocation(\n') self.ObsDataLocation.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') showIndent(outfile, level) outfile.write('Description=[\n') level += 1 for Description_ in self.Description: showIndent(outfile, level) outfile.write('%s,\n' % quote_python(Description_).encode(ExternalEncoding)) level -= 1 showIndent(outfile, level) outfile.write('],\n') showIndent(outfile, level) outfile.write('Reference=[\n') level += 1 for Reference_ in self.Reference: showIndent(outfile, level) outfile.write('model_.Reference(\n') Reference_.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') level -= 1 showIndent(outfile, level) outfile.write('],\n') self.buildAttributes(node, node.attrib) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] self.buildChildren(child, nodeName_) value = attrs.get('id') if value is not None: self.id = value if nodeName_ == 'ObsDataLocation': obj_ = ObsDataLocation.factory() obj_.build(child_) self.set_ObsDataLocation(obj_) elif nodeName_ == 'Description': Description_ = child_.text self.Description.append(Description_) elif nodeName_ == 'Reference': obj_ = Reference.factory() obj_.build(child_) self.Reference.append(obj_) # end class WhereWhen
"""Part of WhereWhen""" self.ObservatoryLocation = ObservatoryLocation self.ObservationLocation = ObservationLocation self.export_name = 'ObsDataLocation'
if ObsDataLocation.subclass: return ObsDataLocation.subclass(*args_, **kwargs_) else: return ObsDataLocation(*args_, **kwargs_)
pass if self.ObservatoryLocation: self.ObservatoryLocation.export(outfile, level, namespace_, name_='ObservatoryLocation', ) if self.ObservationLocation: self.ObservationLocation.export(outfile, level, namespace_, name_='ObservationLocation', ) if ( self.ObservatoryLocation is not None or self.ObservationLocation is not None ): return True else: return False level += 1 self.exportLiteralAttributes(outfile, level, name_) if self.hasContent_(): self.exportLiteralChildren(outfile, level, name_) pass if self.ObservatoryLocation is not None: showIndent(outfile, level) outfile.write('ObservatoryLocation=model_.ObservatoryLocation(\n') self.ObservatoryLocation.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') if self.ObservationLocation is not None: showIndent(outfile, level) outfile.write('ObservationLocation=model_.ObservationLocation(\n') self.ObservationLocation.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') self.buildAttributes(node, node.attrib) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] self.buildChildren(child, nodeName_) pass if nodeName_ == 'ObservatoryLocation': obj_ = ObservatoryLocation.factory() obj_.build(child_) self.set_ObservatoryLocation(obj_) elif nodeName_ == 'ObservationLocation': obj_ = ObservationLocation.factory() obj_.build(child_) self.set_ObservationLocation(obj_) # end class ObsDataLocation
"""Part of WhereWhen""" self.AstroCoordSystem = AstroCoordSystem self.AstroCoords = AstroCoords self.export_name = 'ObservationLocation' if ObservationLocation.subclass: return ObservationLocation.subclass(*args_, **kwargs_) else: return ObservationLocation(*args_, **kwargs_)
pass if self.AstroCoordSystem: self.AstroCoordSystem.export(outfile, level, namespace_, name_='AstroCoordSystem', ) if self.AstroCoords: self.AstroCoords.export(outfile, level, namespace_, name_='AstroCoords', ) if ( self.AstroCoordSystem is not None or self.AstroCoords is not None ): return True else: return False level += 1 self.exportLiteralAttributes(outfile, level, name_) if self.hasContent_(): self.exportLiteralChildren(outfile, level, name_) pass if self.AstroCoordSystem is not None: showIndent(outfile, level) outfile.write('AstroCoordSystem=model_.AstroCoordSystem(\n') self.AstroCoordSystem.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') if self.AstroCoords is not None: showIndent(outfile, level) outfile.write('AstroCoords=model_.AstroCoords(\n') self.AstroCoords.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') self.buildAttributes(node, node.attrib) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] self.buildChildren(child, nodeName_) pass if nodeName_ == 'AstroCoordSystem': obj_ = AstroCoordSystem.factory() obj_.build(child_) self.set_AstroCoordSystem(obj_) elif nodeName_ == 'AstroCoords': obj_ = AstroCoords.factory() obj_.build(child_) self.set_AstroCoords(obj_) # end class ObservationLocation
"""Part of WhereWhen""" self.id = _cast(None, id) self.valueOf_ = valueOf_ self.export_name = 'AstroCoordSystem' if AstroCoordSystem.subclass: return AstroCoordSystem.subclass(*args_, **kwargs_) else: return AstroCoordSystem(*args_, **kwargs_) # Validate type idValues, a restriction on xs:string. pass
if self.id is not None: outfile.write(' id=%s' % (quote_attrib(self.id), )) pass if ( self.valueOf_ ): return True else: return False level += 1 self.exportLiteralAttributes(outfile, level, name_) if self.hasContent_(): self.exportLiteralChildren(outfile, level, name_) if self.id is not None: showIndent(outfile, level) outfile.write('id = "%s",\n' % (self.id,)) showIndent(outfile, level) outfile.write('valueOf_ = """%s""",\n' % (self.valueOf_,)) self.buildAttributes(node, node.attrib) self.valueOf_ = get_all_text_(node) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] self.buildChildren(child, nodeName_) value = attrs.get('id') if value is not None: self.id = value self.validate_idValues(self.id) # validate type idValues pass # end class AstroCoordSystem
"""Part of WhereWhen""" self.coord_system_id = _cast(None, coord_system_id) self.Time = Time self.Position2D = Position2D self.Position3D = Position3D self.export_name = 'AstroCoords' if AstroCoords.subclass: return AstroCoords.subclass(*args_, **kwargs_) else: return AstroCoords(*args_, **kwargs_) # Validate type idValues, a restriction on xs:string. pass
if self.coord_system_id is not None: outfile.write(' coord_system_id=%s' % (quote_attrib(self.coord_system_id), )) if self.Time: self.Time.export(outfile, level, namespace_, name_='Time') if self.Position2D: self.Position2D.export(outfile, level, namespace_, name_='Position2D') if self.Position3D: self.Position3D.export(outfile, level, namespace_, name_='Position3D') if ( self.Time is not None or self.Position2D is not None or self.Position3D is not None ): return True else: return False level += 1 self.exportLiteralAttributes(outfile, level, name_) if self.hasContent_(): self.exportLiteralChildren(outfile, level, name_) if self.coord_system_id is not None: showIndent(outfile, level) outfile.write('coord_system_id = "%s",\n' % (self.coord_system_id,)) if self.Time is not None: showIndent(outfile, level) outfile.write('Time=model_.Time(\n') self.Time.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') if self.Position2D is not None: showIndent(outfile, level) outfile.write('Position2D=model_.Position2D(\n') self.Position2D.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') if self.Position3D is not None: showIndent(outfile, level) outfile.write('Position3D=model_.Position3D(\n') self.Position3D.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') self.buildAttributes(node, node.attrib) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] self.buildChildren(child, nodeName_) value = attrs.get('coord_system_id') if value is not None: self.coord_system_id = value self.validate_idValues(self.coord_system_id) # validate type idValues if nodeName_ == 'Time': obj_ = Time.factory() obj_.build(child_) self.set_Time(obj_) elif nodeName_ == 'Position2D': obj_ = Position2D.factory() obj_.build(child_) self.set_Position2D(obj_) elif nodeName_ == 'Position3D': obj_ = Position3D.factory() obj_.build(child_) self.set_Position3D(obj_) # end class AstroCoords
"""Part of WhereWhen""" self.unit = _cast(None, unit) self.TimeInstant = TimeInstant self.Error = Error self.export_name = 'Time' if Time.subclass: return Time.subclass(*args_, **kwargs_) else: return Time(*args_, **kwargs_)
if self.unit is not None: outfile.write(' unit=%s' % (self.format_string(quote_attrib(self.unit).encode(ExternalEncoding), input_name='unit'), )) if self.TimeInstant: self.TimeInstant.export(outfile, level, namespace_, name_='TimeInstant', ) if self.Error is not None: showIndent(outfile, level) outfile.write('<%sError>%s</%sError>\n' % (namespace_, self.format_float(self.Error, input_name='Error'), namespace_)) if ( self.TimeInstant is not None or self.Error is not None ): return True else: return False level += 1 self.exportLiteralAttributes(outfile, level, name_) if self.hasContent_(): self.exportLiteralChildren(outfile, level, name_) if self.unit is not None: showIndent(outfile, level) outfile.write('unit = "%s",\n' % (self.unit,)) if self.TimeInstant is not None: showIndent(outfile, level) outfile.write('TimeInstant=model_.TimeInstant(\n') self.TimeInstant.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') if self.Error is not None: showIndent(outfile, level) outfile.write('Error=%f,\n' % self.Error) self.buildAttributes(node, node.attrib) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] self.buildChildren(child, nodeName_) value = attrs.get('unit') if value is not None: self.unit = value if nodeName_ == 'TimeInstant': obj_ = TimeInstant.factory() obj_.build(child_) self.set_TimeInstant(obj_) elif nodeName_ == 'Error': sval_ = child_.text try: fval_ = float(sval_) except (TypeError, ValueError) as exp: raise_parse_error(child_, 'requires float or double: %s' % exp) self.Error = fval_ # end class Time
"""Part of WhereWhen""" self.ISOTime = ISOTime self.export_name = 'TimeInstant' if TimeInstant.subclass: return TimeInstant.subclass(*args_, **kwargs_) else: return TimeInstant(*args_, **kwargs_)
pass if self.ISOTime is not None: showIndent(outfile, level) outfile.write('<%sISOTime>%s</%sISOTime>\n' % (namespace_, self.format_string(quote_xml(self.ISOTime).encode(ExternalEncoding), input_name='ISOTime'), namespace_)) if ( self.ISOTime is not None ): return True else: return False level += 1 self.exportLiteralAttributes(outfile, level, name_) if self.hasContent_(): self.exportLiteralChildren(outfile, level, name_) pass if self.ISOTime is not None: showIndent(outfile, level) outfile.write('ISOTime=%s,\n' % quote_python(self.ISOTime).encode(ExternalEncoding)) self.buildAttributes(node, node.attrib) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] self.buildChildren(child, nodeName_) pass if nodeName_ == 'ISOTime': ISOTime_ = child_.text self.ISOTime = ISOTime_ # end class TimeInstant
"""Part of WhereWhen""" self.unit = _cast(None, unit) self.Name1 = Name1 self.Name2 = Name2 self.Value2 = Value2 self.Error2Radius = Error2Radius self.export_name = 'Position2D' if Position2D.subclass: return Position2D.subclass(*args_, **kwargs_) else: return Position2D(*args_, **kwargs_)
if self.unit is not None: outfile.write(' unit=%s' % (self.format_string(quote_attrib(self.unit).encode(ExternalEncoding), input_name='unit'), )) if self.Name1 is not None: showIndent(outfile, level) outfile.write('<%sName1>%s</%sName1>\n' % (namespace_, self.format_string(quote_xml(self.Name1).encode(ExternalEncoding), input_name='Name1'), namespace_)) if self.Name2 is not None: showIndent(outfile, level) outfile.write('<%sName2>%s</%sName2>\n' % (namespace_, self.format_string(quote_xml(self.Name2).encode(ExternalEncoding), input_name='Name2'), namespace_)) if self.Value2: self.Value2.export(outfile, level, namespace_, name_='Value2', ) if self.Error2Radius is not None: showIndent(outfile, level) outfile.write('<%sError2Radius>%s</%sError2Radius>\n' % (namespace_, self.format_float(self.Error2Radius, input_name='Error2Radius'), namespace_)) if ( self.Name1 is not None or self.Name2 is not None or self.Value2 is not None or self.Error2Radius is not None ): return True else: return False level += 1 self.exportLiteralAttributes(outfile, level, name_) if self.hasContent_(): self.exportLiteralChildren(outfile, level, name_) if self.unit is not None: showIndent(outfile, level) outfile.write('unit = "%s",\n' % (self.unit,)) if self.Name1 is not None: showIndent(outfile, level) outfile.write('Name1=%s,\n' % quote_python(self.Name1).encode(ExternalEncoding)) if self.Name2 is not None: showIndent(outfile, level) outfile.write('Name2=%s,\n' % quote_python(self.Name2).encode(ExternalEncoding)) if self.Value2 is not None: showIndent(outfile, level) outfile.write('Value2=model_.Value2(\n') self.Value2.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') if self.Error2Radius is not None: showIndent(outfile, level) outfile.write('Error2Radius=%f,\n' % self.Error2Radius) self.buildAttributes(node, node.attrib) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] self.buildChildren(child, nodeName_) value = attrs.get('unit') if value is not None: self.unit = value if nodeName_ == 'Name1': Name1_ = child_.text self.Name1 = Name1_ elif nodeName_ == 'Name2': Name2_ = child_.text self.Name2 = Name2_ elif nodeName_ == 'Value2': obj_ = Value2.factory() obj_.build(child_) self.set_Value2(obj_) elif nodeName_ == 'Error2Radius': sval_ = child_.text try: fval_ = float(sval_) except (TypeError, ValueError) as exp: raise_parse_error(child_, 'requires float or double: %s' % exp) self.Error2Radius = fval_ # end class Position2D
"""Part of WhereWhen""" self.unit = _cast(None, unit) self.Name1 = Name1 self.Name2 = Name2 self.Name3 = Name3 self.Value3 = Value3 self.export_name = 'Position3D' if Position3D.subclass: return Position3D.subclass(*args_, **kwargs_) else: return Position3D(*args_, **kwargs_)
if self.unit is not None: outfile.write(' unit=%s' % (self.format_string(quote_attrib(self.unit).encode(ExternalEncoding), input_name='unit'), )) if self.Name1 is not None: showIndent(outfile, level) outfile.write('<%sName1>%s</%sName1>\n' % (namespace_, self.format_string(quote_xml(self.Name1).encode(ExternalEncoding), input_name='Name1'), namespace_)) if self.Name2 is not None: showIndent(outfile, level) outfile.write('<%sName2>%s</%sName2>\n' % (namespace_, self.format_string(quote_xml(self.Name2).encode(ExternalEncoding), input_name='Name2'), namespace_)) if self.Name3 is not None: showIndent(outfile, level) outfile.write('<%sName3>%s</%sName3>\n' % (namespace_, self.format_string(quote_xml(self.Name3).encode(ExternalEncoding), input_name='Name3'), namespace_)) if self.Value3: self.Value3.export(outfile, level, namespace_, name_='Value3', ) if ( self.Name1 is not None or self.Name2 is not None or self.Name3 is not None or self.Value3 is not None ): return True else: return False level += 1 self.exportLiteralAttributes(outfile, level, name_) if self.hasContent_(): self.exportLiteralChildren(outfile, level, name_) if self.unit is not None: showIndent(outfile, level) outfile.write('unit = "%s",\n' % (self.unit,)) if self.Name1 is not None: showIndent(outfile, level) outfile.write('Name1=%s,\n' % quote_python(self.Name1).encode(ExternalEncoding)) if self.Name2 is not None: showIndent(outfile, level) outfile.write('Name2=%s,\n' % quote_python(self.Name2).encode(ExternalEncoding)) if self.Name3 is not None: showIndent(outfile, level) outfile.write('Name3=%s,\n' % quote_python(self.Name3).encode(ExternalEncoding)) if self.Value3 is not None: showIndent(outfile, level) outfile.write('Value3=model_.Value3(\n') self.Value3.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') self.buildAttributes(node, node.attrib) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] self.buildChildren(child, nodeName_) value = attrs.get('unit') if value is not None: self.unit = value if nodeName_ == 'Name1': Name1_ = child_.text self.Name1 = Name1_ elif nodeName_ == 'Name2': Name2_ = child_.text self.Name2 = Name2_ elif nodeName_ == 'Name3': Name3_ = child_.text self.Name3 = Name3_ elif nodeName_ == 'Value3': obj_ = Value3.factory() obj_.build(child_) self.set_Value3(obj_) # end class Position3D
"""Part of WhereWhen""" self.C1 = C1 self.C2 = C2 self.export_name = "Value2" if Value2.subclass: return Value2.subclass(*args_, **kwargs_) else: return Value2(*args_, **kwargs_)
pass if self.C1 is not None: showIndent(outfile, level) outfile.write('<%sC1>%s</%sC1> <!-- RA --> \n' % (namespace_, self.format_float(self.C1, input_name='C1'), namespace_)) if self.C2 is not None: showIndent(outfile, level) outfile.write('<%sC2>%s</%sC2> <!-- Dec --> \n' % (namespace_, self.format_float(self.C2, input_name='C2'), namespace_)) if ( self.C1 is not None or self.C2 is not None ): return True else: return False level += 1 self.exportLiteralAttributes(outfile, level, name_) if self.hasContent_(): self.exportLiteralChildren(outfile, level, name_) pass if self.C1 is not None: showIndent(outfile, level) outfile.write('C1=%f,\n' % self.C1) if self.C2 is not None: showIndent(outfile, level) outfile.write('C2=%f,\n' % self.C2) self.buildAttributes(node, node.attrib) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] self.buildChildren(child, nodeName_) pass if nodeName_ == 'C1': sval_ = child_.text try: fval_ = float(sval_) except (TypeError, ValueError) as exp: raise_parse_error(child_, 'requires float or double: %s' % exp) self.C1 = fval_ elif nodeName_ == 'C2': sval_ = child_.text try: fval_ = float(sval_) except (TypeError, ValueError) as exp: raise_parse_error(child_, 'requires float or double: %s' % exp) self.C2 = fval_ # end class Value2
"""Part of WhereWhen""" self.C1 = C1 self.C2 = C2 self.C3 = C3 self.export_name = 'Value3' if Value3.subclass: return Value3.subclass(*args_, **kwargs_) else: return Value3(*args_, **kwargs_)
pass if self.C1 is not None: showIndent(outfile, level) outfile.write('<%sC1>%s</%sC1>\n' % (namespace_, self.format_float(self.C1, input_name='C1'), namespace_)) if self.C2 is not None: showIndent(outfile, level) outfile.write('<%sC2>%s</%sC2>\n' % (namespace_, self.format_float(self.C2, input_name='C2'), namespace_)) if self.C3 is not None: showIndent(outfile, level) outfile.write('<%sC3>%s</%sC3>\n' % (namespace_, self.format_float(self.C3, input_name='C3'), namespace_)) if ( self.C1 is not None or self.C2 is not None or self.C3 is not None ): return True else: return False level += 1 self.exportLiteralAttributes(outfile, level, name_) if self.hasContent_(): self.exportLiteralChildren(outfile, level, name_) pass if self.C1 is not None: showIndent(outfile, level) outfile.write('C1=%f,\n' % self.C1) if self.C2 is not None: showIndent(outfile, level) outfile.write('C2=%f,\n' % self.C2) if self.C3 is not None: showIndent(outfile, level) outfile.write('C3=%f,\n' % self.C3) self.buildAttributes(node, node.attrib) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] self.buildChildren(child, nodeName_) pass if nodeName_ == 'C1': sval_ = child_.text try: fval_ = float(sval_) except (TypeError, ValueError) as exp: raise_parse_error(child_, 'requires float or double: %s' % exp) self.C1 = fval_ elif nodeName_ == 'C2': sval_ = child_.text try: fval_ = float(sval_) except (TypeError, ValueError) as exp: raise_parse_error(child_, 'requires float or double: %s' % exp) self.C2 = fval_ elif nodeName_ == 'C3': sval_ = child_.text try: fval_ = float(sval_) except (TypeError, ValueError) as exp: raise_parse_error(child_, 'requires float or double: %s' % exp) self.C3 = fval_ # end class Value3
"""Part of WhereWhen""" self.id = _cast(None, id) self.AstroCoordSystem = AstroCoordSystem self.AstroCoords = AstroCoords self.export_name = 'ObservatoryLocation' if ObservatoryLocation.subclass: return ObservatoryLocation.subclass(*args_, **kwargs_) else: return ObservatoryLocation(*args_, **kwargs_)
if self.id is not None: outfile.write(' id=%s' % (self.format_string(quote_attrib(self.id).encode(ExternalEncoding), input_name='id'), )) if self.AstroCoordSystem: self.AstroCoordSystem.export(outfile, level, namespace_, name_='AstroCoordSystem') if self.AstroCoords: self.AstroCoords.export(outfile, level, namespace_, name_='AstroCoords') if ( self.AstroCoordSystem is not None or self.AstroCoords is not None ): return True else: return False level += 1 self.exportLiteralAttributes(outfile, level, name_) if self.hasContent_(): self.exportLiteralChildren(outfile, level, name_) if self.id is not None: showIndent(outfile, level) outfile.write('id = "%s",\n' % (self.id,)) if self.AstroCoordSystem is not None: showIndent(outfile, level) outfile.write('AstroCoordSystem=model_.AstroCoordSystem(\n') self.AstroCoordSystem.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') if self.AstroCoords is not None: showIndent(outfile, level) outfile.write('AstroCoords=model_.AstroCoords(\n') self.AstroCoords.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') self.buildAttributes(node, node.attrib) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] self.buildChildren(child, nodeName_) value = attrs.get('id') if value is not None: self.id = value if nodeName_ == 'AstroCoordSystem': obj_ = AstroCoordSystem.factory() obj_.build(child_) self.set_AstroCoordSystem(obj_) elif nodeName_ == 'AstroCoords': obj_ = AstroCoords.factory() obj_.build(child_) self.set_AstroCoords(obj_) # end class ObservatoryLocation
"""How: Instrument Configuration. Built with some Description and Reference elements.""" if Description is None: self.Description = [] else: self.Description = Description if Reference is None: self.Reference = [] else: self.Reference = Reference self.export_name = 'How'
if How.subclass: return How.subclass(*args_, **kwargs_) else: return How(*args_, **kwargs_)
pass for Description_ in self.Description: showIndent(outfile, level) outfile.write('<%sDescription>%s</%sDescription>\n' % (namespace_, self.format_string(quote_xml(Description_).encode(ExternalEncoding), input_name='Description'), namespace_)) for Reference_ in self.Reference: Reference_.export(outfile, level, namespace_, name_='Reference') if ( self.Description or self.Reference ): return True else: return False level += 1 self.exportLiteralAttributes(outfile, level, name_) if self.hasContent_(): self.exportLiteralChildren(outfile, level, name_) pass showIndent(outfile, level) outfile.write('Description=[\n') level += 1 for Description_ in self.Description: showIndent(outfile, level) outfile.write('%s,\n' % quote_python(Description_).encode(ExternalEncoding)) level -= 1 showIndent(outfile, level) outfile.write('],\n') showIndent(outfile, level) outfile.write('Reference=[\n') level += 1 for Reference_ in self.Reference: showIndent(outfile, level) outfile.write('model_.Reference(\n') Reference_.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') level -= 1 showIndent(outfile, level) outfile.write('],\n') self.buildAttributes(node, node.attrib) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] self.buildChildren(child, nodeName_) pass if nodeName_ == 'Description': Description_ = child_.text self.Description.append(Description_) elif nodeName_ == 'Reference': obj_ = Reference.factory() obj_.build(child_) self.Reference.append(obj_) # end class How
"""Why: Initial Scientific Assessment. Can make simple Concept/Name/Desc/Ref for the inference or use multiple Inference containers for more semantic sophistication.""" self.importance = _cast(float, importance) self.expires = _cast(None, expires) if Name is None: self.Name = [] else: self.Name = Name if Concept is None: self.Concept = [] else: self.Concept = Concept if Inference is None: self.Inference = [] else: self.Inference = Inference if Description is None: self.Description = [] else: self.Description = Description if Reference is None: self.Reference = [] else: self.Reference = Reference self.export_name = 'Why'
if Why.subclass: return Why.subclass(*args_, **kwargs_) else: return Why(*args_, **kwargs_)
if self.importance is not None: outfile.write(' importance="%s"' % self.format_float(self.importance, input_name='importance')) if self.expires is not None: outfile.write(' expires=%s' % (self.format_string(quote_attrib(self.expires).encode(ExternalEncoding), input_name='expires'), )) for Name_ in self.Name: showIndent(outfile, level) outfile.write('<%sName>%s</%sName>\n' % (namespace_, self.format_string(quote_xml(Name_).encode(ExternalEncoding), input_name='Name'), namespace_)) for Concept_ in self.Concept: showIndent(outfile, level) outfile.write('<%sConcept>%s</%sConcept>\n' % (namespace_, self.format_string(quote_xml(Concept_).encode(ExternalEncoding), input_name='Concept'), namespace_)) for Inference_ in self.Inference: Inference_.export(outfile, level, namespace_, name_='Inference') for Description_ in self.Description: showIndent(outfile, level) outfile.write('<%sDescription>%s</%sDescription>\n' % (namespace_, self.format_string(quote_xml(Description_).encode(ExternalEncoding), input_name='Description'), namespace_)) for Reference_ in self.Reference: Reference_.export(outfile, level, namespace_, name_='Reference') if ( self.Name or self.Concept or self.Inference or self.Description or self.Reference ): return True else: return False level += 1 self.exportLiteralAttributes(outfile, level, name_) if self.hasContent_(): self.exportLiteralChildren(outfile, level, name_) if self.importance is not None: showIndent(outfile, level) outfile.write('importance = %f,\n' % (self.importance,)) if self.expires is not None: showIndent(outfile, level) outfile.write('expires = "%s",\n' % (self.expires,)) showIndent(outfile, level) outfile.write('Name=[\n') level += 1 for Name_ in self.Name: showIndent(outfile, level) outfile.write('%s,\n' % quote_python(Name_).encode(ExternalEncoding)) level -= 1 showIndent(outfile, level) outfile.write('],\n') showIndent(outfile, level) outfile.write('Concept=[\n') level += 1 for Concept_ in self.Concept: showIndent(outfile, level) outfile.write('%s,\n' % quote_python(Concept_).encode(ExternalEncoding)) level -= 1 showIndent(outfile, level) outfile.write('],\n') showIndent(outfile, level) outfile.write('Inference=[\n') level += 1 for Inference_ in self.Inference: showIndent(outfile, level) outfile.write('model_.Inference(\n') Inference_.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') level -= 1 showIndent(outfile, level) outfile.write('],\n') showIndent(outfile, level) outfile.write('Description=[\n') level += 1 for Description_ in self.Description: showIndent(outfile, level) outfile.write('%s,\n' % quote_python(Description_).encode(ExternalEncoding)) level -= 1 showIndent(outfile, level) outfile.write('],\n') showIndent(outfile, level) outfile.write('Reference=[\n') level += 1 for Reference_ in self.Reference: showIndent(outfile, level) outfile.write('model_.Reference(\n') Reference_.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') level -= 1 showIndent(outfile, level) outfile.write('],\n') self.buildAttributes(node, node.attrib) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] self.buildChildren(child, nodeName_) value = attrs.get('importance') if value is not None: try: self.importance = float(value) except ValueError as exp: raise ValueError('Bad float/double attribute (importance): %s' % exp) value = attrs.get('expires') if value is not None: self.expires = value if nodeName_ == 'Name': Name_ = child_.text self.Name.append(Name_) elif nodeName_ == 'Concept': Concept_ = child_.text self.Concept.append(Concept_) elif nodeName_ == 'Inference': obj_ = Inference.factory() obj_.build(child_) self.Inference.append(obj_) elif nodeName_ == 'Description': Description_ = child_.text self.Description.append(Description_) elif nodeName_ == 'Reference': obj_ = Reference.factory() obj_.build(child_) self.Reference.append(obj_) # end class Why
"""Why/Inference: A container for a more nuanced expression, including relationships and probability.""" self.relation = _cast(None, relation) self.probability = _cast(None, probability) if Name is None: self.Name = [] else: self.Name = Name if Concept is None: self.Concept = [] else: self.Concept = Concept if Description is None: self.Description = [] else: self.Description = Description if Reference is None: self.Reference = [] else: self.Reference = Reference self.export_name = 'Inference'
if Inference.subclass: return Inference.subclass(*args_, **kwargs_) else: return Inference(*args_, **kwargs_) # Validate type smallFloat, a restriction on xs:float. pass
if self.relation is not None: outfile.write(' relation=%s' % (self.format_string(quote_attrib(self.relation).encode(ExternalEncoding), input_name='relation'), )) if self.probability is not None: outfile.write(' probability=%s' % (quote_attrib(self.probability), )) for Name_ in self.Name: showIndent(outfile, level) outfile.write('<%sName>%s</%sName>\n' % (namespace_, self.format_string(quote_xml(Name_).encode(ExternalEncoding), input_name='Name'), namespace_)) for Concept_ in self.Concept: showIndent(outfile, level) outfile.write('<%sConcept>%s</%sConcept>\n' % (namespace_, self.format_string(quote_xml(Concept_).encode(ExternalEncoding), input_name='Concept'), namespace_)) for Description_ in self.Description: showIndent(outfile, level) outfile.write('<%sDescription>%s</%sDescription>\n' % (namespace_, self.format_string(quote_xml(Description_).encode(ExternalEncoding), input_name='Description'), namespace_)) for Reference_ in self.Reference: Reference_.export(outfile, level, namespace_, name_='Reference') if ( self.Name or self.Concept or self.Description or self.Reference ): return True else: return False level += 1 self.exportLiteralAttributes(outfile, level, name_) if self.hasContent_(): self.exportLiteralChildren(outfile, level, name_) if self.relation is not None: showIndent(outfile, level) outfile.write('relation = "%s",\n' % (self.relation,)) if self.probability is not None: showIndent(outfile, level) outfile.write('probability = %f,\n' % (self.probability,)) showIndent(outfile, level) outfile.write('Name=[\n') level += 1 for Name_ in self.Name: showIndent(outfile, level) outfile.write('%s,\n' % quote_python(Name_).encode(ExternalEncoding)) level -= 1 showIndent(outfile, level) outfile.write('],\n') showIndent(outfile, level) outfile.write('Concept=[\n') level += 1 for Concept_ in self.Concept: showIndent(outfile, level) outfile.write('%s,\n' % quote_python(Concept_).encode(ExternalEncoding)) level -= 1 showIndent(outfile, level) outfile.write('],\n') showIndent(outfile, level) outfile.write('Description=[\n') level += 1 for Description_ in self.Description: showIndent(outfile, level) outfile.write('%s,\n' % quote_python(Description_).encode(ExternalEncoding)) level -= 1 showIndent(outfile, level) outfile.write('],\n') showIndent(outfile, level) outfile.write('Reference=[\n') level += 1 for Reference_ in self.Reference: showIndent(outfile, level) outfile.write('model_.Reference(\n') Reference_.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') level -= 1 showIndent(outfile, level) outfile.write('],\n') self.buildAttributes(node, node.attrib) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] self.buildChildren(child, nodeName_) value = attrs.get('relation') if value is not None: self.relation = value value = attrs.get('probability') if value is not None: self.probability = value self.validate_smallFloat(self.probability) # validate type smallFloat if nodeName_ == 'Name': Name_ = child_.text self.Name.append(Name_) elif nodeName_ == 'Concept': Concept_ = child_.text self.Concept.append(Concept_) elif nodeName_ == 'Description': Description_ = child_.text self.Description.append(Description_) elif nodeName_ == 'Reference': obj_ = Reference.factory() obj_.build(child_) self.Reference.append(obj_) # end class Inference
"""Citations: Follow-up Observations. This section is a sequence of EventIVORN elements, each of which has the IVORN of a cited event.""" if EventIVORN is None: self.EventIVORN = [] else: self.EventIVORN = EventIVORN self.Description = Description self.export_name = 'Citations'
if Citations.subclass: return Citations.subclass(*args_, **kwargs_) else: return Citations(*args_, **kwargs_)
pass for EventIVORN_ in self.EventIVORN: EventIVORN_.export(outfile, level, namespace_, name_='EventIVORN') if self.Description is not None: showIndent(outfile, level) outfile.write('<%sDescription>%s</%sDescription>\n' % (namespace_, self.format_string(quote_xml(self.Description).encode(ExternalEncoding), input_name='Description'), namespace_)) if ( self.EventIVORN or self.Description is not None ): return True else: return False level += 1 self.exportLiteralAttributes(outfile, level, name_) if self.hasContent_(): self.exportLiteralChildren(outfile, level, name_) pass showIndent(outfile, level) outfile.write('EventIVORN=[\n') level += 1 for EventIVORN_ in self.EventIVORN: showIndent(outfile, level) outfile.write('model_.EventIVORN(\n') EventIVORN_.exportLiteral(outfile, level) showIndent(outfile, level) outfile.write('),\n') level -= 1 showIndent(outfile, level) outfile.write('],\n') if self.Description is not None: showIndent(outfile, level) outfile.write('Description=%s,\n' % quote_python(self.Description).encode(ExternalEncoding)) self.buildAttributes(node, node.attrib) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] self.buildChildren(child, nodeName_) pass if nodeName_ == 'EventIVORN': obj_ = EventIVORN.factory() obj_.build(child_) self.EventIVORN.append(obj_) elif nodeName_ == 'Description': Description_ = child_.text self.Description = Description_ # end class Citations
"""Citations/EventIVORN. The value is the IVORN of the cited event, the 'cite' attribute is the nature of that relationship, choosing from 'followup', 'supersedes', or 'retraction'.""" self.cite = _cast(None, cite) self.valueOf_ = valueOf_ self.export_name = 'EventIVORN' if EventIVORN.subclass: return EventIVORN.subclass(*args_, **kwargs_) else: return EventIVORN(*args_, **kwargs_) # Validate type citeValues, a restriction on xs:string. pass
if self.cite is not None: outfile.write(' cite=%s' % (quote_attrib(self.cite), )) pass if ( self.valueOf_ ): return True else: return False level += 1 self.exportLiteralAttributes(outfile, level, name_) if self.hasContent_(): self.exportLiteralChildren(outfile, level, name_) if self.cite is not None: showIndent(outfile, level) outfile.write('cite = "%s",\n' % (self.cite,)) showIndent(outfile, level) outfile.write('valueOf_ = """%s""",\n' % (self.valueOf_,)) self.buildAttributes(node, node.attrib) self.valueOf_ = get_all_text_(node) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] self.buildChildren(child, nodeName_) value = attrs.get('cite') if value is not None: self.cite = value self.validate_citeValues(self.cite) # validate type citeValues pass # end class EventIVORN
"""Reference: External Content. The payload is the uri, and the 'type' describes the nature of the data under that uri. The Reference can also be named.""" self.type_ = _cast(None, type_) self.uri = _cast(None, uri) self.name = _cast(None, name) self.valueOf_ = valueOf_ self.export_name = 'Reference' if Reference.subclass: return Reference.subclass(*args_, **kwargs_) else: return Reference(*args_, **kwargs_)
if self.type_ is not None: outfile.write(' type=%s' % (self.format_string(quote_attrib(self.type_).encode(ExternalEncoding), input_name='type'), )) outfile.write(' uri=%s' % (self.format_string(quote_attrib(self.uri).encode(ExternalEncoding), input_name='uri'), )) if self.name is not None: outfile.write(' name=%s' % (self.format_string(quote_attrib(self.name).encode(ExternalEncoding), input_name='name'), )) pass if ( self.valueOf_ ): return True else: return False level += 1 self.exportLiteralAttributes(outfile, level, name_) if self.hasContent_(): self.exportLiteralChildren(outfile, level, name_) if self.type_ is not None: showIndent(outfile, level) outfile.write('type_ = "%s",\n' % (self.type_,)) if self.uri is not None: showIndent(outfile, level) outfile.write('uri = "%s",\n' % (self.uri,)) if self.name is not None: showIndent(outfile, level) outfile.write('name = "%s",\n' % (self.name,)) showIndent(outfile, level) outfile.write('valueOf_ = """%s""",\n' % (self.valueOf_,)) self.buildAttributes(node, node.attrib) self.valueOf_ = get_all_text_(node) for child in node: nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] self.buildChildren(child, nodeName_) value = attrs.get('type') if value is not None: self.type_ = value value = attrs.get('uri') if value is not None: self.uri = value value = attrs.get('name') if value is not None: self.name = value pass # end class Reference
Usage: python <Parser>.py [ -s ] <in_xml_file> """
print(USAGE_TEXT) sys.exit(1)
tag = Tag_pattern_.match(node.tag).groups()[-1] rootClass = globals().get(tag) return tag, rootClass
doc = parsexml_(inFileName) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) rootObj = rootClass.factory() rootObj.build(rootNode) # Enable Python to collect the space used by the DOM. doc = None sys.stdout.write('<?xml version="1.0" ?>\n') rootObj.export(sys.stdout, 0, name_=rootTag, namespacedef_='') return rootObj
doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) rootObj = rootClass.factory() rootObj.build(rootNode) # Enable Python to collect the space used by the DOM. doc = None sys.stdout.write('<?xml version="1.0" ?>\n') rootObj.export(sys.stdout, 0, name_="VOEvent", namespacedef_='') return rootObj
doc = parsexml_(inFileName) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) rootObj = rootClass.factory() rootObj.build(rootNode) # Enable Python to collect the space used by the DOM. doc = None sys.stdout.write('#from VOEvent import *\n\n') sys.stdout.write('import VOEvent as model_\n\n') sys.stdout.write('rootObj = model_.rootTag(\n') rootObj.exportLiteral(sys.stdout, 0, name_=rootTag) sys.stdout.write(')\n') return rootObj
args = sys.argv[1:] if len(args) == 1: parse(args[0]) else: usage()
#import pdb; pdb.set_trace() main()
|