How to use gds_format_string method in autotest

Best Python code snippet using autotest_python

mets.py

Source:mets.py Github

copy

Full Screen

...68try:69 from generatedssuper import GeneratedsSuper70except ImportError, exp:71 class GeneratedsSuper(object):72 def gds_format_string(self, input_data, input_name=''):73 return input_data74 def gds_validate_string(75 self,76 input_data,77 node,78 input_name='',79 ):80 return input_data81 def gds_format_integer(self, input_data, input_name=''):82 return '%d' % input_data83 def gds_validate_integer(84 self,85 input_data,86 node,87 input_name='',88 ):89 return input_data90 def gds_format_integer_list(self, input_data, input_name=''):91 return '%s' % input_data92 def gds_validate_integer_list(93 self,94 input_data,95 node,96 input_name='',97 ):98 values = input_data.split()99 for value in values:100 try:101 fvalue = float(value)102 except (TypeError, ValueError), exp:103 raise_parse_error(node,104 'Requires sequence of integers')105 return input_data106 def gds_format_float(self, input_data, input_name=''):107 return '%f' % input_data108 def gds_validate_float(109 self,110 input_data,111 node,112 input_name='',113 ):114 return input_data115 def gds_format_float_list(self, input_data, input_name=''):116 return '%s' % input_data117 def gds_validate_float_list(118 self,119 input_data,120 node,121 input_name='',122 ):123 values = input_data.split()124 for value in values:125 try:126 fvalue = float(value)127 except (TypeError, ValueError), exp:128 raise_parse_error(node,129 'Requires sequence of floats')130 return input_data131 def gds_format_double(self, input_data, input_name=''):132 return '%e' % input_data133 def gds_validate_double(134 self,135 input_data,136 node,137 input_name='',138 ):139 return input_data140 def gds_format_double_list(self, input_data, input_name=''):141 return '%s' % input_data142 def gds_validate_double_list(143 self,144 input_data,145 node,146 input_name='',147 ):148 values = input_data.split()149 for value in values:150 try:151 fvalue = float(value)152 except (TypeError, ValueError), exp:153 raise_parse_error(node,154 'Requires sequence of doubles')155 return input_data156 def gds_format_boolean(self, input_data, input_name=''):157 return '%s' % input_data158 def gds_validate_boolean(159 self,160 input_data,161 node,162 input_name='',163 ):164 return input_data165 def gds_format_boolean_list(self, input_data, input_name=''):166 return '%s' % input_data167 def gds_validate_boolean_list(168 self,169 input_data,170 node,171 input_name='',172 ):173 values = input_data.split()174 for value in values:175 if value not in ('true', '1', 'false', '0'):176 raise_parse_error(node,177 'Requires sequence of booleans ("true", "1", "false", "0")'178 )179 return input_data180 def gds_str_lower(self, instring):181 return instring.lower()182 def get_path_(self, node):183 path_list = []184 self.get_path_list_(node, path_list)185 path_list.reverse()186 path = '/'.join(path_list)187 return path188 Tag_strip_pattern_ = re_.compile(r'\{.*\}')189 def get_path_list_(self, node, path_list):190 if node is None:191 return192 tag = GeneratedsSuper.Tag_strip_pattern_.sub('', node.tag)193 if tag:194 path_list.append(tag)195 self.get_path_list_(node.getparent(), path_list)196#197# If you have installed IPython you can uncomment and use the following.198# IPython is available from http://ipython.scipy.org/.199#200## from IPython.Shell import IPShellEmbed201## args = ''202## ipshell = IPShellEmbed(args,203## banner = 'Dropping into IPython',204## exit_msg = 'Leaving Interpreter, back to program.')205# Then use the following line where and when you want to drop into the206# IPython shell:207# ipshell('<some message> -- Entering ipshell.\nHit Ctrl-D to exit')208#209# Globals210#211ExternalEncoding = 'ascii'212Tag_pattern_ = re_.compile(r'({.*})?(.*)')213STRING_CLEANUP_PAT = re_.compile(r"[\n\r\s]+")214#215# Support/utility functions.216#217def showIndent(outfile, level):218 for idx in range(level):219 outfile.write(' ')220def quote_xml(inStr):221 if not inStr:222 return ''223 s1 = isinstance(inStr, basestring) and inStr or '%s' % inStr224 s1 = s1.replace('&', '&amp;')225 s1 = s1.replace('<', '&lt;')226 s1 = s1.replace('>', '&gt;')227 return s1228def quote_attrib(inStr):229 s1 = isinstance(inStr, basestring) and inStr or '%s' % inStr230 s1 = s1.replace('&', '&amp;')231 s1 = s1.replace('<', '&lt;')232 s1 = s1.replace('>', '&gt;')233 if '"' in s1:234 if "'" in s1:235 s1 = '"%s"' % s1.replace('"', '&quot;')236 else:237 s1 = "'%s'" % s1238 else:239 s1 = '"%s"' % s1240 return s1241def quote_python(inStr):242 s1 = inStr243 if s1.find("'") == -1:244 if s1.find('\n') == -1:245 return "'%s'" % s1246 else:247 return "'''%s'''" % s1248 else:249 if s1.find('"') != -1:250 s1 = s1.replace('"', '\\"')251 if s1.find('\n') == -1:252 return '"%s"' % s1253 else:254 return '"""%s"""' % s1255def get_all_text_(node):256 if node.text is not None:257 text = node.text258 else:259 text = ''260 for child in node:261 if child.tail is not None:262 text += child.tail263 return text264class GDSParseError(Exception):265 pass266def raise_parse_error(node, msg):267 if XMLParser_import_library == XMLParser_import_lxml:268 msg = '%s (element %s/line %d)' % (msg, node.tag,269 node.sourceline)270 else:271 msg = '%s (element %s)' % (msg, node.tag)272 raise GDSParseError(msg)273class MixedContainer:274 # Constants for category:275 CategoryNone = 0276 CategoryText = 1277 CategorySimple = 2278 CategoryComplex = 3279 # Constants for content_type:280 TypeNone = 0281 TypeText = 1282 TypeString = 2283 TypeInteger = 3284 TypeFloat = 4285 TypeDecimal = 5286 TypeDouble = 6287 TypeBoolean = 7288 def __init__(289 self,290 category,291 content_type,292 name,293 value,294 ):295 self.category = category296 self.content_type = content_type297 self.name = name298 self.value = value299 def getCategory(self):300 return self.category301 def getContenttype(self, content_type):302 return self.content_type303 def getValue(self):304 return self.value305 def getName(self):306 return self.name307 def export(308 self,309 outfile,310 level,311 name,312 namespace,313 ):314 if self.category == MixedContainer.CategoryText:315 # Prevent exporting empty content as empty lines.316 if self.value.strip():317 outfile.write(self.value)318 elif self.category == MixedContainer.CategorySimple:319 self.exportSimple(outfile, level, name)320 else:321 # category == MixedContainer.CategoryComplex322 self.value.export(outfile, level, namespace, name)323 def exportSimple(324 self,325 outfile,326 level,327 name,328 ):329 if self.content_type == MixedContainer.TypeString:330 outfile.write('<%s>%s</%s>' % (self.name, self.value,331 self.name))332 elif self.content_type == MixedContainer.TypeInteger \333 or self.content_type == MixedContainer.TypeBoolean:334 outfile.write('<%s>%d</%s>' % (self.name, self.value,335 self.name))336 elif self.content_type == MixedContainer.TypeFloat \337 or self.content_type == MixedContainer.TypeDecimal:338 outfile.write('<%s>%f</%s>' % (self.name, self.value,339 self.name))340 elif self.content_type == MixedContainer.TypeDouble:341 outfile.write('<%s>%g</%s>' % (self.name, self.value,342 self.name))343 def exportLiteral(344 self,345 outfile,346 level,347 name,348 ):349 if self.category == MixedContainer.CategoryText:350 showIndent(outfile, level)351 outfile.write('model_.MixedContainer(%d, %d, "%s", "%s"),\n'352 % (self.category, self.content_type,353 self.name, self.value))354 elif self.category == MixedContainer.CategorySimple:355 showIndent(outfile, level)356 outfile.write('model_.MixedContainer(%d, %d, "%s", "%s"),\n'357 % (self.category, self.content_type,358 self.name, self.value))359 else:360 # category == MixedContainer.CategoryComplex361 showIndent(outfile, level)362 outfile.write('model_.MixedContainer(%d, %d, "%s",\n'363 % (self.category, self.content_type,364 self.name))365 self.value.exportLiteral(outfile, level + 1)366 showIndent(outfile, level)367 outfile.write(')\n')368class MemberSpec_(object):369 def __init__(370 self,371 name='',372 data_type='',373 container=0,374 ):375 self.name = name376 self.data_type = data_type377 self.container = container378 def set_name(self, name):379 self.name = name380 def get_name(self):381 return self.name382 def set_data_type(self, data_type):383 self.data_type = data_type384 def get_data_type_chain(self):385 return self.data_type386 def get_data_type(self):387 if isinstance(self.data_type, list):388 if len(self.data_type) > 0:389 return self.data_type[-1]390 else:391 return 'xs:string'392 else:393 return self.data_type394 def set_container(self, container):395 self.container = container396 def get_container(self):397 return self.container398def _cast(typ, value):399 if typ is None or value is None:400 return value401 return typ(value)402#403# Data representation classes.404#405class metsType(GeneratedsSuper):406 """metsType: Complex Type for METS Sections A METS document consists of407 seven possible subsidiary sections: metsHdr (METS document408 header), dmdSec (descriptive metadata section), amdSec409 (administrative metadata section), fileGrp (file inventory410 group), structLink (structural map linking), structMap411 (structural map) and behaviorSec (behaviors section). ID (ID/O):412 This attribute uniquely identifies the element within the METS413 document, and would allow the element to be referenced414 unambiguously from another element or document via an IDREF or415 an XPTR. For more information on using ID attributes for416 internal and external linking see Chapter 4 of the METS Primer.417 OBJID (string/O): Is the primary identifier assigned to the METS418 object as a whole. Although this attribute is not required, it419 is strongly recommended. This identifier is used to tag the420 entire METS object to external systems, in contrast with the ID421 identifier. LABEL (string/O): Is a simple title string used to422 identify the object/entity being described in the METS document423 for the user. TYPE (string/O): Specifies the class or type of424 the object, e.g.: book, journal, stereograph, dataset, video,425 etc. PROFILE (string/O): Indicates to which of the registered426 profile(s) the METS document conforms. For additional427 information about PROFILES see Chapter 5 of the METS Primer."""428 subclass = None429 superclass = None430 def __init__(431 self,432 PROFILE=None,433 LABEL=None,434 TYPE=None,435 ID=None,436 OBJID=None,437 metsHdr=None,438 dmdSec=None,439 amdSec=None,440 fileSec=None,441 structMap=None,442 structLink=None,443 behaviorSec=None,444 ):445 self.PROFILE = _cast(None, PROFILE)446 self.LABEL = _cast(None, LABEL)447 self.TYPE = _cast(None, TYPE)448 self.ID = _cast(None, ID)449 self.OBJID = _cast(None, OBJID)450 self.metsHdr = metsHdr451 if dmdSec is None:452 self.dmdSec = []453 else:454 self.dmdSec = dmdSec455 if amdSec is None:456 self.amdSec = []457 else:458 self.amdSec = amdSec459 self.fileSec = fileSec460 if structMap is None:461 self.structMap = []462 else:463 self.structMap = structMap464 self.structLink = structLink465 if behaviorSec is None:466 self.behaviorSec = []467 else:468 self.behaviorSec = behaviorSec469 def factory(*args_, **kwargs_):470 if metsType.subclass:471 return metsType.subclass(*args_, **kwargs_)472 else:473 return metsType(*args_, **kwargs_)474 factory = staticmethod(factory)475 def get_metsHdr(self):476 return self.metsHdr477 def set_metsHdr(self, metsHdr):478 self.metsHdr = metsHdr479 def get_dmdSec(self):480 return self.dmdSec481 def set_dmdSec(self, dmdSec):482 self.dmdSec = dmdSec483 def add_dmdSec(self, value):484 self.dmdSec.append(value)485 def insert_dmdSec(self, index, value):486 self.dmdSec[index] = value487 def get_amdSec(self):488 return self.amdSec489 def set_amdSec(self, amdSec):490 self.amdSec = amdSec491 def add_amdSec(self, value):492 self.amdSec.append(value)493 def insert_amdSec(self, index, value):494 self.amdSec[index] = value495 def get_fileSec(self):496 return self.fileSec497 def set_fileSec(self, fileSec):498 self.fileSec = fileSec499 def get_structMap(self):500 return self.structMap501 def set_structMap(self, structMap):502 self.structMap = structMap503 def add_structMap(self, value):504 self.structMap.append(value)505 def insert_structMap(self, index, value):506 self.structMap[index] = value507 def get_structLink(self):508 return self.structLink509 def set_structLink(self, structLink):510 self.structLink = structLink511 def get_behaviorSec(self):512 return self.behaviorSec513 def set_behaviorSec(self, behaviorSec):514 self.behaviorSec = behaviorSec515 def add_behaviorSec(self, value):516 self.behaviorSec.append(value)517 def insert_behaviorSec(self, index, value):518 self.behaviorSec[index] = value519 def get_PROFILE(self):520 return self.PROFILE521 def set_PROFILE(self, PROFILE):522 self.PROFILE = PROFILE523 def get_LABEL(self):524 return self.LABEL525 def set_LABEL(self, LABEL):526 self.LABEL = LABEL527 def get_TYPE(self):528 return self.TYPE529 def set_TYPE(self, TYPE):530 self.TYPE = TYPE531 def get_ID(self):532 return self.ID533 def set_ID(self, ID):534 self.ID = ID535 def get_OBJID(self):536 return self.OBJID537 def set_OBJID(self, OBJID):538 self.OBJID = OBJID539 def export(540 self,541 outfile,542 level,543 namespace_='',544 name_='metsType',545 namespacedef_='',546 ):547 showIndent(outfile, level)548 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_549 and ' ' + namespacedef_ or ''))550 self.exportAttributes(outfile, level, [], namespace_,551 name_='metsType')552 if self.hasContent_():553 outfile.write('>\n')554 self.exportChildren(outfile, level + 1, namespace_, name_)555 showIndent(outfile, level)556 outfile.write('</%s%s>\n' % (namespace_, name_))557 else:558 outfile.write('/>\n')559 def exportAttributes(560 self,561 outfile,562 level,563 already_processed,564 namespace_='',565 name_='metsType',566 ):567 if self.PROFILE is not None and 'PROFILE' \568 not in already_processed:569 already_processed.append('PROFILE')570 outfile.write(' PROFILE=%s'571 % (self.gds_format_string(self.PROFILE.encode(ExternalEncoding),572 input_name='PROFILE'), ))573 if self.LABEL is not None and 'LABEL' not in already_processed:574 already_processed.append('LABEL')575 outfile.write(' LABEL=%s'576 % (self.gds_format_string(quote_attrib(self.LABEL).encode(ExternalEncoding),577 input_name='LABEL'), ))578 if self.TYPE is not None and 'TYPE' not in already_processed:579 already_processed.append('TYPE')580 outfile.write(' TYPE=%s'581 % (self.gds_format_string(quote_attrib(self.TYPE).encode(ExternalEncoding),582 input_name='TYPE'), ))583 if self.ID is not None and 'ID' not in already_processed:584 already_processed.append('ID')585 outfile.write(' ID=%s'586 % (self.gds_format_string(quote_attrib(self.ID).encode(ExternalEncoding),587 input_name='ID'), ))588 if self.OBJID is not None and 'OBJID' not in already_processed:589 already_processed.append('OBJID')590 outfile.write(' OBJID=%s'591 % (self.gds_format_string(quote_attrib(self.OBJID).encode(ExternalEncoding),592 input_name='OBJID'), ))593 def exportChildren(594 self,595 outfile,596 level,597 namespace_='',598 name_='metsType',599 ):600 if self.metsHdr:601 self.metsHdr.export(outfile, level, namespace_,602 name_='metsHdr')603 for dmdSec_ in self.dmdSec:604 dmdSec_.export(outfile, level, namespace_, name_='dmdSec')605 for amdSec_ in self.amdSec:606 amdSec_.export(outfile, level, namespace_, name_='amdSec')607 if self.fileSec:608 self.fileSec.export(outfile, level, namespace_,609 name_='fileSec')610 for structMap_ in self.structMap:611 structMap_.export(outfile, level, namespace_,612 name_='structMap')613 if self.structLink:614 self.structLink.export(outfile, level, namespace_,615 name_='structLink')616 for behaviorSec_ in self.behaviorSec:617 behaviorSec_.export(outfile, level, namespace_,618 name_='behaviorSec')619 def hasContent_(self):620 if self.metsHdr is not None or self.dmdSec or self.amdSec \621 or self.fileSec is not None or self.structMap \622 or self.structLink is not None or self.behaviorSec:623 return True624 else:625 return False626 def exportLiteral(627 self,628 outfile,629 level,630 name_='metsType',631 ):632 level += 1633 self.exportLiteralAttributes(outfile, level, [], name_)634 if self.hasContent_():635 self.exportLiteralChildren(outfile, level, name_)636 def exportLiteralAttributes(637 self,638 outfile,639 level,640 already_processed,641 name_,642 ):643 if self.PROFILE is not None and 'PROFILE' \644 not in already_processed:645 already_processed.append('PROFILE')646 showIndent(outfile, level)647 outfile.write('PROFILE = "%s",\n' % (self.PROFILE, ))648 if self.LABEL is not None and 'LABEL' not in already_processed:649 already_processed.append('LABEL')650 showIndent(outfile, level)651 outfile.write('LABEL = "%s",\n' % (self.LABEL, ))652 if self.TYPE is not None and 'TYPE' not in already_processed:653 already_processed.append('TYPE')654 showIndent(outfile, level)655 outfile.write('TYPE = "%s",\n' % (self.TYPE, ))656 if self.ID is not None and 'ID' not in already_processed:657 already_processed.append('ID')658 showIndent(outfile, level)659 outfile.write('ID = "%s",\n' % (self.ID, ))660 if self.OBJID is not None and 'OBJID' not in already_processed:661 already_processed.append('OBJID')662 showIndent(outfile, level)663 outfile.write('OBJID = "%s",\n' % (self.OBJID, ))664 def exportLiteralChildren(665 self,666 outfile,667 level,668 name_,669 ):670 if self.metsHdr is not None:671 showIndent(outfile, level)672 outfile.write('metsHdr=model_.metsHdr(\n')673 self.metsHdr.exportLiteral(outfile, level)674 showIndent(outfile, level)675 outfile.write('),\n')676 showIndent(outfile, level)677 outfile.write('dmdSec=[\n')678 level += 1679 for dmdSec_ in self.dmdSec:680 showIndent(outfile, level)681 outfile.write('model_.mdSecType(\n')682 dmdSec_.exportLiteral(outfile, level, name_='mdSecType')683 showIndent(outfile, level)684 outfile.write('),\n')685 level -= 1686 showIndent(outfile, level)687 outfile.write('],\n')688 showIndent(outfile, level)689 outfile.write('amdSec=[\n')690 level += 1691 for amdSec_ in self.amdSec:692 showIndent(outfile, level)693 outfile.write('model_.amdSecType(\n')694 amdSec_.exportLiteral(outfile, level, name_='amdSecType')695 showIndent(outfile, level)696 outfile.write('),\n')697 level -= 1698 showIndent(outfile, level)699 outfile.write('],\n')700 if self.fileSec is not None:701 showIndent(outfile, level)702 outfile.write('fileSec=model_.fileSec(\n')703 self.fileSec.exportLiteral(outfile, level)704 showIndent(outfile, level)705 outfile.write('),\n')706 showIndent(outfile, level)707 outfile.write('structMap=[\n')708 level += 1709 for structMap_ in self.structMap:710 showIndent(outfile, level)711 outfile.write('model_.structMapType(\n')712 structMap_.exportLiteral(outfile, level,713 name_='structMapType')714 showIndent(outfile, level)715 outfile.write('),\n')716 level -= 1717 showIndent(outfile, level)718 outfile.write('],\n')719 if self.structLink is not None:720 showIndent(outfile, level)721 outfile.write('structLink=model_.structLink(\n')722 self.structLink.exportLiteral(outfile, level)723 showIndent(outfile, level)724 outfile.write('),\n')725 showIndent(outfile, level)726 outfile.write('behaviorSec=[\n')727 level += 1728 for behaviorSec_ in self.behaviorSec:729 showIndent(outfile, level)730 outfile.write('model_.behaviorSecType(\n')731 behaviorSec_.exportLiteral(outfile, level,732 name_='behaviorSecType')733 showIndent(outfile, level)734 outfile.write('),\n')735 level -= 1736 showIndent(outfile, level)737 outfile.write('],\n')738 def build(self, node):739 self.buildAttributes(node, node.attrib, [])740 for child in node:741 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]742 self.buildChildren(child, node, nodeName_)743 def buildAttributes(744 self,745 node,746 attrs,747 already_processed,748 ):749 value = attrs.get('PROFILE')750 if value is not None and 'PROFILE' not in already_processed:751 already_processed.append('PROFILE')752 self.PROFILE = value753 value = attrs.get('LABEL')754 if value is not None and 'LABEL' not in already_processed:755 already_processed.append('LABEL')756 self.LABEL = value757 value = attrs.get('TYPE')758 if value is not None and 'TYPE' not in already_processed:759 already_processed.append('TYPE')760 self.TYPE = value761 value = attrs.get('ID')762 if value is not None and 'ID' not in already_processed:763 already_processed.append('ID')764 self.ID = value765 value = attrs.get('OBJID')766 if value is not None and 'OBJID' not in already_processed:767 already_processed.append('OBJID')768 self.OBJID = value769 def buildChildren(770 self,771 child_,772 node,773 nodeName_,774 from_subclass=False,775 ):776 if nodeName_ == 'metsHdr':777 obj_ = metsHdr.factory()778 obj_.build(child_)779 self.set_metsHdr(obj_)780 elif nodeName_ == 'dmdSec':781 obj_ = mdSecType.factory()782 obj_.build(child_)783 self.dmdSec.append(obj_)784 elif nodeName_ == 'amdSec':785 obj_ = amdSecType.factory()786 obj_.build(child_)787 self.amdSec.append(obj_)788 elif nodeName_ == 'fileSec':789 obj_ = fileSec.factory()790 obj_.build(child_)791 self.set_fileSec(obj_)792 elif nodeName_ == 'structMap':793 obj_ = structMapType.factory()794 obj_.build(child_)795 self.structMap.append(obj_)796 elif nodeName_ == 'structLink':797 obj_ = structLink.factory()798 obj_.build(child_)799 self.set_structLink(obj_)800 elif nodeName_ == 'behaviorSec':801 obj_ = behaviorSecType.factory()802 obj_.build(child_)803 self.behaviorSec.append(obj_)804# end class metsType805class metsHdr(GeneratedsSuper):806 """The mets header element <metsHdr> captures metadata about the METS807 document itself, not the digital object the METS document808 encodes. Although it records a more limited set of metadata, it809 is very similar in function and purpose to the headers employed810 in other schema such as the Text Encoding Initiative (TEI) or in811 the Encoded Archival Description (EAD). ID (ID/O): This812 attribute uniquely identifies the element within the METS813 document, and would allow the element to be referenced814 unambiguously from another element or document via an IDREF or815 an XPTR. For more information on using ID attributes for816 internal and external linking see Chapter 4 of the METS Primer.817 ADMID (IDREFS/O): Contains the ID attribute values of the818 <techMD>, <sourceMD>, <rightsMD> and/or <digiprovMD> elements819 within the <amdSec> of the METS document that contain820 administrative metadata pertaining to the METS document itself.821 For more information on using METS IDREFS and IDREF type822 attributes for internal linking, see Chapter 4 of the METS823 Primer. CREATEDATE (dateTime/O): Records the date/time the METS824 document was created. LASTMODDATE (dateTime/O): Is used to825 indicate the date/time the METS document was last modified.826 RECORDSTATUS (string/O): Specifies the status of the METS827 document. It is used for internal processing purposes."""828 subclass = None829 superclass = None830 def __init__(831 self,832 CREATEDATE=None,833 RECORDSTATUS=None,834 ADMID=None,835 LASTMODDATE=None,836 ID=None,837 agent=None,838 altRecordID=None,839 metsDocumentID=None,840 ):841 self.CREATEDATE = _cast(None, CREATEDATE)842 self.RECORDSTATUS = _cast(None, RECORDSTATUS)843 self.ADMID = _cast(None, ADMID)844 self.LASTMODDATE = _cast(None, LASTMODDATE)845 self.ID = _cast(None, ID)846 if agent is None:847 self.agent = []848 else:849 self.agent = agent850 if altRecordID is None:851 self.altRecordID = []852 else:853 self.altRecordID = altRecordID854 self.metsDocumentID = metsDocumentID855 def factory(*args_, **kwargs_):856 if metsHdr.subclass:857 return metsHdr.subclass(*args_, **kwargs_)858 else:859 return metsHdr(*args_, **kwargs_)860 factory = staticmethod(factory)861 def get_agent(self):862 return self.agent863 def set_agent(self, agent):864 self.agent = agent865 def add_agent(self, value):866 self.agent.append(value)867 def insert_agent(self, index, value):868 self.agent[index] = value869 def get_altRecordID(self):870 return self.altRecordID871 def set_altRecordID(self, altRecordID):872 self.altRecordID = altRecordID873 def add_altRecordID(self, value):874 self.altRecordID.append(value)875 def insert_altRecordID(self, index, value):876 self.altRecordID[index] = value877 def get_metsDocumentID(self):878 return self.metsDocumentID879 def set_metsDocumentID(self, metsDocumentID):880 self.metsDocumentID = metsDocumentID881 def get_CREATEDATE(self):882 return self.CREATEDATE883 def set_CREATEDATE(self, CREATEDATE):884 self.CREATEDATE = CREATEDATE885 def get_RECORDSTATUS(self):886 return self.RECORDSTATUS887 def set_RECORDSTATUS(self, RECORDSTATUS):888 self.RECORDSTATUS = RECORDSTATUS889 def get_ADMID(self):890 return self.ADMID891 def set_ADMID(self, ADMID):892 self.ADMID = ADMID893 def get_LASTMODDATE(self):894 return self.LASTMODDATE895 def set_LASTMODDATE(self, LASTMODDATE):896 self.LASTMODDATE = LASTMODDATE897 def get_ID(self):898 return self.ID899 def set_ID(self, ID):900 self.ID = ID901 def export(902 self,903 outfile,904 level,905 namespace_='',906 name_='metsHdr',907 namespacedef_='',908 ):909 showIndent(outfile, level)910 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_911 and ' ' + namespacedef_ or ''))912 self.exportAttributes(outfile, level, [], namespace_,913 name_='metsHdr')914 if self.hasContent_():915 outfile.write('>\n')916 self.exportChildren(outfile, level + 1, namespace_, name_)917 showIndent(outfile, level)918 outfile.write('</%s%s>\n' % (namespace_, name_))919 else:920 outfile.write('/>\n')921 def exportAttributes(922 self,923 outfile,924 level,925 already_processed,926 namespace_='',927 name_='metsHdr',928 ):929 if self.CREATEDATE is not None and 'CREATEDATE' \930 not in already_processed:931 already_processed.append('CREATEDATE')932 outfile.write(' CREATEDATE=%s'933 % (self.gds_format_string(quote_attrib(self.CREATEDATE).encode(ExternalEncoding),934 input_name='CREATEDATE'), ))935 if self.RECORDSTATUS is not None and 'RECORDSTATUS' \936 not in already_processed:937 already_processed.append('RECORDSTATUS')938 outfile.write(' RECORDSTATUS=%s'939 % (self.gds_format_string(quote_attrib(self.RECORDSTATUS).encode(ExternalEncoding),940 input_name='RECORDSTATUS'), ))941 if self.ADMID is not None and 'ADMID' not in already_processed:942 already_processed.append('ADMID')943 outfile.write(' ADMID=%s'944 % (self.gds_format_string(quote_attrib(self.ADMID).encode(ExternalEncoding),945 input_name='ADMID'), ))946 if self.LASTMODDATE is not None and 'LASTMODDATE' \947 not in already_processed:948 already_processed.append('LASTMODDATE')949 outfile.write(' LASTMODDATE=%s'950 % (self.gds_format_string(quote_attrib(self.LASTMODDATE).encode(ExternalEncoding),951 input_name='LASTMODDATE'), ))952 if self.ID is not None and 'ID' not in already_processed:953 already_processed.append('ID')954 outfile.write(' ID=%s'955 % (self.gds_format_string(quote_attrib(self.ID).encode(ExternalEncoding),956 input_name='ID'), ))957 def exportChildren(958 self,959 outfile,960 level,961 namespace_='',962 name_='metsHdr',963 ):964 for agent_ in self.agent:965 agent_.export(outfile, level, namespace_, name_='agent')966 for altRecordID_ in self.altRecordID:967 altRecordID_.export(outfile, level, namespace_,968 name_='altRecordID')969 if self.metsDocumentID:970 self.metsDocumentID.export(outfile, level, namespace_,971 name_='metsDocumentID')972 def hasContent_(self):973 if self.agent or self.altRecordID or self.metsDocumentID \974 is not None:975 return True976 else:977 return False978 def exportLiteral(979 self,980 outfile,981 level,982 name_='metsHdr',983 ):984 level += 1985 self.exportLiteralAttributes(outfile, level, [], name_)986 if self.hasContent_():987 self.exportLiteralChildren(outfile, level, name_)988 def exportLiteralAttributes(989 self,990 outfile,991 level,992 already_processed,993 name_,994 ):995 if self.CREATEDATE is not None and 'CREATEDATE' \996 not in already_processed:997 already_processed.append('CREATEDATE')998 showIndent(outfile, level)999 outfile.write('CREATEDATE = "%s",\n' % (self.CREATEDATE, ))1000 if self.RECORDSTATUS is not None and 'RECORDSTATUS' \1001 not in already_processed:1002 already_processed.append('RECORDSTATUS')1003 showIndent(outfile, level)1004 outfile.write('RECORDSTATUS = "%s",\n'1005 % (self.RECORDSTATUS, ))1006 if self.ADMID is not None and 'ADMID' not in already_processed:1007 already_processed.append('ADMID')1008 showIndent(outfile, level)1009 outfile.write('ADMID = "%s",\n' % (self.ADMID, ))1010 if self.LASTMODDATE is not None and 'LASTMODDATE' \1011 not in already_processed:1012 already_processed.append('LASTMODDATE')1013 showIndent(outfile, level)1014 outfile.write('LASTMODDATE = "%s",\n' % (self.LASTMODDATE,1015 ))1016 if self.ID is not None and 'ID' not in already_processed:1017 already_processed.append('ID')1018 showIndent(outfile, level)1019 outfile.write('ID = "%s",\n' % (self.ID, ))1020 def exportLiteralChildren(1021 self,1022 outfile,1023 level,1024 name_,1025 ):1026 showIndent(outfile, level)1027 outfile.write('agent=[\n')1028 level += 11029 for agent_ in self.agent:1030 showIndent(outfile, level)1031 outfile.write('model_.agent(\n')1032 agent_.exportLiteral(outfile, level)1033 showIndent(outfile, level)1034 outfile.write('),\n')1035 level -= 11036 showIndent(outfile, level)1037 outfile.write('],\n')1038 showIndent(outfile, level)1039 outfile.write('altRecordID=[\n')1040 level += 11041 for altRecordID_ in self.altRecordID:1042 showIndent(outfile, level)1043 outfile.write('model_.altRecordID(\n')1044 altRecordID_.exportLiteral(outfile, level)1045 showIndent(outfile, level)1046 outfile.write('),\n')1047 level -= 11048 showIndent(outfile, level)1049 outfile.write('],\n')1050 if self.metsDocumentID is not None:1051 showIndent(outfile, level)1052 outfile.write('metsDocumentID=model_.metsDocumentID(\n')1053 self.metsDocumentID.exportLiteral(outfile, level)1054 showIndent(outfile, level)1055 outfile.write('),\n')1056 def build(self, node):1057 self.buildAttributes(node, node.attrib, [])1058 for child in node:1059 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]1060 self.buildChildren(child, node, nodeName_)1061 def buildAttributes(1062 self,1063 node,1064 attrs,1065 already_processed,1066 ):1067 value = attrs.get('CREATEDATE')1068 if value is not None and 'CREATEDATE' not in already_processed:1069 already_processed.append('CREATEDATE')1070 self.CREATEDATE = value1071 value = attrs.get('RECORDSTATUS')1072 if value is not None and 'RECORDSTATUS' \1073 not in already_processed:1074 already_processed.append('RECORDSTATUS')1075 self.RECORDSTATUS = value1076 value = attrs.get('ADMID')1077 if value is not None and 'ADMID' not in already_processed:1078 already_processed.append('ADMID')1079 self.ADMID = value1080 value = attrs.get('LASTMODDATE')1081 if value is not None and 'LASTMODDATE' not in already_processed:1082 already_processed.append('LASTMODDATE')1083 self.LASTMODDATE = value1084 value = attrs.get('ID')1085 if value is not None and 'ID' not in already_processed:1086 already_processed.append('ID')1087 self.ID = value1088 def buildChildren(1089 self,1090 child_,1091 node,1092 nodeName_,1093 from_subclass=False,1094 ):1095 if nodeName_ == 'agent':1096 obj_ = agent.factory()1097 obj_.build(child_)1098 self.agent.append(obj_)1099 elif nodeName_ == 'altRecordID':1100 obj_ = altRecordID.factory()1101 obj_.build(child_)1102 self.altRecordID.append(obj_)1103 elif nodeName_ == 'metsDocumentID':1104 obj_ = metsDocumentID.factory()1105 obj_.build(child_)1106 self.set_metsDocumentID(obj_)1107# end class metsHdr1108class agent(GeneratedsSuper):1109 """agent: The agent element <agent> provides for various parties and1110 their roles with respect to the METS record to be documented. ID1111 (ID/O): This attribute uniquely identifies the element within1112 the METS document, and would allow the element to be referenced1113 unambiguously from another element or document via an IDREF or1114 an XPTR. For more information on using ID attributes for1115 internal and external linking see Chapter 4 of the METS Primer.1116 ROLE (string/R): Specifies the function of the agent with1117 respect to the METS record. The allowed values are: CREATOR: The1118 person(s) or institution(s) responsible for the METS document.1119 EDITOR: The person(s) or institution(s) that prepares the1120 metadata for encoding. ARCHIVIST: The person(s) or1121 institution(s) responsible for the document/collection.1122 PRESERVATION: The person(s) or institution(s) responsible for1123 preservation functions. DISSEMINATOR: The person(s) or1124 institution(s) responsible for dissemination functions.1125 CUSTODIAN: The person(s) or institution(s) charged with the1126 oversight of a document/collection. IPOWNER: Intellectual1127 Property Owner: The person(s) or institution holding copyright,1128 trade or service marks or other intellectual property rights for1129 the object. OTHER: Use OTHER if none of the preceding values1130 pertains and clarify the type and location specifier being used1131 in the OTHERROLE attribute (see below). OTHERROLE (string/O):1132 Denotes a role not contained in the allowed values set if OTHER1133 is indicated in the ROLE attribute. TYPE (string/O): is used to1134 specify the type of AGENT. It must be one of the following1135 values: INDIVIDUAL: Use if an individual has served as the1136 agent. ORGANIZATION: Use if an institution, corporate body,1137 association, non-profit enterprise, government, religious body,1138 etc. has served as the agent. OTHER: Use OTHER if none of the1139 preceding values pertain and clarify the type of agent specifier1140 being used in the OTHERTYPE attribute OTHERTYPE (string/O):1141 Specifies the type of agent when the value OTHER is indicated in1142 the TYPE attribute."""1143 subclass = None1144 superclass = None1145 def __init__(1146 self,1147 TYPE=None,1148 OTHERTYPE=None,1149 ROLE=None,1150 ID=None,1151 OTHERROLE=None,1152 name=None,1153 note=None,1154 ):1155 self.TYPE = _cast(None, TYPE)1156 self.OTHERTYPE = _cast(None, OTHERTYPE)1157 self.ROLE = _cast(None, ROLE)1158 self.ID = _cast(None, ID)1159 self.OTHERROLE = _cast(None, OTHERROLE)1160 self.name = name1161 if note is None:1162 self.note = []1163 else:1164 self.note = note1165 def factory(*args_, **kwargs_):1166 if agent.subclass:1167 return agent.subclass(*args_, **kwargs_)1168 else:1169 return agent(*args_, **kwargs_)1170 factory = staticmethod(factory)1171 def get_name(self):1172 return self.name1173 def set_name(self, name):1174 self.name = name1175 def get_note(self):1176 return self.note1177 def set_note(self, note):1178 self.note = note1179 def add_note(self, value):1180 self.note.append(value)1181 def insert_note(self, index, value):1182 self.note[index] = value1183 def get_TYPE(self):1184 return self.TYPE1185 def set_TYPE(self, TYPE):1186 self.TYPE = TYPE1187 def get_OTHERTYPE(self):1188 return self.OTHERTYPE1189 def set_OTHERTYPE(self, OTHERTYPE):1190 self.OTHERTYPE = OTHERTYPE1191 def get_ROLE(self):1192 return self.ROLE1193 def set_ROLE(self, ROLE):1194 self.ROLE = ROLE1195 def get_ID(self):1196 return self.ID1197 def set_ID(self, ID):1198 self.ID = ID1199 def get_OTHERROLE(self):1200 return self.OTHERROLE1201 def set_OTHERROLE(self, OTHERROLE):1202 self.OTHERROLE = OTHERROLE1203 def export(1204 self,1205 outfile,1206 level,1207 namespace_='',1208 name_='agent',1209 namespacedef_='',1210 ):1211 showIndent(outfile, level)1212 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_1213 and ' ' + namespacedef_ or ''))1214 self.exportAttributes(outfile, level, [], namespace_,1215 name_='agent')1216 if self.hasContent_():1217 outfile.write('>\n')1218 self.exportChildren(outfile, level + 1, namespace_, name_)1219 showIndent(outfile, level)1220 outfile.write('</%s%s>\n' % (namespace_, name_))1221 else:1222 outfile.write('/>\n')1223 def exportAttributes(1224 self,1225 outfile,1226 level,1227 already_processed,1228 namespace_='',1229 name_='agent',1230 ):1231 if self.TYPE is not None and 'TYPE' not in already_processed:1232 already_processed.append('TYPE')1233 outfile.write(' TYPE=%s'1234 % (self.gds_format_string(quote_attrib(self.TYPE).encode(ExternalEncoding),1235 input_name='TYPE'), ))1236 if self.OTHERTYPE is not None and 'OTHERTYPE' \1237 not in already_processed:1238 already_processed.append('OTHERTYPE')1239 outfile.write(' OTHERTYPE=%s'1240 % (self.gds_format_string(quote_attrib(self.OTHERTYPE).encode(ExternalEncoding),1241 input_name='OTHERTYPE'), ))1242 if self.ROLE is not None and 'ROLE' not in already_processed:1243 already_processed.append('ROLE')1244 outfile.write(' ROLE=%s'1245 % (self.gds_format_string(quote_attrib(self.ROLE).encode(ExternalEncoding),1246 input_name='ROLE'), ))1247 if self.ID is not None and 'ID' not in already_processed:1248 already_processed.append('ID')1249 outfile.write(' ID=%s'1250 % (self.gds_format_string(quote_attrib(self.ID).encode(ExternalEncoding),1251 input_name='ID'), ))1252 if self.OTHERROLE is not None and 'OTHERROLE' \1253 not in already_processed:1254 already_processed.append('OTHERROLE')1255 outfile.write(' OTHERROLE=%s'1256 % (self.gds_format_string(quote_attrib(self.OTHERROLE).encode(ExternalEncoding),1257 input_name='OTHERROLE'), ))1258 def exportChildren(1259 self,1260 outfile,1261 level,1262 namespace_='',1263 name_='agent',1264 ):1265 if self.name is not None:1266 showIndent(outfile, level)1267 outfile.write('<%sname>%s</%sname>\n' % (namespace_,1268 self.gds_format_string(quote_xml(self.name).encode(ExternalEncoding),1269 input_name='name'), namespace_))1270 for note_ in self.note:1271 showIndent(outfile, level)1272 outfile.write('<%snote>%s</%snote>\n' % (namespace_,1273 self.gds_format_string(quote_xml(note_).encode(ExternalEncoding),1274 input_name='note'), namespace_))1275 def hasContent_(self):1276 if self.name is not None or self.note:1277 return True1278 else:1279 return False1280 def exportLiteral(1281 self,1282 outfile,1283 level,1284 name_='agent',1285 ):1286 level += 11287 self.exportLiteralAttributes(outfile, level, [], name_)1288 if self.hasContent_():1289 self.exportLiteralChildren(outfile, level, name_)1290 def exportLiteralAttributes(1291 self,1292 outfile,1293 level,1294 already_processed,1295 name_,1296 ):1297 if self.TYPE is not None and 'TYPE' not in already_processed:1298 already_processed.append('TYPE')1299 showIndent(outfile, level)1300 outfile.write('TYPE = "%s",\n' % (self.TYPE, ))1301 if self.OTHERTYPE is not None and 'OTHERTYPE' \1302 not in already_processed:1303 already_processed.append('OTHERTYPE')1304 showIndent(outfile, level)1305 outfile.write('OTHERTYPE = "%s",\n' % (self.OTHERTYPE, ))1306 if self.ROLE is not None and 'ROLE' not in already_processed:1307 already_processed.append('ROLE')1308 showIndent(outfile, level)1309 outfile.write('ROLE = "%s",\n' % (self.ROLE, ))1310 if self.ID is not None and 'ID' not in already_processed:1311 already_processed.append('ID')1312 showIndent(outfile, level)1313 outfile.write('ID = "%s",\n' % (self.ID, ))1314 if self.OTHERROLE is not None and 'OTHERROLE' \1315 not in already_processed:1316 already_processed.append('OTHERROLE')1317 showIndent(outfile, level)1318 outfile.write('OTHERROLE = "%s",\n' % (self.OTHERROLE, ))1319 def exportLiteralChildren(1320 self,1321 outfile,1322 level,1323 name_,1324 ):1325 if self.name is not None:1326 showIndent(outfile, level)1327 outfile.write('name=%s,\n'1328 % quote_python(self.name).encode(ExternalEncoding))1329 showIndent(outfile, level)1330 outfile.write('note=[\n')1331 level += 11332 for note_ in self.note:1333 showIndent(outfile, level)1334 outfile.write('%s,\n'1335 % quote_python(note_).encode(ExternalEncoding))1336 level -= 11337 showIndent(outfile, level)1338 outfile.write('],\n')1339 def build(self, node):1340 self.buildAttributes(node, node.attrib, [])1341 for child in node:1342 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]1343 self.buildChildren(child, node, nodeName_)1344 def buildAttributes(1345 self,1346 node,1347 attrs,1348 already_processed,1349 ):1350 value = attrs.get('TYPE')1351 if value is not None and 'TYPE' not in already_processed:1352 already_processed.append('TYPE')1353 self.TYPE = value1354 value = attrs.get('OTHERTYPE')1355 if value is not None and 'OTHERTYPE' not in already_processed:1356 already_processed.append('OTHERTYPE')1357 self.OTHERTYPE = value1358 value = attrs.get('ROLE')1359 if value is not None and 'ROLE' not in already_processed:1360 already_processed.append('ROLE')1361 self.ROLE = value1362 value = attrs.get('ID')1363 if value is not None and 'ID' not in already_processed:1364 already_processed.append('ID')1365 self.ID = value1366 value = attrs.get('OTHERROLE')1367 if value is not None and 'OTHERROLE' not in already_processed:1368 already_processed.append('OTHERROLE')1369 self.OTHERROLE = value1370 def buildChildren(1371 self,1372 child_,1373 node,1374 nodeName_,1375 from_subclass=False,1376 ):1377 if nodeName_ == 'name':1378 name_ = child_.text1379 name_ = self.gds_validate_string(name_, node, 'name')1380 self.name = name_1381 elif nodeName_ == 'note':1382 note_ = child_.text1383 note_ = self.gds_validate_string(note_, node, 'note')1384 self.note.append(note_)1385# end class agent1386class altRecordID(GeneratedsSuper):1387 """The alternative record identifier element <altRecordID> allows one1388 to use alternative record identifier values for the digital1389 object represented by the METS document; the primary record1390 identifier is stored in the OBJID attribute in the root <mets>1391 element. ID (ID/O): This attribute uniquely identifies the1392 element within the METS document, and would allow the element to1393 be referenced unambiguously from another element or document via1394 an IDREF or an XPTR. For more information on using ID attributes1395 for internal and external linking see Chapter 4 of the METS1396 Primer. TYPE (string/O): A description of the identifier type1397 (e.g., OCLC record number, LCCN, etc.)."""1398 subclass = None1399 superclass = None1400 def __init__(1401 self,1402 TYPE=None,1403 ID=None,1404 valueOf_=None,1405 ):1406 self.TYPE = _cast(None, TYPE)1407 self.ID = _cast(None, ID)1408 self.valueOf_ = valueOf_1409 def factory(*args_, **kwargs_):1410 if altRecordID.subclass:1411 return altRecordID.subclass(*args_, **kwargs_)1412 else:1413 return altRecordID(*args_, **kwargs_)1414 factory = staticmethod(factory)1415 def get_TYPE(self):1416 return self.TYPE1417 def set_TYPE(self, TYPE):1418 self.TYPE = TYPE1419 def get_ID(self):1420 return self.ID1421 def set_ID(self, ID):1422 self.ID = ID1423 def get_valueOf_(self):1424 return self.valueOf_1425 def set_valueOf_(self, valueOf_):1426 self.valueOf_ = valueOf_1427 def export(1428 self,1429 outfile,1430 level,1431 namespace_='',1432 name_='altRecordID',1433 namespacedef_='',1434 ):1435 showIndent(outfile, level)1436 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_1437 and ' ' + namespacedef_ or ''))1438 self.exportAttributes(outfile, level, [], namespace_,1439 name_='altRecordID')1440 if self.hasContent_():1441 outfile.write('>')1442 outfile.write(self.valueOf_)1443 self.exportChildren(outfile, level + 1, namespace_, name_)1444 outfile.write('</%s%s>\n' % (namespace_, name_))1445 else:1446 outfile.write('/>\n')1447 def exportAttributes(1448 self,1449 outfile,1450 level,1451 already_processed,1452 namespace_='',1453 name_='altRecordID',1454 ):1455 if self.TYPE is not None and 'TYPE' not in already_processed:1456 already_processed.append('TYPE')1457 outfile.write(' TYPE=%s'1458 % (self.gds_format_string(quote_attrib(self.TYPE).encode(ExternalEncoding),1459 input_name='TYPE'), ))1460 if self.ID is not None and 'ID' not in already_processed:1461 already_processed.append('ID')1462 outfile.write(' ID=%s'1463 % (self.gds_format_string(quote_attrib(self.ID).encode(ExternalEncoding),1464 input_name='ID'), ))1465 def exportChildren(1466 self,1467 outfile,1468 level,1469 namespace_='',1470 name_='altRecordID',1471 ):1472 pass1473 def hasContent_(self):1474 if self.valueOf_:1475 return True1476 else:1477 return False1478 def exportLiteral(1479 self,1480 outfile,1481 level,1482 name_='altRecordID',1483 ):1484 level += 11485 self.exportLiteralAttributes(outfile, level, [], name_)1486 if self.hasContent_():1487 self.exportLiteralChildren(outfile, level, name_)1488 showIndent(outfile, level)1489 outfile.write('valueOf_ = """%s""",\n' % (self.valueOf_, ))1490 def exportLiteralAttributes(1491 self,1492 outfile,1493 level,1494 already_processed,1495 name_,1496 ):1497 if self.TYPE is not None and 'TYPE' not in already_processed:1498 already_processed.append('TYPE')1499 showIndent(outfile, level)1500 outfile.write('TYPE = "%s",\n' % (self.TYPE, ))1501 if self.ID is not None and 'ID' not in already_processed:1502 already_processed.append('ID')1503 showIndent(outfile, level)1504 outfile.write('ID = "%s",\n' % (self.ID, ))1505 def exportLiteralChildren(1506 self,1507 outfile,1508 level,1509 name_,1510 ):1511 pass1512 def build(self, node):1513 self.buildAttributes(node, node.attrib, [])1514 self.valueOf_ = get_all_text_(node)1515 for child in node:1516 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]1517 self.buildChildren(child, node, nodeName_)1518 def buildAttributes(1519 self,1520 node,1521 attrs,1522 already_processed,1523 ):1524 value = attrs.get('TYPE')1525 if value is not None and 'TYPE' not in already_processed:1526 already_processed.append('TYPE')1527 self.TYPE = value1528 value = attrs.get('ID')1529 if value is not None and 'ID' not in already_processed:1530 already_processed.append('ID')1531 self.ID = value1532 def buildChildren(1533 self,1534 child_,1535 node,1536 nodeName_,1537 from_subclass=False,1538 ):1539 pass1540# end class altRecordID1541class metsDocumentID(GeneratedsSuper):1542 """The metsDocument identifier element <metsDocumentID> allows a unique1543 identifier to be assigned to the METS document itself. This may1544 be different from the OBJID attribute value in the root <mets>1545 element, which uniquely identifies the entire digital object1546 represented by the METS document. ID (ID/O): This attribute1547 uniquely identifies the element within the METS document, and1548 would allow the element to be referenced unambiguously from1549 another element or document via an IDREF or an XPTR. For more1550 information on using ID attributes for internal and external1551 linking see Chapter 4 of the METS Primer. TYPE (string/O): A1552 description of the identifier type."""1553 subclass = None1554 superclass = None1555 def __init__(1556 self,1557 TYPE=None,1558 ID=None,1559 valueOf_=None,1560 ):1561 self.TYPE = _cast(None, TYPE)1562 self.ID = _cast(None, ID)1563 self.valueOf_ = valueOf_1564 def factory(*args_, **kwargs_):1565 if metsDocumentID.subclass:1566 return metsDocumentID.subclass(*args_, **kwargs_)1567 else:1568 return metsDocumentID(*args_, **kwargs_)1569 factory = staticmethod(factory)1570 def get_TYPE(self):1571 return self.TYPE1572 def set_TYPE(self, TYPE):1573 self.TYPE = TYPE1574 def get_ID(self):1575 return self.ID1576 def set_ID(self, ID):1577 self.ID = ID1578 def get_valueOf_(self):1579 return self.valueOf_1580 def set_valueOf_(self, valueOf_):1581 self.valueOf_ = valueOf_1582 def export(1583 self,1584 outfile,1585 level,1586 namespace_='',1587 name_='metsDocumentID',1588 namespacedef_='',1589 ):1590 showIndent(outfile, level)1591 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_1592 and ' ' + namespacedef_ or ''))1593 self.exportAttributes(outfile, level, [], namespace_,1594 name_='metsDocumentID')1595 if self.hasContent_():1596 outfile.write('>')1597 outfile.write(self.valueOf_)1598 self.exportChildren(outfile, level + 1, namespace_, name_)1599 outfile.write('</%s%s>\n' % (namespace_, name_))1600 else:1601 outfile.write('/>\n')1602 def exportAttributes(1603 self,1604 outfile,1605 level,1606 already_processed,1607 namespace_='',1608 name_='metsDocumentID',1609 ):1610 if self.TYPE is not None and 'TYPE' not in already_processed:1611 already_processed.append('TYPE')1612 outfile.write(' TYPE=%s'1613 % (self.gds_format_string(quote_attrib(self.TYPE).encode(ExternalEncoding),1614 input_name='TYPE'), ))1615 if self.ID is not None and 'ID' not in already_processed:1616 already_processed.append('ID')1617 outfile.write(' ID=%s'1618 % (self.gds_format_string(quote_attrib(self.ID).encode(ExternalEncoding),1619 input_name='ID'), ))1620 def exportChildren(1621 self,1622 outfile,1623 level,1624 namespace_='',1625 name_='metsDocumentID',1626 ):1627 pass1628 def hasContent_(self):1629 if self.valueOf_:1630 return True1631 else:1632 return False1633 def exportLiteral(1634 self,1635 outfile,1636 level,1637 name_='metsDocumentID',1638 ):1639 level += 11640 self.exportLiteralAttributes(outfile, level, [], name_)1641 if self.hasContent_():1642 self.exportLiteralChildren(outfile, level, name_)1643 showIndent(outfile, level)1644 outfile.write('valueOf_ = """%s""",\n' % (self.valueOf_, ))1645 def exportLiteralAttributes(1646 self,1647 outfile,1648 level,1649 already_processed,1650 name_,1651 ):1652 if self.TYPE is not None and 'TYPE' not in already_processed:1653 already_processed.append('TYPE')1654 showIndent(outfile, level)1655 outfile.write('TYPE = "%s",\n' % (self.TYPE, ))1656 if self.ID is not None and 'ID' not in already_processed:1657 already_processed.append('ID')1658 showIndent(outfile, level)1659 outfile.write('ID = "%s",\n' % (self.ID, ))1660 def exportLiteralChildren(1661 self,1662 outfile,1663 level,1664 name_,1665 ):1666 pass1667 def build(self, node):1668 self.buildAttributes(node, node.attrib, [])1669 self.valueOf_ = get_all_text_(node)1670 for child in node:1671 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]1672 self.buildChildren(child, node, nodeName_)1673 def buildAttributes(1674 self,1675 node,1676 attrs,1677 already_processed,1678 ):1679 value = attrs.get('TYPE')1680 if value is not None and 'TYPE' not in already_processed:1681 already_processed.append('TYPE')1682 self.TYPE = value1683 value = attrs.get('ID')1684 if value is not None and 'ID' not in already_processed:1685 already_processed.append('ID')1686 self.ID = value1687 def buildChildren(1688 self,1689 child_,1690 node,1691 nodeName_,1692 from_subclass=False,1693 ):1694 pass1695# end class metsDocumentID1696class fileSec(GeneratedsSuper):1697 """The overall purpose of the content file section element <fileSec> is1698 to provide an inventory of and the location for the content1699 files that comprise the digital object being described in the1700 METS document. ID (ID/O): This attribute uniquely identifies the1701 element within the METS document, and would allow the element to1702 be referenced unambiguously from another element or document via1703 an IDREF or an XPTR. For more information on using ID attributes1704 for internal and external linking see Chapter 4 of the METS1705 Primer."""1706 subclass = None1707 superclass = None1708 def __init__(self, ID=None, fileGrp=None):1709 self.ID = _cast(None, ID)1710 if fileGrp is None:1711 self.fileGrp = []1712 else:1713 self.fileGrp = fileGrp1714 def factory(*args_, **kwargs_):1715 if fileSec.subclass:1716 return fileSec.subclass(*args_, **kwargs_)1717 else:1718 return fileSec(*args_, **kwargs_)1719 factory = staticmethod(factory)1720 def get_fileGrp(self):1721 return self.fileGrp1722 def set_fileGrp(self, fileGrp):1723 self.fileGrp = fileGrp1724 def add_fileGrp(self, value):1725 self.fileGrp.append(value)1726 def insert_fileGrp(self, index, value):1727 self.fileGrp[index] = value1728 def get_ID(self):1729 return self.ID1730 def set_ID(self, ID):1731 self.ID = ID1732 def export(1733 self,1734 outfile,1735 level,1736 namespace_='',1737 name_='fileSec',1738 namespacedef_='',1739 ):1740 showIndent(outfile, level)1741 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_1742 and ' ' + namespacedef_ or ''))1743 self.exportAttributes(outfile, level, [], namespace_,1744 name_='fileSec')1745 if self.hasContent_():1746 outfile.write('>\n')1747 self.exportChildren(outfile, level + 1, namespace_, name_)1748 showIndent(outfile, level)1749 outfile.write('</%s%s>\n' % (namespace_, name_))1750 else:1751 outfile.write('/>\n')1752 def exportAttributes(1753 self,1754 outfile,1755 level,1756 already_processed,1757 namespace_='',1758 name_='fileSec',1759 ):1760 if self.ID is not None and 'ID' not in already_processed:1761 already_processed.append('ID')1762 outfile.write(' ID=%s'1763 % (self.gds_format_string(quote_attrib(self.ID).encode(ExternalEncoding),1764 input_name='ID'), ))1765 def exportChildren(1766 self,1767 outfile,1768 level,1769 namespace_='',1770 name_='fileSec',1771 ):1772 for fileGrp_ in self.fileGrp:1773 fileGrp_.export(outfile, level, namespace_, name_='fileGrp')1774 def hasContent_(self):1775 if self.fileGrp:1776 return True1777 else:1778 return False1779 def exportLiteral(1780 self,1781 outfile,1782 level,1783 name_='fileSec',1784 ):1785 level += 11786 self.exportLiteralAttributes(outfile, level, [], name_)1787 if self.hasContent_():1788 self.exportLiteralChildren(outfile, level, name_)1789 def exportLiteralAttributes(1790 self,1791 outfile,1792 level,1793 already_processed,1794 name_,1795 ):1796 if self.ID is not None and 'ID' not in already_processed:1797 already_processed.append('ID')1798 showIndent(outfile, level)1799 outfile.write('ID = "%s",\n' % (self.ID, ))1800 def exportLiteralChildren(1801 self,1802 outfile,1803 level,1804 name_,1805 ):1806 showIndent(outfile, level)1807 outfile.write('fileGrp=[\n')1808 level += 11809 for fileGrp_ in self.fileGrp:1810 showIndent(outfile, level)1811 outfile.write('model_.fileGrp(\n')1812 fileGrp_.exportLiteral(outfile, level)1813 showIndent(outfile, level)1814 outfile.write('),\n')1815 level -= 11816 showIndent(outfile, level)1817 outfile.write('],\n')1818 def build(self, node):1819 self.buildAttributes(node, node.attrib, [])1820 for child in node:1821 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]1822 self.buildChildren(child, node, nodeName_)1823 def buildAttributes(1824 self,1825 node,1826 attrs,1827 already_processed,1828 ):1829 value = attrs.get('ID')1830 if value is not None and 'ID' not in already_processed:1831 already_processed.append('ID')1832 self.ID = value1833 def buildChildren(1834 self,1835 child_,1836 node,1837 nodeName_,1838 from_subclass=False,1839 ):1840 if nodeName_ == 'fileGrp':1841 obj_ = fileGrp.factory()1842 obj_.build(child_)1843 self.fileGrp.append(obj_)1844# end class fileSec1845class amdSecType(GeneratedsSuper):1846 """amdSecType: Complex Type for Administrative Metadata Sections The1847 administrative metadata section consists of four possible1848 subsidiary sections: techMD (technical metadata for1849 text/image/audio/video files), rightsMD (intellectual property1850 rights metadata), sourceMD (analog/digital source metadata), and1851 digiprovMD (digital provenance metadata, that is, the history of1852 migrations/translations performed on a digital library object1853 from it's original digital capture/encoding). ID (ID/O): This1854 attribute uniquely identifies the element within the METS1855 document, and would allow the element to be referenced1856 unambiguously from another element or document via an IDREF or1857 an XPTR. For more information on using ID attributes for1858 internal and external linking see Chapter 4 of the METS Primer."""1859 subclass = None1860 superclass = None1861 def __init__(1862 self,1863 ID=None,1864 techMD=None,1865 rightsMD=None,1866 sourceMD=None,1867 digiprovMD=None,1868 ):1869 self.ID = _cast(None, ID)1870 if techMD is None:1871 self.techMD = []1872 else:1873 self.techMD = techMD1874 if rightsMD is None:1875 self.rightsMD = []1876 else:1877 self.rightsMD = rightsMD1878 if sourceMD is None:1879 self.sourceMD = []1880 else:1881 self.sourceMD = sourceMD1882 if digiprovMD is None:1883 self.digiprovMD = []1884 else:1885 self.digiprovMD = digiprovMD1886 def factory(*args_, **kwargs_):1887 if amdSecType.subclass:1888 return amdSecType.subclass(*args_, **kwargs_)1889 else:1890 return amdSecType(*args_, **kwargs_)1891 factory = staticmethod(factory)1892 def get_techMD(self):1893 return self.techMD1894 def set_techMD(self, techMD):1895 self.techMD = techMD1896 def add_techMD(self, value):1897 self.techMD.append(value)1898 def insert_techMD(self, index, value):1899 self.techMD[index] = value1900 def get_rightsMD(self):1901 return self.rightsMD1902 def set_rightsMD(self, rightsMD):1903 self.rightsMD = rightsMD1904 def add_rightsMD(self, value):1905 self.rightsMD.append(value)1906 def insert_rightsMD(self, index, value):1907 self.rightsMD[index] = value1908 def get_sourceMD(self):1909 return self.sourceMD1910 def set_sourceMD(self, sourceMD):1911 self.sourceMD = sourceMD1912 def add_sourceMD(self, value):1913 self.sourceMD.append(value)1914 def insert_sourceMD(self, index, value):1915 self.sourceMD[index] = value1916 def get_digiprovMD(self):1917 return self.digiprovMD1918 def set_digiprovMD(self, digiprovMD):1919 self.digiprovMD = digiprovMD1920 def add_digiprovMD(self, value):1921 self.digiprovMD.append(value)1922 def insert_digiprovMD(self, index, value):1923 self.digiprovMD[index] = value1924 def get_ID(self):1925 return self.ID1926 def set_ID(self, ID):1927 self.ID = ID1928 def export(1929 self,1930 outfile,1931 level,1932 namespace_='',1933 name_='amdSecType',1934 namespacedef_='',1935 ):1936 showIndent(outfile, level)1937 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_1938 and ' ' + namespacedef_ or ''))1939 self.exportAttributes(outfile, level, [], namespace_,1940 name_='amdSecType')1941 if self.hasContent_():1942 outfile.write('>\n')1943 self.exportChildren(outfile, level + 1, namespace_, name_)1944 showIndent(outfile, level)1945 outfile.write('</%s%s>\n' % (namespace_, name_))1946 else:1947 outfile.write('/>\n')1948 def exportAttributes(1949 self,1950 outfile,1951 level,1952 already_processed,1953 namespace_='',1954 name_='amdSecType',1955 ):1956 if self.ID is not None and 'ID' not in already_processed:1957 already_processed.append('ID')1958 outfile.write(' ID=%s'1959 % (self.gds_format_string(quote_attrib(self.ID).encode(ExternalEncoding),1960 input_name='ID'), ))1961 def exportChildren(1962 self,1963 outfile,1964 level,1965 namespace_='',1966 name_='amdSecType',1967 ):1968 for techMD_ in self.techMD:1969 techMD_.export(outfile, level, namespace_, name_='techMD')1970 for rightsMD_ in self.rightsMD:1971 rightsMD_.export(outfile, level, namespace_,1972 name_='rightsMD')1973 for sourceMD_ in self.sourceMD:1974 sourceMD_.export(outfile, level, namespace_,1975 name_='sourceMD')1976 for digiprovMD_ in self.digiprovMD:1977 digiprovMD_.export(outfile, level, namespace_,1978 name_='digiprovMD')1979 def hasContent_(self):1980 if self.techMD or self.rightsMD or self.sourceMD \1981 or self.digiprovMD:1982 return True1983 else:1984 return False1985 def exportLiteral(1986 self,1987 outfile,1988 level,1989 name_='amdSecType',1990 ):1991 level += 11992 self.exportLiteralAttributes(outfile, level, [], name_)1993 if self.hasContent_():1994 self.exportLiteralChildren(outfile, level, name_)1995 def exportLiteralAttributes(1996 self,1997 outfile,1998 level,1999 already_processed,2000 name_,2001 ):2002 if self.ID is not None and 'ID' not in already_processed:2003 already_processed.append('ID')2004 showIndent(outfile, level)2005 outfile.write('ID = "%s",\n' % (self.ID, ))2006 def exportLiteralChildren(2007 self,2008 outfile,2009 level,2010 name_,2011 ):2012 showIndent(outfile, level)2013 outfile.write('techMD=[\n')2014 level += 12015 for techMD_ in self.techMD:2016 showIndent(outfile, level)2017 outfile.write('model_.mdSecType(\n')2018 techMD_.exportLiteral(outfile, level, name_='mdSecType')2019 showIndent(outfile, level)2020 outfile.write('),\n')2021 level -= 12022 showIndent(outfile, level)2023 outfile.write('],\n')2024 showIndent(outfile, level)2025 outfile.write('rightsMD=[\n')2026 level += 12027 for rightsMD_ in self.rightsMD:2028 showIndent(outfile, level)2029 outfile.write('model_.mdSecType(\n')2030 rightsMD_.exportLiteral(outfile, level, name_='mdSecType')2031 showIndent(outfile, level)2032 outfile.write('),\n')2033 level -= 12034 showIndent(outfile, level)2035 outfile.write('],\n')2036 showIndent(outfile, level)2037 outfile.write('sourceMD=[\n')2038 level += 12039 for sourceMD_ in self.sourceMD:2040 showIndent(outfile, level)2041 outfile.write('model_.mdSecType(\n')2042 sourceMD_.exportLiteral(outfile, level, name_='mdSecType')2043 showIndent(outfile, level)2044 outfile.write('),\n')2045 level -= 12046 showIndent(outfile, level)2047 outfile.write('],\n')2048 showIndent(outfile, level)2049 outfile.write('digiprovMD=[\n')2050 level += 12051 for digiprovMD_ in self.digiprovMD:2052 showIndent(outfile, level)2053 outfile.write('model_.mdSecType(\n')2054 digiprovMD_.exportLiteral(outfile, level, name_='mdSecType')2055 showIndent(outfile, level)2056 outfile.write('),\n')2057 level -= 12058 showIndent(outfile, level)2059 outfile.write('],\n')2060 def build(self, node):2061 self.buildAttributes(node, node.attrib, [])2062 for child in node:2063 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]2064 self.buildChildren(child, node, nodeName_)2065 def buildAttributes(2066 self,2067 node,2068 attrs,2069 already_processed,2070 ):2071 value = attrs.get('ID')2072 if value is not None and 'ID' not in already_processed:2073 already_processed.append('ID')2074 self.ID = value2075 def buildChildren(2076 self,2077 child_,2078 node,2079 nodeName_,2080 from_subclass=False,2081 ):2082 if nodeName_ == 'techMD':2083 obj_ = mdSecType.factory()2084 obj_.build(child_)2085 self.techMD.append(obj_)2086 elif nodeName_ == 'rightsMD':2087 obj_ = mdSecType.factory()2088 obj_.build(child_)2089 self.rightsMD.append(obj_)2090 elif nodeName_ == 'sourceMD':2091 obj_ = mdSecType.factory()2092 obj_.build(child_)2093 self.sourceMD.append(obj_)2094 elif nodeName_ == 'digiprovMD':2095 obj_ = mdSecType.factory()2096 obj_.build(child_)2097 self.digiprovMD.append(obj_)2098# end class amdSecType2099class fileGrpType(GeneratedsSuper):2100 """fileGrpType: Complex Type for File Groups The file group is used to2101 cluster all of the digital files composing a digital library2102 object in a hierarchical arrangement (fileGrp is recursively2103 defined to enable the creation of the hierarchy). Any file group2104 may contain zero or more file elements. File elements in turn2105 can contain one or more FLocat elements (a pointer to a file2106 containing content for this object) and/or a FContent element2107 (the contents of the file, in either XML or Base64 encoding). ID2108 (ID/O): This attribute uniquely identifies the element within2109 the METS document, and would allow the element to be referenced2110 unambiguously from another element or document via an IDREF or2111 an XPTR. For more information on using ID attributes for2112 internal and external linking see Chapter 4 of the METS Primer.2113 VERSDATE (dateTime/O): An optional dateTime attribute specifying2114 the date this version/fileGrp of the digital object was created.2115 ADMID (IDREF/O): Contains the ID attribute values of the2116 <techMD>, <sourceMD>, <rightsMD> and/or <digiprovMD> elements2117 within the <amdSec> of the METS document applicable to all of2118 the files in a particular file group. For more information on2119 using METS IDREFS and IDREF type attributes for internal2120 linking, see Chapter 4 of the METS Primer. USE (string/O): A2121 tagging attribute to indicate the intended use of files within2122 this file group (e.g., master, reference, thumbnails for image2123 files). A USE attribute can be expressed at the<fileGrp> level,2124 the <file> level, the <FLocat> level and/or the <FContent>2125 level. A USE attribute value at the <fileGrp> level should2126 pertain to all of the files in the <fileGrp>. A USE attribute at2127 the <file> level should pertain to all copies of the file as2128 represented by subsidiary <FLocat> and/or <FContent> elements. A2129 USE attribute at the <FLocat> or <FContent> level pertains to2130 the particular copy of the file that is either referenced2131 (<FLocat>) or wrapped (<FContent>)."""2132 subclass = None2133 superclass = None2134 def __init__(2135 self,2136 VERSDATE=None,2137 ADMID=None,2138 ID=None,2139 USE=None,2140 fileGrp=None,2141 file=None,2142 ):2143 self.VERSDATE = _cast(None, VERSDATE)2144 self.ADMID = _cast(None, ADMID)2145 self.ID = _cast(None, ID)2146 self.USE = _cast(None, USE)2147 if fileGrp is None:2148 self.fileGrp = []2149 else:2150 self.fileGrp = fileGrp2151 if file is None:2152 self.file = []2153 else:2154 self.file = file2155 def factory(*args_, **kwargs_):2156 if fileGrpType.subclass:2157 return fileGrpType.subclass(*args_, **kwargs_)2158 else:2159 return fileGrpType(*args_, **kwargs_)2160 factory = staticmethod(factory)2161 def get_fileGrp(self):2162 return self.fileGrp2163 def set_fileGrp(self, fileGrp):2164 self.fileGrp = fileGrp2165 def add_fileGrp(self, value):2166 self.fileGrp.append(value)2167 def insert_fileGrp(self, index, value):2168 self.fileGrp[index] = value2169 def get_file(self):2170 return self.file2171 def set_file(self, file):2172 self.file = file2173 def add_file(self, value):2174 self.file.append(value)2175 def insert_file(self, index, value):2176 self.file[index] = value2177 def get_VERSDATE(self):2178 return self.VERSDATE2179 def set_VERSDATE(self, VERSDATE):2180 self.VERSDATE = VERSDATE2181 def get_ADMID(self):2182 return self.ADMID2183 def set_ADMID(self, ADMID):2184 self.ADMID = ADMID2185 def get_ID(self):2186 return self.ID2187 def set_ID(self, ID):2188 self.ID = ID2189 def get_USE(self):2190 return self.USE2191 def set_USE(self, USE):2192 self.USE = USE2193 def export(2194 self,2195 outfile,2196 level,2197 namespace_='',2198 name_='fileGrpType',2199 namespacedef_='',2200 ):2201 showIndent(outfile, level)2202 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_2203 and ' ' + namespacedef_ or ''))2204 self.exportAttributes(outfile, level, [], namespace_,2205 name_='fileGrpType')2206 if self.hasContent_():2207 outfile.write('>\n')2208 self.exportChildren(outfile, level + 1, namespace_, name_)2209 showIndent(outfile, level)2210 outfile.write('</%s%s>\n' % (namespace_, name_))2211 else:2212 outfile.write('/>\n')2213 def exportAttributes(2214 self,2215 outfile,2216 level,2217 already_processed,2218 namespace_='',2219 name_='fileGrpType',2220 ):2221 if self.VERSDATE is not None and 'VERSDATE' \2222 not in already_processed:2223 already_processed.append('VERSDATE')2224 outfile.write(' VERSDATE=%s'2225 % (self.gds_format_string(quote_attrib(self.VERSDATE).encode(ExternalEncoding),2226 input_name='VERSDATE'), ))2227 if self.ADMID is not None and 'ADMID' not in already_processed:2228 already_processed.append('ADMID')2229 outfile.write(' ADMID=%s'2230 % (self.gds_format_string(quote_attrib(self.ADMID).encode(ExternalEncoding),2231 input_name='ADMID'), ))2232 if self.ID is not None and 'ID' not in already_processed:2233 already_processed.append('ID')2234 outfile.write(' ID=%s'2235 % (self.gds_format_string(quote_attrib(self.ID).encode(ExternalEncoding),2236 input_name='ID'), ))2237 if self.USE is not None and 'USE' not in already_processed:2238 already_processed.append('USE')2239 outfile.write(' USE=%s'2240 % (self.gds_format_string(quote_attrib(self.USE).encode(ExternalEncoding),2241 input_name='USE'), ))2242 def exportChildren(2243 self,2244 outfile,2245 level,2246 namespace_='',2247 name_='fileGrpType',2248 ):2249 for fileGrp_ in self.fileGrp:2250 fileGrp_.export(outfile, level, namespace_, name_='fileGrp')2251 for file_ in self.file:2252 file_.export(outfile, level, namespace_, name_='file')2253 def hasContent_(self):2254 if self.fileGrp or self.file:2255 return True2256 else:2257 return False2258 def exportLiteral(2259 self,2260 outfile,2261 level,2262 name_='fileGrpType',2263 ):2264 level += 12265 self.exportLiteralAttributes(outfile, level, [], name_)2266 if self.hasContent_():2267 self.exportLiteralChildren(outfile, level, name_)2268 def exportLiteralAttributes(2269 self,2270 outfile,2271 level,2272 already_processed,2273 name_,2274 ):2275 if self.VERSDATE is not None and 'VERSDATE' \2276 not in already_processed:2277 already_processed.append('VERSDATE')2278 showIndent(outfile, level)2279 outfile.write('VERSDATE = "%s",\n' % (self.VERSDATE, ))2280 if self.ADMID is not None and 'ADMID' not in already_processed:2281 already_processed.append('ADMID')2282 showIndent(outfile, level)2283 outfile.write('ADMID = "%s",\n' % (self.ADMID, ))2284 if self.ID is not None and 'ID' not in already_processed:2285 already_processed.append('ID')2286 showIndent(outfile, level)2287 outfile.write('ID = "%s",\n' % (self.ID, ))2288 if self.USE is not None and 'USE' not in already_processed:2289 already_processed.append('USE')2290 showIndent(outfile, level)2291 outfile.write('USE = "%s",\n' % (self.USE, ))2292 def exportLiteralChildren(2293 self,2294 outfile,2295 level,2296 name_,2297 ):2298 showIndent(outfile, level)2299 outfile.write('fileGrp=[\n')2300 level += 12301 for fileGrp_ in self.fileGrp:2302 showIndent(outfile, level)2303 outfile.write('model_.fileGrpType(\n')2304 fileGrp_.exportLiteral(outfile, level, name_='fileGrpType')2305 showIndent(outfile, level)2306 outfile.write('),\n')2307 level -= 12308 showIndent(outfile, level)2309 outfile.write('],\n')2310 showIndent(outfile, level)2311 outfile.write('file=[\n')2312 level += 12313 for file_ in self.file:2314 showIndent(outfile, level)2315 outfile.write('model_.fileType(\n')2316 file_.exportLiteral(outfile, level, name_='fileType')2317 showIndent(outfile, level)2318 outfile.write('),\n')2319 level -= 12320 showIndent(outfile, level)2321 outfile.write('],\n')2322 def build(self, node):2323 self.buildAttributes(node, node.attrib, [])2324 for child in node:2325 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]2326 self.buildChildren(child, node, nodeName_)2327 def buildAttributes(2328 self,2329 node,2330 attrs,2331 already_processed,2332 ):2333 value = attrs.get('VERSDATE')2334 if value is not None and 'VERSDATE' not in already_processed:2335 already_processed.append('VERSDATE')2336 self.VERSDATE = value2337 value = attrs.get('ADMID')2338 if value is not None and 'ADMID' not in already_processed:2339 already_processed.append('ADMID')2340 self.ADMID = value2341 value = attrs.get('ID')2342 if value is not None and 'ID' not in already_processed:2343 already_processed.append('ID')2344 self.ID = value2345 value = attrs.get('USE')2346 if value is not None and 'USE' not in already_processed:2347 already_processed.append('USE')2348 self.USE = value2349 def buildChildren(2350 self,2351 child_,2352 node,2353 nodeName_,2354 from_subclass=False,2355 ):2356 if nodeName_ == 'fileGrp':2357 obj_ = fileGrpType.factory()2358 obj_.build(child_)2359 self.fileGrp.append(obj_)2360 elif nodeName_ == 'file':2361 obj_ = fileType.factory()2362 obj_.build(child_)2363 self.file.append(obj_)2364# end class fileGrpType2365class structMapType(GeneratedsSuper):2366 """structMapType: Complex Type for Structural Maps The structural map2367 (structMap) outlines a hierarchical structure for the original2368 object being encoded, using a series of nested div elements. ID2369 (ID/O): This attribute uniquely identifies the element within2370 the METS document, and would allow the element to be referenced2371 unambiguously from another element or document via an IDREF or2372 an XPTR. For more information on using ID attributes for2373 internal and external linking see Chapter 4 of the METS Primer.2374 TYPE (string/O): Identifies the type of structure represented by2375 the <structMap>. For example, a <structMap> that represented a2376 purely logical or intellectual structure could be assigned a2377 TYPE value of "logical" whereas a <structMap> that2378 represented a purely physical structure could be assigned a TYPE2379 value of "physical". However, the METS schema neither2380 defines nor requires a common vocabulary for this attribute. A2381 METS profile, however, may well constrain the values for the2382 <structMap> TYPE. LABEL (string/O): Describes the <structMap> to2383 viewers of the METS document. This would be useful primarily2384 where more than one <structMap> is provided for a single object.2385 A descriptive LABEL value, in that case, could clarify to users2386 the purpose of each of the available structMaps."""2387 subclass = None2388 superclass = None2389 def __init__(2390 self,2391 TYPE=None,2392 ID=None,2393 LABEL=None,2394 div=None,2395 ):2396 self.TYPE = _cast(None, TYPE)2397 self.ID = _cast(None, ID)2398 self.LABEL = _cast(None, LABEL)2399 self.div = div2400 def factory(*args_, **kwargs_):2401 if structMapType.subclass:2402 return structMapType.subclass(*args_, **kwargs_)2403 else:2404 return structMapType(*args_, **kwargs_)2405 factory = staticmethod(factory)2406 def get_div(self):2407 return self.div2408 def set_div(self, div):2409 self.div = div2410 def get_TYPE(self):2411 return self.TYPE2412 def set_TYPE(self, TYPE):2413 self.TYPE = TYPE2414 def get_ID(self):2415 return self.ID2416 def set_ID(self, ID):2417 self.ID = ID2418 def get_LABEL(self):2419 return self.LABEL2420 def set_LABEL(self, LABEL):2421 self.LABEL = LABEL2422 def export(2423 self,2424 outfile,2425 level,2426 namespace_='',2427 name_='structMapType',2428 namespacedef_='',2429 ):2430 showIndent(outfile, level)2431 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_2432 and ' ' + namespacedef_ or ''))2433 self.exportAttributes(outfile, level, [], namespace_,2434 name_='structMapType')2435 if self.hasContent_():2436 outfile.write('>\n')2437 self.exportChildren(outfile, level + 1, namespace_, name_)2438 showIndent(outfile, level)2439 outfile.write('</%s%s>\n' % (namespace_, name_))2440 else:2441 outfile.write('/>\n')2442 def exportAttributes(2443 self,2444 outfile,2445 level,2446 already_processed,2447 namespace_='',2448 name_='structMapType',2449 ):2450 if self.TYPE is not None and 'TYPE' not in already_processed:2451 already_processed.append('TYPE')2452 outfile.write(' TYPE=%s'2453 % (self.gds_format_string(quote_attrib(self.TYPE).encode(ExternalEncoding),2454 input_name='TYPE'), ))2455 if self.ID is not None and 'ID' not in already_processed:2456 already_processed.append('ID')2457 outfile.write(' ID=%s'2458 % (self.gds_format_string(quote_attrib(self.ID).encode(ExternalEncoding),2459 input_name='ID'), ))2460 if self.LABEL is not None and 'LABEL' not in already_processed:2461 already_processed.append('LABEL')2462 outfile.write(' LABEL=%s'2463 % (self.gds_format_string(quote_attrib(self.LABEL).encode(ExternalEncoding),2464 input_name='LABEL'), ))2465 def exportChildren(2466 self,2467 outfile,2468 level,2469 namespace_='',2470 name_='structMapType',2471 ):2472 if self.div:2473 self.div.export(outfile, level, namespace_, name_='div')2474 def hasContent_(self):2475 if self.div is not None:2476 return True2477 else:2478 return False2479 def exportLiteral(2480 self,2481 outfile,2482 level,2483 name_='structMapType',2484 ):2485 level += 12486 self.exportLiteralAttributes(outfile, level, [], name_)2487 if self.hasContent_():2488 self.exportLiteralChildren(outfile, level, name_)2489 def exportLiteralAttributes(2490 self,2491 outfile,2492 level,2493 already_processed,2494 name_,2495 ):2496 if self.TYPE is not None and 'TYPE' not in already_processed:2497 already_processed.append('TYPE')2498 showIndent(outfile, level)2499 outfile.write('TYPE = "%s",\n' % (self.TYPE, ))2500 if self.ID is not None and 'ID' not in already_processed:2501 already_processed.append('ID')2502 showIndent(outfile, level)2503 outfile.write('ID = "%s",\n' % (self.ID, ))2504 if self.LABEL is not None and 'LABEL' not in already_processed:2505 already_processed.append('LABEL')2506 showIndent(outfile, level)2507 outfile.write('LABEL = "%s",\n' % (self.LABEL, ))2508 def exportLiteralChildren(2509 self,2510 outfile,2511 level,2512 name_,2513 ):2514 if self.div is not None:2515 showIndent(outfile, level)2516 outfile.write('div=model_.divType(\n')2517 self.div.exportLiteral(outfile, level, name_='div')2518 showIndent(outfile, level)2519 outfile.write('),\n')2520 def build(self, node):2521 self.buildAttributes(node, node.attrib, [])2522 for child in node:2523 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]2524 self.buildChildren(child, node, nodeName_)2525 def buildAttributes(2526 self,2527 node,2528 attrs,2529 already_processed,2530 ):2531 value = attrs.get('TYPE')2532 if value is not None and 'TYPE' not in already_processed:2533 already_processed.append('TYPE')2534 self.TYPE = value2535 value = attrs.get('ID')2536 if value is not None and 'ID' not in already_processed:2537 already_processed.append('ID')2538 self.ID = value2539 value = attrs.get('LABEL')2540 if value is not None and 'LABEL' not in already_processed:2541 already_processed.append('LABEL')2542 self.LABEL = value2543 def buildChildren(2544 self,2545 child_,2546 node,2547 nodeName_,2548 from_subclass=False,2549 ):2550 if nodeName_ == 'div':2551 obj_ = divType.factory()2552 obj_.build(child_)2553 self.set_div(obj_)2554# end class structMapType2555class divType(GeneratedsSuper):2556 """divType: Complex Type for Divisions The METS standard represents a2557 document structurally as a series of nested div elements, that2558 is, as a hierarchy (e.g., a book, which is composed of chapters,2559 which are composed of subchapters, which are composed of text).2560 Every div node in the structural map hierarchy may be connected2561 (via subsidiary mptr or fptr elements) to content files which2562 represent that div's portion of the whole document. SPECIAL NOTE2563 REGARDING DIV ATTRIBUTE VALUES: to clarify the differences2564 between the ORDER, ORDERLABEL, and LABEL attributes for the2565 <div> element, imagine a text with 10 roman numbered pages2566 followed by 10 arabic numbered pages. Page iii would have an2567 ORDER of "3", an ORDERLABEL of "iii" and a LABEL of "Page iii",2568 while page 3 would have an ORDER of "13", an ORDERLABEL of "3"2569 and a LABEL of "Page 3". ID (ID/O): This attribute uniquely2570 identifies the element within the METS document, and would allow2571 the element to be referenced unambiguously from another element2572 or document via an IDREF or an XPTR. For more information on2573 using ID attributes for internal and external linking see2574 Chapter 4 of the METS Primer. ORDER (integer/O): A2575 representation of the div's order among its siblings (e.g., its2576 absolute, numeric sequence). For an example, and clarification2577 of the distinction between ORDER and ORDERLABEL, see the2578 description of the ORDERLABEL attribute. ORDERLABEL (string/O):2579 A representation of the div's order among its siblings (e.g.,2580 "xii"), or of any non-integer native numbering system. It is2581 presumed that this value will still be machine actionable (e.g.,2582 it would support 'go to page ___' function), and it should2583 not be used as a replacement/substitute for the LABEL attribute.2584 To understand the differences between ORDER, ORDERLABEL and2585 LABEL, imagine a text with 10 roman numbered pages followed by2586 10 arabic numbered pages. Page iii would have an ORDER of2587 "3", an ORDERLABEL of "iii" and a LABEL of "Page2588 iii", while page 3 would have an ORDER of "13", an2589 ORDERLABEL of "3" and a LABEL of "Page 3". LABEL2590 (string/O): An attribute used, for example, to identify a <div>2591 to an end user viewing the document. Thus a hierarchical2592 arrangement of the <div> LABEL values could provide a table of2593 contents to the digital content represented by a METS document2594 and facilitate the users' navigation of the digital object.2595 Note that a <div> LABEL should be specific to its level in the2596 structural map. In the case of a book with chapters, the book2597 <div> LABEL should have the book title and the chapter <div>;2598 LABELs should have the individual chapter titles, rather than2599 having the chapter <div> LABELs combine both book title and2600 chapter title . For further of the distinction between LABEL and2601 ORDERLABEL see the description of the ORDERLABEL attribute.2602 DMDID (IDREFS/O): Contains the ID attribute values identifying2603 the <dmdSec>, elements in the METS document that contain or link2604 to descriptive metadata pertaining to the structural division2605 represented by the current <div> element. For more information2606 on using METS IDREFS and IDREF type attributes for internal2607 linking, see Chapter 4 of the METS Primer. ADMID (IDREFS/O):2608 Contains the ID attribute values identifying the <rightsMD>,2609 <sourceMD>, <techMD> and/or <digiprovMD> elements within the2610 <amdSec> of the METS document that contain or link to2611 administrative metadata pertaining to the structural division2612 represented by the <div> element. Typically the <div> ADMID2613 attribute would be used to identify the <rightsMD> element or2614 elements that pertain to the <div>, but it could be used anytime2615 there was a need to link a <div> with pertinent administrative2616 metadata. For more information on using METS IDREFS and IDREF2617 type attributes for internal linking, see Chapter 4 of the METS2618 Primer. TYPE (string/O): An attribute that specifies the type of2619 structural division that the <div> element represents. Possible2620 <div> TYPE attribute values include: chapter, article, page,2621 track, segment, section etc. METS places no constraints on the2622 possible TYPE values. Suggestions for controlled vocabularies2623 for TYPE may be found on the METS website. CONTENTIDS (URI/O):2624 Content IDs for the content represented by the <div> (equivalent2625 to DIDL DII or Digital Item Identifier, a unique external ID).2626 xlink:label - an xlink label to be referred to by an smLink2627 element"""2628 subclass = None2629 superclass = None2630 def __init__(2631 self,2632 ADMID=None,2633 TYPE=None,2634 LABEL=None,2635 DMDID=None,2636 ORDERLABEL=None,2637 CONTENTIDS=None,2638 label=None,2639 ORDER=None,2640 ID=None,2641 mptr=None,2642 fptr=None,2643 div=None,2644 ):2645 self.ADMID = _cast(None, ADMID)2646 self.TYPE = _cast(None, TYPE)2647 self.LABEL = _cast(None, LABEL)2648 self.DMDID = _cast(None, DMDID)2649 self.ORDERLABEL = _cast(None, ORDERLABEL)2650 self.CONTENTIDS = _cast(None, CONTENTIDS)2651 self.label = _cast(None, label)2652 self.ORDER = _cast(int, ORDER)2653 self.ID = _cast(None, ID)2654 if mptr is None:2655 self.mptr = []2656 else:2657 self.mptr = mptr2658 if fptr is None:2659 self.fptr = []2660 else:2661 self.fptr = fptr2662 if div is None:2663 self.div = []2664 else:2665 self.div = div2666 def factory(*args_, **kwargs_):2667 if divType.subclass:2668 return divType.subclass(*args_, **kwargs_)2669 else:2670 return divType(*args_, **kwargs_)2671 factory = staticmethod(factory)2672 def get_mptr(self):2673 return self.mptr2674 def set_mptr(self, mptr):2675 self.mptr = mptr2676 def add_mptr(self, value):2677 self.mptr.append(value)2678 def insert_mptr(self, index, value):2679 self.mptr[index] = value2680 def get_fptr(self):2681 return self.fptr2682 def set_fptr(self, fptr):2683 self.fptr = fptr2684 def add_fptr(self, value):2685 self.fptr.append(value)2686 def insert_fptr(self, index, value):2687 self.fptr[index] = value2688 def get_div(self):2689 return self.div2690 def set_div(self, div):2691 self.div = div2692 def add_div(self, value):2693 self.div.append(value)2694 def insert_div(self, index, value):2695 self.div[index] = value2696 def get_ADMID(self):2697 return self.ADMID2698 def set_ADMID(self, ADMID):2699 self.ADMID = ADMID2700 def get_TYPE(self):2701 return self.TYPE2702 def set_TYPE(self, TYPE):2703 self.TYPE = TYPE2704 def get_LABEL(self):2705 return self.LABEL2706 def set_LABEL(self, LABEL):2707 self.LABEL = LABEL2708 def get_DMDID(self):2709 return self.DMDID2710 def set_DMDID(self, DMDID):2711 self.DMDID = DMDID2712 def get_ORDERLABEL(self):2713 return self.ORDERLABEL2714 def set_ORDERLABEL(self, ORDERLABEL):2715 self.ORDERLABEL = ORDERLABEL2716 def get_CONTENTIDS(self):2717 return self.CONTENTIDS2718 def set_CONTENTIDS(self, CONTENTIDS):2719 self.CONTENTIDS = CONTENTIDS2720 def validate_URIs(self, value):2721 # Validate type URIs, a restriction on xsd:anyURI.2722 pass2723 def get_label(self):2724 return self.label2725 def set_label(self, label):2726 self.label = label2727 def get_ORDER(self):2728 return self.ORDER2729 def set_ORDER(self, ORDER):2730 self.ORDER = ORDER2731 def get_ID(self):2732 return self.ID2733 def set_ID(self, ID):2734 self.ID = ID2735 def export(2736 self,2737 outfile,2738 level,2739 namespace_='',2740 name_='divType',2741 namespacedef_='',2742 ):2743 showIndent(outfile, level)2744 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_2745 and ' ' + namespacedef_ or ''))2746 self.exportAttributes(outfile, level, [], namespace_,2747 name_='divType')2748 if self.hasContent_():2749 outfile.write('>\n')2750 self.exportChildren(outfile, level + 1, namespace_, name_)2751 showIndent(outfile, level)2752 outfile.write('</%s%s>\n' % (namespace_, name_))2753 else:2754 outfile.write('/>\n')2755 def exportAttributes(2756 self,2757 outfile,2758 level,2759 already_processed,2760 namespace_='',2761 name_='divType',2762 ):2763 if self.ADMID is not None and 'ADMID' not in already_processed:2764 already_processed.append('ADMID')2765 outfile.write(' ADMID=%s'2766 % (self.gds_format_string(quote_attrib(self.ADMID).encode(ExternalEncoding),2767 input_name='ADMID'), ))2768 if self.TYPE is not None and 'TYPE' not in already_processed:2769 already_processed.append('TYPE')2770 outfile.write(' TYPE=%s'2771 % (self.gds_format_string(quote_attrib(self.TYPE).encode(ExternalEncoding),2772 input_name='TYPE'), ))2773 if self.LABEL is not None and 'LABEL' not in already_processed:2774 already_processed.append('LABEL')2775 outfile.write(' LABEL=%s'2776 % (self.gds_format_string(quote_attrib(self.LABEL).encode(ExternalEncoding),2777 input_name='LABEL'), ))2778 if self.DMDID is not None and 'DMDID' not in already_processed:2779 already_processed.append('DMDID')2780 outfile.write(' DMDID=%s'2781 % (self.gds_format_string(quote_attrib(self.DMDID).encode(ExternalEncoding),2782 input_name='DMDID'), ))2783 if self.ORDERLABEL is not None and 'ORDERLABEL' \2784 not in already_processed:2785 already_processed.append('ORDERLABEL')2786 outfile.write(' ORDERLABEL=%s'2787 % (self.gds_format_string(quote_attrib(self.ORDERLABEL).encode(ExternalEncoding),2788 input_name='ORDERLABEL'), ))2789 if self.CONTENTIDS is not None and 'CONTENTIDS' \2790 not in already_processed:2791 already_processed.append('CONTENTIDS')2792 outfile.write(' CONTENTIDS=%s'2793 % (quote_attrib(self.CONTENTIDS), ))2794 if self.label is not None and 'label' not in already_processed:2795 already_processed.append('label')2796 outfile.write(' label=%s'2797 % (self.gds_format_string(quote_attrib(self.label).encode(ExternalEncoding),2798 input_name='label'), ))2799 if self.ORDER is not None and 'ORDER' not in already_processed:2800 already_processed.append('ORDER')2801 outfile.write(' ORDER="%s"'2802 % self.gds_format_integer(self.ORDER,2803 input_name='ORDER'))2804 if self.ID is not None and 'ID' not in already_processed:2805 already_processed.append('ID')2806 outfile.write(' ID=%s'2807 % (self.gds_format_string(quote_attrib(self.ID).encode(ExternalEncoding),2808 input_name='ID'), ))2809 def exportChildren(2810 self,2811 outfile,2812 level,2813 namespace_='',2814 name_='divType',2815 ):2816 for mptr_ in self.mptr:2817 mptr_.export(outfile, level, namespace_, name_='mptr')2818 for fptr_ in self.fptr:2819 fptr_.export(outfile, level, namespace_, name_='fptr')2820 for div_ in self.div:2821 div_.export(outfile, level, namespace_, name_='div')2822 def hasContent_(self):2823 if self.mptr or self.fptr or self.div:2824 return True2825 else:2826 return False2827 def exportLiteral(2828 self,2829 outfile,2830 level,2831 name_='divType',2832 ):2833 level += 12834 self.exportLiteralAttributes(outfile, level, [], name_)2835 if self.hasContent_():2836 self.exportLiteralChildren(outfile, level, name_)2837 def exportLiteralAttributes(2838 self,2839 outfile,2840 level,2841 already_processed,2842 name_,2843 ):2844 if self.ADMID is not None and 'ADMID' not in already_processed:2845 already_processed.append('ADMID')2846 showIndent(outfile, level)2847 outfile.write('ADMID = "%s",\n' % (self.ADMID, ))2848 if self.TYPE is not None and 'TYPE' not in already_processed:2849 already_processed.append('TYPE')2850 showIndent(outfile, level)2851 outfile.write('TYPE = "%s",\n' % (self.TYPE, ))2852 if self.LABEL is not None and 'LABEL' not in already_processed:2853 already_processed.append('LABEL')2854 showIndent(outfile, level)2855 outfile.write('LABEL = "%s",\n' % (self.LABEL, ))2856 if self.DMDID is not None and 'DMDID' not in already_processed:2857 already_processed.append('DMDID')2858 showIndent(outfile, level)2859 outfile.write('DMDID = "%s",\n' % (self.DMDID, ))2860 if self.ORDERLABEL is not None and 'ORDERLABEL' \2861 not in already_processed:2862 already_processed.append('ORDERLABEL')2863 showIndent(outfile, level)2864 outfile.write('ORDERLABEL = "%s",\n' % (self.ORDERLABEL, ))2865 if self.CONTENTIDS is not None and 'CONTENTIDS' \2866 not in already_processed:2867 already_processed.append('CONTENTIDS')2868 showIndent(outfile, level)2869 outfile.write('CONTENTIDS = "%s",\n' % (self.CONTENTIDS, ))2870 if self.label is not None and 'label' not in already_processed:2871 already_processed.append('label')2872 showIndent(outfile, level)2873 outfile.write('label = "%s",\n' % (self.label, ))2874 if self.ORDER is not None and 'ORDER' not in already_processed:2875 already_processed.append('ORDER')2876 showIndent(outfile, level)2877 outfile.write('ORDER = %d,\n' % (self.ORDER, ))2878 if self.ID is not None and 'ID' not in already_processed:2879 already_processed.append('ID')2880 showIndent(outfile, level)2881 outfile.write('ID = "%s",\n' % (self.ID, ))2882 def exportLiteralChildren(2883 self,2884 outfile,2885 level,2886 name_,2887 ):2888 showIndent(outfile, level)2889 outfile.write('mptr=[\n')2890 level += 12891 for mptr_ in self.mptr:2892 showIndent(outfile, level)2893 outfile.write('model_.mptr(\n')2894 mptr_.exportLiteral(outfile, level)2895 showIndent(outfile, level)2896 outfile.write('),\n')2897 level -= 12898 showIndent(outfile, level)2899 outfile.write('],\n')2900 showIndent(outfile, level)2901 outfile.write('fptr=[\n')2902 level += 12903 for fptr_ in self.fptr:2904 showIndent(outfile, level)2905 outfile.write('model_.fptr(\n')2906 fptr_.exportLiteral(outfile, level)2907 showIndent(outfile, level)2908 outfile.write('),\n')2909 level -= 12910 showIndent(outfile, level)2911 outfile.write('],\n')2912 showIndent(outfile, level)2913 outfile.write('div=[\n')2914 level += 12915 for div_ in self.div:2916 showIndent(outfile, level)2917 outfile.write('model_.divType(\n')2918 div_.exportLiteral(outfile, level, name_='divType')2919 showIndent(outfile, level)2920 outfile.write('),\n')2921 level -= 12922 showIndent(outfile, level)2923 outfile.write('],\n')2924 def build(self, node):2925 self.buildAttributes(node, node.attrib, [])2926 for child in node:2927 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]2928 self.buildChildren(child, node, nodeName_)2929 def buildAttributes(2930 self,2931 node,2932 attrs,2933 already_processed,2934 ):2935 value = attrs.get('ADMID')2936 if value is not None and 'ADMID' not in already_processed:2937 already_processed.append('ADMID')2938 self.ADMID = value2939 value = attrs.get('TYPE')2940 if value is not None and 'TYPE' not in already_processed:2941 already_processed.append('TYPE')2942 self.TYPE = value2943 value = attrs.get('LABEL')2944 if value is not None and 'LABEL' not in already_processed:2945 already_processed.append('LABEL')2946 self.LABEL = value2947 value = attrs.get('DMDID')2948 if value is not None and 'DMDID' not in already_processed:2949 already_processed.append('DMDID')2950 self.DMDID = value2951 value = attrs.get('ORDERLABEL')2952 if value is not None and 'ORDERLABEL' not in already_processed:2953 already_processed.append('ORDERLABEL')2954 self.ORDERLABEL = value2955 value = attrs.get('CONTENTIDS')2956 if value is not None and 'CONTENTIDS' not in already_processed:2957 already_processed.append('CONTENTIDS')2958 self.CONTENTIDS = value2959 self.validate_URIs(self.CONTENTIDS) # validate type URIs2960 value = attrs.get('label')2961 if value is not None and 'label' not in already_processed:2962 already_processed.append('label')2963 self.label = value2964 value = attrs.get('ORDER')2965 if value is not None and 'ORDER' not in already_processed:2966 already_processed.append('ORDER')2967 try:2968 self.ORDER = int(value)2969 except ValueError, exp:2970 raise_parse_error(node, 'Bad integer attribute: %s'2971 % exp)2972 value = attrs.get('ID')2973 if value is not None and 'ID' not in already_processed:2974 already_processed.append('ID')2975 self.ID = value2976 def buildChildren(2977 self,2978 child_,2979 node,2980 nodeName_,2981 from_subclass=False,2982 ):2983 if nodeName_ == 'mptr':2984 obj_ = mptr.factory()2985 obj_.build(child_)2986 self.mptr.append(obj_)2987 elif nodeName_ == 'fptr':2988 obj_ = fptr.factory()2989 obj_.build(child_)2990 self.fptr.append(obj_)2991 elif nodeName_ == 'div':2992 obj_ = divType.factory()2993 obj_.build(child_)2994 self.div.append(obj_)2995# end class divType2996class mptr(GeneratedsSuper):2997 """Like the <fptr> element, the METS pointer element <mptr> represents2998 digital content that manifests its parent <div> element. Unlike2999 the <fptr>, which either directly or indirectly points to3000 content represented in the <fileSec> of the parent METS3001 document, the <mptr> element points to content represented by an3002 external METS document. Thus, this element allows multiple3003 discrete and separate METS documents to be organized at a higher3004 level by a separate METS document. For example, METS documents3005 representing the individual issues in the series of a journal3006 could be grouped together and organized by a higher level METS3007 document that represents the entire journal series. Each of the3008 <div> elements in the <structMap> of the METS document3009 representing the journal series would point to a METS document3010 representing an issue. It would do so via a child <mptr>3011 element. Thus the <mptr> element gives METS users considerable3012 flexibility in managing the depth of the <structMap> hierarchy3013 of individual METS documents. The <mptr> element points to an3014 external METS document by means of an xlink:href attribute and3015 associated XLink attributes. ID (ID/O): This attribute uniquely3016 identifies the element within the METS document, and would allow3017 the element to be referenced unambiguously from another element3018 or document via an IDREF or an XPTR. For more information on3019 using ID attributes for internal and external linking see3020 Chapter 4 of the METS Primer. CONTENTIDS (URI/O): Content IDs3021 for the content represented by the <mptr> (equivalent to DIDL3022 DII or Digital Item Identifier, a unique external ID)."""3023 subclass = None3024 superclass = None3025 def __init__(3026 self,3027 arcrole=None,3028 show=None,3029 OTHERLOCTYPE=None,3030 title=None,3031 actuate=None,3032 href=None,3033 role=None,3034 LOCTYPE=None,3035 CONTENTIDS=None,3036 type_=None,3037 ID=None,3038 valueOf_=None,3039 ):3040 self.arcrole = _cast(None, arcrole)3041 self.show = _cast(None, show)3042 self.OTHERLOCTYPE = _cast(None, OTHERLOCTYPE)3043 self.title = _cast(None, title)3044 self.actuate = _cast(None, actuate)3045 self.href = _cast(None, href)3046 self.role = _cast(None, role)3047 self.LOCTYPE = _cast(None, LOCTYPE)3048 self.CONTENTIDS = _cast(None, CONTENTIDS)3049 self.type_ = _cast(None, type_)3050 self.ID = _cast(None, ID)3051 self.valueOf_ = valueOf_3052 def factory(*args_, **kwargs_):3053 if mptr.subclass:3054 return mptr.subclass(*args_, **kwargs_)3055 else:3056 return mptr(*args_, **kwargs_)3057 factory = staticmethod(factory)3058 def get_arcrole(self):3059 return self.arcrole3060 def set_arcrole(self, arcrole):3061 self.arcrole = arcrole3062 def get_show(self):3063 return self.show3064 def set_show(self, show):3065 self.show = show3066 def get_OTHERLOCTYPE(self):3067 return self.OTHERLOCTYPE3068 def set_OTHERLOCTYPE(self, OTHERLOCTYPE):3069 self.OTHERLOCTYPE = OTHERLOCTYPE3070 def get_title(self):3071 return self.title3072 def set_title(self, title):3073 self.title = title3074 def get_actuate(self):3075 return self.actuate3076 def set_actuate(self, actuate):3077 self.actuate = actuate3078 def get_href(self):3079 return self.href3080 def set_href(self, href):3081 self.href = href3082 def get_role(self):3083 return self.role3084 def set_role(self, role):3085 self.role = role3086 def get_LOCTYPE(self):3087 return self.LOCTYPE3088 def set_LOCTYPE(self, LOCTYPE):3089 self.LOCTYPE = LOCTYPE3090 def get_CONTENTIDS(self):3091 return self.CONTENTIDS3092 def set_CONTENTIDS(self, CONTENTIDS):3093 self.CONTENTIDS = CONTENTIDS3094 def validate_URIs(self, value):3095 # Validate type URIs, a restriction on xsd:anyURI.3096 pass3097 def get_type(self):3098 return self.type_3099 def set_type(self, type_):3100 self.type_ = type_3101 def get_ID(self):3102 return self.ID3103 def set_ID(self, ID):3104 self.ID = ID3105 def get_valueOf_(self):3106 return self.valueOf_3107 def set_valueOf_(self, valueOf_):3108 self.valueOf_ = valueOf_3109 def export(3110 self,3111 outfile,3112 level,3113 namespace_='',3114 name_='mptr',3115 namespacedef_='',3116 ):3117 showIndent(outfile, level)3118 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_3119 and ' ' + namespacedef_ or ''))3120 self.exportAttributes(outfile, level, [], namespace_,3121 name_='mptr')3122 if self.hasContent_():3123 outfile.write('>')3124 outfile.write(self.valueOf_)3125 self.exportChildren(outfile, level + 1, namespace_, name_)3126 outfile.write('</%s%s>\n' % (namespace_, name_))3127 else:3128 outfile.write('/>\n')3129 def exportAttributes(3130 self,3131 outfile,3132 level,3133 already_processed,3134 namespace_='',3135 name_='mptr',3136 ):3137 if self.arcrole is not None and 'arcrole' \3138 not in already_processed:3139 already_processed.append('arcrole')3140 outfile.write(' arcrole=%s'3141 % (self.gds_format_string(quote_attrib(self.arcrole).encode(ExternalEncoding),3142 input_name='arcrole'), ))3143 if self.show is not None and 'show' not in already_processed:3144 already_processed.append('show')3145 outfile.write(' show=%s'3146 % (self.gds_format_string(quote_attrib(self.show).encode(ExternalEncoding),3147 input_name='show'), ))3148 if self.OTHERLOCTYPE is not None and 'OTHERLOCTYPE' \3149 not in already_processed:3150 already_processed.append('OTHERLOCTYPE')3151 outfile.write(' OTHERLOCTYPE=%s'3152 % (self.gds_format_string(quote_attrib(self.OTHERLOCTYPE).encode(ExternalEncoding),3153 input_name='OTHERLOCTYPE'), ))3154 if self.title is not None and 'title' not in already_processed:3155 already_processed.append('title')3156 outfile.write(' title=%s'3157 % (self.gds_format_string(quote_attrib(self.title).encode(ExternalEncoding),3158 input_name='title'), ))3159 if self.actuate is not None and 'actuate' \3160 not in already_processed:3161 already_processed.append('actuate')3162 outfile.write(' actuate=%s'3163 % (self.gds_format_string(quote_attrib(self.actuate).encode(ExternalEncoding),3164 input_name='actuate'), ))3165 if self.href is not None and 'href' not in already_processed:3166 already_processed.append('href')3167 outfile.write(' href=%s'3168 % (self.gds_format_string(quote_attrib(self.href).encode(ExternalEncoding),3169 input_name='href'), ))3170 if self.role is not None and 'role' not in already_processed:3171 already_processed.append('role')3172 outfile.write(' role=%s'3173 % (self.gds_format_string(quote_attrib(self.role).encode(ExternalEncoding),3174 input_name='role'), ))3175 if self.LOCTYPE is not None and 'LOCTYPE' \3176 not in already_processed:3177 already_processed.append('LOCTYPE')3178 outfile.write(' LOCTYPE=%s'3179 % (self.gds_format_string(quote_attrib(self.LOCTYPE).encode(ExternalEncoding),3180 input_name='LOCTYPE'), ))3181 if self.CONTENTIDS is not None and 'CONTENTIDS' \3182 not in already_processed:3183 already_processed.append('CONTENTIDS')3184 outfile.write(' CONTENTIDS=%s'3185 % (quote_attrib(self.CONTENTIDS), ))3186 if self.type_ is not None and 'type_' not in already_processed:3187 already_processed.append('type_')3188 outfile.write(' type=%s' % (quote_attrib(self.type_), ))3189 if self.ID is not None and 'ID' not in already_processed:3190 already_processed.append('ID')3191 outfile.write(' ID=%s'3192 % (self.gds_format_string(quote_attrib(self.ID).encode(ExternalEncoding),3193 input_name='ID'), ))3194 def exportChildren(3195 self,3196 outfile,3197 level,3198 namespace_='',3199 name_='mptr',3200 ):3201 pass3202 def hasContent_(self):3203 if self.valueOf_:3204 return True3205 else:3206 return False3207 def exportLiteral(3208 self,3209 outfile,3210 level,3211 name_='mptr',3212 ):3213 level += 13214 self.exportLiteralAttributes(outfile, level, [], name_)3215 if self.hasContent_():3216 self.exportLiteralChildren(outfile, level, name_)3217 showIndent(outfile, level)3218 outfile.write('valueOf_ = """%s""",\n' % (self.valueOf_, ))3219 def exportLiteralAttributes(3220 self,3221 outfile,3222 level,3223 already_processed,3224 name_,3225 ):3226 if self.arcrole is not None and 'arcrole' \3227 not in already_processed:3228 already_processed.append('arcrole')3229 showIndent(outfile, level)3230 outfile.write('arcrole = "%s",\n' % (self.arcrole, ))3231 if self.show is not None and 'show' not in already_processed:3232 already_processed.append('show')3233 showIndent(outfile, level)3234 outfile.write('show = "%s",\n' % (self.show, ))3235 if self.OTHERLOCTYPE is not None and 'OTHERLOCTYPE' \3236 not in already_processed:3237 already_processed.append('OTHERLOCTYPE')3238 showIndent(outfile, level)3239 outfile.write('OTHERLOCTYPE = "%s",\n'3240 % (self.OTHERLOCTYPE, ))3241 if self.title is not None and 'title' not in already_processed:3242 already_processed.append('title')3243 showIndent(outfile, level)3244 outfile.write('title = "%s",\n' % (self.title, ))3245 if self.actuate is not None and 'actuate' \3246 not in already_processed:3247 already_processed.append('actuate')3248 showIndent(outfile, level)3249 outfile.write('actuate = "%s",\n' % (self.actuate, ))3250 if self.href is not None and 'href' not in already_processed:3251 already_processed.append('href')3252 showIndent(outfile, level)3253 outfile.write('href = "%s",\n' % (self.href, ))3254 if self.role is not None and 'role' not in already_processed:3255 already_processed.append('role')3256 showIndent(outfile, level)3257 outfile.write('role = "%s",\n' % (self.role, ))3258 if self.LOCTYPE is not None and 'LOCTYPE' \3259 not in already_processed:3260 already_processed.append('LOCTYPE')3261 showIndent(outfile, level)3262 outfile.write('LOCTYPE = "%s",\n' % (self.LOCTYPE, ))3263 if self.CONTENTIDS is not None and 'CONTENTIDS' \3264 not in already_processed:3265 already_processed.append('CONTENTIDS')3266 showIndent(outfile, level)3267 outfile.write('CONTENTIDS = "%s",\n' % (self.CONTENTIDS, ))3268 if self.type_ is not None and 'type_' not in already_processed:3269 already_processed.append('type_')3270 showIndent(outfile, level)3271 outfile.write('type_ = %s,\n' % (self.type_, ))3272 if self.ID is not None and 'ID' not in already_processed:3273 already_processed.append('ID')3274 showIndent(outfile, level)3275 outfile.write('ID = "%s",\n' % (self.ID, ))3276 def exportLiteralChildren(3277 self,3278 outfile,3279 level,3280 name_,3281 ):3282 pass3283 def build(self, node):3284 self.buildAttributes(node, node.attrib, [])3285 self.valueOf_ = get_all_text_(node)3286 for child in node:3287 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]3288 self.buildChildren(child, node, nodeName_)3289 def buildAttributes(3290 self,3291 node,3292 attrs,3293 already_processed,3294 ):3295 value = attrs.get('arcrole')3296 if value is not None and 'arcrole' not in already_processed:3297 already_processed.append('arcrole')3298 self.arcrole = value3299 value = attrs.get('show')3300 if value is not None and 'show' not in already_processed:3301 already_processed.append('show')3302 self.show = value3303 value = attrs.get('OTHERLOCTYPE')3304 if value is not None and 'OTHERLOCTYPE' \3305 not in already_processed:3306 already_processed.append('OTHERLOCTYPE')3307 self.OTHERLOCTYPE = value3308 value = attrs.get('title')3309 if value is not None and 'title' not in already_processed:3310 already_processed.append('title')3311 self.title = value3312 value = attrs.get('actuate')3313 if value is not None and 'actuate' not in already_processed:3314 already_processed.append('actuate')3315 self.actuate = value3316 value = attrs.get('href')3317 if value is not None and 'href' not in already_processed:3318 already_processed.append('href')3319 self.href = value3320 value = attrs.get('role')3321 if value is not None and 'role' not in already_processed:3322 already_processed.append('role')3323 self.role = value3324 value = attrs.get('LOCTYPE')3325 if value is not None and 'LOCTYPE' not in already_processed:3326 already_processed.append('LOCTYPE')3327 self.LOCTYPE = value3328 value = attrs.get('CONTENTIDS')3329 if value is not None and 'CONTENTIDS' not in already_processed:3330 already_processed.append('CONTENTIDS')3331 self.CONTENTIDS = value3332 self.validate_URIs(self.CONTENTIDS) # validate type URIs3333 value = attrs.get('type')3334 if value is not None and 'type' not in already_processed:3335 already_processed.append('type')3336 self.type_ = value3337 value = attrs.get('ID')3338 if value is not None and 'ID' not in already_processed:3339 already_processed.append('ID')3340 self.ID = value3341 def buildChildren(3342 self,3343 child_,3344 node,3345 nodeName_,3346 from_subclass=False,3347 ):3348 pass3349# end class mptr3350class fptr(GeneratedsSuper):3351 """The <fptr> or file pointer element represents digital content that3352 manifests its parent <div> element. The content represented by3353 an <fptr> element must consist of integral files or parts of3354 files that are represented by <file> elements in the <fileSec>.3355 Via its FILEID attribute, an <fptr> may point directly to a3356 single integral <file> element that manifests a structural3357 division. However, an <fptr> element may also govern an <area>3358 element, a <par>, or a <seq> which in turn would point to the3359 relevant file or files. A child <area> element can point to part3360 of a <file> that manifests a division, while the <par> and <seq>3361 elements can point to multiple files or parts of files that3362 together manifest a division. More than one <fptr> element can3363 be associated with a <div> element. Typically sibling <fptr>3364 elements represent alternative versions, or manifestations, of3365 the same content ID (ID/O): This attribute uniquely identifies3366 the element within the METS document, and would allow the3367 element to be referenced unambiguously from another element or3368 document via an IDREF or an XPTR. For more information on using3369 ID attributes for internal and external linking see Chapter 4 of3370 the METS Primer. FILEID (IDREF/O): An optional attribute that3371 provides the XML ID identifying the <file> element that links to3372 and/or contains the digital content represented by the <fptr>. A3373 <fptr> element should only have a FILEID attribute value if it3374 does not have a child <area>, <par> or <seq> element. If it has3375 a child element, then the responsibility for pointing to the3376 relevant content falls to this child element or its descendants.3377 CONTENTIDS (URI/O): Content IDs for the content represented by3378 the <fptr> (equivalent to DIDL DII or Digital Item Identifier, a3379 unique external ID)."""3380 subclass = None3381 superclass = None3382 def __init__(3383 self,3384 CONTENTIDS=None,3385 ID=None,3386 FILEID=None,3387 par=None,3388 seq=None,3389 area=None,3390 ):3391 self.CONTENTIDS = _cast(None, CONTENTIDS)3392 self.ID = _cast(None, ID)3393 self.FILEID = _cast(None, FILEID)3394 self.par = par3395 self.seq = seq3396 self.area = area3397 def factory(*args_, **kwargs_):3398 if fptr.subclass:3399 return fptr.subclass(*args_, **kwargs_)3400 else:3401 return fptr(*args_, **kwargs_)3402 factory = staticmethod(factory)3403 def get_par(self):3404 return self.par3405 def set_par(self, par):3406 self.par = par3407 def get_seq(self):3408 return self.seq3409 def set_seq(self, seq):3410 self.seq = seq3411 def get_area(self):3412 return self.area3413 def set_area(self, area):3414 self.area = area3415 def get_CONTENTIDS(self):3416 return self.CONTENTIDS3417 def set_CONTENTIDS(self, CONTENTIDS):3418 self.CONTENTIDS = CONTENTIDS3419 def validate_URIs(self, value):3420 # Validate type URIs, a restriction on xsd:anyURI.3421 pass3422 def get_ID(self):3423 return self.ID3424 def set_ID(self, ID):3425 self.ID = ID3426 def get_FILEID(self):3427 return self.FILEID3428 def set_FILEID(self, FILEID):3429 self.FILEID = FILEID3430 def export(3431 self,3432 outfile,3433 level,3434 namespace_='',3435 name_='fptr',3436 namespacedef_='',3437 ):3438 showIndent(outfile, level)3439 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_3440 and ' ' + namespacedef_ or ''))3441 self.exportAttributes(outfile, level, [], namespace_,3442 name_='fptr')3443 if self.hasContent_():3444 outfile.write('>\n')3445 self.exportChildren(outfile, level + 1, namespace_, name_)3446 showIndent(outfile, level)3447 outfile.write('</%s%s>\n' % (namespace_, name_))3448 else:3449 outfile.write('/>\n')3450 def exportAttributes(3451 self,3452 outfile,3453 level,3454 already_processed,3455 namespace_='',3456 name_='fptr',3457 ):3458 if self.CONTENTIDS is not None and 'CONTENTIDS' \3459 not in already_processed:3460 already_processed.append('CONTENTIDS')3461 outfile.write(' CONTENTIDS=%s'3462 % (quote_attrib(self.CONTENTIDS), ))3463 if self.ID is not None and 'ID' not in already_processed:3464 already_processed.append('ID')3465 outfile.write(' ID=%s'3466 % (self.gds_format_string(quote_attrib(self.ID).encode(ExternalEncoding),3467 input_name='ID'), ))3468 if self.FILEID is not None and 'FILEID' \3469 not in already_processed:3470 already_processed.append('FILEID')3471 outfile.write(' FILEID=%s'3472 % (self.gds_format_string(quote_attrib(self.FILEID).encode(ExternalEncoding),3473 input_name='FILEID'), ))3474 def exportChildren(3475 self,3476 outfile,3477 level,3478 namespace_='',3479 name_='fptr',3480 ):3481 if self.par:3482 self.par.export(outfile, level, namespace_, name_='par')3483 if self.seq:3484 self.seq.export(outfile, level, namespace_, name_='seq')3485 if self.area:3486 self.area.export(outfile, level, namespace_, name_='area')3487 def hasContent_(self):3488 if self.par is not None or self.seq is not None or self.area \3489 is not None:3490 return True3491 else:3492 return False3493 def exportLiteral(3494 self,3495 outfile,3496 level,3497 name_='fptr',3498 ):3499 level += 13500 self.exportLiteralAttributes(outfile, level, [], name_)3501 if self.hasContent_():3502 self.exportLiteralChildren(outfile, level, name_)3503 def exportLiteralAttributes(3504 self,3505 outfile,3506 level,3507 already_processed,3508 name_,3509 ):3510 if self.CONTENTIDS is not None and 'CONTENTIDS' \3511 not in already_processed:3512 already_processed.append('CONTENTIDS')3513 showIndent(outfile, level)3514 outfile.write('CONTENTIDS = "%s",\n' % (self.CONTENTIDS, ))3515 if self.ID is not None and 'ID' not in already_processed:3516 already_processed.append('ID')3517 showIndent(outfile, level)3518 outfile.write('ID = "%s",\n' % (self.ID, ))3519 if self.FILEID is not None and 'FILEID' \3520 not in already_processed:3521 already_processed.append('FILEID')3522 showIndent(outfile, level)3523 outfile.write('FILEID = "%s",\n' % (self.FILEID, ))3524 def exportLiteralChildren(3525 self,3526 outfile,3527 level,3528 name_,3529 ):3530 if self.par is not None:3531 showIndent(outfile, level)3532 outfile.write('par=model_.parType(\n')3533 self.par.exportLiteral(outfile, level, name_='par')3534 showIndent(outfile, level)3535 outfile.write('),\n')3536 if self.seq is not None:3537 showIndent(outfile, level)3538 outfile.write('seq=model_.seqType(\n')3539 self.seq.exportLiteral(outfile, level, name_='seq')3540 showIndent(outfile, level)3541 outfile.write('),\n')3542 if self.area is not None:3543 showIndent(outfile, level)3544 outfile.write('area=model_.areaType(\n')3545 self.area.exportLiteral(outfile, level, name_='area')3546 showIndent(outfile, level)3547 outfile.write('),\n')3548 def build(self, node):3549 self.buildAttributes(node, node.attrib, [])3550 for child in node:3551 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]3552 self.buildChildren(child, node, nodeName_)3553 def buildAttributes(3554 self,3555 node,3556 attrs,3557 already_processed,3558 ):3559 value = attrs.get('CONTENTIDS')3560 if value is not None and 'CONTENTIDS' not in already_processed:3561 already_processed.append('CONTENTIDS')3562 self.CONTENTIDS = value3563 self.validate_URIs(self.CONTENTIDS) # validate type URIs3564 value = attrs.get('ID')3565 if value is not None and 'ID' not in already_processed:3566 already_processed.append('ID')3567 self.ID = value3568 value = attrs.get('FILEID')3569 if value is not None and 'FILEID' not in already_processed:3570 already_processed.append('FILEID')3571 self.FILEID = value3572 def buildChildren(3573 self,3574 child_,3575 node,3576 nodeName_,3577 from_subclass=False,3578 ):3579 if nodeName_ == 'par':3580 obj_ = parType.factory()3581 obj_.build(child_)3582 self.set_par(obj_)3583 elif nodeName_ == 'seq':3584 obj_ = seqType.factory()3585 obj_.build(child_)3586 self.set_seq(obj_)3587 elif nodeName_ == 'area':3588 obj_ = areaType.factory()3589 obj_.build(child_)3590 self.set_area(obj_)3591# end class fptr3592class parType(GeneratedsSuper):3593 """parType: Complex Type for Parallel Files The <par> or parallel files3594 element aggregates pointers to files, parts of files, and/or3595 sequences of files or parts of files that must be played or3596 displayed simultaneously to manifest a block of digital content3597 represented by an <fptr> element. ID (ID/O): This attribute3598 uniquely identifies the element within the METS document, and3599 would allow the element to be referenced unambiguously from3600 another element or document via an IDREF or an XPTR. For more3601 information on using ID attributes for internal and external3602 linking see Chapter 4 of the METS Primer."""3603 subclass = None3604 superclass = None3605 def __init__(3606 self,3607 ID=None,3608 area=None,3609 seq=None,3610 ):3611 self.ID = _cast(None, ID)3612 if area is None:3613 self.area = []3614 else:3615 self.area = area3616 if seq is None:3617 self.seq = []3618 else:3619 self.seq = seq3620 def factory(*args_, **kwargs_):3621 if parType.subclass:3622 return parType.subclass(*args_, **kwargs_)3623 else:3624 return parType(*args_, **kwargs_)3625 factory = staticmethod(factory)3626 def get_area(self):3627 return self.area3628 def set_area(self, area):3629 self.area = area3630 def add_area(self, value):3631 self.area.append(value)3632 def insert_area(self, index, value):3633 self.area[index] = value3634 def get_seq(self):3635 return self.seq3636 def set_seq(self, seq):3637 self.seq = seq3638 def add_seq(self, value):3639 self.seq.append(value)3640 def insert_seq(self, index, value):3641 self.seq[index] = value3642 def get_ID(self):3643 return self.ID3644 def set_ID(self, ID):3645 self.ID = ID3646 def export(3647 self,3648 outfile,3649 level,3650 namespace_='',3651 name_='parType',3652 namespacedef_='',3653 ):3654 showIndent(outfile, level)3655 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_3656 and ' ' + namespacedef_ or ''))3657 self.exportAttributes(outfile, level, [], namespace_,3658 name_='parType')3659 if self.hasContent_():3660 outfile.write('>\n')3661 self.exportChildren(outfile, level + 1, namespace_, name_)3662 showIndent(outfile, level)3663 outfile.write('</%s%s>\n' % (namespace_, name_))3664 else:3665 outfile.write('/>\n')3666 def exportAttributes(3667 self,3668 outfile,3669 level,3670 already_processed,3671 namespace_='',3672 name_='parType',3673 ):3674 if self.ID is not None and 'ID' not in already_processed:3675 already_processed.append('ID')3676 outfile.write(' ID=%s'3677 % (self.gds_format_string(quote_attrib(self.ID).encode(ExternalEncoding),3678 input_name='ID'), ))3679 def exportChildren(3680 self,3681 outfile,3682 level,3683 namespace_='',3684 name_='parType',3685 ):3686 for area_ in self.area:3687 area_.export(outfile, level, namespace_, name_='area')3688 for seq_ in self.seq:3689 seq_.export(outfile, level, namespace_, name_='seq')3690 def hasContent_(self):3691 if self.area or self.seq:3692 return True3693 else:3694 return False3695 def exportLiteral(3696 self,3697 outfile,3698 level,3699 name_='parType',3700 ):3701 level += 13702 self.exportLiteralAttributes(outfile, level, [], name_)3703 if self.hasContent_():3704 self.exportLiteralChildren(outfile, level, name_)3705 def exportLiteralAttributes(3706 self,3707 outfile,3708 level,3709 already_processed,3710 name_,3711 ):3712 if self.ID is not None and 'ID' not in already_processed:3713 already_processed.append('ID')3714 showIndent(outfile, level)3715 outfile.write('ID = "%s",\n' % (self.ID, ))3716 def exportLiteralChildren(3717 self,3718 outfile,3719 level,3720 name_,3721 ):3722 showIndent(outfile, level)3723 outfile.write('area=[\n')3724 level += 13725 for area_ in self.area:3726 showIndent(outfile, level)3727 outfile.write('model_.areaType(\n')3728 area_.exportLiteral(outfile, level, name_='areaType')3729 showIndent(outfile, level)3730 outfile.write('),\n')3731 level -= 13732 showIndent(outfile, level)3733 outfile.write('],\n')3734 showIndent(outfile, level)3735 outfile.write('seq=[\n')3736 level += 13737 for seq_ in self.seq:3738 showIndent(outfile, level)3739 outfile.write('model_.seqType(\n')3740 seq_.exportLiteral(outfile, level, name_='seqType')3741 showIndent(outfile, level)3742 outfile.write('),\n')3743 level -= 13744 showIndent(outfile, level)3745 outfile.write('],\n')3746 def build(self, node):3747 self.buildAttributes(node, node.attrib, [])3748 for child in node:3749 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]3750 self.buildChildren(child, node, nodeName_)3751 def buildAttributes(3752 self,3753 node,3754 attrs,3755 already_processed,3756 ):3757 value = attrs.get('ID')3758 if value is not None and 'ID' not in already_processed:3759 already_processed.append('ID')3760 self.ID = value3761 def buildChildren(3762 self,3763 child_,3764 node,3765 nodeName_,3766 from_subclass=False,3767 ):3768 if nodeName_ == 'area':3769 obj_ = areaType.factory()3770 obj_.build(child_)3771 self.area.append(obj_)3772 elif nodeName_ == 'seq':3773 obj_ = seqType.factory()3774 obj_.build(child_)3775 self.seq.append(obj_)3776# end class parType3777class seqType(GeneratedsSuper):3778 """seqType: Complex Type for Sequences of Files The seq element should3779 be used to link a div to a set of content files when those files3780 should be played/displayed sequentially to deliver content to a3781 user. Individual <area> subelements within the seq element3782 provide the links to the files or portions thereof. ID (ID/O):3783 This attribute uniquely identifies the element within the METS3784 document, and would allow the element to be referenced3785 unambiguously from another element or document via an IDREF or3786 an XPTR. For more information on using ID attributes for3787 internal and external linking see Chapter 4 of the METS Primer."""3788 subclass = None3789 superclass = None3790 def __init__(3791 self,3792 ID=None,3793 area=None,3794 par=None,3795 ):3796 self.ID = _cast(None, ID)3797 if area is None:3798 self.area = []3799 else:3800 self.area = area3801 if par is None:3802 self.par = []3803 else:3804 self.par = par3805 def factory(*args_, **kwargs_):3806 if seqType.subclass:3807 return seqType.subclass(*args_, **kwargs_)3808 else:3809 return seqType(*args_, **kwargs_)3810 factory = staticmethod(factory)3811 def get_area(self):3812 return self.area3813 def set_area(self, area):3814 self.area = area3815 def add_area(self, value):3816 self.area.append(value)3817 def insert_area(self, index, value):3818 self.area[index] = value3819 def get_par(self):3820 return self.par3821 def set_par(self, par):3822 self.par = par3823 def add_par(self, value):3824 self.par.append(value)3825 def insert_par(self, index, value):3826 self.par[index] = value3827 def get_ID(self):3828 return self.ID3829 def set_ID(self, ID):3830 self.ID = ID3831 def export(3832 self,3833 outfile,3834 level,3835 namespace_='',3836 name_='seqType',3837 namespacedef_='',3838 ):3839 showIndent(outfile, level)3840 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_3841 and ' ' + namespacedef_ or ''))3842 self.exportAttributes(outfile, level, [], namespace_,3843 name_='seqType')3844 if self.hasContent_():3845 outfile.write('>\n')3846 self.exportChildren(outfile, level + 1, namespace_, name_)3847 showIndent(outfile, level)3848 outfile.write('</%s%s>\n' % (namespace_, name_))3849 else:3850 outfile.write('/>\n')3851 def exportAttributes(3852 self,3853 outfile,3854 level,3855 already_processed,3856 namespace_='',3857 name_='seqType',3858 ):3859 if self.ID is not None and 'ID' not in already_processed:3860 already_processed.append('ID')3861 outfile.write(' ID=%s'3862 % (self.gds_format_string(quote_attrib(self.ID).encode(ExternalEncoding),3863 input_name='ID'), ))3864 def exportChildren(3865 self,3866 outfile,3867 level,3868 namespace_='',3869 name_='seqType',3870 ):3871 for area_ in self.area:3872 area_.export(outfile, level, namespace_, name_='area')3873 for par_ in self.par:3874 par_.export(outfile, level, namespace_, name_='par')3875 def hasContent_(self):3876 if self.area or self.par:3877 return True3878 else:3879 return False3880 def exportLiteral(3881 self,3882 outfile,3883 level,3884 name_='seqType',3885 ):3886 level += 13887 self.exportLiteralAttributes(outfile, level, [], name_)3888 if self.hasContent_():3889 self.exportLiteralChildren(outfile, level, name_)3890 def exportLiteralAttributes(3891 self,3892 outfile,3893 level,3894 already_processed,3895 name_,3896 ):3897 if self.ID is not None and 'ID' not in already_processed:3898 already_processed.append('ID')3899 showIndent(outfile, level)3900 outfile.write('ID = "%s",\n' % (self.ID, ))3901 def exportLiteralChildren(3902 self,3903 outfile,3904 level,3905 name_,3906 ):3907 showIndent(outfile, level)3908 outfile.write('area=[\n')3909 level += 13910 for area_ in self.area:3911 showIndent(outfile, level)3912 outfile.write('model_.areaType(\n')3913 area_.exportLiteral(outfile, level, name_='areaType')3914 showIndent(outfile, level)3915 outfile.write('),\n')3916 level -= 13917 showIndent(outfile, level)3918 outfile.write('],\n')3919 showIndent(outfile, level)3920 outfile.write('par=[\n')3921 level += 13922 for par_ in self.par:3923 showIndent(outfile, level)3924 outfile.write('model_.parType(\n')3925 par_.exportLiteral(outfile, level, name_='parType')3926 showIndent(outfile, level)3927 outfile.write('),\n')3928 level -= 13929 showIndent(outfile, level)3930 outfile.write('],\n')3931 def build(self, node):3932 self.buildAttributes(node, node.attrib, [])3933 for child in node:3934 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]3935 self.buildChildren(child, node, nodeName_)3936 def buildAttributes(3937 self,3938 node,3939 attrs,3940 already_processed,3941 ):3942 value = attrs.get('ID')3943 if value is not None and 'ID' not in already_processed:3944 already_processed.append('ID')3945 self.ID = value3946 def buildChildren(3947 self,3948 child_,3949 node,3950 nodeName_,3951 from_subclass=False,3952 ):3953 if nodeName_ == 'area':3954 obj_ = areaType.factory()3955 obj_.build(child_)3956 self.area.append(obj_)3957 elif nodeName_ == 'par':3958 obj_ = parType.factory()3959 obj_.build(child_)3960 self.par.append(obj_)3961# end class seqType3962class areaType(GeneratedsSuper):3963 """areaType: Complex Type for Area Linking The area element provides3964 for more sophisticated linking between a div element and content3965 files representing that div, be they text, image, audio, or3966 video files. An area element can link a div to a point within a3967 file, to a one-dimension segment of a file (e.g., text segment,3968 image line, audio/video clip), or a two-dimensional section of a3969 file (e.g, subsection of an image, or a subsection of the video3970 display of a video file. The area element has no content; all3971 information is recorded within its various attributes. ID3972 (ID/O): This attribute uniquely identifies the element within3973 the METS document, and would allow the element to be referenced3974 unambiguously from another element or document via an IDREF or3975 an XPTR. For more information on using ID attributes for3976 internal and external linking see Chapter 4 of the METS Primer.3977 FILEID (IDREF/R): An attribute which provides the XML ID value3978 that identifies the <file> element in the <fileSec> that then3979 points to and/or contains the digital content represented by the3980 <area> element. It must contain an ID value represented in an ID3981 attribute associated with a <file> element in the <fileSec>3982 element in the same METS document. SHAPE (string/O): An3983 attribute that can be used as in HTML to define the shape of the3984 relevant area within the content file pointed to by the <area>3985 element. Typically this would be used with image content (still3986 image or video frame) when only a portion of an integal image3987 map pertains. If SHAPE is specified then COORDS must also be3988 present. SHAPE should be used in conjunction with COORDS in the3989 manner defined for the shape and coords attributes on an HTML43990 <area> element. SHAPE must contain one of the following values:3991 RECT CIRCLE POLY COORDS (string/O): Specifies the coordinates in3992 an image map for the shape of the pertinent area as specified in3993 the SHAPE attribute. While technically optional, SHAPE and3994 COORDS must both appear together to define the relevant area of3995 image content. COORDS should be used in conjunction with SHAPE3996 in the manner defined for the COORDs and SHAPE attributes on an3997 HTML4 <area> element. COORDS must be a comma delimited string of3998 integer value pairs representing coordinates (plus radius in the3999 case of CIRCLE) within an image map. Number of coordinates pairs4000 depends on shape: RECT: x1, y1, x2, y2; CIRC: x1, y1; POLY: x1,4001 y1, x2, y2, x3, y3 . . . BEGIN (string/O): An attribute that4002 specifies the point in the content file where the relevant4003 section of content begins. It can be used in conjunction with4004 either the END attribute or the EXTENT attribute as a means of4005 defining the relevant portion of the referenced file precisely.4006 It can only be interpreted meaningfully in conjunction with the4007 BETYPE or EXTTYPE, which specify the kind of beginning/ending4008 point values or beginning/extent values that are being used. The4009 BEGIN attribute can be used with or without a companion END or4010 EXTENT element. In this case, the end of the content file is4011 assumed to be the end point. END (string/O): An attribute that4012 specifies the point in the content file where the relevant4013 section of content ends. It can only be interpreted meaningfully4014 in conjunction with the BETYPE, which specifies the kind of4015 ending point values being used. Typically the END attribute4016 would only appear in conjunction with a BEGIN element. BETYPE:4017 Begin/End Type. BETYPE (string/O): An attribute that specifies4018 the kind of BEGIN and/or END values that are being used. For4019 example, if BYTE is specified, then the BEGIN and END point4020 values represent the byte offsets into a file. If IDREF is4021 specified, then the BEGIN element specifies the ID value that4022 identifies the element in a structured text file where the4023 relevant section of the file begins; and the END value (if4024 present) would specify the ID value that identifies the element4025 with which the relevant section of the file ends. Must be one of4026 the following values: BYTE IDREF SMIL MIDI SMPTE-25 SMPTE-244027 SMPTE-DF30 SMPTE-NDF30 SMPTE-DF29.97 SMPTE-NDF29.97 TIME TCF4028 XPTR EXTENT (string/O): An attribute that specifies the extent4029 of the relevant section of the content file. Can only be4030 interpreted meaningfully in conjunction with the EXTTYPE which4031 specifies the kind of value that is being used. Typically the4032 EXTENT attribute would only appear in conjunction with a BEGIN4033 element and would not be used if the BEGIN point represents an4034 IDREF. EXTTYPE (string/O): An attribute that specifies the kind4035 of EXTENT values that are being used. For example if BYTE is4036 specified then EXTENT would represent a byte count. If TIME is4037 specified the EXTENT would represent a duration of time. EXTTYPE4038 must be one of the following values: BYTE SMIL MIDI SMPTE-254039 SMPTE-24 SMPTE-DF30 SMPTE-NDF30 SMPTE-DF29.97 SMPTE-NDF29.974040 TIME TCF. ADMID (IDREFS/O): Contains the ID attribute values4041 identifying the <rightsMD>, <sourceMD>, <techMD> and/or4042 <digiprovMD> elements within the <amdSec> of the METS document4043 that contain or link to administrative metadata pertaining to4044 the content represented by the <area> element. Typically the4045 <area> ADMID attribute would be used to identify the <rightsMD>4046 element or elements that pertain to the <area>, but it could be4047 used anytime there was a need to link an <area> with pertinent4048 administrative metadata. For more information on using METS4049 IDREFS and IDREF type attributes for internal linking, see4050 Chapter 4 of the METS Primer CONTENTIDS (URI/O): Content IDs for4051 the content represented by the <area> (equivalent to DIDL DII or4052 Digital Item Identifier, a unique external ID)."""4053 subclass = None4054 superclass = None4055 def __init__(4056 self,4057 BEGIN=None,4058 END=None,4059 BETYPE=None,4060 SHAPE=None,4061 COORDS=None,4062 EXTENT=None,4063 CONTENTIDS=None,4064 ADMID=None,4065 ID=None,4066 EXTTYPE=None,4067 FILEID=None,4068 valueOf_=None,4069 ):4070 self.BEGIN = _cast(None, BEGIN)4071 self.END = _cast(None, END)4072 self.BETYPE = _cast(None, BETYPE)4073 self.SHAPE = _cast(None, SHAPE)4074 self.COORDS = _cast(None, COORDS)4075 self.EXTENT = _cast(None, EXTENT)4076 self.CONTENTIDS = _cast(None, CONTENTIDS)4077 self.ADMID = _cast(None, ADMID)4078 self.ID = _cast(None, ID)4079 self.EXTTYPE = _cast(None, EXTTYPE)4080 self.FILEID = _cast(None, FILEID)4081 self.valueOf_ = valueOf_4082 def factory(*args_, **kwargs_):4083 if areaType.subclass:4084 return areaType.subclass(*args_, **kwargs_)4085 else:4086 return areaType(*args_, **kwargs_)4087 factory = staticmethod(factory)4088 def get_BEGIN(self):4089 return self.BEGIN4090 def set_BEGIN(self, BEGIN):4091 self.BEGIN = BEGIN4092 def get_END(self):4093 return self.END4094 def set_END(self, END):4095 self.END = END4096 def get_BETYPE(self):4097 return self.BETYPE4098 def set_BETYPE(self, BETYPE):4099 self.BETYPE = BETYPE4100 def get_SHAPE(self):4101 return self.SHAPE4102 def set_SHAPE(self, SHAPE):4103 self.SHAPE = SHAPE4104 def get_COORDS(self):4105 return self.COORDS4106 def set_COORDS(self, COORDS):4107 self.COORDS = COORDS4108 def get_EXTENT(self):4109 return self.EXTENT4110 def set_EXTENT(self, EXTENT):4111 self.EXTENT = EXTENT4112 def get_CONTENTIDS(self):4113 return self.CONTENTIDS4114 def set_CONTENTIDS(self, CONTENTIDS):4115 self.CONTENTIDS = CONTENTIDS4116 def validate_URIs(self, value):4117 # Validate type URIs, a restriction on xsd:anyURI.4118 pass4119 def get_ADMID(self):4120 return self.ADMID4121 def set_ADMID(self, ADMID):4122 self.ADMID = ADMID4123 def get_ID(self):4124 return self.ID4125 def set_ID(self, ID):4126 self.ID = ID4127 def get_EXTTYPE(self):4128 return self.EXTTYPE4129 def set_EXTTYPE(self, EXTTYPE):4130 self.EXTTYPE = EXTTYPE4131 def get_FILEID(self):4132 return self.FILEID4133 def set_FILEID(self, FILEID):4134 self.FILEID = FILEID4135 def get_valueOf_(self):4136 return self.valueOf_4137 def set_valueOf_(self, valueOf_):4138 self.valueOf_ = valueOf_4139 def export(4140 self,4141 outfile,4142 level,4143 namespace_='',4144 name_='areaType',4145 namespacedef_='',4146 ):4147 showIndent(outfile, level)4148 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_4149 and ' ' + namespacedef_ or ''))4150 self.exportAttributes(outfile, level, [], namespace_,4151 name_='areaType')4152 if self.hasContent_():4153 outfile.write('>')4154 outfile.write(self.valueOf_)4155 self.exportChildren(outfile, level + 1, namespace_, name_)4156 outfile.write('</%s%s>\n' % (namespace_, name_))4157 else:4158 outfile.write('/>\n')4159 def exportAttributes(4160 self,4161 outfile,4162 level,4163 already_processed,4164 namespace_='',4165 name_='areaType',4166 ):4167 if self.BEGIN is not None and 'BEGIN' not in already_processed:4168 already_processed.append('BEGIN')4169 outfile.write(' BEGIN=%s'4170 % (self.gds_format_string(quote_attrib(self.BEGIN).encode(ExternalEncoding),4171 input_name='BEGIN'), ))4172 if self.END is not None and 'END' not in already_processed:4173 already_processed.append('END')4174 outfile.write(' END=%s'4175 % (self.gds_format_string(quote_attrib(self.END).encode(ExternalEncoding),4176 input_name='END'), ))4177 if self.BETYPE is not None and 'BETYPE' \4178 not in already_processed:4179 already_processed.append('BETYPE')4180 outfile.write(' BETYPE=%s'4181 % (self.gds_format_string(quote_attrib(self.BETYPE).encode(ExternalEncoding),4182 input_name='BETYPE'), ))4183 if self.SHAPE is not None and 'SHAPE' not in already_processed:4184 already_processed.append('SHAPE')4185 outfile.write(' SHAPE=%s'4186 % (self.gds_format_string(quote_attrib(self.SHAPE).encode(ExternalEncoding),4187 input_name='SHAPE'), ))4188 if self.COORDS is not None and 'COORDS' \4189 not in already_processed:4190 already_processed.append('COORDS')4191 outfile.write(' COORDS=%s'4192 % (self.gds_format_string(quote_attrib(self.COORDS).encode(ExternalEncoding),4193 input_name='COORDS'), ))4194 if self.EXTENT is not None and 'EXTENT' \4195 not in already_processed:4196 already_processed.append('EXTENT')4197 outfile.write(' EXTENT=%s'4198 % (self.gds_format_string(quote_attrib(self.EXTENT).encode(ExternalEncoding),4199 input_name='EXTENT'), ))4200 if self.CONTENTIDS is not None and 'CONTENTIDS' \4201 not in already_processed:4202 already_processed.append('CONTENTIDS')4203 outfile.write(' CONTENTIDS=%s'4204 % (quote_attrib(self.CONTENTIDS), ))4205 if self.ADMID is not None and 'ADMID' not in already_processed:4206 already_processed.append('ADMID')4207 outfile.write(' ADMID=%s'4208 % (self.gds_format_string(quote_attrib(self.ADMID).encode(ExternalEncoding),4209 input_name='ADMID'), ))4210 if self.ID is not None and 'ID' not in already_processed:4211 already_processed.append('ID')4212 outfile.write(' ID=%s'4213 % (self.gds_format_string(quote_attrib(self.ID).encode(ExternalEncoding),4214 input_name='ID'), ))4215 if self.EXTTYPE is not None and 'EXTTYPE' \4216 not in already_processed:4217 already_processed.append('EXTTYPE')4218 outfile.write(' EXTTYPE=%s'4219 % (self.gds_format_string(quote_attrib(self.EXTTYPE).encode(ExternalEncoding),4220 input_name='EXTTYPE'), ))4221 if self.FILEID is not None and 'FILEID' \4222 not in already_processed:4223 already_processed.append('FILEID')4224 outfile.write(' FILEID=%s'4225 % (self.gds_format_string(quote_attrib(self.FILEID).encode(ExternalEncoding),4226 input_name='FILEID'), ))4227 def exportChildren(4228 self,4229 outfile,4230 level,4231 namespace_='',4232 name_='areaType',4233 ):4234 pass4235 def hasContent_(self):4236 if self.valueOf_:4237 return True4238 else:4239 return False4240 def exportLiteral(4241 self,4242 outfile,4243 level,4244 name_='areaType',4245 ):4246 level += 14247 self.exportLiteralAttributes(outfile, level, [], name_)4248 if self.hasContent_():4249 self.exportLiteralChildren(outfile, level, name_)4250 showIndent(outfile, level)4251 outfile.write('valueOf_ = """%s""",\n' % (self.valueOf_, ))4252 def exportLiteralAttributes(4253 self,4254 outfile,4255 level,4256 already_processed,4257 name_,4258 ):4259 if self.BEGIN is not None and 'BEGIN' not in already_processed:4260 already_processed.append('BEGIN')4261 showIndent(outfile, level)4262 outfile.write('BEGIN = "%s",\n' % (self.BEGIN, ))4263 if self.END is not None and 'END' not in already_processed:4264 already_processed.append('END')4265 showIndent(outfile, level)4266 outfile.write('END = "%s",\n' % (self.END, ))4267 if self.BETYPE is not None and 'BETYPE' \4268 not in already_processed:4269 already_processed.append('BETYPE')4270 showIndent(outfile, level)4271 outfile.write('BETYPE = "%s",\n' % (self.BETYPE, ))4272 if self.SHAPE is not None and 'SHAPE' not in already_processed:4273 already_processed.append('SHAPE')4274 showIndent(outfile, level)4275 outfile.write('SHAPE = "%s",\n' % (self.SHAPE, ))4276 if self.COORDS is not None and 'COORDS' \4277 not in already_processed:4278 already_processed.append('COORDS')4279 showIndent(outfile, level)4280 outfile.write('COORDS = "%s",\n' % (self.COORDS, ))4281 if self.EXTENT is not None and 'EXTENT' \4282 not in already_processed:4283 already_processed.append('EXTENT')4284 showIndent(outfile, level)4285 outfile.write('EXTENT = "%s",\n' % (self.EXTENT, ))4286 if self.CONTENTIDS is not None and 'CONTENTIDS' \4287 not in already_processed:4288 already_processed.append('CONTENTIDS')4289 showIndent(outfile, level)4290 outfile.write('CONTENTIDS = "%s",\n' % (self.CONTENTIDS, ))4291 if self.ADMID is not None and 'ADMID' not in already_processed:4292 already_processed.append('ADMID')4293 showIndent(outfile, level)4294 outfile.write('ADMID = "%s",\n' % (self.ADMID, ))4295 if self.ID is not None and 'ID' not in already_processed:4296 already_processed.append('ID')4297 showIndent(outfile, level)4298 outfile.write('ID = "%s",\n' % (self.ID, ))4299 if self.EXTTYPE is not None and 'EXTTYPE' \4300 not in already_processed:4301 already_processed.append('EXTTYPE')4302 showIndent(outfile, level)4303 outfile.write('EXTTYPE = "%s",\n' % (self.EXTTYPE, ))4304 if self.FILEID is not None and 'FILEID' \4305 not in already_processed:4306 already_processed.append('FILEID')4307 showIndent(outfile, level)4308 outfile.write('FILEID = "%s",\n' % (self.FILEID, ))4309 def exportLiteralChildren(4310 self,4311 outfile,4312 level,4313 name_,4314 ):4315 pass4316 def build(self, node):4317 self.buildAttributes(node, node.attrib, [])4318 self.valueOf_ = get_all_text_(node)4319 for child in node:4320 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]4321 self.buildChildren(child, node, nodeName_)4322 def buildAttributes(4323 self,4324 node,4325 attrs,4326 already_processed,4327 ):4328 value = attrs.get('BEGIN')4329 if value is not None and 'BEGIN' not in already_processed:4330 already_processed.append('BEGIN')4331 self.BEGIN = value4332 value = attrs.get('END')4333 if value is not None and 'END' not in already_processed:4334 already_processed.append('END')4335 self.END = value4336 value = attrs.get('BETYPE')4337 if value is not None and 'BETYPE' not in already_processed:4338 already_processed.append('BETYPE')4339 self.BETYPE = value4340 value = attrs.get('SHAPE')4341 if value is not None and 'SHAPE' not in already_processed:4342 already_processed.append('SHAPE')4343 self.SHAPE = value4344 value = attrs.get('COORDS')4345 if value is not None and 'COORDS' not in already_processed:4346 already_processed.append('COORDS')4347 self.COORDS = value4348 value = attrs.get('EXTENT')4349 if value is not None and 'EXTENT' not in already_processed:4350 already_processed.append('EXTENT')4351 self.EXTENT = value4352 value = attrs.get('CONTENTIDS')4353 if value is not None and 'CONTENTIDS' not in already_processed:4354 already_processed.append('CONTENTIDS')4355 self.CONTENTIDS = value4356 self.validate_URIs(self.CONTENTIDS) # validate type URIs4357 value = attrs.get('ADMID')4358 if value is not None and 'ADMID' not in already_processed:4359 already_processed.append('ADMID')4360 self.ADMID = value4361 value = attrs.get('ID')4362 if value is not None and 'ID' not in already_processed:4363 already_processed.append('ID')4364 self.ID = value4365 value = attrs.get('EXTTYPE')4366 if value is not None and 'EXTTYPE' not in already_processed:4367 already_processed.append('EXTTYPE')4368 self.EXTTYPE = value4369 value = attrs.get('FILEID')4370 if value is not None and 'FILEID' not in already_processed:4371 already_processed.append('FILEID')4372 self.FILEID = value4373 def buildChildren(4374 self,4375 child_,4376 node,4377 nodeName_,4378 from_subclass=False,4379 ):4380 pass4381# end class areaType4382class structLinkType(GeneratedsSuper):4383 """structLinkType: Complex Type for Structural Map Linking The4384 Structural Map Linking section allows for the specification of4385 hyperlinks between different components of a METS structure4386 delineated in a structural map. structLink contains a single,4387 repeatable element, smLink. Each smLink element indicates a4388 hyperlink between two nodes in the structMap. The structMap4389 nodes recorded in smLink are identified using their XML ID4390 attribute values. ID (ID/O): This attribute uniquely identifies4391 the element within the METS document, and would allow the4392 element to be referenced unambiguously from another element or4393 document via an IDREF or an XPTR. For more information on using4394 ID attributes for internal and external linking see Chapter 4 of4395 the METS Primer."""4396 subclass = None4397 superclass = None4398 def __init__(4399 self,4400 ID=None,4401 smLink=None,4402 smLinkGrp=None,4403 ):4404 self.ID = _cast(None, ID)4405 if smLink is None:4406 self.smLink = []4407 else:4408 self.smLink = smLink4409 if smLinkGrp is None:4410 self.smLinkGrp = []4411 else:4412 self.smLinkGrp = smLinkGrp4413 def factory(*args_, **kwargs_):4414 if structLinkType.subclass:4415 return structLinkType.subclass(*args_, **kwargs_)4416 else:4417 return structLinkType(*args_, **kwargs_)4418 factory = staticmethod(factory)4419 def get_smLink(self):4420 return self.smLink4421 def set_smLink(self, smLink):4422 self.smLink = smLink4423 def add_smLink(self, value):4424 self.smLink.append(value)4425 def insert_smLink(self, index, value):4426 self.smLink[index] = value4427 def get_smLinkGrp(self):4428 return self.smLinkGrp4429 def set_smLinkGrp(self, smLinkGrp):4430 self.smLinkGrp = smLinkGrp4431 def add_smLinkGrp(self, value):4432 self.smLinkGrp.append(value)4433 def insert_smLinkGrp(self, index, value):4434 self.smLinkGrp[index] = value4435 def get_ID(self):4436 return self.ID4437 def set_ID(self, ID):4438 self.ID = ID4439 def export(4440 self,4441 outfile,4442 level,4443 namespace_='',4444 name_='structLinkType',4445 namespacedef_='',4446 ):4447 showIndent(outfile, level)4448 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_4449 and ' ' + namespacedef_ or ''))4450 self.exportAttributes(outfile, level, [], namespace_,4451 name_='structLinkType')4452 if self.hasContent_():4453 outfile.write('>\n')4454 self.exportChildren(outfile, level + 1, namespace_, name_)4455 showIndent(outfile, level)4456 outfile.write('</%s%s>\n' % (namespace_, name_))4457 else:4458 outfile.write('/>\n')4459 def exportAttributes(4460 self,4461 outfile,4462 level,4463 already_processed,4464 namespace_='',4465 name_='structLinkType',4466 ):4467 if self.ID is not None and 'ID' not in already_processed:4468 already_processed.append('ID')4469 outfile.write(' ID=%s'4470 % (self.gds_format_string(quote_attrib(self.ID).encode(ExternalEncoding),4471 input_name='ID'), ))4472 def exportChildren(4473 self,4474 outfile,4475 level,4476 namespace_='',4477 name_='structLinkType',4478 ):4479 for smLink_ in self.smLink:4480 smLink_.export(outfile, level, namespace_, name_='smLink')4481 for smLinkGrp_ in self.smLinkGrp:4482 smLinkGrp_.export(outfile, level, namespace_,4483 name_='smLinkGrp')4484 def hasContent_(self):4485 if self.smLink or self.smLinkGrp:4486 return True4487 else:4488 return False4489 def exportLiteral(4490 self,4491 outfile,4492 level,4493 name_='structLinkType',4494 ):4495 level += 14496 self.exportLiteralAttributes(outfile, level, [], name_)4497 if self.hasContent_():4498 self.exportLiteralChildren(outfile, level, name_)4499 def exportLiteralAttributes(4500 self,4501 outfile,4502 level,4503 already_processed,4504 name_,4505 ):4506 if self.ID is not None and 'ID' not in already_processed:4507 already_processed.append('ID')4508 showIndent(outfile, level)4509 outfile.write('ID = "%s",\n' % (self.ID, ))4510 def exportLiteralChildren(4511 self,4512 outfile,4513 level,4514 name_,4515 ):4516 showIndent(outfile, level)4517 outfile.write('smLink=[\n')4518 level += 14519 for smLink_ in self.smLink:4520 showIndent(outfile, level)4521 outfile.write('model_.smLink(\n')4522 smLink_.exportLiteral(outfile, level)4523 showIndent(outfile, level)4524 outfile.write('),\n')4525 level -= 14526 showIndent(outfile, level)4527 outfile.write('],\n')4528 showIndent(outfile, level)4529 outfile.write('smLinkGrp=[\n')4530 level += 14531 for smLinkGrp_ in self.smLinkGrp:4532 showIndent(outfile, level)4533 outfile.write('model_.smLinkGrp(\n')4534 smLinkGrp_.exportLiteral(outfile, level)4535 showIndent(outfile, level)4536 outfile.write('),\n')4537 level -= 14538 showIndent(outfile, level)4539 outfile.write('],\n')4540 def build(self, node):4541 self.buildAttributes(node, node.attrib, [])4542 for child in node:4543 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]4544 self.buildChildren(child, node, nodeName_)4545 def buildAttributes(4546 self,4547 node,4548 attrs,4549 already_processed,4550 ):4551 value = attrs.get('ID')4552 if value is not None and 'ID' not in already_processed:4553 already_processed.append('ID')4554 self.ID = value4555 def buildChildren(4556 self,4557 child_,4558 node,4559 nodeName_,4560 from_subclass=False,4561 ):4562 if nodeName_ == 'smLink':4563 obj_ = smLink.factory()4564 obj_.build(child_)4565 self.smLink.append(obj_)4566 elif nodeName_ == 'smLinkGrp':4567 obj_ = smLinkGrp.factory()4568 obj_.build(child_)4569 self.smLinkGrp.append(obj_)4570# end class structLinkType4571class smLink(GeneratedsSuper):4572 """The Structural Map Link element <smLink> identifies a hyperlink4573 between two nodes in the structural map. You would use <smLink>,4574 for instance, to note the existence of hypertext links between4575 web pages, if you wished to record those links within METS.4576 NOTE: <smLink> is an empty element. The location of the <smLink>4577 element to which the <smLink> element is pointing MUST be stored4578 in the xlink:href attribute. ID (ID/O): This attribute uniquely4579 identifies the element within the METS document, and would allow4580 the element to be referenced unambiguously from another element4581 or document via an IDREF or an XPTR. For more information on4582 using ID attributes for internal and external linking see4583 Chapter 4 of the METS Primer. xlink:arcrole - the role of the4584 link, as per the xlink specification. See4585 http://www.w3.org/TR/xlink/ xlink:title - a title for the link4586 (if needed), as per the xlink specification. See4587 http://www.w3.org/TR/xlink/ xlink:show - see the xlink4588 specification at http://www.w3.org/TR/xlink/ xlink:actuate - see4589 the xlink specification at http://www.w3.org/TR/xlink/ xlink:to4590 - the value of the label for the element in the structMap you4591 are linking to. xlink:from - the value of the label for the4592 element in the structMap you are linking from."""4593 subclass = None4594 superclass = None4595 def __init__(4596 self,4597 fromxx=None,4598 show=None,4599 title=None,4600 actuate=None,4601 to=None,4602 arcrole=None,4603 ID=None,4604 valueOf_=None,4605 ):4606 self.fromxx = _cast(None, fromxx)4607 self.show = _cast(None, show)4608 self.title = _cast(None, title)4609 self.actuate = _cast(None, actuate)4610 self.to = _cast(None, to)4611 self.arcrole = _cast(None, arcrole)4612 self.ID = _cast(None, ID)4613 self.valueOf_ = valueOf_4614 def factory(*args_, **kwargs_):4615 if smLink.subclass:4616 return smLink.subclass(*args_, **kwargs_)4617 else:4618 return smLink(*args_, **kwargs_)4619 factory = staticmethod(factory)4620 def get_from(self):4621 return self.fromxx4622 def set_from(self, fromxx):4623 self.fromxx = fromxx4624 def get_show(self):4625 return self.show4626 def set_show(self, show):4627 self.show = show4628 def get_title(self):4629 return self.title4630 def set_title(self, title):4631 self.title = title4632 def get_actuate(self):4633 return self.actuate4634 def set_actuate(self, actuate):4635 self.actuate = actuate4636 def get_to(self):4637 return self.to4638 def set_to(self, to):4639 self.to = to4640 def get_arcrole(self):4641 return self.arcrole4642 def set_arcrole(self, arcrole):4643 self.arcrole = arcrole4644 def get_ID(self):4645 return self.ID4646 def set_ID(self, ID):4647 self.ID = ID4648 def get_valueOf_(self):4649 return self.valueOf_4650 def set_valueOf_(self, valueOf_):4651 self.valueOf_ = valueOf_4652 def export(4653 self,4654 outfile,4655 level,4656 namespace_='',4657 name_='smLink',4658 namespacedef_='',4659 ):4660 showIndent(outfile, level)4661 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_4662 and ' ' + namespacedef_ or ''))4663 self.exportAttributes(outfile, level, [], namespace_,4664 name_='smLink')4665 if self.hasContent_():4666 outfile.write('>')4667 outfile.write(self.valueOf_)4668 self.exportChildren(outfile, level + 1, namespace_, name_)4669 outfile.write('</%s%s>\n' % (namespace_, name_))4670 else:4671 outfile.write('/>\n')4672 def exportAttributes(4673 self,4674 outfile,4675 level,4676 already_processed,4677 namespace_='',4678 name_='smLink',4679 ):4680 if self.fromxx is not None and 'fromxx' \4681 not in already_processed:4682 already_processed.append('fromxx')4683 outfile.write(' from=%s'4684 % (self.gds_format_string(quote_attrib(self.fromxx).encode(ExternalEncoding),4685 input_name='from'), ))4686 if self.show is not None and 'show' not in already_processed:4687 already_processed.append('show')4688 outfile.write(' show=%s'4689 % (self.gds_format_string(quote_attrib(self.show).encode(ExternalEncoding),4690 input_name='show'), ))4691 if self.title is not None and 'title' not in already_processed:4692 already_processed.append('title')4693 outfile.write(' title=%s'4694 % (self.gds_format_string(quote_attrib(self.title).encode(ExternalEncoding),4695 input_name='title'), ))4696 if self.actuate is not None and 'actuate' \4697 not in already_processed:4698 already_processed.append('actuate')4699 outfile.write(' actuate=%s'4700 % (self.gds_format_string(quote_attrib(self.actuate).encode(ExternalEncoding),4701 input_name='actuate'), ))4702 if self.to is not None and 'to' not in already_processed:4703 already_processed.append('to')4704 outfile.write(' to=%s'4705 % (self.gds_format_string(quote_attrib(self.to).encode(ExternalEncoding),4706 input_name='to'), ))4707 if self.arcrole is not None and 'arcrole' \4708 not in already_processed:4709 already_processed.append('arcrole')4710 outfile.write(' arcrole=%s'4711 % (self.gds_format_string(quote_attrib(self.arcrole).encode(ExternalEncoding),4712 input_name='arcrole'), ))4713 if self.ID is not None and 'ID' not in already_processed:4714 already_processed.append('ID')4715 outfile.write(' ID=%s'4716 % (self.gds_format_string(quote_attrib(self.ID).encode(ExternalEncoding),4717 input_name='ID'), ))4718 def exportChildren(4719 self,4720 outfile,4721 level,4722 namespace_='',4723 name_='smLink',4724 ):4725 pass4726 def hasContent_(self):4727 if self.valueOf_:4728 return True4729 else:4730 return False4731 def exportLiteral(4732 self,4733 outfile,4734 level,4735 name_='smLink',4736 ):4737 level += 14738 self.exportLiteralAttributes(outfile, level, [], name_)4739 if self.hasContent_():4740 self.exportLiteralChildren(outfile, level, name_)4741 showIndent(outfile, level)4742 outfile.write('valueOf_ = """%s""",\n' % (self.valueOf_, ))4743 def exportLiteralAttributes(4744 self,4745 outfile,4746 level,4747 already_processed,4748 name_,4749 ):4750 if self.fromxx is not None and 'fromxx' \4751 not in already_processed:4752 already_processed.append('fromxx')4753 showIndent(outfile, level)4754 outfile.write('fromxx = "%s",\n' % (self.fromxx, ))4755 if self.show is not None and 'show' not in already_processed:4756 already_processed.append('show')4757 showIndent(outfile, level)4758 outfile.write('show = "%s",\n' % (self.show, ))4759 if self.title is not None and 'title' not in already_processed:4760 already_processed.append('title')4761 showIndent(outfile, level)4762 outfile.write('title = "%s",\n' % (self.title, ))4763 if self.actuate is not None and 'actuate' \4764 not in already_processed:4765 already_processed.append('actuate')4766 showIndent(outfile, level)4767 outfile.write('actuate = "%s",\n' % (self.actuate, ))4768 if self.to is not None and 'to' not in already_processed:4769 already_processed.append('to')4770 showIndent(outfile, level)4771 outfile.write('to = "%s",\n' % (self.to, ))4772 if self.arcrole is not None and 'arcrole' \4773 not in already_processed:4774 already_processed.append('arcrole')4775 showIndent(outfile, level)4776 outfile.write('arcrole = "%s",\n' % (self.arcrole, ))4777 if self.ID is not None and 'ID' not in already_processed:4778 already_processed.append('ID')4779 showIndent(outfile, level)4780 outfile.write('ID = "%s",\n' % (self.ID, ))4781 def exportLiteralChildren(4782 self,4783 outfile,4784 level,4785 name_,4786 ):4787 pass4788 def build(self, node):4789 self.buildAttributes(node, node.attrib, [])4790 self.valueOf_ = get_all_text_(node)4791 for child in node:4792 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]4793 self.buildChildren(child, node, nodeName_)4794 def buildAttributes(4795 self,4796 node,4797 attrs,4798 already_processed,4799 ):4800 value = attrs.get('from')4801 if value is not None and 'from' not in already_processed:4802 already_processed.append('from')4803 self.fromxx = value4804 value = attrs.get('show')4805 if value is not None and 'show' not in already_processed:4806 already_processed.append('show')4807 self.show = value4808 value = attrs.get('title')4809 if value is not None and 'title' not in already_processed:4810 already_processed.append('title')4811 self.title = value4812 value = attrs.get('actuate')4813 if value is not None and 'actuate' not in already_processed:4814 already_processed.append('actuate')4815 self.actuate = value4816 value = attrs.get('to')4817 if value is not None and 'to' not in already_processed:4818 already_processed.append('to')4819 self.to = value4820 value = attrs.get('arcrole')4821 if value is not None and 'arcrole' not in already_processed:4822 already_processed.append('arcrole')4823 self.arcrole = value4824 value = attrs.get('ID')4825 if value is not None and 'ID' not in already_processed:4826 already_processed.append('ID')4827 self.ID = value4828 def buildChildren(4829 self,4830 child_,4831 node,4832 nodeName_,4833 from_subclass=False,4834 ):4835 pass4836# end class smLink4837class smLinkGrp(GeneratedsSuper):4838 """The structMap link group element <smLinkGrp> provides an4839 implementation of xlink:extendLink, and provides xlink compliant4840 mechanisms for establishing xlink:arcLink type links between 24841 or more <div> elements in <structMap> element(s) occurring4842 within the same METS document or different METS documents. The4843 smLinkGrp could be used as an alternative to the <smLink>4844 element to establish a one-to-one link between <div> elements in4845 the same METS document in a fully xlink compliant manner.4846 However, it can also be used to establish one-to-many or many-4847 to-many links between <div> elements. For example, if a METS4848 document contains two <structMap> elements, one of which4849 represents a purely logical structure and one of which4850 represents a purely physical structure, the <smLinkGrp> element4851 would provide a means of mapping a <div> representing a logical4852 entity (for example, a newspaper article) with multiple <div>4853 elements in the physical <structMap> representing the physical4854 areas that together comprise the logical entity (for example,4855 the <div> elements representing the page areas that together4856 comprise the newspaper article). ARCLINKORDER (enumerated4857 string/O): ARCLINKORDER is used to indicate whether the order of4858 the smArcLink elements aggregated by the smLinkGrp element is4859 significant. If the order is significant, then a value of4860 "ordered" should be supplied. Value defaults to "unordered" Note4861 that the ARLINKORDER attribute has no xlink specified meaning."""4862 subclass = None4863 superclass = None4864 def __init__(4865 self,4866 role=None,4867 title=None,4868 ARCLINKORDER='unordered',4869 ID=None,4870 type_=None,4871 smLocatorLink=None,4872 smArcLink=None,4873 ):4874 self.role = _cast(None, role)4875 self.title = _cast(None, title)4876 self.ARCLINKORDER = _cast(None, ARCLINKORDER)4877 self.ID = _cast(None, ID)4878 self.type_ = _cast(None, type_)4879 if smLocatorLink is None:4880 self.smLocatorLink = []4881 else:4882 self.smLocatorLink = smLocatorLink4883 if smArcLink is None:4884 self.smArcLink = []4885 else:4886 self.smArcLink = smArcLink4887 def factory(*args_, **kwargs_):4888 if smLinkGrp.subclass:4889 return smLinkGrp.subclass(*args_, **kwargs_)4890 else:4891 return smLinkGrp(*args_, **kwargs_)4892 factory = staticmethod(factory)4893 def get_smLocatorLink(self):4894 return self.smLocatorLink4895 def set_smLocatorLink(self, smLocatorLink):4896 self.smLocatorLink = smLocatorLink4897 def add_smLocatorLink(self, value):4898 self.smLocatorLink.append(value)4899 def insert_smLocatorLink(self, index, value):4900 self.smLocatorLink[index] = value4901 def get_smArcLink(self):4902 return self.smArcLink4903 def set_smArcLink(self, smArcLink):4904 self.smArcLink = smArcLink4905 def add_smArcLink(self, value):4906 self.smArcLink.append(value)4907 def insert_smArcLink(self, index, value):4908 self.smArcLink[index] = value4909 def get_role(self):4910 return self.role4911 def set_role(self, role):4912 self.role = role4913 def get_title(self):4914 return self.title4915 def set_title(self, title):4916 self.title = title4917 def get_ARCLINKORDER(self):4918 return self.ARCLINKORDER4919 def set_ARCLINKORDER(self, ARCLINKORDER):4920 self.ARCLINKORDER = ARCLINKORDER4921 def get_ID(self):4922 return self.ID4923 def set_ID(self, ID):4924 self.ID = ID4925 def get_type(self):4926 return self.type_4927 def set_type(self, type_):4928 self.type_ = type_4929 def export(4930 self,4931 outfile,4932 level,4933 namespace_='',4934 name_='smLinkGrp',4935 namespacedef_='',4936 ):4937 showIndent(outfile, level)4938 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_4939 and ' ' + namespacedef_ or ''))4940 self.exportAttributes(outfile, level, [], namespace_,4941 name_='smLinkGrp')4942 if self.hasContent_():4943 outfile.write('>\n')4944 self.exportChildren(outfile, level + 1, namespace_, name_)4945 showIndent(outfile, level)4946 outfile.write('</%s%s>\n' % (namespace_, name_))4947 else:4948 outfile.write('/>\n')4949 def exportAttributes(4950 self,4951 outfile,4952 level,4953 already_processed,4954 namespace_='',4955 name_='smLinkGrp',4956 ):4957 if self.role is not None and 'role' not in already_processed:4958 already_processed.append('role')4959 outfile.write(' role=%s'4960 % (self.gds_format_string(quote_attrib(self.role).encode(ExternalEncoding),4961 input_name='role'), ))4962 if self.title is not None and 'title' not in already_processed:4963 already_processed.append('title')4964 outfile.write(' title=%s'4965 % (self.gds_format_string(quote_attrib(self.title).encode(ExternalEncoding),4966 input_name='title'), ))4967 if self.ARCLINKORDER is not None and 'ARCLINKORDER' \4968 not in already_processed:4969 already_processed.append('ARCLINKORDER')4970 outfile.write(' ARCLINKORDER=%s'4971 % (self.gds_format_string(quote_attrib(self.ARCLINKORDER).encode(ExternalEncoding),4972 input_name='ARCLINKORDER'), ))4973 if self.ID is not None and 'ID' not in already_processed:4974 already_processed.append('ID')4975 outfile.write(' ID=%s'4976 % (self.gds_format_string(quote_attrib(self.ID).encode(ExternalEncoding),4977 input_name='ID'), ))4978 if self.type_ is not None and 'type_' not in already_processed:4979 already_processed.append('type_')4980 outfile.write(' type=%s' % (quote_attrib(self.type_), ))4981 def exportChildren(4982 self,4983 outfile,4984 level,4985 namespace_='',4986 name_='smLinkGrp',4987 ):4988 for smLocatorLink_ in self.smLocatorLink:4989 smLocatorLink_.export(outfile, level, namespace_,4990 name_='smLocatorLink')4991 for smArcLink_ in self.smArcLink:4992 smArcLink_.export(outfile, level, namespace_,4993 name_='smArcLink')4994 def hasContent_(self):4995 if self.smLocatorLink or self.smArcLink:4996 return True4997 else:4998 return False4999 def exportLiteral(5000 self,5001 outfile,5002 level,5003 name_='smLinkGrp',5004 ):5005 level += 15006 self.exportLiteralAttributes(outfile, level, [], name_)5007 if self.hasContent_():5008 self.exportLiteralChildren(outfile, level, name_)5009 def exportLiteralAttributes(5010 self,5011 outfile,5012 level,5013 already_processed,5014 name_,5015 ):5016 if self.role is not None and 'role' not in already_processed:5017 already_processed.append('role')5018 showIndent(outfile, level)5019 outfile.write('role = "%s",\n' % (self.role, ))5020 if self.title is not None and 'title' not in already_processed:5021 already_processed.append('title')5022 showIndent(outfile, level)5023 outfile.write('title = "%s",\n' % (self.title, ))5024 if self.ARCLINKORDER is not None and 'ARCLINKORDER' \5025 not in already_processed:5026 already_processed.append('ARCLINKORDER')5027 showIndent(outfile, level)5028 outfile.write('ARCLINKORDER = "%s",\n'5029 % (self.ARCLINKORDER, ))5030 if self.ID is not None and 'ID' not in already_processed:5031 already_processed.append('ID')5032 showIndent(outfile, level)5033 outfile.write('ID = "%s",\n' % (self.ID, ))5034 if self.type_ is not None and 'type_' not in already_processed:5035 already_processed.append('type_')5036 showIndent(outfile, level)5037 outfile.write('type_ = %s,\n' % (self.type_, ))5038 def exportLiteralChildren(5039 self,5040 outfile,5041 level,5042 name_,5043 ):5044 showIndent(outfile, level)5045 outfile.write('smLocatorLink=[\n')5046 level += 15047 for smLocatorLink_ in self.smLocatorLink:5048 showIndent(outfile, level)5049 outfile.write('model_.smLocatorLink(\n')5050 smLocatorLink_.exportLiteral(outfile, level)5051 showIndent(outfile, level)5052 outfile.write('),\n')5053 level -= 15054 showIndent(outfile, level)5055 outfile.write('],\n')5056 showIndent(outfile, level)5057 outfile.write('smArcLink=[\n')5058 level += 15059 for smArcLink_ in self.smArcLink:5060 showIndent(outfile, level)5061 outfile.write('model_.smArcLink(\n')5062 smArcLink_.exportLiteral(outfile, level)5063 showIndent(outfile, level)5064 outfile.write('),\n')5065 level -= 15066 showIndent(outfile, level)5067 outfile.write('],\n')5068 def build(self, node):5069 self.buildAttributes(node, node.attrib, [])5070 for child in node:5071 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]5072 self.buildChildren(child, node, nodeName_)5073 def buildAttributes(5074 self,5075 node,5076 attrs,5077 already_processed,5078 ):5079 value = attrs.get('role')5080 if value is not None and 'role' not in already_processed:5081 already_processed.append('role')5082 self.role = value5083 value = attrs.get('title')5084 if value is not None and 'title' not in already_processed:5085 already_processed.append('title')5086 self.title = value5087 value = attrs.get('ARCLINKORDER')5088 if value is not None and 'ARCLINKORDER' \5089 not in already_processed:5090 already_processed.append('ARCLINKORDER')5091 self.ARCLINKORDER = value5092 value = attrs.get('ID')5093 if value is not None and 'ID' not in already_processed:5094 already_processed.append('ID')5095 self.ID = value5096 value = attrs.get('type')5097 if value is not None and 'type' not in already_processed:5098 already_processed.append('type')5099 self.type_ = value5100 def buildChildren(5101 self,5102 child_,5103 node,5104 nodeName_,5105 from_subclass=False,5106 ):5107 if nodeName_ == 'smLocatorLink':5108 obj_ = smLocatorLink.factory()5109 obj_.build(child_)5110 self.smLocatorLink.append(obj_)5111 elif nodeName_ == 'smArcLink':5112 obj_ = smArcLink.factory()5113 obj_.build(child_)5114 self.smArcLink.append(obj_)5115# end class smLinkGrp5116class smLocatorLink(GeneratedsSuper):5117 """The structMap locator link element <smLocatorLink> is of xlink:type5118 "locator". It provides a means of identifying a <div> element5119 that will participate in one or more of the links specified by5120 means of <smArcLink> elements within the same <smLinkGrp>. The5121 participating <div> element that is represented by the5122 <smLocatorLink> is identified by means of a URI in the associate5123 xlink:href attribute. The lowest level of this xlink:href URI5124 value should be a fragment identifier that references the ID5125 value that identifies the relevant <div> element. For example,5126 "xlink:href='#div20'" where "div20" is the ID value that5127 identifies the pertinent <div> in the current METS document.5128 Although not required by the xlink specification, an5129 <smLocatorLink> element will typically include an xlink:label5130 attribute in this context, as the <smArcLink> elements will5131 reference these labels to establish the from and to sides of5132 each arc link. ID (ID/O): This attribute uniquely identifies the5133 element within the METS document, and would allow the element to5134 be referenced unambiguously from another element or document via5135 an IDREF or an XPTR. For more information on using ID attributes5136 for internal and external linking see Chapter 4 of the METS5137 Primer."""5138 subclass = None5139 superclass = None5140 def __init__(5141 self,5142 title=None,5143 label=None,5144 href=None,5145 role=None,5146 type_=None,5147 ID=None,5148 valueOf_=None,5149 ):5150 self.title = _cast(None, title)5151 self.label = _cast(None, label)5152 self.href = _cast(None, href)5153 self.role = _cast(None, role)5154 self.type_ = _cast(None, type_)5155 self.ID = _cast(None, ID)5156 self.valueOf_ = valueOf_5157 def factory(*args_, **kwargs_):5158 if smLocatorLink.subclass:5159 return smLocatorLink.subclass(*args_, **kwargs_)5160 else:5161 return smLocatorLink(*args_, **kwargs_)5162 factory = staticmethod(factory)5163 def get_title(self):5164 return self.title5165 def set_title(self, title):5166 self.title = title5167 def get_label(self):5168 return self.label5169 def set_label(self, label):5170 self.label = label5171 def get_href(self):5172 return self.href5173 def set_href(self, href):5174 self.href = href5175 def get_role(self):5176 return self.role5177 def set_role(self, role):5178 self.role = role5179 def get_type(self):5180 return self.type_5181 def set_type(self, type_):5182 self.type_ = type_5183 def get_ID(self):5184 return self.ID5185 def set_ID(self, ID):5186 self.ID = ID5187 def get_valueOf_(self):5188 return self.valueOf_5189 def set_valueOf_(self, valueOf_):5190 self.valueOf_ = valueOf_5191 def export(5192 self,5193 outfile,5194 level,5195 namespace_='',5196 name_='smLocatorLink',5197 namespacedef_='',5198 ):5199 showIndent(outfile, level)5200 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_5201 and ' ' + namespacedef_ or ''))5202 self.exportAttributes(outfile, level, [], namespace_,5203 name_='smLocatorLink')5204 if self.hasContent_():5205 outfile.write('>')5206 outfile.write(self.valueOf_)5207 self.exportChildren(outfile, level + 1, namespace_, name_)5208 outfile.write('</%s%s>\n' % (namespace_, name_))5209 else:5210 outfile.write('/>\n')5211 def exportAttributes(5212 self,5213 outfile,5214 level,5215 already_processed,5216 namespace_='',5217 name_='smLocatorLink',5218 ):5219 if self.title is not None and 'title' not in already_processed:5220 already_processed.append('title')5221 outfile.write(' title=%s'5222 % (self.gds_format_string(quote_attrib(self.title).encode(ExternalEncoding),5223 input_name='title'), ))5224 if self.label is not None and 'label' not in already_processed:5225 already_processed.append('label')5226 outfile.write(' label=%s'5227 % (self.gds_format_string(quote_attrib(self.label).encode(ExternalEncoding),5228 input_name='label'), ))5229 if self.href is not None and 'href' not in already_processed:5230 already_processed.append('href')5231 outfile.write(' href=%s'5232 % (self.gds_format_string(quote_attrib(self.href).encode(ExternalEncoding),5233 input_name='href'), ))5234 if self.role is not None and 'role' not in already_processed:5235 already_processed.append('role')5236 outfile.write(' role=%s'5237 % (self.gds_format_string(quote_attrib(self.role).encode(ExternalEncoding),5238 input_name='role'), ))5239 if self.type_ is not None and 'type_' not in already_processed:5240 already_processed.append('type_')5241 outfile.write(' type=%s' % (quote_attrib(self.type_), ))5242 if self.ID is not None and 'ID' not in already_processed:5243 already_processed.append('ID')5244 outfile.write(' ID=%s'5245 % (self.gds_format_string(quote_attrib(self.ID).encode(ExternalEncoding),5246 input_name='ID'), ))5247 def exportChildren(5248 self,5249 outfile,5250 level,5251 namespace_='',5252 name_='smLocatorLink',5253 ):5254 pass5255 def hasContent_(self):5256 if self.valueOf_:5257 return True5258 else:5259 return False5260 def exportLiteral(5261 self,5262 outfile,5263 level,5264 name_='smLocatorLink',5265 ):5266 level += 15267 self.exportLiteralAttributes(outfile, level, [], name_)5268 if self.hasContent_():5269 self.exportLiteralChildren(outfile, level, name_)5270 showIndent(outfile, level)5271 outfile.write('valueOf_ = """%s""",\n' % (self.valueOf_, ))5272 def exportLiteralAttributes(5273 self,5274 outfile,5275 level,5276 already_processed,5277 name_,5278 ):5279 if self.title is not None and 'title' not in already_processed:5280 already_processed.append('title')5281 showIndent(outfile, level)5282 outfile.write('title = "%s",\n' % (self.title, ))5283 if self.label is not None and 'label' not in already_processed:5284 already_processed.append('label')5285 showIndent(outfile, level)5286 outfile.write('label = "%s",\n' % (self.label, ))5287 if self.href is not None and 'href' not in already_processed:5288 already_processed.append('href')5289 showIndent(outfile, level)5290 outfile.write('href = "%s",\n' % (self.href, ))5291 if self.role is not None and 'role' not in already_processed:5292 already_processed.append('role')5293 showIndent(outfile, level)5294 outfile.write('role = "%s",\n' % (self.role, ))5295 if self.type_ is not None and 'type_' not in already_processed:5296 already_processed.append('type_')5297 showIndent(outfile, level)5298 outfile.write('type_ = %s,\n' % (self.type_, ))5299 if self.ID is not None and 'ID' not in already_processed:5300 already_processed.append('ID')5301 showIndent(outfile, level)5302 outfile.write('ID = "%s",\n' % (self.ID, ))5303 def exportLiteralChildren(5304 self,5305 outfile,5306 level,5307 name_,5308 ):5309 pass5310 def build(self, node):5311 self.buildAttributes(node, node.attrib, [])5312 self.valueOf_ = get_all_text_(node)5313 for child in node:5314 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]5315 self.buildChildren(child, node, nodeName_)5316 def buildAttributes(5317 self,5318 node,5319 attrs,5320 already_processed,5321 ):5322 value = attrs.get('title')5323 if value is not None and 'title' not in already_processed:5324 already_processed.append('title')5325 self.title = value5326 value = attrs.get('label')5327 if value is not None and 'label' not in already_processed:5328 already_processed.append('label')5329 self.label = value5330 value = attrs.get('href')5331 if value is not None and 'href' not in already_processed:5332 already_processed.append('href')5333 self.href = value5334 value = attrs.get('role')5335 if value is not None and 'role' not in already_processed:5336 already_processed.append('role')5337 self.role = value5338 value = attrs.get('type')5339 if value is not None and 'type' not in already_processed:5340 already_processed.append('type')5341 self.type_ = value5342 value = attrs.get('ID')5343 if value is not None and 'ID' not in already_processed:5344 already_processed.append('ID')5345 self.ID = value5346 def buildChildren(5347 self,5348 child_,5349 node,5350 nodeName_,5351 from_subclass=False,5352 ):5353 pass5354# end class smLocatorLink5355class smArcLink(GeneratedsSuper):5356 """The structMap arc link element <smArcLink> is of xlink:type "arc" It5357 can be used to establish a traversal link between two <div>5358 elements as identified by <smLocatorLink> elements within the5359 same smLinkGrp element. The associated xlink:from and xlink:to5360 attributes identify the from and to sides of the arc link by5361 referencing the xlink:label attribute values on the5362 participating smLocatorLink elements. ID (ID/O): This attribute5363 uniquely identifies the element within the METS document, and5364 would allow the element to be referenced unambiguously from5365 another element or document via an IDREF or an XPTR. For more5366 information on using ID attributes for internal and external5367 linking see Chapter 4 of the METS Primer.ARCTYPE (string/O):The5368 ARCTYPE attribute provides a means of specifying the5369 relationship between the <div> elements participating in the arc5370 link, and hence the purpose or role of the link. While it can be5371 considered analogous to the xlink:arcrole attribute, its type is5372 a simple string, rather than anyURI. ARCTYPE has no xlink5373 specified meaning, and the xlink:arcrole attribute should be5374 used instead of or in addition to the ARCTYPE attribute when5375 full xlink compliance is desired with respect to specifying the5376 role or purpose of the arc link. ADMID (IDREFS/O): Contains the5377 ID attribute values identifying the <sourceMD>, <techMD>,5378 <digiprovMD> and/or <rightsMD> elements within the <amdSec> of5379 the METS document that contain or link to administrative5380 metadata pertaining to <smArcLink>. Typically the <smArcLink>5381 ADMID attribute would be used to identify one or more <sourceMD>5382 and/or <techMD> elements that refine or clarify the relationship5383 between the xlink:from and xlink:to sides of the arc. For more5384 information on using METS IDREFS and IDREF type attributes for5385 internal linking, see Chapter 4 of the METS Primer."""5386 subclass = None5387 superclass = None5388 def __init__(5389 self,5390 ADMID=None,5391 fromxx=None,5392 title=None,5393 show=None,5394 actuate=None,5395 ARCTYPE=None,5396 to=None,5397 arcrole=None,5398 type_=None,5399 ID=None,5400 valueOf_=None,5401 ):5402 self.ADMID = _cast(None, ADMID)5403 self.fromxx = _cast(None, fromxx)5404 self.title = _cast(None, title)5405 self.show = _cast(None, show)5406 self.actuate = _cast(None, actuate)5407 self.ARCTYPE = _cast(None, ARCTYPE)5408 self.to = _cast(None, to)5409 self.arcrole = _cast(None, arcrole)5410 self.type_ = _cast(None, type_)5411 self.ID = _cast(None, ID)5412 self.valueOf_ = valueOf_5413 def factory(*args_, **kwargs_):5414 if smArcLink.subclass:5415 return smArcLink.subclass(*args_, **kwargs_)5416 else:5417 return smArcLink(*args_, **kwargs_)5418 factory = staticmethod(factory)5419 def get_ADMID(self):5420 return self.ADMID5421 def set_ADMID(self, ADMID):5422 self.ADMID = ADMID5423 def get_from(self):5424 return self.fromxx5425 def set_from(self, fromxx):5426 self.fromxx = fromxx5427 def get_title(self):5428 return self.title5429 def set_title(self, title):5430 self.title = title5431 def get_show(self):5432 return self.show5433 def set_show(self, show):5434 self.show = show5435 def get_actuate(self):5436 return self.actuate5437 def set_actuate(self, actuate):5438 self.actuate = actuate5439 def get_ARCTYPE(self):5440 return self.ARCTYPE5441 def set_ARCTYPE(self, ARCTYPE):5442 self.ARCTYPE = ARCTYPE5443 def get_to(self):5444 return self.to5445 def set_to(self, to):5446 self.to = to5447 def get_arcrole(self):5448 return self.arcrole5449 def set_arcrole(self, arcrole):5450 self.arcrole = arcrole5451 def get_type(self):5452 return self.type_5453 def set_type(self, type_):5454 self.type_ = type_5455 def get_ID(self):5456 return self.ID5457 def set_ID(self, ID):5458 self.ID = ID5459 def get_valueOf_(self):5460 return self.valueOf_5461 def set_valueOf_(self, valueOf_):5462 self.valueOf_ = valueOf_5463 def export(5464 self,5465 outfile,5466 level,5467 namespace_='',5468 name_='smArcLink',5469 namespacedef_='',5470 ):5471 showIndent(outfile, level)5472 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_5473 and ' ' + namespacedef_ or ''))5474 self.exportAttributes(outfile, level, [], namespace_,5475 name_='smArcLink')5476 if self.hasContent_():5477 outfile.write('>')5478 outfile.write(self.valueOf_)5479 self.exportChildren(outfile, level + 1, namespace_, name_)5480 outfile.write('</%s%s>\n' % (namespace_, name_))5481 else:5482 outfile.write('/>\n')5483 def exportAttributes(5484 self,5485 outfile,5486 level,5487 already_processed,5488 namespace_='',5489 name_='smArcLink',5490 ):5491 if self.ADMID is not None and 'ADMID' not in already_processed:5492 already_processed.append('ADMID')5493 outfile.write(' ADMID=%s'5494 % (self.gds_format_string(quote_attrib(self.ADMID).encode(ExternalEncoding),5495 input_name='ADMID'), ))5496 if self.fromxx is not None and 'fromxx' \5497 not in already_processed:5498 already_processed.append('fromxx')5499 outfile.write(' from=%s'5500 % (self.gds_format_string(quote_attrib(self.fromxx).encode(ExternalEncoding),5501 input_name='from'), ))5502 if self.title is not None and 'title' not in already_processed:5503 already_processed.append('title')5504 outfile.write(' title=%s'5505 % (self.gds_format_string(quote_attrib(self.title).encode(ExternalEncoding),5506 input_name='title'), ))5507 if self.show is not None and 'show' not in already_processed:5508 already_processed.append('show')5509 outfile.write(' show=%s'5510 % (self.gds_format_string(quote_attrib(self.show).encode(ExternalEncoding),5511 input_name='show'), ))5512 if self.actuate is not None and 'actuate' \5513 not in already_processed:5514 already_processed.append('actuate')5515 outfile.write(' actuate=%s'5516 % (self.gds_format_string(quote_attrib(self.actuate).encode(ExternalEncoding),5517 input_name='actuate'), ))5518 if self.ARCTYPE is not None and 'ARCTYPE' \5519 not in already_processed:5520 already_processed.append('ARCTYPE')5521 outfile.write(' ARCTYPE=%s'5522 % (self.gds_format_string(quote_attrib(self.ARCTYPE).encode(ExternalEncoding),5523 input_name='ARCTYPE'), ))5524 if self.to is not None and 'to' not in already_processed:5525 already_processed.append('to')5526 outfile.write(' to=%s'5527 % (self.gds_format_string(quote_attrib(self.to).encode(ExternalEncoding),5528 input_name='to'), ))5529 if self.arcrole is not None and 'arcrole' \5530 not in already_processed:5531 already_processed.append('arcrole')5532 outfile.write(' arcrole=%s'5533 % (self.gds_format_string(quote_attrib(self.arcrole).encode(ExternalEncoding),5534 input_name='arcrole'), ))5535 if self.type_ is not None and 'type_' not in already_processed:5536 already_processed.append('type_')5537 outfile.write(' type=%s' % (quote_attrib(self.type_), ))5538 if self.ID is not None and 'ID' not in already_processed:5539 already_processed.append('ID')5540 outfile.write(' ID=%s'5541 % (self.gds_format_string(quote_attrib(self.ID).encode(ExternalEncoding),5542 input_name='ID'), ))5543 def exportChildren(5544 self,5545 outfile,5546 level,5547 namespace_='',5548 name_='smArcLink',5549 ):5550 pass5551 def hasContent_(self):5552 if self.valueOf_:5553 return True5554 else:5555 return False5556 def exportLiteral(5557 self,5558 outfile,5559 level,5560 name_='smArcLink',5561 ):5562 level += 15563 self.exportLiteralAttributes(outfile, level, [], name_)5564 if self.hasContent_():5565 self.exportLiteralChildren(outfile, level, name_)5566 showIndent(outfile, level)5567 outfile.write('valueOf_ = """%s""",\n' % (self.valueOf_, ))5568 def exportLiteralAttributes(5569 self,5570 outfile,5571 level,5572 already_processed,5573 name_,5574 ):5575 if self.ADMID is not None and 'ADMID' not in already_processed:5576 already_processed.append('ADMID')5577 showIndent(outfile, level)5578 outfile.write('ADMID = "%s",\n' % (self.ADMID, ))5579 if self.fromxx is not None and 'fromxx' \5580 not in already_processed:5581 already_processed.append('fromxx')5582 showIndent(outfile, level)5583 outfile.write('fromxx = "%s",\n' % (self.fromxx, ))5584 if self.title is not None and 'title' not in already_processed:5585 already_processed.append('title')5586 showIndent(outfile, level)5587 outfile.write('title = "%s",\n' % (self.title, ))5588 if self.show is not None and 'show' not in already_processed:5589 already_processed.append('show')5590 showIndent(outfile, level)5591 outfile.write('show = "%s",\n' % (self.show, ))5592 if self.actuate is not None and 'actuate' \5593 not in already_processed:5594 already_processed.append('actuate')5595 showIndent(outfile, level)5596 outfile.write('actuate = "%s",\n' % (self.actuate, ))5597 if self.ARCTYPE is not None and 'ARCTYPE' \5598 not in already_processed:5599 already_processed.append('ARCTYPE')5600 showIndent(outfile, level)5601 outfile.write('ARCTYPE = "%s",\n' % (self.ARCTYPE, ))5602 if self.to is not None and 'to' not in already_processed:5603 already_processed.append('to')5604 showIndent(outfile, level)5605 outfile.write('to = "%s",\n' % (self.to, ))5606 if self.arcrole is not None and 'arcrole' \5607 not in already_processed:5608 already_processed.append('arcrole')5609 showIndent(outfile, level)5610 outfile.write('arcrole = "%s",\n' % (self.arcrole, ))5611 if self.type_ is not None and 'type_' not in already_processed:5612 already_processed.append('type_')5613 showIndent(outfile, level)5614 outfile.write('type_ = %s,\n' % (self.type_, ))5615 if self.ID is not None and 'ID' not in already_processed:5616 already_processed.append('ID')5617 showIndent(outfile, level)5618 outfile.write('ID = "%s",\n' % (self.ID, ))5619 def exportLiteralChildren(5620 self,5621 outfile,5622 level,5623 name_,5624 ):5625 pass5626 def build(self, node):5627 self.buildAttributes(node, node.attrib, [])5628 self.valueOf_ = get_all_text_(node)5629 for child in node:5630 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]5631 self.buildChildren(child, node, nodeName_)5632 def buildAttributes(5633 self,5634 node,5635 attrs,5636 already_processed,5637 ):5638 value = attrs.get('ADMID')5639 if value is not None and 'ADMID' not in already_processed:5640 already_processed.append('ADMID')5641 self.ADMID = value5642 value = attrs.get('from')5643 if value is not None and 'from' not in already_processed:5644 already_processed.append('from')5645 self.fromxx = value5646 value = attrs.get('title')5647 if value is not None and 'title' not in already_processed:5648 already_processed.append('title')5649 self.title = value5650 value = attrs.get('show')5651 if value is not None and 'show' not in already_processed:5652 already_processed.append('show')5653 self.show = value5654 value = attrs.get('actuate')5655 if value is not None and 'actuate' not in already_processed:5656 already_processed.append('actuate')5657 self.actuate = value5658 value = attrs.get('ARCTYPE')5659 if value is not None and 'ARCTYPE' not in already_processed:5660 already_processed.append('ARCTYPE')5661 self.ARCTYPE = value5662 value = attrs.get('to')5663 if value is not None and 'to' not in already_processed:5664 already_processed.append('to')5665 self.to = value5666 value = attrs.get('arcrole')5667 if value is not None and 'arcrole' not in already_processed:5668 already_processed.append('arcrole')5669 self.arcrole = value5670 value = attrs.get('type')5671 if value is not None and 'type' not in already_processed:5672 already_processed.append('type')5673 self.type_ = value5674 value = attrs.get('ID')5675 if value is not None and 'ID' not in already_processed:5676 already_processed.append('ID')5677 self.ID = value5678 def buildChildren(5679 self,5680 child_,5681 node,5682 nodeName_,5683 from_subclass=False,5684 ):5685 pass5686# end class smArcLink5687class behaviorSecType(GeneratedsSuper):5688 """behaviorSecType: Complex Type for Behavior Sections Behaviors are5689 executable code which can be associated with parts of a METS5690 object. The behaviorSec element is used to group individual5691 behaviors within a hierarchical structure. Such grouping can be5692 useful to organize families of behaviors together or to indicate5693 other relationships between particular behaviors. ID (ID/O):5694 This attribute uniquely identifies the element within the METS5695 document, and would allow the element to be referenced5696 unambiguously from another element or document via an IDREF or5697 an XPTR. For more information on using ID attributes for5698 internal and external linking see Chapter 4 of the METS Primer.5699 CREATED (dateTime/O): Specifies the date and time of creation5700 for the <behaviorSec> LABEL (string/O): A text description of5701 the behavior section."""5702 subclass = None5703 superclass = None5704 def __init__(5705 self,5706 LABEL=None,5707 ID=None,5708 CREATED=None,5709 behaviorSec=None,5710 behavior=None,5711 ):5712 self.LABEL = _cast(None, LABEL)5713 self.ID = _cast(None, ID)5714 self.CREATED = _cast(None, CREATED)5715 if behaviorSec is None:5716 self.behaviorSec = []5717 else:5718 self.behaviorSec = behaviorSec5719 if behavior is None:5720 self.behavior = []5721 else:5722 self.behavior = behavior5723 def factory(*args_, **kwargs_):5724 if behaviorSecType.subclass:5725 return behaviorSecType.subclass(*args_, **kwargs_)5726 else:5727 return behaviorSecType(*args_, **kwargs_)5728 factory = staticmethod(factory)5729 def get_behaviorSec(self):5730 return self.behaviorSec5731 def set_behaviorSec(self, behaviorSec):5732 self.behaviorSec = behaviorSec5733 def add_behaviorSec(self, value):5734 self.behaviorSec.append(value)5735 def insert_behaviorSec(self, index, value):5736 self.behaviorSec[index] = value5737 def get_behavior(self):5738 return self.behavior5739 def set_behavior(self, behavior):5740 self.behavior = behavior5741 def add_behavior(self, value):5742 self.behavior.append(value)5743 def insert_behavior(self, index, value):5744 self.behavior[index] = value5745 def get_LABEL(self):5746 return self.LABEL5747 def set_LABEL(self, LABEL):5748 self.LABEL = LABEL5749 def get_ID(self):5750 return self.ID5751 def set_ID(self, ID):5752 self.ID = ID5753 def get_CREATED(self):5754 return self.CREATED5755 def set_CREATED(self, CREATED):5756 self.CREATED = CREATED5757 def export(5758 self,5759 outfile,5760 level,5761 namespace_='',5762 name_='behaviorSecType',5763 namespacedef_='',5764 ):5765 showIndent(outfile, level)5766 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_5767 and ' ' + namespacedef_ or ''))5768 self.exportAttributes(outfile, level, [], namespace_,5769 name_='behaviorSecType')5770 if self.hasContent_():5771 outfile.write('>\n')5772 self.exportChildren(outfile, level + 1, namespace_, name_)5773 showIndent(outfile, level)5774 outfile.write('</%s%s>\n' % (namespace_, name_))5775 else:5776 outfile.write('/>\n')5777 def exportAttributes(5778 self,5779 outfile,5780 level,5781 already_processed,5782 namespace_='',5783 name_='behaviorSecType',5784 ):5785 if self.LABEL is not None and 'LABEL' not in already_processed:5786 already_processed.append('LABEL')5787 outfile.write(' LABEL=%s'5788 % (self.gds_format_string(quote_attrib(self.LABEL).encode(ExternalEncoding),5789 input_name='LABEL'), ))5790 if self.ID is not None and 'ID' not in already_processed:5791 already_processed.append('ID')5792 outfile.write(' ID=%s'5793 % (self.gds_format_string(quote_attrib(self.ID).encode(ExternalEncoding),5794 input_name='ID'), ))5795 if self.CREATED is not None and 'CREATED' \5796 not in already_processed:5797 already_processed.append('CREATED')5798 outfile.write(' CREATED=%s'5799 % (self.gds_format_string(quote_attrib(self.CREATED).encode(ExternalEncoding),5800 input_name='CREATED'), ))5801 def exportChildren(5802 self,5803 outfile,5804 level,5805 namespace_='',5806 name_='behaviorSecType',5807 ):5808 for behaviorSec_ in self.behaviorSec:5809 behaviorSec_.export(outfile, level, namespace_,5810 name_='behaviorSec')5811 for behavior_ in self.behavior:5812 behavior_.export(outfile, level, namespace_,5813 name_='behavior')5814 def hasContent_(self):5815 if self.behaviorSec or self.behavior:5816 return True5817 else:5818 return False5819 def exportLiteral(5820 self,5821 outfile,5822 level,5823 name_='behaviorSecType',5824 ):5825 level += 15826 self.exportLiteralAttributes(outfile, level, [], name_)5827 if self.hasContent_():5828 self.exportLiteralChildren(outfile, level, name_)5829 def exportLiteralAttributes(5830 self,5831 outfile,5832 level,5833 already_processed,5834 name_,5835 ):5836 if self.LABEL is not None and 'LABEL' not in already_processed:5837 already_processed.append('LABEL')5838 showIndent(outfile, level)5839 outfile.write('LABEL = "%s",\n' % (self.LABEL, ))5840 if self.ID is not None and 'ID' not in already_processed:5841 already_processed.append('ID')5842 showIndent(outfile, level)5843 outfile.write('ID = "%s",\n' % (self.ID, ))5844 if self.CREATED is not None and 'CREATED' \5845 not in already_processed:5846 already_processed.append('CREATED')5847 showIndent(outfile, level)5848 outfile.write('CREATED = "%s",\n' % (self.CREATED, ))5849 def exportLiteralChildren(5850 self,5851 outfile,5852 level,5853 name_,5854 ):5855 showIndent(outfile, level)5856 outfile.write('behaviorSec=[\n')5857 level += 15858 for behaviorSec_ in self.behaviorSec:5859 showIndent(outfile, level)5860 outfile.write('model_.behaviorSecType(\n')5861 behaviorSec_.exportLiteral(outfile, level,5862 name_='behaviorSecType')5863 showIndent(outfile, level)5864 outfile.write('),\n')5865 level -= 15866 showIndent(outfile, level)5867 outfile.write('],\n')5868 showIndent(outfile, level)5869 outfile.write('behavior=[\n')5870 level += 15871 for behavior_ in self.behavior:5872 showIndent(outfile, level)5873 outfile.write('model_.behaviorType(\n')5874 behavior_.exportLiteral(outfile, level, name_='behaviorType'5875 )5876 showIndent(outfile, level)5877 outfile.write('),\n')5878 level -= 15879 showIndent(outfile, level)5880 outfile.write('],\n')5881 def build(self, node):5882 self.buildAttributes(node, node.attrib, [])5883 for child in node:5884 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]5885 self.buildChildren(child, node, nodeName_)5886 def buildAttributes(5887 self,5888 node,5889 attrs,5890 already_processed,5891 ):5892 value = attrs.get('LABEL')5893 if value is not None and 'LABEL' not in already_processed:5894 already_processed.append('LABEL')5895 self.LABEL = value5896 value = attrs.get('ID')5897 if value is not None and 'ID' not in already_processed:5898 already_processed.append('ID')5899 self.ID = value5900 value = attrs.get('CREATED')5901 if value is not None and 'CREATED' not in already_processed:5902 already_processed.append('CREATED')5903 self.CREATED = value5904 def buildChildren(5905 self,5906 child_,5907 node,5908 nodeName_,5909 from_subclass=False,5910 ):5911 if nodeName_ == 'behaviorSec':5912 obj_ = behaviorSecType.factory()5913 obj_.build(child_)5914 self.behaviorSec.append(obj_)5915 elif nodeName_ == 'behavior':5916 obj_ = behaviorType.factory()5917 obj_.build(child_)5918 self.behavior.append(obj_)5919# end class behaviorSecType5920class behaviorType(GeneratedsSuper):5921 """behaviorType: Complex Type for Behaviors A behavior can be used to5922 associate executable behaviors with content in the METS object.5923 A behavior element has an interface definition element that5924 represents an abstract definition of the set of behaviors5925 represented by a particular behavior. A behavior element also5926 has an behavior mechanism which is a module of executable code5927 that implements and runs the behavior defined abstractly by the5928 interface definition. ID (ID/O): This attribute uniquely5929 identifies the element within the METS document, and would allow5930 the element to be referenced unambiguously from another element5931 or document via an IDREF or an XPTR. In the case of a <behavior>5932 element that applies to a <transformFile> element, the ID value5933 must be present and would be referenced from the5934 transformFile/@TRANSFORMBEHAVIOR attribute. For more information5935 on using ID attributes for internal and external linking see5936 Chapter 4 of the METS Primer. STRUCTID (IDREFS/O): An XML IDREFS5937 attribute used to link a <behavior> to one or more <div>5938 elements within a <structMap> in the METS document. The content5939 to which the STRUCTID points is considered input to the5940 executable behavior mechanism defined for the behavior. If the5941 <behavior> applies to one or more <div> elements, then the5942 STRUCTID attribute must be present. BTYPE (string/O): The5943 behavior type provides a means of categorizing the related5944 behavior.CREATED (dateTime/O): The dateTime of creation for the5945 behavior. LABEL (string/O): A text description of the behavior.5946 GROUPID (string/O): An identifier that establishes a5947 correspondence between the given behavior and other behaviors,5948 typically used to facilitate versions of behaviors. ADMID5949 (IDREFS/O): An optional attribute listing the XML ID values of5950 administrative metadata sections within the METS document5951 pertaining to this behavior."""5952 subclass = None5953 superclass = None5954 def __init__(5955 self,5956 ADMID=None,5957 CREATED=None,5958 STRUCTID=None,5959 LABEL=None,5960 GROUPID=None,5961 BTYPE=None,5962 ID=None,5963 interfaceDef=None,5964 mechanism=None,5965 ):5966 self.ADMID = _cast(None, ADMID)5967 self.CREATED = _cast(None, CREATED)5968 self.STRUCTID = _cast(None, STRUCTID)5969 self.LABEL = _cast(None, LABEL)5970 self.GROUPID = _cast(None, GROUPID)5971 self.BTYPE = _cast(None, BTYPE)5972 self.ID = _cast(None, ID)5973 self.interfaceDef = interfaceDef5974 self.mechanism = mechanism5975 def factory(*args_, **kwargs_):5976 if behaviorType.subclass:5977 return behaviorType.subclass(*args_, **kwargs_)5978 else:5979 return behaviorType(*args_, **kwargs_)5980 factory = staticmethod(factory)5981 def get_interfaceDef(self):5982 return self.interfaceDef5983 def set_interfaceDef(self, interfaceDef):5984 self.interfaceDef = interfaceDef5985 def get_mechanism(self):5986 return self.mechanism5987 def set_mechanism(self, mechanism):5988 self.mechanism = mechanism5989 def get_ADMID(self):5990 return self.ADMID5991 def set_ADMID(self, ADMID):5992 self.ADMID = ADMID5993 def get_CREATED(self):5994 return self.CREATED5995 def set_CREATED(self, CREATED):5996 self.CREATED = CREATED5997 def get_STRUCTID(self):5998 return self.STRUCTID5999 def set_STRUCTID(self, STRUCTID):6000 self.STRUCTID = STRUCTID6001 def get_LABEL(self):6002 return self.LABEL6003 def set_LABEL(self, LABEL):6004 self.LABEL = LABEL6005 def get_GROUPID(self):6006 return self.GROUPID6007 def set_GROUPID(self, GROUPID):6008 self.GROUPID = GROUPID6009 def get_BTYPE(self):6010 return self.BTYPE6011 def set_BTYPE(self, BTYPE):6012 self.BTYPE = BTYPE6013 def get_ID(self):6014 return self.ID6015 def set_ID(self, ID):6016 self.ID = ID6017 def export(6018 self,6019 outfile,6020 level,6021 namespace_='',6022 name_='behaviorType',6023 namespacedef_='',6024 ):6025 showIndent(outfile, level)6026 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_6027 and ' ' + namespacedef_ or ''))6028 self.exportAttributes(outfile, level, [], namespace_,6029 name_='behaviorType')6030 if self.hasContent_():6031 outfile.write('>\n')6032 self.exportChildren(outfile, level + 1, namespace_, name_)6033 showIndent(outfile, level)6034 outfile.write('</%s%s>\n' % (namespace_, name_))6035 else:6036 outfile.write('/>\n')6037 def exportAttributes(6038 self,6039 outfile,6040 level,6041 already_processed,6042 namespace_='',6043 name_='behaviorType',6044 ):6045 if self.ADMID is not None and 'ADMID' not in already_processed:6046 already_processed.append('ADMID')6047 outfile.write(' ADMID=%s'6048 % (self.gds_format_string(quote_attrib(self.ADMID).encode(ExternalEncoding),6049 input_name='ADMID'), ))6050 if self.CREATED is not None and 'CREATED' \6051 not in already_processed:6052 already_processed.append('CREATED')6053 outfile.write(' CREATED=%s'6054 % (self.gds_format_string(quote_attrib(self.CREATED).encode(ExternalEncoding),6055 input_name='CREATED'), ))6056 if self.STRUCTID is not None and 'STRUCTID' \6057 not in already_processed:6058 already_processed.append('STRUCTID')6059 outfile.write(' STRUCTID=%s'6060 % (self.gds_format_string(quote_attrib(self.STRUCTID).encode(ExternalEncoding),6061 input_name='STRUCTID'), ))6062 if self.LABEL is not None and 'LABEL' not in already_processed:6063 already_processed.append('LABEL')6064 outfile.write(' LABEL=%s'6065 % (self.gds_format_string(quote_attrib(self.LABEL).encode(ExternalEncoding),6066 input_name='LABEL'), ))6067 if self.GROUPID is not None and 'GROUPID' \6068 not in already_processed:6069 already_processed.append('GROUPID')6070 outfile.write(' GROUPID=%s'6071 % (self.gds_format_string(quote_attrib(self.GROUPID).encode(ExternalEncoding),6072 input_name='GROUPID'), ))6073 if self.BTYPE is not None and 'BTYPE' not in already_processed:6074 already_processed.append('BTYPE')6075 outfile.write(' BTYPE=%s'6076 % (self.gds_format_string(quote_attrib(self.BTYPE).encode(ExternalEncoding),6077 input_name='BTYPE'), ))6078 if self.ID is not None and 'ID' not in already_processed:6079 already_processed.append('ID')6080 outfile.write(' ID=%s'6081 % (self.gds_format_string(quote_attrib(self.ID).encode(ExternalEncoding),6082 input_name='ID'), ))6083 def exportChildren(6084 self,6085 outfile,6086 level,6087 namespace_='',6088 name_='behaviorType',6089 ):6090 if self.interfaceDef:6091 self.interfaceDef.export(outfile, level, namespace_,6092 name_='interfaceDef')6093 if self.mechanism:6094 self.mechanism.export(outfile, level, namespace_,6095 name_='mechanism')6096 def hasContent_(self):6097 if self.interfaceDef is not None or self.mechanism is not None:6098 return True6099 else:6100 return False6101 def exportLiteral(6102 self,6103 outfile,6104 level,6105 name_='behaviorType',6106 ):6107 level += 16108 self.exportLiteralAttributes(outfile, level, [], name_)6109 if self.hasContent_():6110 self.exportLiteralChildren(outfile, level, name_)6111 def exportLiteralAttributes(6112 self,6113 outfile,6114 level,6115 already_processed,6116 name_,6117 ):6118 if self.ADMID is not None and 'ADMID' not in already_processed:6119 already_processed.append('ADMID')6120 showIndent(outfile, level)6121 outfile.write('ADMID = "%s",\n' % (self.ADMID, ))6122 if self.CREATED is not None and 'CREATED' \6123 not in already_processed:6124 already_processed.append('CREATED')6125 showIndent(outfile, level)6126 outfile.write('CREATED = "%s",\n' % (self.CREATED, ))6127 if self.STRUCTID is not None and 'STRUCTID' \6128 not in already_processed:6129 already_processed.append('STRUCTID')6130 showIndent(outfile, level)6131 outfile.write('STRUCTID = "%s",\n' % (self.STRUCTID, ))6132 if self.LABEL is not None and 'LABEL' not in already_processed:6133 already_processed.append('LABEL')6134 showIndent(outfile, level)6135 outfile.write('LABEL = "%s",\n' % (self.LABEL, ))6136 if self.GROUPID is not None and 'GROUPID' \6137 not in already_processed:6138 already_processed.append('GROUPID')6139 showIndent(outfile, level)6140 outfile.write('GROUPID = "%s",\n' % (self.GROUPID, ))6141 if self.BTYPE is not None and 'BTYPE' not in already_processed:6142 already_processed.append('BTYPE')6143 showIndent(outfile, level)6144 outfile.write('BTYPE = "%s",\n' % (self.BTYPE, ))6145 if self.ID is not None and 'ID' not in already_processed:6146 already_processed.append('ID')6147 showIndent(outfile, level)6148 outfile.write('ID = "%s",\n' % (self.ID, ))6149 def exportLiteralChildren(6150 self,6151 outfile,6152 level,6153 name_,6154 ):6155 if self.interfaceDef is not None:6156 showIndent(outfile, level)6157 outfile.write('interfaceDef=model_.objectType(\n')6158 self.interfaceDef.exportLiteral(outfile, level,6159 name_='interfaceDef')6160 showIndent(outfile, level)6161 outfile.write('),\n')6162 if self.mechanism is not None:6163 showIndent(outfile, level)6164 outfile.write('mechanism=model_.objectType(\n')6165 self.mechanism.exportLiteral(outfile, level,6166 name_='mechanism')6167 showIndent(outfile, level)6168 outfile.write('),\n')6169 def build(self, node):6170 self.buildAttributes(node, node.attrib, [])6171 for child in node:6172 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]6173 self.buildChildren(child, node, nodeName_)6174 def buildAttributes(6175 self,6176 node,6177 attrs,6178 already_processed,6179 ):6180 value = attrs.get('ADMID')6181 if value is not None and 'ADMID' not in already_processed:6182 already_processed.append('ADMID')6183 self.ADMID = value6184 value = attrs.get('CREATED')6185 if value is not None and 'CREATED' not in already_processed:6186 already_processed.append('CREATED')6187 self.CREATED = value6188 value = attrs.get('STRUCTID')6189 if value is not None and 'STRUCTID' not in already_processed:6190 already_processed.append('STRUCTID')6191 self.STRUCTID = value6192 value = attrs.get('LABEL')6193 if value is not None and 'LABEL' not in already_processed:6194 already_processed.append('LABEL')6195 self.LABEL = value6196 value = attrs.get('GROUPID')6197 if value is not None and 'GROUPID' not in already_processed:6198 already_processed.append('GROUPID')6199 self.GROUPID = value6200 value = attrs.get('BTYPE')6201 if value is not None and 'BTYPE' not in already_processed:6202 already_processed.append('BTYPE')6203 self.BTYPE = value6204 value = attrs.get('ID')6205 if value is not None and 'ID' not in already_processed:6206 already_processed.append('ID')6207 self.ID = value6208 def buildChildren(6209 self,6210 child_,6211 node,6212 nodeName_,6213 from_subclass=False,6214 ):6215 if nodeName_ == 'interfaceDef':6216 obj_ = objectType.factory()6217 obj_.build(child_)6218 self.set_interfaceDef(obj_)6219 elif nodeName_ == 'mechanism':6220 obj_ = objectType.factory()6221 obj_.build(child_)6222 self.set_mechanism(obj_)6223# end class behaviorType6224class objectType(GeneratedsSuper):6225 """objectType: complexType for interfaceDef and mechanism elements The6226 mechanism and behavior elements point to external objects--an6227 interface definition object or an executable code object6228 respectively--which together constitute a behavior that can be6229 applied to one or more <div> elements in a <structMap>. ID6230 (ID/O): This attribute uniquely identifies the element within6231 the METS document, and would allow the element to be referenced6232 unambiguously from another element or document via an IDREF or6233 an XPTR. For more information on using ID attributes for6234 internal and external linking see Chapter 4 of the METS Primer.6235 LABEL (string/O): A text description of the entity represented."""6236 subclass = None6237 superclass = None6238 def __init__(6239 self,6240 arcrole=None,6241 title=None,6242 OTHERLOCTYPE=None,6243 show=None,6244 actuate=None,6245 LABEL=None,6246 href=None,6247 role=None,6248 LOCTYPE=None,6249 type_=None,6250 ID=None,6251 valueOf_=None,6252 ):6253 self.arcrole = _cast(None, arcrole)6254 self.title = _cast(None, title)6255 self.OTHERLOCTYPE = _cast(None, OTHERLOCTYPE)6256 self.show = _cast(None, show)6257 self.actuate = _cast(None, actuate)6258 self.LABEL = _cast(None, LABEL)6259 self.href = _cast(None, href)6260 self.role = _cast(None, role)6261 self.LOCTYPE = _cast(None, LOCTYPE)6262 self.type_ = _cast(None, type_)6263 self.ID = _cast(None, ID)6264 self.valueOf_ = valueOf_6265 def factory(*args_, **kwargs_):6266 if objectType.subclass:6267 return objectType.subclass(*args_, **kwargs_)6268 else:6269 return objectType(*args_, **kwargs_)6270 factory = staticmethod(factory)6271 def get_arcrole(self):6272 return self.arcrole6273 def set_arcrole(self, arcrole):6274 self.arcrole = arcrole6275 def get_title(self):6276 return self.title6277 def set_title(self, title):6278 self.title = title6279 def get_OTHERLOCTYPE(self):6280 return self.OTHERLOCTYPE6281 def set_OTHERLOCTYPE(self, OTHERLOCTYPE):6282 self.OTHERLOCTYPE = OTHERLOCTYPE6283 def get_show(self):6284 return self.show6285 def set_show(self, show):6286 self.show = show6287 def get_actuate(self):6288 return self.actuate6289 def set_actuate(self, actuate):6290 self.actuate = actuate6291 def get_LABEL(self):6292 return self.LABEL6293 def set_LABEL(self, LABEL):6294 self.LABEL = LABEL6295 def get_href(self):6296 return self.href6297 def set_href(self, href):6298 self.href = href6299 def get_role(self):6300 return self.role6301 def set_role(self, role):6302 self.role = role6303 def get_LOCTYPE(self):6304 return self.LOCTYPE6305 def set_LOCTYPE(self, LOCTYPE):6306 self.LOCTYPE = LOCTYPE6307 def get_type(self):6308 return self.type_6309 def set_type(self, type_):6310 self.type_ = type_6311 def get_ID(self):6312 return self.ID6313 def set_ID(self, ID):6314 self.ID = ID6315 def get_valueOf_(self):6316 return self.valueOf_6317 def set_valueOf_(self, valueOf_):6318 self.valueOf_ = valueOf_6319 def export(6320 self,6321 outfile,6322 level,6323 namespace_='',6324 name_='objectType',6325 namespacedef_='',6326 ):6327 showIndent(outfile, level)6328 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_6329 and ' ' + namespacedef_ or ''))6330 self.exportAttributes(outfile, level, [], namespace_,6331 name_='objectType')6332 if self.hasContent_():6333 outfile.write('>')6334 outfile.write(self.valueOf_)6335 self.exportChildren(outfile, level + 1, namespace_, name_)6336 outfile.write('</%s%s>\n' % (namespace_, name_))6337 else:6338 outfile.write('/>\n')6339 def exportAttributes(6340 self,6341 outfile,6342 level,6343 already_processed,6344 namespace_='',6345 name_='objectType',6346 ):6347 if self.arcrole is not None and 'arcrole' \6348 not in already_processed:6349 already_processed.append('arcrole')6350 outfile.write(' arcrole=%s'6351 % (self.gds_format_string(quote_attrib(self.arcrole).encode(ExternalEncoding),6352 input_name='arcrole'), ))6353 if self.title is not None and 'title' not in already_processed:6354 already_processed.append('title')6355 outfile.write(' title=%s'6356 % (self.gds_format_string(quote_attrib(self.title).encode(ExternalEncoding),6357 input_name='title'), ))6358 if self.OTHERLOCTYPE is not None and 'OTHERLOCTYPE' \6359 not in already_processed:6360 already_processed.append('OTHERLOCTYPE')6361 outfile.write(' OTHERLOCTYPE=%s'6362 % (self.gds_format_string(quote_attrib(self.OTHERLOCTYPE).encode(ExternalEncoding),6363 input_name='OTHERLOCTYPE'), ))6364 if self.show is not None and 'show' not in already_processed:6365 already_processed.append('show')6366 outfile.write(' show=%s'6367 % (self.gds_format_string(quote_attrib(self.show).encode(ExternalEncoding),6368 input_name='show'), ))6369 if self.actuate is not None and 'actuate' \6370 not in already_processed:6371 already_processed.append('actuate')6372 outfile.write(' actuate=%s'6373 % (self.gds_format_string(quote_attrib(self.actuate).encode(ExternalEncoding),6374 input_name='actuate'), ))6375 if self.LABEL is not None and 'LABEL' not in already_processed:6376 already_processed.append('LABEL')6377 outfile.write(' LABEL=%s'6378 % (self.gds_format_string(quote_attrib(self.LABEL).encode(ExternalEncoding),6379 input_name='LABEL'), ))6380 if self.href is not None and 'href' not in already_processed:6381 already_processed.append('href')6382 outfile.write(' href=%s'6383 % (self.gds_format_string(quote_attrib(self.href).encode(ExternalEncoding),6384 input_name='href'), ))6385 if self.role is not None and 'role' not in already_processed:6386 already_processed.append('role')6387 outfile.write(' role=%s'6388 % (self.gds_format_string(quote_attrib(self.role).encode(ExternalEncoding),6389 input_name='role'), ))6390 if self.LOCTYPE is not None and 'LOCTYPE' \6391 not in already_processed:6392 already_processed.append('LOCTYPE')6393 outfile.write(' LOCTYPE=%s'6394 % (self.gds_format_string(quote_attrib(self.LOCTYPE).encode(ExternalEncoding),6395 input_name='LOCTYPE'), ))6396 if self.type_ is not None and 'type_' not in already_processed:6397 already_processed.append('type_')6398 outfile.write(' type=%s' % (quote_attrib(self.type_), ))6399 if self.ID is not None and 'ID' not in already_processed:6400 already_processed.append('ID')6401 outfile.write(' ID=%s'6402 % (self.gds_format_string(quote_attrib(self.ID).encode(ExternalEncoding),6403 input_name='ID'), ))6404 def exportChildren(6405 self,6406 outfile,6407 level,6408 namespace_='',6409 name_='objectType',6410 ):6411 pass6412 def hasContent_(self):6413 if self.valueOf_:6414 return True6415 else:6416 return False6417 def exportLiteral(6418 self,6419 outfile,6420 level,6421 name_='objectType',6422 ):6423 level += 16424 self.exportLiteralAttributes(outfile, level, [], name_)6425 if self.hasContent_():6426 self.exportLiteralChildren(outfile, level, name_)6427 showIndent(outfile, level)6428 outfile.write('valueOf_ = """%s""",\n' % (self.valueOf_, ))6429 def exportLiteralAttributes(6430 self,6431 outfile,6432 level,6433 already_processed,6434 name_,6435 ):6436 if self.arcrole is not None and 'arcrole' \6437 not in already_processed:6438 already_processed.append('arcrole')6439 showIndent(outfile, level)6440 outfile.write('arcrole = "%s",\n' % (self.arcrole, ))6441 if self.title is not None and 'title' not in already_processed:6442 already_processed.append('title')6443 showIndent(outfile, level)6444 outfile.write('title = "%s",\n' % (self.title, ))6445 if self.OTHERLOCTYPE is not None and 'OTHERLOCTYPE' \6446 not in already_processed:6447 already_processed.append('OTHERLOCTYPE')6448 showIndent(outfile, level)6449 outfile.write('OTHERLOCTYPE = "%s",\n'6450 % (self.OTHERLOCTYPE, ))6451 if self.show is not None and 'show' not in already_processed:6452 already_processed.append('show')6453 showIndent(outfile, level)6454 outfile.write('show = "%s",\n' % (self.show, ))6455 if self.actuate is not None and 'actuate' \6456 not in already_processed:6457 already_processed.append('actuate')6458 showIndent(outfile, level)6459 outfile.write('actuate = "%s",\n' % (self.actuate, ))6460 if self.LABEL is not None and 'LABEL' not in already_processed:6461 already_processed.append('LABEL')6462 showIndent(outfile, level)6463 outfile.write('LABEL = "%s",\n' % (self.LABEL, ))6464 if self.href is not None and 'href' not in already_processed:6465 already_processed.append('href')6466 showIndent(outfile, level)6467 outfile.write('href = "%s",\n' % (self.href, ))6468 if self.role is not None and 'role' not in already_processed:6469 already_processed.append('role')6470 showIndent(outfile, level)6471 outfile.write('role = "%s",\n' % (self.role, ))6472 if self.LOCTYPE is not None and 'LOCTYPE' \6473 not in already_processed:6474 already_processed.append('LOCTYPE')6475 showIndent(outfile, level)6476 outfile.write('LOCTYPE = "%s",\n' % (self.LOCTYPE, ))6477 if self.type_ is not None and 'type_' not in already_processed:6478 already_processed.append('type_')6479 showIndent(outfile, level)6480 outfile.write('type_ = %s,\n' % (self.type_, ))6481 if self.ID is not None and 'ID' not in already_processed:6482 already_processed.append('ID')6483 showIndent(outfile, level)6484 outfile.write('ID = "%s",\n' % (self.ID, ))6485 def exportLiteralChildren(6486 self,6487 outfile,6488 level,6489 name_,6490 ):6491 pass6492 def build(self, node):6493 self.buildAttributes(node, node.attrib, [])6494 self.valueOf_ = get_all_text_(node)6495 for child in node:6496 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]6497 self.buildChildren(child, node, nodeName_)6498 def buildAttributes(6499 self,6500 node,6501 attrs,6502 already_processed,6503 ):6504 value = attrs.get('arcrole')6505 if value is not None and 'arcrole' not in already_processed:6506 already_processed.append('arcrole')6507 self.arcrole = value6508 value = attrs.get('title')6509 if value is not None and 'title' not in already_processed:6510 already_processed.append('title')6511 self.title = value6512 value = attrs.get('OTHERLOCTYPE')6513 if value is not None and 'OTHERLOCTYPE' \6514 not in already_processed:6515 already_processed.append('OTHERLOCTYPE')6516 self.OTHERLOCTYPE = value6517 value = attrs.get('show')6518 if value is not None and 'show' not in already_processed:6519 already_processed.append('show')6520 self.show = value6521 value = attrs.get('actuate')6522 if value is not None and 'actuate' not in already_processed:6523 already_processed.append('actuate')6524 self.actuate = value6525 value = attrs.get('LABEL')6526 if value is not None and 'LABEL' not in already_processed:6527 already_processed.append('LABEL')6528 self.LABEL = value6529 value = attrs.get('href')6530 if value is not None and 'href' not in already_processed:6531 already_processed.append('href')6532 self.href = value6533 value = attrs.get('role')6534 if value is not None and 'role' not in already_processed:6535 already_processed.append('role')6536 self.role = value6537 value = attrs.get('LOCTYPE')6538 if value is not None and 'LOCTYPE' not in already_processed:6539 already_processed.append('LOCTYPE')6540 self.LOCTYPE = value6541 value = attrs.get('type')6542 if value is not None and 'type' not in already_processed:6543 already_processed.append('type')6544 self.type_ = value6545 value = attrs.get('ID')6546 if value is not None and 'ID' not in already_processed:6547 already_processed.append('ID')6548 self.ID = value6549 def buildChildren(6550 self,6551 child_,6552 node,6553 nodeName_,6554 from_subclass=False,6555 ):6556 pass6557# end class objectType6558class mdSecType(GeneratedsSuper):6559 """mdSecType: Complex Type for Metadata Sections A generic framework6560 for pointing to/including metadata within a METS document, a la6561 Warwick Framework. ID (ID/R): This attribute uniquely identifies6562 the element within the METS document, and would allow the6563 element to be referenced unambiguously from another element or6564 document via an IDREF or an XPTR. The ID attribute on the6565 <dmdSec>, <techMD>, <sourceMD>, <rightsMD> and <digiprovMD>6566 elements (which are all of mdSecType) is required, and its value6567 should be referenced from one or more DMDID attributes (when the6568 ID identifies a <dmdSec> element) or ADMID attributes (when the6569 ID identifies a <techMD>, <sourceMD>, <rightsMD> or <digiprovMD>6570 element) that are associated with other elements in the METS6571 document. The following elements support references to a6572 <dmdSec> via a DMDID attribute: <file>, <stream>, <div>. The6573 following elements support references to <techMD>, <sourceMD>,6574 <rightsMD> and <digiprovMD> elements via an ADMID attribute:6575 <metsHdr>, <dmdSec>, <techMD>, <sourceMD>, <rightsMD>,6576 <digiprovMD>, <fileGrp>, <file>, <stream>, <div>, <area>,6577 <behavior>. For more information on using ID attributes for6578 internal and external linking see Chapter 4 of the METS Primer.6579 GROUPID (string/O): This identifier is used to indicate that6580 different metadata sections may be considered as part of a6581 group. Two metadata sections with the same GROUPID value are to6582 be considered part of the same group. For example this facility6583 might be used to group changed versions of the same metadata if6584 previous versions are maintained in a file for tracking6585 purposes. ADMID (IDREFS/O): Contains the ID attribute values of6586 the <digiprovMD>, <techMD>, <sourceMD> and/or <rightsMD>6587 elements within the <amdSec> of the METS document that contain6588 administrative metadata pertaining to the current mdSecType6589 element. Typically used in this context to reference6590 preservation metadata (digiprovMD) which applies to the current6591 metadata. For more information on using METS IDREFS and IDREF6592 type attributes for internal linking, see Chapter 4 of the METS6593 Primer. CREATED (dateTime/O): Specifies the date and time of6594 creation for the metadata. STATUS (string/O): Indicates the6595 status of this metadata (e.g., superseded, current, etc.)."""6596 subclass = None6597 superclass = None6598 def __init__(6599 self,6600 STATUS=None,6601 ADMID=None,6602 CREATED=None,6603 ID=None,6604 GROUPID=None,6605 mdRef=None,6606 mdWrap=None,6607 ):6608 self.STATUS = _cast(None, STATUS)6609 self.ADMID = _cast(None, ADMID)6610 self.CREATED = _cast(None, CREATED)6611 self.ID = _cast(None, ID)6612 self.GROUPID = _cast(None, GROUPID)6613 self.mdRef = mdRef6614 self.mdWrap = mdWrap6615 def factory(*args_, **kwargs_):6616 if mdSecType.subclass:6617 return mdSecType.subclass(*args_, **kwargs_)6618 else:6619 return mdSecType(*args_, **kwargs_)6620 factory = staticmethod(factory)6621 def get_mdRef(self):6622 return self.mdRef6623 def set_mdRef(self, mdRef):6624 self.mdRef = mdRef6625 def get_mdWrap(self):6626 return self.mdWrap6627 def set_mdWrap(self, mdWrap):6628 self.mdWrap = mdWrap6629 def get_STATUS(self):6630 return self.STATUS6631 def set_STATUS(self, STATUS):6632 self.STATUS = STATUS6633 def get_ADMID(self):6634 return self.ADMID6635 def set_ADMID(self, ADMID):6636 self.ADMID = ADMID6637 def get_CREATED(self):6638 return self.CREATED6639 def set_CREATED(self, CREATED):6640 self.CREATED = CREATED6641 def get_ID(self):6642 return self.ID6643 def set_ID(self, ID):6644 self.ID = ID6645 def get_GROUPID(self):6646 return self.GROUPID6647 def set_GROUPID(self, GROUPID):6648 self.GROUPID = GROUPID6649 def export(6650 self,6651 outfile,6652 level,6653 namespace_='',6654 name_='mdSecType',6655 namespacedef_='',6656 ):6657 showIndent(outfile, level)6658 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_6659 and ' ' + namespacedef_ or ''))6660 self.exportAttributes(outfile, level, [], namespace_,6661 name_='mdSecType')6662 if self.hasContent_():6663 outfile.write('>\n')6664 self.exportChildren(outfile, level + 1, namespace_, name_)6665 showIndent(outfile, level)6666 outfile.write('</%s%s>\n' % (namespace_, name_))6667 else:6668 outfile.write('/>\n')6669 def exportAttributes(6670 self,6671 outfile,6672 level,6673 already_processed,6674 namespace_='',6675 name_='mdSecType',6676 ):6677 if self.STATUS is not None and 'STATUS' \6678 not in already_processed:6679 already_processed.append('STATUS')6680 outfile.write(' STATUS=%s'6681 % (self.gds_format_string(quote_attrib(self.STATUS).encode(ExternalEncoding),6682 input_name='STATUS'), ))6683 if self.ADMID is not None and 'ADMID' not in already_processed:6684 already_processed.append('ADMID')6685 outfile.write(' ADMID=%s'6686 % (self.gds_format_string(quote_attrib(self.ADMID).encode(ExternalEncoding),6687 input_name='ADMID'), ))6688 if self.CREATED is not None and 'CREATED' \6689 not in already_processed:6690 already_processed.append('CREATED')6691 outfile.write(' CREATED=%s'6692 % (self.gds_format_string(quote_attrib(self.CREATED).encode(ExternalEncoding),6693 input_name='CREATED'), ))6694 if self.ID is not None and 'ID' not in already_processed:6695 already_processed.append('ID')6696 outfile.write(' ID=%s'6697 % (self.gds_format_string(quote_attrib(self.ID).encode(ExternalEncoding),6698 input_name='ID'), ))6699 if self.GROUPID is not None and 'GROUPID' \6700 not in already_processed:6701 already_processed.append('GROUPID')6702 outfile.write(' GROUPID=%s'6703 % (self.gds_format_string(quote_attrib(self.GROUPID).encode(ExternalEncoding),6704 input_name='GROUPID'), ))6705 def exportChildren(6706 self,6707 outfile,6708 level,6709 namespace_='',6710 name_='mdSecType',6711 ):6712 if self.mdRef:6713 self.mdRef.export(outfile, level, namespace_, name_='mdRef')6714 if self.mdWrap:6715 self.mdWrap.export(outfile, level, namespace_,6716 name_='mdWrap')6717 def hasContent_(self):6718 if self.mdRef is not None or self.mdWrap is not None:6719 return True6720 else:6721 return False6722 def exportLiteral(6723 self,6724 outfile,6725 level,6726 name_='mdSecType',6727 ):6728 level += 16729 self.exportLiteralAttributes(outfile, level, [], name_)6730 if self.hasContent_():6731 self.exportLiteralChildren(outfile, level, name_)6732 def exportLiteralAttributes(6733 self,6734 outfile,6735 level,6736 already_processed,6737 name_,6738 ):6739 if self.STATUS is not None and 'STATUS' \6740 not in already_processed:6741 already_processed.append('STATUS')6742 showIndent(outfile, level)6743 outfile.write('STATUS = "%s",\n' % (self.STATUS, ))6744 if self.ADMID is not None and 'ADMID' not in already_processed:6745 already_processed.append('ADMID')6746 showIndent(outfile, level)6747 outfile.write('ADMID = "%s",\n' % (self.ADMID, ))6748 if self.CREATED is not None and 'CREATED' \6749 not in already_processed:6750 already_processed.append('CREATED')6751 showIndent(outfile, level)6752 outfile.write('CREATED = "%s",\n' % (self.CREATED, ))6753 if self.ID is not None and 'ID' not in already_processed:6754 already_processed.append('ID')6755 showIndent(outfile, level)6756 outfile.write('ID = "%s",\n' % (self.ID, ))6757 if self.GROUPID is not None and 'GROUPID' \6758 not in already_processed:6759 already_processed.append('GROUPID')6760 showIndent(outfile, level)6761 outfile.write('GROUPID = "%s",\n' % (self.GROUPID, ))6762 def exportLiteralChildren(6763 self,6764 outfile,6765 level,6766 name_,6767 ):6768 if self.mdRef is not None:6769 showIndent(outfile, level)6770 outfile.write('mdRef=model_.mdRef(\n')6771 self.mdRef.exportLiteral(outfile, level)6772 showIndent(outfile, level)6773 outfile.write('),\n')6774 if self.mdWrap is not None:6775 showIndent(outfile, level)6776 outfile.write('mdWrap=model_.mdWrap(\n')6777 self.mdWrap.exportLiteral(outfile, level)6778 showIndent(outfile, level)6779 outfile.write('),\n')6780 def build(self, node):6781 self.buildAttributes(node, node.attrib, [])6782 for child in node:6783 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]6784 self.buildChildren(child, node, nodeName_)6785 def buildAttributes(6786 self,6787 node,6788 attrs,6789 already_processed,6790 ):6791 value = attrs.get('STATUS')6792 if value is not None and 'STATUS' not in already_processed:6793 already_processed.append('STATUS')6794 self.STATUS = value6795 value = attrs.get('ADMID')6796 if value is not None and 'ADMID' not in already_processed:6797 already_processed.append('ADMID')6798 self.ADMID = value6799 value = attrs.get('CREATED')6800 if value is not None and 'CREATED' not in already_processed:6801 already_processed.append('CREATED')6802 self.CREATED = value6803 value = attrs.get('ID')6804 if value is not None and 'ID' not in already_processed:6805 already_processed.append('ID')6806 self.ID = value6807 value = attrs.get('GROUPID')6808 if value is not None and 'GROUPID' not in already_processed:6809 already_processed.append('GROUPID')6810 self.GROUPID = value6811 def buildChildren(6812 self,6813 child_,6814 node,6815 nodeName_,6816 from_subclass=False,6817 ):6818 if nodeName_ == 'mdRef':6819 obj_ = mdRef.factory()6820 obj_.build(child_)6821 self.set_mdRef(obj_)6822 elif nodeName_ == 'mdWrap':6823 obj_ = mdWrap.factory()6824 obj_.build(child_)6825 self.set_mdWrap(obj_)6826# end class mdSecType6827class mdRef(GeneratedsSuper):6828 """The metadata reference element <mdRef> element is a generic element6829 used throughout the METS schema to provide a pointer to metadata6830 which resides outside the METS document. NB: <mdRef> is an empty6831 element. The location of the metadata must be recorded in the6832 xlink:href attribute, supplemented by the XPTR attribute as6833 needed. ID (ID/O): This attribute uniquely identifies the6834 element within the METS document, and would allow the element to6835 be referenced unambiguously from another element or document via6836 an IDREF or an XPTR. For more information on using ID attributes6837 for internal and external linking see Chapter 4 of the METS6838 Primer. LABEL (string/O): Provides a label to display to the6839 viewer of the METS document that identifies the associated6840 metadata. XPTR (string/O): Locates the point within a file to6841 which the <mdRef> element refers, if applicable."""6842 subclass = None6843 superclass = None6844 def __init__(6845 self,6846 MIMETYPE=None,6847 arcrole=None,6848 XPTR=None,6849 CHECKSUMTYPE=None,6850 show=None,6851 OTHERLOCTYPE=None,6852 CHECKSUM=None,6853 OTHERMDTYPE=None,6854 title=None,6855 actuate=None,6856 MDTYPE=None,6857 LABEL=None,6858 href=None,6859 role=None,6860 LOCTYPE=None,6861 MDTYPEVERSION=None,6862 CREATED=None,6863 type_=None,6864 ID=None,6865 SIZE=None,6866 valueOf_=None,6867 ):6868 self.MIMETYPE = _cast(None, MIMETYPE)6869 self.arcrole = _cast(None, arcrole)6870 self.XPTR = _cast(None, XPTR)6871 self.CHECKSUMTYPE = _cast(None, CHECKSUMTYPE)6872 self.show = _cast(None, show)6873 self.OTHERLOCTYPE = _cast(None, OTHERLOCTYPE)6874 self.CHECKSUM = _cast(None, CHECKSUM)6875 self.OTHERMDTYPE = _cast(None, OTHERMDTYPE)6876 self.title = _cast(None, title)6877 self.actuate = _cast(None, actuate)6878 self.MDTYPE = _cast(None, MDTYPE)6879 self.LABEL = _cast(None, LABEL)6880 self.href = _cast(None, href)6881 self.role = _cast(None, role)6882 self.LOCTYPE = _cast(None, LOCTYPE)6883 self.MDTYPEVERSION = _cast(None, MDTYPEVERSION)6884 self.CREATED = _cast(None, CREATED)6885 self.type_ = _cast(None, type_)6886 self.ID = _cast(None, ID)6887 self.SIZE = _cast(int, SIZE)6888 self.valueOf_ = valueOf_6889 def factory(*args_, **kwargs_):6890 if mdRef.subclass:6891 return mdRef.subclass(*args_, **kwargs_)6892 else:6893 return mdRef(*args_, **kwargs_)6894 factory = staticmethod(factory)6895 def get_MIMETYPE(self):6896 return self.MIMETYPE6897 def set_MIMETYPE(self, MIMETYPE):6898 self.MIMETYPE = MIMETYPE6899 def get_arcrole(self):6900 return self.arcrole6901 def set_arcrole(self, arcrole):6902 self.arcrole = arcrole6903 def get_XPTR(self):6904 return self.XPTR6905 def set_XPTR(self, XPTR):6906 self.XPTR = XPTR6907 def get_CHECKSUMTYPE(self):6908 return self.CHECKSUMTYPE6909 def set_CHECKSUMTYPE(self, CHECKSUMTYPE):6910 self.CHECKSUMTYPE = CHECKSUMTYPE6911 def get_show(self):6912 return self.show6913 def set_show(self, show):6914 self.show = show6915 def get_OTHERLOCTYPE(self):6916 return self.OTHERLOCTYPE6917 def set_OTHERLOCTYPE(self, OTHERLOCTYPE):6918 self.OTHERLOCTYPE = OTHERLOCTYPE6919 def get_CHECKSUM(self):6920 return self.CHECKSUM6921 def set_CHECKSUM(self, CHECKSUM):6922 self.CHECKSUM = CHECKSUM6923 def get_OTHERMDTYPE(self):6924 return self.OTHERMDTYPE6925 def set_OTHERMDTYPE(self, OTHERMDTYPE):6926 self.OTHERMDTYPE = OTHERMDTYPE6927 def get_title(self):6928 return self.title6929 def set_title(self, title):6930 self.title = title6931 def get_actuate(self):6932 return self.actuate6933 def set_actuate(self, actuate):6934 self.actuate = actuate6935 def get_MDTYPE(self):6936 return self.MDTYPE6937 def set_MDTYPE(self, MDTYPE):6938 self.MDTYPE = MDTYPE6939 def get_LABEL(self):6940 return self.LABEL6941 def set_LABEL(self, LABEL):6942 self.LABEL = LABEL6943 def get_href(self):6944 return self.href6945 def set_href(self, href):6946 self.href = href6947 def get_role(self):6948 return self.role6949 def set_role(self, role):6950 self.role = role6951 def get_LOCTYPE(self):6952 return self.LOCTYPE6953 def set_LOCTYPE(self, LOCTYPE):6954 self.LOCTYPE = LOCTYPE6955 def get_MDTYPEVERSION(self):6956 return self.MDTYPEVERSION6957 def set_MDTYPEVERSION(self, MDTYPEVERSION):6958 self.MDTYPEVERSION = MDTYPEVERSION6959 def get_CREATED(self):6960 return self.CREATED6961 def set_CREATED(self, CREATED):6962 self.CREATED = CREATED6963 def get_type(self):6964 return self.type_6965 def set_type(self, type_):6966 self.type_ = type_6967 def get_ID(self):6968 return self.ID6969 def set_ID(self, ID):6970 self.ID = ID6971 def get_SIZE(self):6972 return self.SIZE6973 def set_SIZE(self, SIZE):6974 self.SIZE = SIZE6975 def get_valueOf_(self):6976 return self.valueOf_6977 def set_valueOf_(self, valueOf_):6978 self.valueOf_ = valueOf_6979 def export(6980 self,6981 outfile,6982 level,6983 namespace_='',6984 name_='mdRef',6985 namespacedef_='',6986 ):6987 showIndent(outfile, level)6988 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_6989 and ' ' + namespacedef_ or ''))6990 self.exportAttributes(outfile, level, [], namespace_,6991 name_='mdRef')6992 if self.hasContent_():6993 outfile.write('>')6994 outfile.write(self.valueOf_)6995 self.exportChildren(outfile, level + 1, namespace_, name_)6996 outfile.write('</%s%s>\n' % (namespace_, name_))6997 else:6998 outfile.write('/>\n')6999 def exportAttributes(7000 self,7001 outfile,7002 level,7003 already_processed,7004 namespace_='',7005 name_='mdRef',7006 ):7007 if self.MIMETYPE is not None and 'MIMETYPE' \7008 not in already_processed:7009 already_processed.append('MIMETYPE')7010 outfile.write(' MIMETYPE=%s'7011 % (self.gds_format_string(quote_attrib(self.MIMETYPE).encode(ExternalEncoding),7012 input_name='MIMETYPE'), ))7013 if self.arcrole is not None and 'arcrole' \7014 not in already_processed:7015 already_processed.append('arcrole')7016 outfile.write(' arcrole=%s'7017 % (self.gds_format_string(quote_attrib(self.arcrole).encode(ExternalEncoding),7018 input_name='arcrole'), ))7019 if self.XPTR is not None and 'XPTR' not in already_processed:7020 already_processed.append('XPTR')7021 outfile.write(' XPTR=%s'7022 % (self.gds_format_string(quote_attrib(self.XPTR).encode(ExternalEncoding),7023 input_name='XPTR'), ))7024 if self.CHECKSUMTYPE is not None and 'CHECKSUMTYPE' \7025 not in already_processed:7026 already_processed.append('CHECKSUMTYPE')7027 outfile.write(' CHECKSUMTYPE=%s'7028 % (self.gds_format_string(quote_attrib(self.CHECKSUMTYPE).encode(ExternalEncoding),7029 input_name='CHECKSUMTYPE'), ))7030 if self.show is not None and 'show' not in already_processed:7031 already_processed.append('show')7032 outfile.write(' show=%s'7033 % (self.gds_format_string(quote_attrib(self.show).encode(ExternalEncoding),7034 input_name='show'), ))7035 if self.OTHERLOCTYPE is not None and 'OTHERLOCTYPE' \7036 not in already_processed:7037 already_processed.append('OTHERLOCTYPE')7038 outfile.write(' OTHERLOCTYPE=%s'7039 % (self.gds_format_string(quote_attrib(self.OTHERLOCTYPE).encode(ExternalEncoding),7040 input_name='OTHERLOCTYPE'), ))7041 if self.CHECKSUM is not None and 'CHECKSUM' \7042 not in already_processed:7043 already_processed.append('CHECKSUM')7044 outfile.write(' CHECKSUM=%s'7045 % (self.gds_format_string(quote_attrib(self.CHECKSUM).encode(ExternalEncoding),7046 input_name='CHECKSUM'), ))7047 if self.OTHERMDTYPE is not None and 'OTHERMDTYPE' \7048 not in already_processed:7049 already_processed.append('OTHERMDTYPE')7050 outfile.write(' OTHERMDTYPE=%s'7051 % (self.gds_format_string(quote_attrib(self.OTHERMDTYPE).encode(ExternalEncoding),7052 input_name='OTHERMDTYPE'), ))7053 if self.title is not None and 'title' not in already_processed:7054 already_processed.append('title')7055 outfile.write(' title=%s'7056 % (self.gds_format_string(quote_attrib(self.title).encode(ExternalEncoding),7057 input_name='title'), ))7058 if self.actuate is not None and 'actuate' \7059 not in already_processed:7060 already_processed.append('actuate')7061 outfile.write(' actuate=%s'7062 % (self.gds_format_string(quote_attrib(self.actuate).encode(ExternalEncoding),7063 input_name='actuate'), ))7064 if self.MDTYPE is not None and 'MDTYPE' \7065 not in already_processed:7066 already_processed.append('MDTYPE')7067 outfile.write(' MDTYPE=%s'7068 % (self.gds_format_string(quote_attrib(self.MDTYPE).encode(ExternalEncoding),7069 input_name='MDTYPE'), ))7070 if self.LABEL is not None and 'LABEL' not in already_processed:7071 already_processed.append('LABEL')7072 outfile.write(' LABEL=%s'7073 % (self.gds_format_string(quote_attrib(self.LABEL).encode(ExternalEncoding),7074 input_name='LABEL'), ))7075 if self.href is not None and 'href' not in already_processed:7076 already_processed.append('href')7077 outfile.write(' href=%s'7078 % (self.gds_format_string(quote_attrib(self.href).encode(ExternalEncoding),7079 input_name='href'), ))7080 if self.role is not None and 'role' not in already_processed:7081 already_processed.append('role')7082 outfile.write(' role=%s'7083 % (self.gds_format_string(quote_attrib(self.role).encode(ExternalEncoding),7084 input_name='role'), ))7085 if self.LOCTYPE is not None and 'LOCTYPE' \7086 not in already_processed:7087 already_processed.append('LOCTYPE')7088 outfile.write(' LOCTYPE=%s'7089 % (self.gds_format_string(quote_attrib(self.LOCTYPE).encode(ExternalEncoding),7090 input_name='LOCTYPE'), ))7091 if self.MDTYPEVERSION is not None and 'MDTYPEVERSION' \7092 not in already_processed:7093 already_processed.append('MDTYPEVERSION')7094 outfile.write(' MDTYPEVERSION=%s'7095 % (self.gds_format_string(quote_attrib(self.MDTYPEVERSION).encode(ExternalEncoding),7096 input_name='MDTYPEVERSION'), ))7097 if self.CREATED is not None and 'CREATED' \7098 not in already_processed:7099 already_processed.append('CREATED')7100 outfile.write(' CREATED=%s'7101 % (self.gds_format_string(quote_attrib(self.CREATED).encode(ExternalEncoding),7102 input_name='CREATED'), ))7103 if self.type_ is not None and 'type_' not in already_processed:7104 already_processed.append('type_')7105 outfile.write(' type=%s' % (quote_attrib(self.type_), ))7106 if self.ID is not None and 'ID' not in already_processed:7107 already_processed.append('ID')7108 outfile.write(' ID=%s'7109 % (self.gds_format_string(quote_attrib(self.ID).encode(ExternalEncoding),7110 input_name='ID'), ))7111 if self.SIZE is not None and 'SIZE' not in already_processed:7112 already_processed.append('SIZE')7113 outfile.write(' SIZE="%s"'7114 % self.gds_format_integer(self.SIZE,7115 input_name='SIZE'))7116 def exportChildren(7117 self,7118 outfile,7119 level,7120 namespace_='',7121 name_='mdRef',7122 ):7123 pass7124 def hasContent_(self):7125 if self.valueOf_:7126 return True7127 else:7128 return False7129 def exportLiteral(7130 self,7131 outfile,7132 level,7133 name_='mdRef',7134 ):7135 level += 17136 self.exportLiteralAttributes(outfile, level, [], name_)7137 if self.hasContent_():7138 self.exportLiteralChildren(outfile, level, name_)7139 showIndent(outfile, level)7140 outfile.write('valueOf_ = """%s""",\n' % (self.valueOf_, ))7141 def exportLiteralAttributes(7142 self,7143 outfile,7144 level,7145 already_processed,7146 name_,7147 ):7148 if self.MIMETYPE is not None and 'MIMETYPE' \7149 not in already_processed:7150 already_processed.append('MIMETYPE')7151 showIndent(outfile, level)7152 outfile.write('MIMETYPE = "%s",\n' % (self.MIMETYPE, ))7153 if self.arcrole is not None and 'arcrole' \7154 not in already_processed:7155 already_processed.append('arcrole')7156 showIndent(outfile, level)7157 outfile.write('arcrole = "%s",\n' % (self.arcrole, ))7158 if self.XPTR is not None and 'XPTR' not in already_processed:7159 already_processed.append('XPTR')7160 showIndent(outfile, level)7161 outfile.write('XPTR = "%s",\n' % (self.XPTR, ))7162 if self.CHECKSUMTYPE is not None and 'CHECKSUMTYPE' \7163 not in already_processed:7164 already_processed.append('CHECKSUMTYPE')7165 showIndent(outfile, level)7166 outfile.write('CHECKSUMTYPE = "%s",\n'7167 % (self.CHECKSUMTYPE, ))7168 if self.show is not None and 'show' not in already_processed:7169 already_processed.append('show')7170 showIndent(outfile, level)7171 outfile.write('show = "%s",\n' % (self.show, ))7172 if self.OTHERLOCTYPE is not None and 'OTHERLOCTYPE' \7173 not in already_processed:7174 already_processed.append('OTHERLOCTYPE')7175 showIndent(outfile, level)7176 outfile.write('OTHERLOCTYPE = "%s",\n'7177 % (self.OTHERLOCTYPE, ))7178 if self.CHECKSUM is not None and 'CHECKSUM' \7179 not in already_processed:7180 already_processed.append('CHECKSUM')7181 showIndent(outfile, level)7182 outfile.write('CHECKSUM = "%s",\n' % (self.CHECKSUM, ))7183 if self.OTHERMDTYPE is not None and 'OTHERMDTYPE' \7184 not in already_processed:7185 already_processed.append('OTHERMDTYPE')7186 showIndent(outfile, level)7187 outfile.write('OTHERMDTYPE = "%s",\n' % (self.OTHERMDTYPE,7188 ))7189 if self.title is not None and 'title' not in already_processed:7190 already_processed.append('title')7191 showIndent(outfile, level)7192 outfile.write('title = "%s",\n' % (self.title, ))7193 if self.actuate is not None and 'actuate' \7194 not in already_processed:7195 already_processed.append('actuate')7196 showIndent(outfile, level)7197 outfile.write('actuate = "%s",\n' % (self.actuate, ))7198 if self.MDTYPE is not None and 'MDTYPE' \7199 not in already_processed:7200 already_processed.append('MDTYPE')7201 showIndent(outfile, level)7202 outfile.write('MDTYPE = "%s",\n' % (self.MDTYPE, ))7203 if self.LABEL is not None and 'LABEL' not in already_processed:7204 already_processed.append('LABEL')7205 showIndent(outfile, level)7206 outfile.write('LABEL = "%s",\n' % (self.LABEL, ))7207 if self.href is not None and 'href' not in already_processed:7208 already_processed.append('href')7209 showIndent(outfile, level)7210 outfile.write('href = "%s",\n' % (self.href, ))7211 if self.role is not None and 'role' not in already_processed:7212 already_processed.append('role')7213 showIndent(outfile, level)7214 outfile.write('role = "%s",\n' % (self.role, ))7215 if self.LOCTYPE is not None and 'LOCTYPE' \7216 not in already_processed:7217 already_processed.append('LOCTYPE')7218 showIndent(outfile, level)7219 outfile.write('LOCTYPE = "%s",\n' % (self.LOCTYPE, ))7220 if self.MDTYPEVERSION is not None and 'MDTYPEVERSION' \7221 not in already_processed:7222 already_processed.append('MDTYPEVERSION')7223 showIndent(outfile, level)7224 outfile.write('MDTYPEVERSION = "%s",\n'7225 % (self.MDTYPEVERSION, ))7226 if self.CREATED is not None and 'CREATED' \7227 not in already_processed:7228 already_processed.append('CREATED')7229 showIndent(outfile, level)7230 outfile.write('CREATED = "%s",\n' % (self.CREATED, ))7231 if self.type_ is not None and 'type_' not in already_processed:7232 already_processed.append('type_')7233 showIndent(outfile, level)7234 outfile.write('type_ = %s,\n' % (self.type_, ))7235 if self.ID is not None and 'ID' not in already_processed:7236 already_processed.append('ID')7237 showIndent(outfile, level)7238 outfile.write('ID = "%s",\n' % (self.ID, ))7239 if self.SIZE is not None and 'SIZE' not in already_processed:7240 already_processed.append('SIZE')7241 showIndent(outfile, level)7242 outfile.write('SIZE = %d,\n' % (self.SIZE, ))7243 def exportLiteralChildren(7244 self,7245 outfile,7246 level,7247 name_,7248 ):7249 pass7250 def build(self, node):7251 self.buildAttributes(node, node.attrib, [])7252 self.valueOf_ = get_all_text_(node)7253 for child in node:7254 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]7255 self.buildChildren(child, node, nodeName_)7256 def buildAttributes(7257 self,7258 node,7259 attrs,7260 already_processed,7261 ):7262 value = attrs.get('MIMETYPE')7263 if value is not None and 'MIMETYPE' not in already_processed:7264 already_processed.append('MIMETYPE')7265 self.MIMETYPE = value7266 value = attrs.get('arcrole')7267 if value is not None and 'arcrole' not in already_processed:7268 already_processed.append('arcrole')7269 self.arcrole = value7270 value = attrs.get('XPTR')7271 if value is not None and 'XPTR' not in already_processed:7272 already_processed.append('XPTR')7273 self.XPTR = value7274 value = attrs.get('CHECKSUMTYPE')7275 if value is not None and 'CHECKSUMTYPE' \7276 not in already_processed:7277 already_processed.append('CHECKSUMTYPE')7278 self.CHECKSUMTYPE = value7279 value = attrs.get('show')7280 if value is not None and 'show' not in already_processed:7281 already_processed.append('show')7282 self.show = value7283 value = attrs.get('OTHERLOCTYPE')7284 if value is not None and 'OTHERLOCTYPE' \7285 not in already_processed:7286 already_processed.append('OTHERLOCTYPE')7287 self.OTHERLOCTYPE = value7288 value = attrs.get('CHECKSUM')7289 if value is not None and 'CHECKSUM' not in already_processed:7290 already_processed.append('CHECKSUM')7291 self.CHECKSUM = value7292 value = attrs.get('OTHERMDTYPE')7293 if value is not None and 'OTHERMDTYPE' not in already_processed:7294 already_processed.append('OTHERMDTYPE')7295 self.OTHERMDTYPE = value7296 value = attrs.get('title')7297 if value is not None and 'title' not in already_processed:7298 already_processed.append('title')7299 self.title = value7300 value = attrs.get('actuate')7301 if value is not None and 'actuate' not in already_processed:7302 already_processed.append('actuate')7303 self.actuate = value7304 value = attrs.get('MDTYPE')7305 if value is not None and 'MDTYPE' not in already_processed:7306 already_processed.append('MDTYPE')7307 self.MDTYPE = value7308 value = attrs.get('LABEL')7309 if value is not None and 'LABEL' not in already_processed:7310 already_processed.append('LABEL')7311 self.LABEL = value7312 value = attrs.get('href')7313 if value is not None and 'href' not in already_processed:7314 already_processed.append('href')7315 self.href = value7316 value = attrs.get('role')7317 if value is not None and 'role' not in already_processed:7318 already_processed.append('role')7319 self.role = value7320 value = attrs.get('LOCTYPE')7321 if value is not None and 'LOCTYPE' not in already_processed:7322 already_processed.append('LOCTYPE')7323 self.LOCTYPE = value7324 value = attrs.get('MDTYPEVERSION')7325 if value is not None and 'MDTYPEVERSION' \7326 not in already_processed:7327 already_processed.append('MDTYPEVERSION')7328 self.MDTYPEVERSION = value7329 value = attrs.get('CREATED')7330 if value is not None and 'CREATED' not in already_processed:7331 already_processed.append('CREATED')7332 self.CREATED = value7333 value = attrs.get('type')7334 if value is not None and 'type' not in already_processed:7335 already_processed.append('type')7336 self.type_ = value7337 value = attrs.get('ID')7338 if value is not None and 'ID' not in already_processed:7339 already_processed.append('ID')7340 self.ID = value7341 value = attrs.get('SIZE')7342 if value is not None and 'SIZE' not in already_processed:7343 already_processed.append('SIZE')7344 try:7345 self.SIZE = int(value)7346 except ValueError, exp:7347 raise_parse_error(node, 'Bad integer attribute: %s'7348 % exp)7349 def buildChildren(7350 self,7351 child_,7352 node,7353 nodeName_,7354 from_subclass=False,7355 ):7356 pass7357# end class mdRef7358class mdWrap(GeneratedsSuper):7359 """A metadata wrapper element <mdWrap> provides a wrapper around7360 metadata embedded within a METS document. The element is7361 repeatable. Such metadata can be in one of two forms: 1) XML-7362 encoded metadata, with the XML-encoding identifying itself as7363 belonging to a namespace other than the METS document namespace.7364 2) Any arbitrary binary or textual form, PROVIDED that the7365 metadata is Base64 encoded and wrapped in a <binData> element7366 within the internal descriptive metadata element. ID (ID/O):7367 This attribute uniquely identifies the element within the METS7368 document, and would allow the element to be referenced7369 unambiguously from another element or document via an IDREF or7370 an XPTR. For more information on using ID attributes for7371 internal and external linking see Chapter 4 of the METS Primer.7372 LABEL: an optional string attribute providing a label to display7373 to the viewer of the METS document identifying the metadata."""7374 subclass = None7375 superclass = None7376 def __init__(7377 self,7378 MIMETYPE=None,7379 CHECKSUMTYPE=None,7380 CREATED=None,7381 CHECKSUM=None,7382 OTHERMDTYPE=None,7383 MDTYPE=None,7384 LABEL=None,7385 MDTYPEVERSION=None,7386 ID=None,7387 SIZE=None,7388 binData=None,7389 xmlData=None,7390 ):7391 self.MIMETYPE = _cast(None, MIMETYPE)7392 self.CHECKSUMTYPE = _cast(None, CHECKSUMTYPE)7393 self.CREATED = _cast(None, CREATED)7394 self.CHECKSUM = _cast(None, CHECKSUM)7395 self.OTHERMDTYPE = _cast(None, OTHERMDTYPE)7396 self.MDTYPE = _cast(None, MDTYPE)7397 self.LABEL = _cast(None, LABEL)7398 self.MDTYPEVERSION = _cast(None, MDTYPEVERSION)7399 self.ID = _cast(None, ID)7400 self.SIZE = _cast(int, SIZE)7401 self.binData = binData7402 self.xmlData = xmlData7403 def factory(*args_, **kwargs_):7404 if mdWrap.subclass:7405 return mdWrap.subclass(*args_, **kwargs_)7406 else:7407 return mdWrap(*args_, **kwargs_)7408 factory = staticmethod(factory)7409 def get_binData(self):7410 return self.binData7411 def set_binData(self, binData):7412 self.binData = binData7413 def get_xmlData(self):7414 return self.xmlData7415 def set_xmlData(self, xmlData):7416 self.xmlData = xmlData7417 def get_MIMETYPE(self):7418 return self.MIMETYPE7419 def set_MIMETYPE(self, MIMETYPE):7420 self.MIMETYPE = MIMETYPE7421 def get_CHECKSUMTYPE(self):7422 return self.CHECKSUMTYPE7423 def set_CHECKSUMTYPE(self, CHECKSUMTYPE):7424 self.CHECKSUMTYPE = CHECKSUMTYPE7425 def get_CREATED(self):7426 return self.CREATED7427 def set_CREATED(self, CREATED):7428 self.CREATED = CREATED7429 def get_CHECKSUM(self):7430 return self.CHECKSUM7431 def set_CHECKSUM(self, CHECKSUM):7432 self.CHECKSUM = CHECKSUM7433 def get_OTHERMDTYPE(self):7434 return self.OTHERMDTYPE7435 def set_OTHERMDTYPE(self, OTHERMDTYPE):7436 self.OTHERMDTYPE = OTHERMDTYPE7437 def get_MDTYPE(self):7438 return self.MDTYPE7439 def set_MDTYPE(self, MDTYPE):7440 self.MDTYPE = MDTYPE7441 def get_LABEL(self):7442 return self.LABEL7443 def set_LABEL(self, LABEL):7444 self.LABEL = LABEL7445 def get_MDTYPEVERSION(self):7446 return self.MDTYPEVERSION7447 def set_MDTYPEVERSION(self, MDTYPEVERSION):7448 self.MDTYPEVERSION = MDTYPEVERSION7449 def get_ID(self):7450 return self.ID7451 def set_ID(self, ID):7452 self.ID = ID7453 def get_SIZE(self):7454 return self.SIZE7455 def set_SIZE(self, SIZE):7456 self.SIZE = SIZE7457 def export(7458 self,7459 outfile,7460 level,7461 namespace_='',7462 name_='mdWrap',7463 namespacedef_='',7464 ):7465 showIndent(outfile, level)7466 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_7467 and ' ' + namespacedef_ or ''))7468 self.exportAttributes(outfile, level, [], namespace_,7469 name_='mdWrap')7470 if self.hasContent_():7471 outfile.write('>\n')7472 self.exportChildren(outfile, level + 1, namespace_, name_)7473 showIndent(outfile, level)7474 outfile.write('</%s%s>\n' % (namespace_, name_))7475 else:7476 outfile.write('/>\n')7477 def exportAttributes(7478 self,7479 outfile,7480 level,7481 already_processed,7482 namespace_='',7483 name_='mdWrap',7484 ):7485 if self.MIMETYPE is not None and 'MIMETYPE' \7486 not in already_processed:7487 already_processed.append('MIMETYPE')7488 outfile.write(' MIMETYPE=%s'7489 % (self.gds_format_string(quote_attrib(self.MIMETYPE).encode(ExternalEncoding),7490 input_name='MIMETYPE'), ))7491 if self.CHECKSUMTYPE is not None and 'CHECKSUMTYPE' \7492 not in already_processed:7493 already_processed.append('CHECKSUMTYPE')7494 outfile.write(' CHECKSUMTYPE=%s'7495 % (self.gds_format_string(quote_attrib(self.CHECKSUMTYPE).encode(ExternalEncoding),7496 input_name='CHECKSUMTYPE'), ))7497 if self.CREATED is not None and 'CREATED' \7498 not in already_processed:7499 already_processed.append('CREATED')7500 outfile.write(' CREATED=%s'7501 % (self.gds_format_string(quote_attrib(self.CREATED).encode(ExternalEncoding),7502 input_name='CREATED'), ))7503 if self.CHECKSUM is not None and 'CHECKSUM' \7504 not in already_processed:7505 already_processed.append('CHECKSUM')7506 outfile.write(' CHECKSUM=%s'7507 % (self.gds_format_string(quote_attrib(self.CHECKSUM).encode(ExternalEncoding),7508 input_name='CHECKSUM'), ))7509 if self.OTHERMDTYPE is not None and 'OTHERMDTYPE' \7510 not in already_processed:7511 already_processed.append('OTHERMDTYPE')7512 outfile.write(' OTHERMDTYPE=%s'7513 % (self.gds_format_string(quote_attrib(self.OTHERMDTYPE).encode(ExternalEncoding),7514 input_name='OTHERMDTYPE'), ))7515 if self.MDTYPE is not None and 'MDTYPE' \7516 not in already_processed:7517 already_processed.append('MDTYPE')7518 outfile.write(' MDTYPE=%s'7519 % (self.gds_format_string(quote_attrib(self.MDTYPE).encode(ExternalEncoding),7520 input_name='MDTYPE'), ))7521 if self.LABEL is not None and 'LABEL' not in already_processed:7522 already_processed.append('LABEL')7523 outfile.write(' LABEL=%s'7524 % (self.gds_format_string(quote_attrib(self.LABEL).encode(ExternalEncoding),7525 input_name='LABEL'), ))7526 if self.MDTYPEVERSION is not None and 'MDTYPEVERSION' \7527 not in already_processed:7528 already_processed.append('MDTYPEVERSION')7529 outfile.write(' MDTYPEVERSION=%s'7530 % (self.gds_format_string(quote_attrib(self.MDTYPEVERSION).encode(ExternalEncoding),7531 input_name='MDTYPEVERSION'), ))7532 if self.ID is not None and 'ID' not in already_processed:7533 already_processed.append('ID')7534 outfile.write(' ID=%s'7535 % (self.gds_format_string(quote_attrib(self.ID).encode(ExternalEncoding),7536 input_name='ID'), ))7537 if self.SIZE is not None and 'SIZE' not in already_processed:7538 already_processed.append('SIZE')7539 outfile.write(' SIZE="%s"'7540 % self.gds_format_integer(self.SIZE,7541 input_name='SIZE'))7542 def exportChildren(7543 self,7544 outfile,7545 level,7546 namespace_='',7547 name_='mdWrap',7548 ):7549 if self.binData is not None:7550 showIndent(outfile, level)7551 outfile.write('<%sbinData>%s</%sbinData>\n' % (namespace_,7552 self.gds_format_string(quote_xml(self.binData).encode(ExternalEncoding),7553 input_name='binData'), namespace_))7554 if self.xmlData is not None:7555 # showIndent(outfile, level)7556 self.xmlData.export(outfile, level, namespace_) # name_, namespacedef_)7557 # outfile.write('<%sxmlData>%s</%sxmlData>\n' % (namespace_, self.gds_format_string(quote_xml(self.xmlData).encode(ExternalEncoding), input_name='xmlData'), namespace_))7558 def hasContent_(self):7559 if self.binData is not None or self.xmlData is not None:7560 return True7561 else:7562 return False7563 def exportLiteral(7564 self,7565 outfile,7566 level,7567 name_='mdWrap',7568 ):7569 level += 17570 self.exportLiteralAttributes(outfile, level, [], name_)7571 if self.hasContent_():7572 self.exportLiteralChildren(outfile, level, name_)7573 def exportLiteralAttributes(7574 self,7575 outfile,7576 level,7577 already_processed,7578 name_,7579 ):7580 if self.MIMETYPE is not None and 'MIMETYPE' \7581 not in already_processed:7582 already_processed.append('MIMETYPE')7583 showIndent(outfile, level)7584 outfile.write('MIMETYPE = "%s",\n' % (self.MIMETYPE, ))7585 if self.CHECKSUMTYPE is not None and 'CHECKSUMTYPE' \7586 not in already_processed:7587 already_processed.append('CHECKSUMTYPE')7588 showIndent(outfile, level)7589 outfile.write('CHECKSUMTYPE = "%s",\n'7590 % (self.CHECKSUMTYPE, ))7591 if self.CREATED is not None and 'CREATED' \7592 not in already_processed:7593 already_processed.append('CREATED')7594 showIndent(outfile, level)7595 outfile.write('CREATED = "%s",\n' % (self.CREATED, ))7596 if self.CHECKSUM is not None and 'CHECKSUM' \7597 not in already_processed:7598 already_processed.append('CHECKSUM')7599 showIndent(outfile, level)7600 outfile.write('CHECKSUM = "%s",\n' % (self.CHECKSUM, ))7601 if self.OTHERMDTYPE is not None and 'OTHERMDTYPE' \7602 not in already_processed:7603 already_processed.append('OTHERMDTYPE')7604 showIndent(outfile, level)7605 outfile.write('OTHERMDTYPE = "%s",\n' % (self.OTHERMDTYPE,7606 ))7607 if self.MDTYPE is not None and 'MDTYPE' \7608 not in already_processed:7609 already_processed.append('MDTYPE')7610 showIndent(outfile, level)7611 outfile.write('MDTYPE = "%s",\n' % (self.MDTYPE, ))7612 if self.LABEL is not None and 'LABEL' not in already_processed:7613 already_processed.append('LABEL')7614 showIndent(outfile, level)7615 outfile.write('LABEL = "%s",\n' % (self.LABEL, ))7616 if self.MDTYPEVERSION is not None and 'MDTYPEVERSION' \7617 not in already_processed:7618 already_processed.append('MDTYPEVERSION')7619 showIndent(outfile, level)7620 outfile.write('MDTYPEVERSION = "%s",\n'7621 % (self.MDTYPEVERSION, ))7622 if self.ID is not None and 'ID' not in already_processed:7623 already_processed.append('ID')7624 showIndent(outfile, level)7625 outfile.write('ID = "%s",\n' % (self.ID, ))7626 if self.SIZE is not None and 'SIZE' not in already_processed:7627 already_processed.append('SIZE')7628 showIndent(outfile, level)7629 outfile.write('SIZE = %d,\n' % (self.SIZE, ))7630 def exportLiteralChildren(7631 self,7632 outfile,7633 level,7634 name_,7635 ):7636 if self.binData is not None:7637 showIndent(outfile, level)7638 outfile.write('binData=%s,\n'7639 % quote_python(self.binData).encode(ExternalEncoding))7640 if self.xmlData is not None:7641 showIndent(outfile, level)7642 outfile.write('xmlData=%s,\n'7643 % quote_python(self.xmlData).encode(ExternalEncoding))7644 def build(self, node):7645 self.buildAttributes(node, node.attrib, [])7646 for child in node:7647 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]7648 self.buildChildren(child, node, nodeName_)7649 def buildAttributes(7650 self,7651 node,7652 attrs,7653 already_processed,7654 ):7655 value = attrs.get('MIMETYPE')7656 if value is not None and 'MIMETYPE' not in already_processed:7657 already_processed.append('MIMETYPE')7658 self.MIMETYPE = value7659 value = attrs.get('CHECKSUMTYPE')7660 if value is not None and 'CHECKSUMTYPE' \7661 not in already_processed:7662 already_processed.append('CHECKSUMTYPE')7663 self.CHECKSUMTYPE = value7664 value = attrs.get('CREATED')7665 if value is not None and 'CREATED' not in already_processed:7666 already_processed.append('CREATED')7667 self.CREATED = value7668 value = attrs.get('CHECKSUM')7669 if value is not None and 'CHECKSUM' not in already_processed:7670 already_processed.append('CHECKSUM')7671 self.CHECKSUM = value7672 value = attrs.get('OTHERMDTYPE')7673 if value is not None and 'OTHERMDTYPE' not in already_processed:7674 already_processed.append('OTHERMDTYPE')7675 self.OTHERMDTYPE = value7676 value = attrs.get('MDTYPE')7677 if value is not None and 'MDTYPE' not in already_processed:7678 already_processed.append('MDTYPE')7679 self.MDTYPE = value7680 value = attrs.get('LABEL')7681 if value is not None and 'LABEL' not in already_processed:7682 already_processed.append('LABEL')7683 self.LABEL = value7684 value = attrs.get('MDTYPEVERSION')7685 if value is not None and 'MDTYPEVERSION' \7686 not in already_processed:7687 already_processed.append('MDTYPEVERSION')7688 self.MDTYPEVERSION = value7689 value = attrs.get('ID')7690 if value is not None and 'ID' not in already_processed:7691 already_processed.append('ID')7692 self.ID = value7693 value = attrs.get('SIZE')7694 if value is not None and 'SIZE' not in already_processed:7695 already_processed.append('SIZE')7696 try:7697 self.SIZE = int(value)7698 except ValueError, exp:7699 raise_parse_error(node, 'Bad integer attribute: %s'7700 % exp)7701 def buildChildren(7702 self,7703 child_,7704 node,7705 nodeName_,7706 from_subclass=False,7707 ):7708 if nodeName_ == 'binData':7709 binData_ = child_.text7710 binData_ = self.gds_validate_string(binData_, node,7711 'binData')7712 self.binData = binData_7713 elif nodeName_ == 'xmlData':7714 xmlData_ = child_.text7715 xmlData_ = self.gds_validate_string(xmlData_, node,7716 'xmlData')7717 self.xmlData = xmlData_7718# end class mdWrap7719class xmlData(GeneratedsSuper):7720 """The xml data wrapper element <xmlData> is used to contain XML7721 encoded metadata. The content of an <xmlData> element can be in7722 any namespace or in no namespace. As permitted by the XML Schema7723 Standard, the processContents attribute value for the metadata7724 in an <xmlData> is set to "lax". Therefore, if the source7725 schema and its location are identified by means of an XML7726 schemaLocation attribute, then an XML processor will validate7727 the elements for which it can find declarations. If a source7728 schema is not identified, or cannot be found at the specified7729 schemaLocation, then an XML validator will check for well-7730 formedness, but otherwise skip over the elements appearing in7731 the <xmlData> element."""7732 subclass = None7733 superclass = None7734 def __init__(self, xsdAny_=None):7735 if xsdAny_ is None:7736 self.xsdAny_ = []7737 else:7738 self.xsdAny_ = xsdAny_7739 def factory(*args_, **kwargs_):7740 if xmlData.subclass:7741 return xmlData.subclass(*args_, **kwargs_)7742 else:7743 return xmlData(*args_, **kwargs_)7744 factory = staticmethod(factory)7745 def get_xsdAny_(self):7746 return self.xsdAny_7747 def set_xsdAny_(self, xsdAny_):7748 self.xsdAny_ = xsdAny_7749 def add_xsdAny_(self, value):7750 self.xsdAny_.append(value)7751 def insert_xsdAny_(self, index, value):7752 self.xsdAny_[index] = value7753 def export(7754 self,7755 outfile,7756 level,7757 namespace_='',7758 name_='xmlData',7759 namespacedef_='',7760 ):7761 showIndent(outfile, level)7762 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_7763 and ' ' + namespacedef_ or ''))7764 self.exportAttributes(outfile, level, [], namespace_,7765 name_='xmlData')7766 if self.hasContent_():7767 outfile.write('>')7768 from elementtree.ElementTree import tostring7769 for xsdAnyContent in self.xsdAny_:7770 outfile.write(tostring(xsdAnyContent))7771 self.exportChildren(outfile, level + 1, namespace_, name_)7772 outfile.write('</%s%s>\n' % (namespace_, name_))7773 else:7774 outfile.write('/>\n')7775 def exportAttributes(7776 self,7777 outfile,7778 level,7779 already_processed,7780 namespace_='',7781 name_='xmlData',7782 ):7783 pass7784 def exportChildren(7785 self,7786 outfile,7787 level,7788 namespace_='',7789 name_='xmlData',7790 ):7791 pass7792 def hasContent_(self):7793 if self.xsdAny_:7794 return True7795 else:7796 return False7797 def exportLiteral(7798 self,7799 outfile,7800 level,7801 name_='xmlData',7802 ):7803 level += 17804 self.exportLiteralAttributes(outfile, level, [], name_)7805 if self.hasContent_():7806 self.exportLiteralChildren(outfile, level, name_)7807 showIndent(outfile, level)7808 outfile.write('valueOf_ = """%s""",\n' % (self.valueOf_, ))7809 def exportLiteralAttributes(7810 self,7811 outfile,7812 level,7813 already_processed,7814 name_,7815 ):7816 pass7817 def exportLiteralChildren(7818 self,7819 outfile,7820 level,7821 name_,7822 ):7823 pass7824 def build(self, node):7825 self.buildAttributes(node, node.attrib, [])7826 self.valueOf_ = get_all_text_(node)7827 for child in node:7828 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]7829 self.buildChildren(child, node, nodeName_)7830 def buildAttributes(7831 self,7832 node,7833 attrs,7834 already_processed,7835 ):7836 pass7837 def buildChildren(7838 self,7839 child_,7840 node,7841 nodeName_,7842 from_subclass=False,7843 ):7844 pass7845# end class xmlData7846class fileType(GeneratedsSuper):7847 """fileType: Complex Type for Files The file element provides access to7848 content files for a METS object. A file element may contain one7849 or more FLocat elements, which provide pointers to a content7850 file, and/or an FContent element, which wraps an encoded version7851 of the file. Note that ALL FLocat and FContent elements7852 underneath a single file element should identify/contain7853 identical copies of a single file. ID (ID/R): This attribute7854 uniquely identifies the element within the METS document, and7855 would allow the element to be referenced unambiguously from7856 another element or document via an IDREF or an XPTR. Typically,7857 the ID attribute value on a <file> element would be referenced7858 from one or more FILEID attributes (which are of type IDREF) on7859 <fptr>and/or <area> elements within the <structMap>. Such7860 references establish links between structural divisions (<div>7861 elements) and the specific content files or parts of content7862 files that manifest them. For more information on using ID7863 attributes for internal and external linking see Chapter 4 of7864 the METS Primer. SEQ (integer/O): Indicates the sequence of this7865 <file> relative to the others in its <fileGrp>. OWNERID7866 (string/O): A unique identifier assigned to the file by its7867 owner. This may be a URI which differs from the URI used to7868 retrieve the file. ADMID (IDREFS/O): Contains the ID attribute7869 values of the <techMD>, <sourceMD>, <rightsMD> and/or7870 <digiprovMD> elements within the <amdSec> of the METS document7871 that contain administrative metadata pertaining to the file. For7872 more information on using METS IDREFS and IDREF type attributes7873 for internal linking, see Chapter 4 of the METS Primer. DMDID7874 (IDREFS/O): Contains the ID attribute values identifying the7875 <dmdSec>, elements in the METS document that contain or link to7876 descriptive metadata pertaining to the content file represented7877 by the current <file> element. For more information on using7878 METS IDREFS and IDREF type attributes for internal linking, see7879 Chapter 4 of the METS Primer. GROUPID (string/O): An identifier7880 that establishes a correspondence between this file and files in7881 other file groups. Typically, this will be used to associate a7882 master file in one file group with the derivative files made7883 from it in other file groups. USE (string/O): A tagging7884 attribute to indicate the intended use of all copies of the file7885 aggregated by the <file> element (e.g., master, reference,7886 thumbnails for image files). A USE attribute can be expressed at7887 the<fileGrp> level, the <file> level, the <FLocat> level and/or7888 the <FContent> level. A USE attribute value at the <fileGrp>7889 level should pertain to all of the files in the <fileGrp>. A USE7890 attribute at the <file> level should pertain to all copies of7891 the file as represented by subsidiary <FLocat> and/or <FContent>7892 elements. A USE attribute at the <FLocat> or <FContent> level7893 pertains to the particular copy of the file that is either7894 referenced (<FLocat>) or wrapped (<FContent>). BEGIN (string/O):7895 An attribute that specifies the point in the parent <file> where7896 the current <file> begins. When used in conjunction with a7897 <file> element, this attribute is only meaningful when this7898 element is nested, and its parent <file> element represents a7899 container file. It can be used in conjunction with the END7900 attribute as a means of defining the location of the current7901 file within its parent file. However, the BEGIN attribute can be7902 used with or without a companion END attribute. When no END7903 attribute is specified, the end of the parent file is assumed7904 also to be the end point of the current file. The BEGIN and END7905 attributes can only be interpreted meaningfully in conjunction7906 with a BETYPE attribute, which specifies the kind of7907 beginning/ending point values that are being used. END7908 (string/O): An attribute that specifies the point in the parent7909 <file> where the current, nested <file> ends. It can only be7910 interpreted meaningfully in conjunction with the BETYPE, which7911 specifies the kind of ending point values being used. Typically7912 the END attribute would only appear in conjunction with a BEGIN7913 attribute. BETYPE: Begin/End Type. BETYPE (string/O): An7914 attribute that specifies the kind of BEGIN and/or END values7915 that are being used. Currently BYTE is the only valid value that7916 can be used in conjunction with nested <file> or <stream>7917 elements."""7918 subclass = None7919 superclass = None7920 def __init__(7921 self,7922 MIMETYPE=None,7923 ADMID=None,7924 END=None,7925 CHECKSUMTYPE=None,7926 SEQ=None,7927 CREATED=None,7928 CHECKSUM=None,7929 USE=None,7930 ID=None,7931 DMDID=None,7932 BEGIN=None,7933 OWNERID=None,7934 SIZE=None,7935 GROUPID=None,7936 BETYPE=None,7937 FLocat=None,7938 FContent=None,7939 stream=None,7940 transformFile=None,7941 file=None,7942 ):7943 self.MIMETYPE = _cast(None, MIMETYPE)7944 self.ADMID = _cast(None, ADMID)7945 self.END = _cast(None, END)7946 self.CHECKSUMTYPE = _cast(None, CHECKSUMTYPE)7947 self.SEQ = _cast(int, SEQ)7948 self.CREATED = _cast(None, CREATED)7949 self.CHECKSUM = _cast(None, CHECKSUM)7950 self.USE = _cast(None, USE)7951 self.ID = _cast(None, ID)7952 self.DMDID = _cast(None, DMDID)7953 self.BEGIN = _cast(None, BEGIN)7954 self.OWNERID = _cast(None, OWNERID)7955 self.SIZE = _cast(int, SIZE)7956 self.GROUPID = _cast(None, GROUPID)7957 self.BETYPE = _cast(None, BETYPE)7958 if FLocat is None:7959 self.FLocat = []7960 else:7961 self.FLocat = FLocat7962 self.FContent = FContent7963 if stream is None:7964 self.stream = []7965 else:7966 self.stream = stream7967 if transformFile is None:7968 self.transformFile = []7969 else:7970 self.transformFile = transformFile7971 if file is None:7972 self.file = []7973 else:7974 self.file = file7975 def factory(*args_, **kwargs_):7976 if fileType.subclass:7977 return fileType.subclass(*args_, **kwargs_)7978 else:7979 return fileType(*args_, **kwargs_)7980 factory = staticmethod(factory)7981 def get_FLocat(self):7982 return self.FLocat7983 def set_FLocat(self, FLocat):7984 self.FLocat = FLocat7985 def add_FLocat(self, value):7986 self.FLocat.append(value)7987 def insert_FLocat(self, index, value):7988 self.FLocat[index] = value7989 def get_FContent(self):7990 return self.FContent7991 def set_FContent(self, FContent):7992 self.FContent = FContent7993 def get_stream(self):7994 return self.stream7995 def set_stream(self, stream):7996 self.stream = stream7997 def add_stream(self, value):7998 self.stream.append(value)7999 def insert_stream(self, index, value):8000 self.stream[index] = value8001 def get_transformFile(self):8002 return self.transformFile8003 def set_transformFile(self, transformFile):8004 self.transformFile = transformFile8005 def add_transformFile(self, value):8006 self.transformFile.append(value)8007 def insert_transformFile(self, index, value):8008 self.transformFile[index] = value8009 def get_file(self):8010 return self.file8011 def set_file(self, file):8012 self.file = file8013 def add_file(self, value):8014 self.file.append(value)8015 def insert_file(self, index, value):8016 self.file[index] = value8017 def get_MIMETYPE(self):8018 return self.MIMETYPE8019 def set_MIMETYPE(self, MIMETYPE):8020 self.MIMETYPE = MIMETYPE8021 def get_ADMID(self):8022 return self.ADMID8023 def set_ADMID(self, ADMID):8024 self.ADMID = ADMID8025 def get_END(self):8026 return self.END8027 def set_END(self, END):8028 self.END = END8029 def get_CHECKSUMTYPE(self):8030 return self.CHECKSUMTYPE8031 def set_CHECKSUMTYPE(self, CHECKSUMTYPE):8032 self.CHECKSUMTYPE = CHECKSUMTYPE8033 def get_SEQ(self):8034 return self.SEQ8035 def set_SEQ(self, SEQ):8036 self.SEQ = SEQ8037 def get_CREATED(self):8038 return self.CREATED8039 def set_CREATED(self, CREATED):8040 self.CREATED = CREATED8041 def get_CHECKSUM(self):8042 return self.CHECKSUM8043 def set_CHECKSUM(self, CHECKSUM):8044 self.CHECKSUM = CHECKSUM8045 def get_USE(self):8046 return self.USE8047 def set_USE(self, USE):8048 self.USE = USE8049 def get_ID(self):8050 return self.ID8051 def set_ID(self, ID):8052 self.ID = ID8053 def get_DMDID(self):8054 return self.DMDID8055 def set_DMDID(self, DMDID):8056 self.DMDID = DMDID8057 def get_BEGIN(self):8058 return self.BEGIN8059 def set_BEGIN(self, BEGIN):8060 self.BEGIN = BEGIN8061 def get_OWNERID(self):8062 return self.OWNERID8063 def set_OWNERID(self, OWNERID):8064 self.OWNERID = OWNERID8065 def get_SIZE(self):8066 return self.SIZE8067 def set_SIZE(self, SIZE):8068 self.SIZE = SIZE8069 def get_GROUPID(self):8070 return self.GROUPID8071 def set_GROUPID(self, GROUPID):8072 self.GROUPID = GROUPID8073 def get_BETYPE(self):8074 return self.BETYPE8075 def set_BETYPE(self, BETYPE):8076 self.BETYPE = BETYPE8077 def export(8078 self,8079 outfile,8080 level,8081 namespace_='',8082 name_='fileType',8083 namespacedef_='',8084 ):8085 showIndent(outfile, level)8086 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_8087 and ' ' + namespacedef_ or ''))8088 self.exportAttributes(outfile, level, [], namespace_,8089 name_='fileType')8090 if self.hasContent_():8091 outfile.write('>\n')8092 self.exportChildren(outfile, level + 1, namespace_, name_)8093 showIndent(outfile, level)8094 outfile.write('</%s%s>\n' % (namespace_, name_))8095 else:8096 outfile.write('/>\n')8097 def exportAttributes(8098 self,8099 outfile,8100 level,8101 already_processed,8102 namespace_='',8103 name_='fileType',8104 ):8105 if self.MIMETYPE is not None and 'MIMETYPE' \8106 not in already_processed:8107 already_processed.append('MIMETYPE')8108 outfile.write(' MIMETYPE=%s'8109 % (self.gds_format_string(quote_attrib(self.MIMETYPE).encode(ExternalEncoding),8110 input_name='MIMETYPE'), ))8111 if self.ADMID is not None and 'ADMID' not in already_processed:8112 already_processed.append('ADMID')8113 outfile.write(' ADMID=%s'8114 % (self.gds_format_string(quote_attrib(self.ADMID).encode(ExternalEncoding),8115 input_name='ADMID'), ))8116 if self.END is not None and 'END' not in already_processed:8117 already_processed.append('END')8118 outfile.write(' END=%s'8119 % (self.gds_format_string(quote_attrib(self.END).encode(ExternalEncoding),8120 input_name='END'), ))8121 if self.CHECKSUMTYPE is not None and 'CHECKSUMTYPE' \8122 not in already_processed:8123 already_processed.append('CHECKSUMTYPE')8124 outfile.write(' CHECKSUMTYPE=%s'8125 % (self.gds_format_string(quote_attrib(self.CHECKSUMTYPE).encode(ExternalEncoding),8126 input_name='CHECKSUMTYPE'), ))8127 if self.SEQ is not None and 'SEQ' not in already_processed:8128 already_processed.append('SEQ')8129 outfile.write(' SEQ="%s"'8130 % self.gds_format_integer(self.SEQ,8131 input_name='SEQ'))8132 if self.CREATED is not None and 'CREATED' \8133 not in already_processed:8134 already_processed.append('CREATED')8135 outfile.write(' CREATED=%s'8136 % (self.gds_format_string(quote_attrib(self.CREATED).encode(ExternalEncoding),8137 input_name='CREATED'), ))8138 if self.CHECKSUM is not None and 'CHECKSUM' \8139 not in already_processed:8140 already_processed.append('CHECKSUM')8141 outfile.write(' CHECKSUM=%s'8142 % (self.gds_format_string(quote_attrib(self.CHECKSUM).encode(ExternalEncoding),8143 input_name='CHECKSUM'), ))8144 if self.USE is not None and 'USE' not in already_processed:8145 already_processed.append('USE')8146 outfile.write(' USE=%s'8147 % (self.gds_format_string(quote_attrib(self.USE).encode(ExternalEncoding),8148 input_name='USE'), ))8149 if self.ID is not None and 'ID' not in already_processed:8150 already_processed.append('ID')8151 outfile.write(' ID=%s'8152 % (self.gds_format_string(quote_attrib(self.ID).encode(ExternalEncoding),8153 input_name='ID'), ))8154 if self.DMDID is not None and 'DMDID' not in already_processed:8155 already_processed.append('DMDID')8156 outfile.write(' DMDID=%s'8157 % (self.gds_format_string(quote_attrib(self.DMDID).encode(ExternalEncoding),8158 input_name='DMDID'), ))8159 if self.BEGIN is not None and 'BEGIN' not in already_processed:8160 already_processed.append('BEGIN')8161 outfile.write(' BEGIN=%s'8162 % (self.gds_format_string(quote_attrib(self.BEGIN).encode(ExternalEncoding),8163 input_name='BEGIN'), ))8164 if self.OWNERID is not None and 'OWNERID' \8165 not in already_processed:8166 already_processed.append('OWNERID')8167 outfile.write(' OWNERID=%s'8168 % (self.gds_format_string(quote_attrib(self.OWNERID).encode(ExternalEncoding),8169 input_name='OWNERID'), ))8170 if self.SIZE is not None and 'SIZE' not in already_processed:8171 already_processed.append('SIZE')8172 outfile.write(' SIZE="%s"'8173 % self.gds_format_integer(self.SIZE,8174 input_name='SIZE'))8175 if self.GROUPID is not None and 'GROUPID' \8176 not in already_processed:8177 already_processed.append('GROUPID')8178 outfile.write(' GROUPID=%s'8179 % (self.gds_format_string(quote_attrib(self.GROUPID).encode(ExternalEncoding),8180 input_name='GROUPID'), ))8181 if self.BETYPE is not None and 'BETYPE' \8182 not in already_processed:8183 already_processed.append('BETYPE')8184 outfile.write(' BETYPE=%s'8185 % (self.gds_format_string(quote_attrib(self.BETYPE).encode(ExternalEncoding),8186 input_name='BETYPE'), ))8187 def exportChildren(8188 self,8189 outfile,8190 level,8191 namespace_='',8192 name_='fileType',8193 ):8194 for FLocat_ in self.FLocat:8195 FLocat_.export(outfile, level, namespace_, name_='FLocat')8196 if self.FContent:8197 self.FContent.export(outfile, level, namespace_,8198 name_='FContent')8199 for stream_ in self.stream:8200 stream_.export(outfile, level, namespace_, name_='stream')8201 for transformFile_ in self.transformFile:8202 transformFile_.export(outfile, level, namespace_,8203 name_='transformFile')8204 for file_ in self.file:8205 file_.export(outfile, level, namespace_, name_='file')8206 def hasContent_(self):8207 if self.FLocat or self.FContent is not None or self.stream \8208 or self.transformFile or self.file:8209 return True8210 else:8211 return False8212 def exportLiteral(8213 self,8214 outfile,8215 level,8216 name_='fileType',8217 ):8218 level += 18219 self.exportLiteralAttributes(outfile, level, [], name_)8220 if self.hasContent_():8221 self.exportLiteralChildren(outfile, level, name_)8222 def exportLiteralAttributes(8223 self,8224 outfile,8225 level,8226 already_processed,8227 name_,8228 ):8229 if self.MIMETYPE is not None and 'MIMETYPE' \8230 not in already_processed:8231 already_processed.append('MIMETYPE')8232 showIndent(outfile, level)8233 outfile.write('MIMETYPE = "%s",\n' % (self.MIMETYPE, ))8234 if self.ADMID is not None and 'ADMID' not in already_processed:8235 already_processed.append('ADMID')8236 showIndent(outfile, level)8237 outfile.write('ADMID = "%s",\n' % (self.ADMID, ))8238 if self.END is not None and 'END' not in already_processed:8239 already_processed.append('END')8240 showIndent(outfile, level)8241 outfile.write('END = "%s",\n' % (self.END, ))8242 if self.CHECKSUMTYPE is not None and 'CHECKSUMTYPE' \8243 not in already_processed:8244 already_processed.append('CHECKSUMTYPE')8245 showIndent(outfile, level)8246 outfile.write('CHECKSUMTYPE = "%s",\n'8247 % (self.CHECKSUMTYPE, ))8248 if self.SEQ is not None and 'SEQ' not in already_processed:8249 already_processed.append('SEQ')8250 showIndent(outfile, level)8251 outfile.write('SEQ = %d,\n' % (self.SEQ, ))8252 if self.CREATED is not None and 'CREATED' \8253 not in already_processed:8254 already_processed.append('CREATED')8255 showIndent(outfile, level)8256 outfile.write('CREATED = "%s",\n' % (self.CREATED, ))8257 if self.CHECKSUM is not None and 'CHECKSUM' \8258 not in already_processed:8259 already_processed.append('CHECKSUM')8260 showIndent(outfile, level)8261 outfile.write('CHECKSUM = "%s",\n' % (self.CHECKSUM, ))8262 if self.USE is not None and 'USE' not in already_processed:8263 already_processed.append('USE')8264 showIndent(outfile, level)8265 outfile.write('USE = "%s",\n' % (self.USE, ))8266 if self.ID is not None and 'ID' not in already_processed:8267 already_processed.append('ID')8268 showIndent(outfile, level)8269 outfile.write('ID = "%s",\n' % (self.ID, ))8270 if self.DMDID is not None and 'DMDID' not in already_processed:8271 already_processed.append('DMDID')8272 showIndent(outfile, level)8273 outfile.write('DMDID = "%s",\n' % (self.DMDID, ))8274 if self.BEGIN is not None and 'BEGIN' not in already_processed:8275 already_processed.append('BEGIN')8276 showIndent(outfile, level)8277 outfile.write('BEGIN = "%s",\n' % (self.BEGIN, ))8278 if self.OWNERID is not None and 'OWNERID' \8279 not in already_processed:8280 already_processed.append('OWNERID')8281 showIndent(outfile, level)8282 outfile.write('OWNERID = "%s",\n' % (self.OWNERID, ))8283 if self.SIZE is not None and 'SIZE' not in already_processed:8284 already_processed.append('SIZE')8285 showIndent(outfile, level)8286 outfile.write('SIZE = %d,\n' % (self.SIZE, ))8287 if self.GROUPID is not None and 'GROUPID' \8288 not in already_processed:8289 already_processed.append('GROUPID')8290 showIndent(outfile, level)8291 outfile.write('GROUPID = "%s",\n' % (self.GROUPID, ))8292 if self.BETYPE is not None and 'BETYPE' \8293 not in already_processed:8294 already_processed.append('BETYPE')8295 showIndent(outfile, level)8296 outfile.write('BETYPE = "%s",\n' % (self.BETYPE, ))8297 def exportLiteralChildren(8298 self,8299 outfile,8300 level,8301 name_,8302 ):8303 showIndent(outfile, level)8304 outfile.write('FLocat=[\n')8305 level += 18306 for FLocat_ in self.FLocat:8307 showIndent(outfile, level)8308 outfile.write('model_.FLocat(\n')8309 FLocat_.exportLiteral(outfile, level)8310 showIndent(outfile, level)8311 outfile.write('),\n')8312 level -= 18313 showIndent(outfile, level)8314 outfile.write('],\n')8315 if self.FContent is not None:8316 showIndent(outfile, level)8317 outfile.write('FContent=model_.FContent(\n')8318 self.FContent.exportLiteral(outfile, level)8319 showIndent(outfile, level)8320 outfile.write('),\n')8321 showIndent(outfile, level)8322 outfile.write('stream=[\n')8323 level += 18324 for stream_ in self.stream:8325 showIndent(outfile, level)8326 outfile.write('model_.stream(\n')8327 stream_.exportLiteral(outfile, level)8328 showIndent(outfile, level)8329 outfile.write('),\n')8330 level -= 18331 showIndent(outfile, level)8332 outfile.write('],\n')8333 showIndent(outfile, level)8334 outfile.write('transformFile=[\n')8335 level += 18336 for transformFile_ in self.transformFile:8337 showIndent(outfile, level)8338 outfile.write('model_.transformFile(\n')8339 transformFile_.exportLiteral(outfile, level)8340 showIndent(outfile, level)8341 outfile.write('),\n')8342 level -= 18343 showIndent(outfile, level)8344 outfile.write('],\n')8345 showIndent(outfile, level)8346 outfile.write('file=[\n')8347 level += 18348 for file_ in self.file:8349 showIndent(outfile, level)8350 outfile.write('model_.fileType(\n')8351 file_.exportLiteral(outfile, level, name_='fileType')8352 showIndent(outfile, level)8353 outfile.write('),\n')8354 level -= 18355 showIndent(outfile, level)8356 outfile.write('],\n')8357 def build(self, node):8358 self.buildAttributes(node, node.attrib, [])8359 for child in node:8360 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]8361 self.buildChildren(child, node, nodeName_)8362 def buildAttributes(8363 self,8364 node,8365 attrs,8366 already_processed,8367 ):8368 value = attrs.get('MIMETYPE')8369 if value is not None and 'MIMETYPE' not in already_processed:8370 already_processed.append('MIMETYPE')8371 self.MIMETYPE = value8372 value = attrs.get('ADMID')8373 if value is not None and 'ADMID' not in already_processed:8374 already_processed.append('ADMID')8375 self.ADMID = value8376 value = attrs.get('END')8377 if value is not None and 'END' not in already_processed:8378 already_processed.append('END')8379 self.END = value8380 value = attrs.get('CHECKSUMTYPE')8381 if value is not None and 'CHECKSUMTYPE' \8382 not in already_processed:8383 already_processed.append('CHECKSUMTYPE')8384 self.CHECKSUMTYPE = value8385 value = attrs.get('SEQ')8386 if value is not None and 'SEQ' not in already_processed:8387 already_processed.append('SEQ')8388 try:8389 self.SEQ = int(value)8390 except ValueError, exp:8391 raise_parse_error(node, 'Bad integer attribute: %s'8392 % exp)8393 value = attrs.get('CREATED')8394 if value is not None and 'CREATED' not in already_processed:8395 already_processed.append('CREATED')8396 self.CREATED = value8397 value = attrs.get('CHECKSUM')8398 if value is not None and 'CHECKSUM' not in already_processed:8399 already_processed.append('CHECKSUM')8400 self.CHECKSUM = value8401 value = attrs.get('USE')8402 if value is not None and 'USE' not in already_processed:8403 already_processed.append('USE')8404 self.USE = value8405 value = attrs.get('ID')8406 if value is not None and 'ID' not in already_processed:8407 already_processed.append('ID')8408 self.ID = value8409 value = attrs.get('DMDID')8410 if value is not None and 'DMDID' not in already_processed:8411 already_processed.append('DMDID')8412 self.DMDID = value8413 value = attrs.get('BEGIN')8414 if value is not None and 'BEGIN' not in already_processed:8415 already_processed.append('BEGIN')8416 self.BEGIN = value8417 value = attrs.get('OWNERID')8418 if value is not None and 'OWNERID' not in already_processed:8419 already_processed.append('OWNERID')8420 self.OWNERID = value8421 value = attrs.get('SIZE')8422 if value is not None and 'SIZE' not in already_processed:8423 already_processed.append('SIZE')8424 try:8425 self.SIZE = int(value)8426 except ValueError, exp:8427 raise_parse_error(node, 'Bad integer attribute: %s'8428 % exp)8429 value = attrs.get('GROUPID')8430 if value is not None and 'GROUPID' not in already_processed:8431 already_processed.append('GROUPID')8432 self.GROUPID = value8433 value = attrs.get('BETYPE')8434 if value is not None and 'BETYPE' not in already_processed:8435 already_processed.append('BETYPE')8436 self.BETYPE = value8437 def buildChildren(8438 self,8439 child_,8440 node,8441 nodeName_,8442 from_subclass=False,8443 ):8444 if nodeName_ == 'FLocat':8445 obj_ = FLocat.factory()8446 obj_.build(child_)8447 self.FLocat.append(obj_)8448 elif nodeName_ == 'FContent':8449 obj_ = FContent.factory()8450 obj_.build(child_)8451 self.set_FContent(obj_)8452 elif nodeName_ == 'stream':8453 obj_ = stream.factory()8454 obj_.build(child_)8455 self.stream.append(obj_)8456 elif nodeName_ == 'transformFile':8457 obj_ = transformFile.factory()8458 obj_.build(child_)8459 self.transformFile.append(obj_)8460 elif nodeName_ == 'file':8461 obj_ = fileType.factory()8462 obj_.build(child_)8463 self.file.append(obj_)8464# end class fileType8465class FLocat(GeneratedsSuper):8466 """The file location element <FLocat> provides a pointer to the8467 location of a content file. It uses the XLink reference syntax8468 to provide linking information indicating the actual location of8469 the content file, along with other attributes specifying8470 additional linking information. NOTE: <FLocat> is an empty8471 element. The location of the resource pointed to MUST be stored8472 in the xlink:href attribute. ID (ID/O): This attribute uniquely8473 identifies the element within the METS document, and would allow8474 the element to be referenced unambiguously from another element8475 or document via an IDREF or an XPTR. For more information on8476 using ID attributes for internal and external linking see8477 Chapter 4 of the METS Primer. USE (string/O): A tagging8478 attribute to indicate the intended use of the specific copy of8479 the file represented by the <FLocat> element (e.g., service8480 master, archive master). A USE attribute can be expressed at8481 the<fileGrp> level, the <file> level, the <FLocat> level and/or8482 the <FContent> level. A USE attribute value at the <fileGrp>8483 level should pertain to all of the files in the <fileGrp>. A USE8484 attribute at the <file> level should pertain to all copies of8485 the file as represented by subsidiary <FLocat> and/or <FContent>8486 elements. A USE attribute at the <FLocat> or <FContent> level8487 pertains to the particular copy of the file that is either8488 referenced (<FLocat>) or wrapped (<FContent>)."""8489 subclass = None8490 superclass = None8491 def __init__(8492 self,8493 arcrole=None,8494 USE=None,8495 title=None,8496 OTHERLOCTYPE=None,8497 show=None,8498 actuate=None,8499 href=None,8500 role=None,8501 LOCTYPE=None,8502 type_=None,8503 ID=None,8504 valueOf_=None,8505 ):8506 self.arcrole = _cast(None, arcrole)8507 self.USE = _cast(None, USE)8508 self.title = _cast(None, title)8509 self.OTHERLOCTYPE = _cast(None, OTHERLOCTYPE)8510 self.show = _cast(None, show)8511 self.actuate = _cast(None, actuate)8512 self.href = _cast(None, href)8513 self.role = _cast(None, role)8514 self.LOCTYPE = _cast(None, LOCTYPE)8515 self.type_ = _cast(None, type_)8516 self.ID = _cast(None, ID)8517 self.valueOf_ = valueOf_8518 def factory(*args_, **kwargs_):8519 if FLocat.subclass:8520 return FLocat.subclass(*args_, **kwargs_)8521 else:8522 return FLocat(*args_, **kwargs_)8523 factory = staticmethod(factory)8524 def get_arcrole(self):8525 return self.arcrole8526 def set_arcrole(self, arcrole):8527 self.arcrole = arcrole8528 def get_USE(self):8529 return self.USE8530 def set_USE(self, USE):8531 self.USE = USE8532 def get_title(self):8533 return self.title8534 def set_title(self, title):8535 self.title = title8536 def get_OTHERLOCTYPE(self):8537 return self.OTHERLOCTYPE8538 def set_OTHERLOCTYPE(self, OTHERLOCTYPE):8539 self.OTHERLOCTYPE = OTHERLOCTYPE8540 def get_show(self):8541 return self.show8542 def set_show(self, show):8543 self.show = show8544 def get_actuate(self):8545 return self.actuate8546 def set_actuate(self, actuate):8547 self.actuate = actuate8548 def get_href(self):8549 return self.href8550 def set_href(self, href):8551 self.href = href8552 def get_role(self):8553 return self.role8554 def set_role(self, role):8555 self.role = role8556 def get_LOCTYPE(self):8557 return self.LOCTYPE8558 def set_LOCTYPE(self, LOCTYPE):8559 self.LOCTYPE = LOCTYPE8560 def get_type(self):8561 return self.type_8562 def set_type(self, type_):8563 self.type_ = type_8564 def get_ID(self):8565 return self.ID8566 def set_ID(self, ID):8567 self.ID = ID8568 def get_valueOf_(self):8569 return self.valueOf_8570 def set_valueOf_(self, valueOf_):8571 self.valueOf_ = valueOf_8572 def export(8573 self,8574 outfile,8575 level,8576 namespace_='',8577 name_='FLocat',8578 namespacedef_='',8579 ):8580 showIndent(outfile, level)8581 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_8582 and ' ' + namespacedef_ or ''))8583 self.exportAttributes(outfile, level, [], namespace_,8584 name_='FLocat')8585 if self.hasContent_():8586 outfile.write('>')8587 outfile.write(self.valueOf_)8588 self.exportChildren(outfile, level + 1, namespace_, name_)8589 outfile.write('</%s%s>\n' % (namespace_, name_))8590 else:8591 outfile.write('/>\n')8592 def exportAttributes(8593 self,8594 outfile,8595 level,8596 already_processed,8597 namespace_='',8598 name_='FLocat',8599 ):8600 if self.arcrole is not None and 'arcrole' \8601 not in already_processed:8602 already_processed.append('arcrole')8603 outfile.write(' arcrole=%s'8604 % (self.gds_format_string(quote_attrib(self.arcrole).encode(ExternalEncoding),8605 input_name='arcrole'), ))8606 if self.USE is not None and 'USE' not in already_processed:8607 already_processed.append('USE')8608 outfile.write(' USE=%s'8609 % (self.gds_format_string(quote_attrib(self.USE).encode(ExternalEncoding),8610 input_name='USE'), ))8611 if self.title is not None and 'title' not in already_processed:8612 already_processed.append('title')8613 outfile.write(' title=%s'8614 % (self.gds_format_string(quote_attrib(self.title).encode(ExternalEncoding),8615 input_name='title'), ))8616 if self.OTHERLOCTYPE is not None and 'OTHERLOCTYPE' \8617 not in already_processed:8618 already_processed.append('OTHERLOCTYPE')8619 outfile.write(' OTHERLOCTYPE=%s'8620 % (self.gds_format_string(quote_attrib(self.OTHERLOCTYPE).encode(ExternalEncoding),8621 input_name='OTHERLOCTYPE'), ))8622 if self.show is not None and 'show' not in already_processed:8623 already_processed.append('show')8624 outfile.write(' show=%s'8625 % (self.gds_format_string(quote_attrib(self.show).encode(ExternalEncoding),8626 input_name='show'), ))8627 if self.actuate is not None and 'actuate' \8628 not in already_processed:8629 already_processed.append('actuate')8630 outfile.write(' actuate=%s'8631 % (self.gds_format_string(quote_attrib(self.actuate).encode(ExternalEncoding),8632 input_name='actuate'), ))8633 if self.href is not None and 'href' not in already_processed:8634 already_processed.append('href')8635 outfile.write(' xlink:href=%s'8636 % (self.gds_format_string(quote_attrib(self.href).encode(ExternalEncoding),8637 input_name='href'), ))8638 if self.role is not None and 'role' not in already_processed:8639 already_processed.append('role')8640 outfile.write(' role=%s'8641 % (self.gds_format_string(quote_attrib(self.role).encode(ExternalEncoding),8642 input_name='role'), ))8643 if self.LOCTYPE is not None and 'LOCTYPE' \8644 not in already_processed:8645 already_processed.append('LOCTYPE')8646 outfile.write(' LOCTYPE=%s'8647 % (self.gds_format_string(quote_attrib(self.LOCTYPE).encode(ExternalEncoding),8648 input_name='LOCTYPE'), ))8649 if self.type_ is not None and 'type_' not in already_processed:8650 already_processed.append('type_')8651 outfile.write(' xlink:type=%s' % (quote_attrib(self.type_), ))8652 if self.ID is not None and 'ID' not in already_processed:8653 already_processed.append('ID')8654 outfile.write(' ID=%s'8655 % (self.gds_format_string(quote_attrib(self.ID).encode(ExternalEncoding),8656 input_name='ID'), ))8657 def exportChildren(8658 self,8659 outfile,8660 level,8661 namespace_='',8662 name_='FLocat',8663 ):8664 pass8665 def hasContent_(self):8666 if self.valueOf_:8667 return True8668 else:8669 return False8670 def exportLiteral(8671 self,8672 outfile,8673 level,8674 name_='FLocat',8675 ):8676 level += 18677 self.exportLiteralAttributes(outfile, level, [], name_)8678 if self.hasContent_():8679 self.exportLiteralChildren(outfile, level, name_)8680 showIndent(outfile, level)8681 outfile.write('valueOf_ = """%s""",\n' % (self.valueOf_, ))8682 def exportLiteralAttributes(8683 self,8684 outfile,8685 level,8686 already_processed,8687 name_,8688 ):8689 if self.arcrole is not None and 'arcrole' \8690 not in already_processed:8691 already_processed.append('arcrole')8692 showIndent(outfile, level)8693 outfile.write('arcrole = "%s",\n' % (self.arcrole, ))8694 if self.USE is not None and 'USE' not in already_processed:8695 already_processed.append('USE')8696 showIndent(outfile, level)8697 outfile.write('USE = "%s",\n' % (self.USE, ))8698 if self.title is not None and 'title' not in already_processed:8699 already_processed.append('title')8700 showIndent(outfile, level)8701 outfile.write('title = "%s",\n' % (self.title, ))8702 if self.OTHERLOCTYPE is not None and 'OTHERLOCTYPE' \8703 not in already_processed:8704 already_processed.append('OTHERLOCTYPE')8705 showIndent(outfile, level)8706 outfile.write('OTHERLOCTYPE = "%s",\n'8707 % (self.OTHERLOCTYPE, ))8708 if self.show is not None and 'show' not in already_processed:8709 already_processed.append('show')8710 showIndent(outfile, level)8711 outfile.write('show = "%s",\n' % (self.show, ))8712 if self.actuate is not None and 'actuate' \8713 not in already_processed:8714 already_processed.append('actuate')8715 showIndent(outfile, level)8716 outfile.write('actuate = "%s",\n' % (self.actuate, ))8717 if self.href is not None and 'href' not in already_processed:8718 already_processed.append('href')8719 showIndent(outfile, level)8720 outfile.write('href = "%s",\n' % (self.href, ))8721 if self.role is not None and 'role' not in already_processed:8722 already_processed.append('role')8723 showIndent(outfile, level)8724 outfile.write('role = "%s",\n' % (self.role, ))8725 if self.LOCTYPE is not None and 'LOCTYPE' \8726 not in already_processed:8727 already_processed.append('LOCTYPE')8728 showIndent(outfile, level)8729 outfile.write('LOCTYPE = "%s",\n' % (self.LOCTYPE, ))8730 if self.type_ is not None and 'type_' not in already_processed:8731 already_processed.append('type_')8732 showIndent(outfile, level)8733 outfile.write('type_ = %s,\n' % (self.type_, ))8734 if self.ID is not None and 'ID' not in already_processed:8735 already_processed.append('ID')8736 showIndent(outfile, level)8737 outfile.write('ID = "%s",\n' % (self.ID, ))8738 def exportLiteralChildren(8739 self,8740 outfile,8741 level,8742 name_,8743 ):8744 pass8745 def build(self, node):8746 self.buildAttributes(node, node.attrib, [])8747 self.valueOf_ = get_all_text_(node)8748 for child in node:8749 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]8750 self.buildChildren(child, node, nodeName_)8751 def buildAttributes(8752 self,8753 node,8754 attrs,8755 already_processed,8756 ):8757 value = attrs.get('arcrole')8758 if value is not None and 'arcrole' not in already_processed:8759 already_processed.append('arcrole')8760 self.arcrole = value8761 value = attrs.get('USE')8762 if value is not None and 'USE' not in already_processed:8763 already_processed.append('USE')8764 self.USE = value8765 value = attrs.get('title')8766 if value is not None and 'title' not in already_processed:8767 already_processed.append('title')8768 self.title = value8769 value = attrs.get('OTHERLOCTYPE')8770 if value is not None and 'OTHERLOCTYPE' \8771 not in already_processed:8772 already_processed.append('OTHERLOCTYPE')8773 self.OTHERLOCTYPE = value8774 value = attrs.get('show')8775 if value is not None and 'show' not in already_processed:8776 already_processed.append('show')8777 self.show = value8778 value = attrs.get('actuate')8779 if value is not None and 'actuate' not in already_processed:8780 already_processed.append('actuate')8781 self.actuate = value8782 value = attrs.get('href')8783 if value is not None and 'href' not in already_processed:8784 already_processed.append('href')8785 self.href = value8786 value = attrs.get('role')8787 if value is not None and 'role' not in already_processed:8788 already_processed.append('role')8789 self.role = value8790 value = attrs.get('LOCTYPE')8791 if value is not None and 'LOCTYPE' not in already_processed:8792 already_processed.append('LOCTYPE')8793 self.LOCTYPE = value8794 value = attrs.get('type')8795 if value is not None and 'type' not in already_processed:8796 already_processed.append('type')8797 self.type_ = value8798 value = attrs.get('ID')8799 if value is not None and 'ID' not in already_processed:8800 already_processed.append('ID')8801 self.ID = value8802 def buildChildren(8803 self,8804 child_,8805 node,8806 nodeName_,8807 from_subclass=False,8808 ):8809 pass8810# end class FLocat8811class FContent(GeneratedsSuper):8812 """The file content element <FContent> is used to identify a content8813 file contained internally within a METS document. The content8814 file must be either Base64 encoded and contained within the8815 subsidiary <binData> wrapper element, or consist of XML8816 information and be contained within the subsidiary <xmlData>8817 wrapper element. ID (ID/O): This attribute uniquely identifies8818 the element within the METS document, and would allow the8819 element to be referenced unambiguously from another element or8820 document via an IDREF or an XPTR. For more information on using8821 ID attributes for internal and external linking see Chapter 4 of8822 the METS Primer. USE (string/O): A tagging attribute to indicate8823 the intended use of the specific copy of the file represented by8824 the <FContent> element (e.g., service master, archive master). A8825 USE attribute can be expressed at the<fileGrp> level, the <file>8826 level, the <FLocat> level and/or the <FContent> level. A USE8827 attribute value at the <fileGrp> level should pertain to all of8828 the files in the <fileGrp>. A USE attribute at the <file> level8829 should pertain to all copies of the file as represented by8830 subsidiary <FLocat> and/or <FContent> elements. A USE attribute8831 at the <FLocat> or <FContent> level pertains to the particular8832 copy of the file that is either referenced (<FLocat>) or wrapped8833 (<FContent>)."""8834 subclass = None8835 superclass = None8836 def __init__(8837 self,8838 USE=None,8839 ID=None,8840 binData=None,8841 xmlData=None,8842 ):8843 self.USE = _cast(None, USE)8844 self.ID = _cast(None, ID)8845 self.binData = binData8846 self.xmlData = xmlData8847 def factory(*args_, **kwargs_):8848 if FContent.subclass:8849 return FContent.subclass(*args_, **kwargs_)8850 else:8851 return FContent(*args_, **kwargs_)8852 factory = staticmethod(factory)8853 def get_binData(self):8854 return self.binData8855 def set_binData(self, binData):8856 self.binData = binData8857 def get_xmlData(self):8858 return self.xmlData8859 def set_xmlData(self, xmlData):8860 self.xmlData = xmlData8861 def get_USE(self):8862 return self.USE8863 def set_USE(self, USE):8864 self.USE = USE8865 def get_ID(self):8866 return self.ID8867 def set_ID(self, ID):8868 self.ID = ID8869 def export(8870 self,8871 outfile,8872 level,8873 namespace_='',8874 name_='FContent',8875 namespacedef_='',8876 ):8877 showIndent(outfile, level)8878 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_8879 and ' ' + namespacedef_ or ''))8880 self.exportAttributes(outfile, level, [], namespace_,8881 name_='FContent')8882 if self.hasContent_():8883 outfile.write('>\n')8884 self.exportChildren(outfile, level + 1, namespace_, name_)8885 showIndent(outfile, level)8886 outfile.write('</%s%s>\n' % (namespace_, name_))8887 else:8888 outfile.write('/>\n')8889 def exportAttributes(8890 self,8891 outfile,8892 level,8893 already_processed,8894 namespace_='',8895 name_='FContent',8896 ):8897 if self.USE is not None and 'USE' not in already_processed:8898 already_processed.append('USE')8899 outfile.write(' USE=%s'8900 % (self.gds_format_string(quote_attrib(self.USE).encode(ExternalEncoding),8901 input_name='USE'), ))8902 if self.ID is not None and 'ID' not in already_processed:8903 already_processed.append('ID')8904 outfile.write(' ID=%s'8905 % (self.gds_format_string(quote_attrib(self.ID).encode(ExternalEncoding),8906 input_name='ID'), ))8907 def exportChildren(8908 self,8909 outfile,8910 level,8911 namespace_='',8912 name_='FContent',8913 ):8914 if self.binData is not None:8915 showIndent(outfile, level)8916 outfile.write('<%sbinData>%s</%sbinData>\n' % (namespace_,8917 self.gds_format_string(quote_xml(self.binData).encode(ExternalEncoding),8918 input_name='binData'), namespace_))8919 if self.xmlData is not None:8920 showIndent(outfile, level)8921 outfile.write('<%sxmlData>%s</%sxmlData>\n' % (namespace_,8922 self.gds_format_string(quote_xml(self.xmlData).encode(ExternalEncoding),8923 input_name='xmlData'), namespace_))8924 def hasContent_(self):8925 if self.binData is not None or self.xmlData is not None:8926 return True8927 else:8928 return False8929 def exportLiteral(8930 self,8931 outfile,8932 level,8933 name_='FContent',8934 ):8935 level += 18936 self.exportLiteralAttributes(outfile, level, [], name_)8937 if self.hasContent_():8938 self.exportLiteralChildren(outfile, level, name_)8939 def exportLiteralAttributes(8940 self,8941 outfile,8942 level,8943 already_processed,8944 name_,8945 ):8946 if self.USE is not None and 'USE' not in already_processed:8947 already_processed.append('USE')8948 showIndent(outfile, level)8949 outfile.write('USE = "%s",\n' % (self.USE, ))8950 if self.ID is not None and 'ID' not in already_processed:8951 already_processed.append('ID')8952 showIndent(outfile, level)8953 outfile.write('ID = "%s",\n' % (self.ID, ))8954 def exportLiteralChildren(8955 self,8956 outfile,8957 level,8958 name_,8959 ):8960 if self.binData is not None:8961 showIndent(outfile, level)8962 outfile.write('binData=%s,\n'8963 % quote_python(self.binData).encode(ExternalEncoding))8964 if self.xmlData is not None:8965 showIndent(outfile, level)8966 outfile.write('xmlData=%s,\n'8967 % quote_python(self.xmlData).encode(ExternalEncoding))8968 def build(self, node):8969 self.buildAttributes(node, node.attrib, [])8970 for child in node:8971 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]8972 self.buildChildren(child, node, nodeName_)8973 def buildAttributes(8974 self,8975 node,8976 attrs,8977 already_processed,8978 ):8979 value = attrs.get('USE')8980 if value is not None and 'USE' not in already_processed:8981 already_processed.append('USE')8982 self.USE = value8983 value = attrs.get('ID')8984 if value is not None and 'ID' not in already_processed:8985 already_processed.append('ID')8986 self.ID = value8987 def buildChildren(8988 self,8989 child_,8990 node,8991 nodeName_,8992 from_subclass=False,8993 ):8994 if nodeName_ == 'binData':8995 binData_ = child_.text8996 binData_ = self.gds_validate_string(binData_, node,8997 'binData')8998 self.binData = binData_8999 elif nodeName_ == 'xmlData':9000 xmlData_ = child_.text9001 xmlData_ = self.gds_validate_string(xmlData_, node,9002 'xmlData')9003 self.xmlData = xmlData_9004# end class FContent9005class stream(GeneratedsSuper):9006 """A component byte stream element <stream> may be composed of one or9007 more subsidiary streams. An MPEG4 file, for example, might9008 contain separate audio and video streams, each of which is9009 associated with technical metadata. The repeatable <stream>9010 element provides a mechanism to record the existence of separate9011 data streams within a particular file, and the opportunity to9012 associate <dmdSec> and <amdSec> with those subsidiary data9013 streams if desired. ID (ID/O): This attribute uniquely9014 identifies the element within the METS document, and would allow9015 the element to be referenced unambiguously from another element9016 or document via an IDREF or an XPTR. For more information on9017 using ID attributes for internal and external linking see9018 Chapter 4 of the METS Primer. streamType (string/O): The IANA9019 MIME media type for the bytestream.OWNERID (string/O): Used to9020 provide a unique identifier (which could include a URI) assigned9021 to the file. This identifier may differ from the URI used to9022 retrieve the file. ADMID (IDREFS/O): Contains the ID attribute9023 values of the <techMD>, <sourceMD>, <rightsMD> and/or9024 <digiprovMD> elements within the <amdSec> of the METS document9025 that contain administrative metadata pertaining to the9026 bytestream. For more information on using METS IDREFS and IDREF9027 type attributes for internal linking, see Chapter 4 of the METS9028 Primer. DMDID (IDREFS/O): Contains the ID attribute values9029 identifying the <dmdSec>, elements in the METS document that9030 contain or link to descriptive metadata pertaining to the9031 content file stream represented by the current <stream> element.9032 For more information on using METS IDREFS and IDREF type9033 attributes for internal linking, see Chapter 4 of the METS9034 Primer. BEGIN (string/O): An attribute that specifies the point9035 in the parent <file> where the current <stream> begins. It can9036 be used in conjunction with the END attribute as a means of9037 defining the location of the stream within its parent file.9038 However, the BEGIN attribute can be used with or without a9039 companion END attribute. When no END attribute is specified, the9040 end of the parent file is assumed also to be the end point of9041 the stream. The BEGIN and END attributes can only be interpreted9042 meaningfully in conjunction with a BETYPE attribute, which9043 specifies the kind of beginning/ending point values that are9044 being used. END (string/O): An attribute that specifies the9045 point in the parent <file> where the <stream> ends. It can only9046 be interpreted meaningfully in conjunction with the BETYPE,9047 which specifies the kind of ending point values being used.9048 Typically the END attribute would only appear in conjunction9049 with a BEGIN attribute. BETYPE: Begin/End Type. BETYPE9050 (string/O): An attribute that specifies the kind of BEGIN and/or9051 END values that are being used. Currently BYTE is the only valid9052 value that can be used in conjunction with nested <file> or9053 <stream> elements."""9054 subclass = None9055 superclass = None9056 def __init__(9057 self,9058 BEGIN=None,9059 END=None,9060 ADMID=None,9061 BETYPE=None,9062 streamType=None,9063 DMDID=None,9064 OWNERID=None,9065 ID=None,9066 valueOf_=None,9067 ):9068 self.BEGIN = _cast(None, BEGIN)9069 self.END = _cast(None, END)9070 self.ADMID = _cast(None, ADMID)9071 self.BETYPE = _cast(None, BETYPE)9072 self.streamType = _cast(None, streamType)9073 self.DMDID = _cast(None, DMDID)9074 self.OWNERID = _cast(None, OWNERID)9075 self.ID = _cast(None, ID)9076 self.valueOf_ = valueOf_9077 def factory(*args_, **kwargs_):9078 if stream.subclass:9079 return stream.subclass(*args_, **kwargs_)9080 else:9081 return stream(*args_, **kwargs_)9082 factory = staticmethod(factory)9083 def get_BEGIN(self):9084 return self.BEGIN9085 def set_BEGIN(self, BEGIN):9086 self.BEGIN = BEGIN9087 def get_END(self):9088 return self.END9089 def set_END(self, END):9090 self.END = END9091 def get_ADMID(self):9092 return self.ADMID9093 def set_ADMID(self, ADMID):9094 self.ADMID = ADMID9095 def get_BETYPE(self):9096 return self.BETYPE9097 def set_BETYPE(self, BETYPE):9098 self.BETYPE = BETYPE9099 def get_streamType(self):9100 return self.streamType9101 def set_streamType(self, streamType):9102 self.streamType = streamType9103 def get_DMDID(self):9104 return self.DMDID9105 def set_DMDID(self, DMDID):9106 self.DMDID = DMDID9107 def get_OWNERID(self):9108 return self.OWNERID9109 def set_OWNERID(self, OWNERID):9110 self.OWNERID = OWNERID9111 def get_ID(self):9112 return self.ID9113 def set_ID(self, ID):9114 self.ID = ID9115 def get_valueOf_(self):9116 return self.valueOf_9117 def set_valueOf_(self, valueOf_):9118 self.valueOf_ = valueOf_9119 def export(9120 self,9121 outfile,9122 level,9123 namespace_='',9124 name_='stream',9125 namespacedef_='',9126 ):9127 showIndent(outfile, level)9128 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_9129 and ' ' + namespacedef_ or ''))9130 self.exportAttributes(outfile, level, [], namespace_,9131 name_='stream')9132 if self.hasContent_():9133 outfile.write('>')9134 outfile.write(self.valueOf_)9135 self.exportChildren(outfile, level + 1, namespace_, name_)9136 outfile.write('</%s%s>\n' % (namespace_, name_))9137 else:9138 outfile.write('/>\n')9139 def exportAttributes(9140 self,9141 outfile,9142 level,9143 already_processed,9144 namespace_='',9145 name_='stream',9146 ):9147 if self.BEGIN is not None and 'BEGIN' not in already_processed:9148 already_processed.append('BEGIN')9149 outfile.write(' BEGIN=%s'9150 % (self.gds_format_string(quote_attrib(self.BEGIN).encode(ExternalEncoding),9151 input_name='BEGIN'), ))9152 if self.END is not None and 'END' not in already_processed:9153 already_processed.append('END')9154 outfile.write(' END=%s'9155 % (self.gds_format_string(quote_attrib(self.END).encode(ExternalEncoding),9156 input_name='END'), ))9157 if self.ADMID is not None and 'ADMID' not in already_processed:9158 already_processed.append('ADMID')9159 outfile.write(' ADMID=%s'9160 % (self.gds_format_string(quote_attrib(self.ADMID).encode(ExternalEncoding),9161 input_name='ADMID'), ))9162 if self.BETYPE is not None and 'BETYPE' \9163 not in already_processed:9164 already_processed.append('BETYPE')9165 outfile.write(' BETYPE=%s'9166 % (self.gds_format_string(quote_attrib(self.BETYPE).encode(ExternalEncoding),9167 input_name='BETYPE'), ))9168 if self.streamType is not None and 'streamType' \9169 not in already_processed:9170 already_processed.append('streamType')9171 outfile.write(' streamType=%s'9172 % (self.gds_format_string(quote_attrib(self.streamType).encode(ExternalEncoding),9173 input_name='streamType'), ))9174 if self.DMDID is not None and 'DMDID' not in already_processed:9175 already_processed.append('DMDID')9176 outfile.write(' DMDID=%s'9177 % (self.gds_format_string(quote_attrib(self.DMDID).encode(ExternalEncoding),9178 input_name='DMDID'), ))9179 if self.OWNERID is not None and 'OWNERID' \9180 not in already_processed:9181 already_processed.append('OWNERID')9182 outfile.write(' OWNERID=%s'9183 % (self.gds_format_string(quote_attrib(self.OWNERID).encode(ExternalEncoding),9184 input_name='OWNERID'), ))9185 if self.ID is not None and 'ID' not in already_processed:9186 already_processed.append('ID')9187 outfile.write(' ID=%s'9188 % (self.gds_format_string(quote_attrib(self.ID).encode(ExternalEncoding),9189 input_name='ID'), ))9190 def exportChildren(9191 self,9192 outfile,9193 level,9194 namespace_='',9195 name_='stream',9196 ):9197 pass9198 def hasContent_(self):9199 if self.valueOf_:9200 return True9201 else:9202 return False9203 def exportLiteral(9204 self,9205 outfile,9206 level,9207 name_='stream',9208 ):9209 level += 19210 self.exportLiteralAttributes(outfile, level, [], name_)9211 if self.hasContent_():9212 self.exportLiteralChildren(outfile, level, name_)9213 showIndent(outfile, level)9214 outfile.write('valueOf_ = """%s""",\n' % (self.valueOf_, ))9215 def exportLiteralAttributes(9216 self,9217 outfile,9218 level,9219 already_processed,9220 name_,9221 ):9222 if self.BEGIN is not None and 'BEGIN' not in already_processed:9223 already_processed.append('BEGIN')9224 showIndent(outfile, level)9225 outfile.write('BEGIN = "%s",\n' % (self.BEGIN, ))9226 if self.END is not None and 'END' not in already_processed:9227 already_processed.append('END')9228 showIndent(outfile, level)9229 outfile.write('END = "%s",\n' % (self.END, ))9230 if self.ADMID is not None and 'ADMID' not in already_processed:9231 already_processed.append('ADMID')9232 showIndent(outfile, level)9233 outfile.write('ADMID = "%s",\n' % (self.ADMID, ))9234 if self.BETYPE is not None and 'BETYPE' \9235 not in already_processed:9236 already_processed.append('BETYPE')9237 showIndent(outfile, level)9238 outfile.write('BETYPE = "%s",\n' % (self.BETYPE, ))9239 if self.streamType is not None and 'streamType' \9240 not in already_processed:9241 already_processed.append('streamType')9242 showIndent(outfile, level)9243 outfile.write('streamType = "%s",\n' % (self.streamType, ))9244 if self.DMDID is not None and 'DMDID' not in already_processed:9245 already_processed.append('DMDID')9246 showIndent(outfile, level)9247 outfile.write('DMDID = "%s",\n' % (self.DMDID, ))9248 if self.OWNERID is not None and 'OWNERID' \9249 not in already_processed:9250 already_processed.append('OWNERID')9251 showIndent(outfile, level)9252 outfile.write('OWNERID = "%s",\n' % (self.OWNERID, ))9253 if self.ID is not None and 'ID' not in already_processed:9254 already_processed.append('ID')9255 showIndent(outfile, level)9256 outfile.write('ID = "%s",\n' % (self.ID, ))9257 def exportLiteralChildren(9258 self,9259 outfile,9260 level,9261 name_,9262 ):9263 pass9264 def build(self, node):9265 self.buildAttributes(node, node.attrib, [])9266 self.valueOf_ = get_all_text_(node)9267 for child in node:9268 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]9269 self.buildChildren(child, node, nodeName_)9270 def buildAttributes(9271 self,9272 node,9273 attrs,9274 already_processed,9275 ):9276 value = attrs.get('BEGIN')9277 if value is not None and 'BEGIN' not in already_processed:9278 already_processed.append('BEGIN')9279 self.BEGIN = value9280 value = attrs.get('END')9281 if value is not None and 'END' not in already_processed:9282 already_processed.append('END')9283 self.END = value9284 value = attrs.get('ADMID')9285 if value is not None and 'ADMID' not in already_processed:9286 already_processed.append('ADMID')9287 self.ADMID = value9288 value = attrs.get('BETYPE')9289 if value is not None and 'BETYPE' not in already_processed:9290 already_processed.append('BETYPE')9291 self.BETYPE = value9292 value = attrs.get('streamType')9293 if value is not None and 'streamType' not in already_processed:9294 already_processed.append('streamType')9295 self.streamType = value9296 value = attrs.get('DMDID')9297 if value is not None and 'DMDID' not in already_processed:9298 already_processed.append('DMDID')9299 self.DMDID = value9300 value = attrs.get('OWNERID')9301 if value is not None and 'OWNERID' not in already_processed:9302 already_processed.append('OWNERID')9303 self.OWNERID = value9304 value = attrs.get('ID')9305 if value is not None and 'ID' not in already_processed:9306 already_processed.append('ID')9307 self.ID = value9308 def buildChildren(9309 self,9310 child_,9311 node,9312 nodeName_,9313 from_subclass=False,9314 ):9315 pass9316# end class stream9317class transformFile(GeneratedsSuper):9318 """The transform file element <transformFile> provides a means to9319 access any subsidiary files listed below a <file> element by9320 indicating the steps required to "unpack" or transform the9321 subsidiary files. This element is repeatable and might provide a9322 link to a <behavior> in the <behaviorSec> that performs the9323 transformation.ID (ID/O): This attribute uniquely identifies the9324 element within the METS document, and would allow the element to9325 be referenced unambiguously from another element or document via9326 an IDREF or an XPTR. For more information on using ID attributes9327 for internal and external linking see Chapter 4 of the METS9328 Primer. TRANSFORMTYPE (string/R): Is used to indicate the type9329 of transformation needed to render content of a file accessible.9330 This may include unpacking a file into subsidiary files/streams.9331 The controlled value constraints for this XML string include9332 "decompression" and "decryption". Decompression is9333 defined as the action of reversing data compression, i.e., the9334 process of encoding information using fewer bits than an9335 unencoded representation would use by means of specific encoding9336 schemas. Decryption is defined as the process of restoring data9337 that has been obscured to make it unreadable without special9338 knowledge (encrypted data) to its original form. TRANSFORM-9339 ALGORITHM (string/R): Specifies the decompression or decryption9340 routine used to access the contents of the file. Algorithms for9341 compression can be either loss-less or lossy.TRANSFORMKEY9342 (string/O): A key to be used with the transform algorithm for9343 accessing the file's contents.TRANSFORMBEHAVIOR (string/O): An9344 IDREF to a behavior element for this9345 transformation.TRANSFORMORDER (postive-integer/R): The order in9346 which the instructions must be followed in order to unpack or9347 transform the container file."""9348 subclass = None9349 superclass = None9350 def __init__(9351 self,9352 TRANSFORMTYPE=None,9353 TRANSFORMKEY=None,9354 TRANSFORMBEHAVIOR=None,9355 TRANSFORMALGORITHM=None,9356 TRANSFORMORDER=None,9357 ID=None,9358 valueOf_=None,9359 ):9360 self.TRANSFORMTYPE = _cast(None, TRANSFORMTYPE)9361 self.TRANSFORMKEY = _cast(None, TRANSFORMKEY)9362 self.TRANSFORMBEHAVIOR = _cast(None, TRANSFORMBEHAVIOR)9363 self.TRANSFORMALGORITHM = _cast(None, TRANSFORMALGORITHM)9364 self.TRANSFORMORDER = _cast(int, TRANSFORMORDER)9365 self.ID = _cast(None, ID)9366 self.valueOf_ = valueOf_9367 def factory(*args_, **kwargs_):9368 if transformFile.subclass:9369 return transformFile.subclass(*args_, **kwargs_)9370 else:9371 return transformFile(*args_, **kwargs_)9372 factory = staticmethod(factory)9373 def get_TRANSFORMTYPE(self):9374 return self.TRANSFORMTYPE9375 def set_TRANSFORMTYPE(self, TRANSFORMTYPE):9376 self.TRANSFORMTYPE = TRANSFORMTYPE9377 def get_TRANSFORMKEY(self):9378 return self.TRANSFORMKEY9379 def set_TRANSFORMKEY(self, TRANSFORMKEY):9380 self.TRANSFORMKEY = TRANSFORMKEY9381 def get_TRANSFORMBEHAVIOR(self):9382 return self.TRANSFORMBEHAVIOR9383 def set_TRANSFORMBEHAVIOR(self, TRANSFORMBEHAVIOR):9384 self.TRANSFORMBEHAVIOR = TRANSFORMBEHAVIOR9385 def get_TRANSFORMALGORITHM(self):9386 return self.TRANSFORMALGORITHM9387 def set_TRANSFORMALGORITHM(self, TRANSFORMALGORITHM):9388 self.TRANSFORMALGORITHM = TRANSFORMALGORITHM9389 def get_TRANSFORMORDER(self):9390 return self.TRANSFORMORDER9391 def set_TRANSFORMORDER(self, TRANSFORMORDER):9392 self.TRANSFORMORDER = TRANSFORMORDER9393 def get_ID(self):9394 return self.ID9395 def set_ID(self, ID):9396 self.ID = ID9397 def get_valueOf_(self):9398 return self.valueOf_9399 def set_valueOf_(self, valueOf_):9400 self.valueOf_ = valueOf_9401 def export(9402 self,9403 outfile,9404 level,9405 namespace_='',9406 name_='transformFile',9407 namespacedef_='',9408 ):9409 showIndent(outfile, level)9410 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_9411 and ' ' + namespacedef_ or ''))9412 self.exportAttributes(outfile, level, [], namespace_,9413 name_='transformFile')9414 if self.hasContent_():9415 outfile.write('>')9416 outfile.write(self.valueOf_)9417 self.exportChildren(outfile, level + 1, namespace_, name_)9418 outfile.write('</%s%s>\n' % (namespace_, name_))9419 else:9420 outfile.write('/>\n')9421 def exportAttributes(9422 self,9423 outfile,9424 level,9425 already_processed,9426 namespace_='',9427 name_='transformFile',9428 ):9429 if self.TRANSFORMTYPE is not None and 'TRANSFORMTYPE' \9430 not in already_processed:9431 already_processed.append('TRANSFORMTYPE')9432 outfile.write(' TRANSFORMTYPE=%s'9433 % (self.gds_format_string(quote_attrib(self.TRANSFORMTYPE).encode(ExternalEncoding),9434 input_name='TRANSFORMTYPE'), ))9435 if self.TRANSFORMKEY is not None and 'TRANSFORMKEY' \9436 not in already_processed:9437 already_processed.append('TRANSFORMKEY')9438 outfile.write(' TRANSFORMKEY=%s'9439 % (self.gds_format_string(quote_attrib(self.TRANSFORMKEY).encode(ExternalEncoding),9440 input_name='TRANSFORMKEY'), ))9441 if self.TRANSFORMBEHAVIOR is not None and 'TRANSFORMBEHAVIOR' \9442 not in already_processed:9443 already_processed.append('TRANSFORMBEHAVIOR')9444 outfile.write(' TRANSFORMBEHAVIOR=%s'9445 % (self.gds_format_string(quote_attrib(self.TRANSFORMBEHAVIOR).encode(ExternalEncoding),9446 input_name='TRANSFORMBEHAVIOR'), ))9447 if self.TRANSFORMALGORITHM is not None and 'TRANSFORMALGORITHM' \9448 not in already_processed:9449 already_processed.append('TRANSFORMALGORITHM')9450 outfile.write(' TRANSFORMALGORITHM=%s'9451 % (self.gds_format_string(quote_attrib(self.TRANSFORMALGORITHM).encode(ExternalEncoding),9452 input_name='TRANSFORMALGORITHM'), ))9453 if self.TRANSFORMORDER is not None and 'TRANSFORMORDER' \9454 not in already_processed:9455 already_processed.append('TRANSFORMORDER')9456 outfile.write(' TRANSFORMORDER="%s"'9457 % self.gds_format_integer(self.TRANSFORMORDER,9458 input_name='TRANSFORMORDER'))9459 if self.ID is not None and 'ID' not in already_processed:9460 already_processed.append('ID')9461 outfile.write(' ID=%s'9462 % (self.gds_format_string(quote_attrib(self.ID).encode(ExternalEncoding),9463 input_name='ID'), ))9464 def exportChildren(9465 self,9466 outfile,9467 level,9468 namespace_='',9469 name_='transformFile',9470 ):9471 pass9472 def hasContent_(self):9473 if self.valueOf_:9474 return True9475 else:9476 return False...

Full Screen

Full Screen

datafile.py

Source:datafile.py Github

copy

Full Screen

...160 def tzname(self, dt):161 return self.__name162 def dst(self, dt):163 return None164 def gds_format_string(self, input_data, input_name=''):165 return input_data166 def gds_parse_string(self, input_data, node=None, input_name=''):167 return input_data168 def gds_validate_string(self, input_data, node=None, input_name=''):169 if not input_data:170 return ''171 else:172 return input_data173 def gds_format_base64(self, input_data, input_name=''):174 return base64.b64encode(input_data)175 def gds_validate_base64(self, input_data, node=None, input_name=''):176 return input_data177 def gds_format_integer(self, input_data, input_name=''):178 return '%d' % input_data179 def gds_parse_integer(self, input_data, node=None, input_name=''):180 try:181 ival = int(input_data)182 except (TypeError, ValueError) as exp:183 raise_parse_error(node, 'Requires integer value: %s' % exp)184 return ival185 def gds_validate_integer(self, input_data, node=None, input_name=''):186 try:187 value = int(input_data)188 except (TypeError, ValueError):189 raise_parse_error(node, 'Requires integer value')190 return value191 def gds_format_integer_list(self, input_data, input_name=''):192 return '%s' % ' '.join(input_data)193 def gds_validate_integer_list(194 self, input_data, node=None, input_name=''):195 values = input_data.split()196 for value in values:197 try:198 int(value)199 except (TypeError, ValueError):200 raise_parse_error(node, 'Requires sequence of integer valuess')201 return values202 def gds_format_float(self, input_data, input_name=''):203 return ('%.15f' % input_data).rstrip('0')204 def gds_parse_float(self, input_data, node=None, input_name=''):205 try:206 fval_ = float(input_data)207 except (TypeError, ValueError) as exp:208 raise_parse_error(node, 'Requires float or double value: %s' % exp)209 return fval_210 def gds_validate_float(self, input_data, node=None, input_name=''):211 try:212 value = float(input_data)213 except (TypeError, ValueError):214 raise_parse_error(node, 'Requires float value')215 return value216 def gds_format_float_list(self, input_data, input_name=''):217 return '%s' % ' '.join(input_data)218 def gds_validate_float_list(219 self, input_data, node=None, input_name=''):220 values = input_data.split()221 for value in values:222 try:223 float(value)224 except (TypeError, ValueError):225 raise_parse_error(node, 'Requires sequence of float values')226 return values227 def gds_format_decimal(self, input_data, input_name=''):228 return ('%0.10f' % input_data).rstrip('0')229 def gds_parse_decimal(self, input_data, node=None, input_name=''):230 try:231 decimal_value = decimal_.Decimal(input_data)232 except (TypeError, ValueError):233 raise_parse_error(node, 'Requires decimal value')234 return decimal_value235 def gds_validate_decimal(self, input_data, node=None, input_name=''):236 try:237 value = decimal_.Decimal(input_data)238 except (TypeError, ValueError):239 raise_parse_error(node, 'Requires decimal value')240 return value241 def gds_format_decimal_list(self, input_data, input_name=''):242 return '%s' % ' '.join(input_data)243 def gds_validate_decimal_list(244 self, input_data, node=None, input_name=''):245 values = input_data.split()246 for value in values:247 try:248 decimal_.Decimal(value)249 except (TypeError, ValueError):250 raise_parse_error(node, 'Requires sequence of decimal values')251 return values252 def gds_format_double(self, input_data, input_name=''):253 return '%e' % input_data254 def gds_parse_double(self, input_data, node=None, input_name=''):255 try:256 fval_ = float(input_data)257 except (TypeError, ValueError) as exp:258 raise_parse_error(node, 'Requires double or float value: %s' % exp)259 return fval_260 def gds_validate_double(self, input_data, node=None, input_name=''):261 try:262 value = float(input_data)263 except (TypeError, ValueError):264 raise_parse_error(node, 'Requires double or float value')265 return value266 def gds_format_double_list(self, input_data, input_name=''):267 return '%s' % ' '.join(input_data)268 def gds_validate_double_list(269 self, input_data, node=None, input_name=''):270 values = input_data.split()271 for value in values:272 try:273 float(value)274 except (TypeError, ValueError):275 raise_parse_error(276 node, 'Requires sequence of double or float values')277 return values278 def gds_format_boolean(self, input_data, input_name=''):279 return ('%s' % input_data).lower()280 def gds_parse_boolean(self, input_data, node=None, input_name=''):281 if input_data in ('true', '1'):282 bval = True283 elif input_data in ('false', '0'):284 bval = False285 else:286 raise_parse_error(node, 'Requires boolean value')287 return bval288 def gds_validate_boolean(self, input_data, node=None, input_name=''):289 if input_data not in (True, 1, False, 0, ):290 raise_parse_error(291 node,292 'Requires boolean value '293 '(one of True, 1, False, 0)')294 return input_data295 def gds_format_boolean_list(self, input_data, input_name=''):296 return '%s' % ' '.join(input_data)297 def gds_validate_boolean_list(298 self, input_data, node=None, input_name=''):299 values = input_data.split()300 for value in values:301 if value not in (True, 1, False, 0, ):302 raise_parse_error(303 node,304 'Requires sequence of boolean values '305 '(one of True, 1, False, 0)')306 return values307 def gds_validate_datetime(self, input_data, node=None, input_name=''):308 return input_data309 def gds_format_datetime(self, input_data, input_name=''):310 if input_data.microsecond == 0:311 _svalue = '%04d-%02d-%02dT%02d:%02d:%02d' % (312 input_data.year,313 input_data.month,314 input_data.day,315 input_data.hour,316 input_data.minute,317 input_data.second,318 )319 else:320 _svalue = '%04d-%02d-%02dT%02d:%02d:%02d.%s' % (321 input_data.year,322 input_data.month,323 input_data.day,324 input_data.hour,325 input_data.minute,326 input_data.second,327 ('%f' % (float(input_data.microsecond) / 1000000))[2:],328 )329 if input_data.tzinfo is not None:330 tzoff = input_data.tzinfo.utcoffset(input_data)331 if tzoff is not None:332 total_seconds = tzoff.seconds + (86400 * tzoff.days)333 if total_seconds == 0:334 _svalue += 'Z'335 else:336 if total_seconds < 0:337 _svalue += '-'338 total_seconds *= -1339 else:340 _svalue += '+'341 hours = total_seconds // 3600342 minutes = (total_seconds - (hours * 3600)) // 60343 _svalue += '{0:02d}:{1:02d}'.format(hours, minutes)344 return _svalue345 @classmethod346 def gds_parse_datetime(cls, input_data):347 tz = None348 if input_data[-1] == 'Z':349 tz = GeneratedsSuper._FixedOffsetTZ(0, 'UTC')350 input_data = input_data[:-1]351 else:352 results = GeneratedsSuper.tzoff_pattern.search(input_data)353 if results is not None:354 tzoff_parts = results.group(2).split(':')355 tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1])356 if results.group(1) == '-':357 tzoff *= -1358 tz = GeneratedsSuper._FixedOffsetTZ(359 tzoff, results.group(0))360 input_data = input_data[:-6]361 time_parts = input_data.split('.')362 if len(time_parts) > 1:363 micro_seconds = int(float('0.' + time_parts[1]) * 1000000)364 input_data = '%s.%s' % (365 time_parts[0], "{}".format(micro_seconds).rjust(6, "0"), )366 dt = datetime_.datetime.strptime(367 input_data, '%Y-%m-%dT%H:%M:%S.%f')368 else:369 dt = datetime_.datetime.strptime(370 input_data, '%Y-%m-%dT%H:%M:%S')371 dt = dt.replace(tzinfo=tz)372 return dt373 def gds_validate_date(self, input_data, node=None, input_name=''):374 return input_data375 def gds_format_date(self, input_data, input_name=''):376 _svalue = '%04d-%02d-%02d' % (377 input_data.year,378 input_data.month,379 input_data.day,380 )381 try:382 if input_data.tzinfo is not None:383 tzoff = input_data.tzinfo.utcoffset(input_data)384 if tzoff is not None:385 total_seconds = tzoff.seconds + (86400 * tzoff.days)386 if total_seconds == 0:387 _svalue += 'Z'388 else:389 if total_seconds < 0:390 _svalue += '-'391 total_seconds *= -1392 else:393 _svalue += '+'394 hours = total_seconds // 3600395 minutes = (total_seconds - (hours * 3600)) // 60396 _svalue += '{0:02d}:{1:02d}'.format(397 hours, minutes)398 except AttributeError:399 pass400 return _svalue401 @classmethod402 def gds_parse_date(cls, input_data):403 tz = None404 if input_data[-1] == 'Z':405 tz = GeneratedsSuper._FixedOffsetTZ(0, 'UTC')406 input_data = input_data[:-1]407 else:408 results = GeneratedsSuper.tzoff_pattern.search(input_data)409 if results is not None:410 tzoff_parts = results.group(2).split(':')411 tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1])412 if results.group(1) == '-':413 tzoff *= -1414 tz = GeneratedsSuper._FixedOffsetTZ(415 tzoff, results.group(0))416 input_data = input_data[:-6]417 dt = datetime_.datetime.strptime(input_data, '%Y-%m-%d')418 dt = dt.replace(tzinfo=tz)419 return dt.date()420 def gds_validate_time(self, input_data, node=None, input_name=''):421 return input_data422 def gds_format_time(self, input_data, input_name=''):423 if input_data.microsecond == 0:424 _svalue = '%02d:%02d:%02d' % (425 input_data.hour,426 input_data.minute,427 input_data.second,428 )429 else:430 _svalue = '%02d:%02d:%02d.%s' % (431 input_data.hour,432 input_data.minute,433 input_data.second,434 ('%f' % (float(input_data.microsecond) / 1000000))[2:],435 )436 if input_data.tzinfo is not None:437 tzoff = input_data.tzinfo.utcoffset(input_data)438 if tzoff is not None:439 total_seconds = tzoff.seconds + (86400 * tzoff.days)440 if total_seconds == 0:441 _svalue += 'Z'442 else:443 if total_seconds < 0:444 _svalue += '-'445 total_seconds *= -1446 else:447 _svalue += '+'448 hours = total_seconds // 3600449 minutes = (total_seconds - (hours * 3600)) // 60450 _svalue += '{0:02d}:{1:02d}'.format(hours, minutes)451 return _svalue452 def gds_validate_simple_patterns(self, patterns, target):453 # pat is a list of lists of strings/patterns.454 # The target value must match at least one of the patterns455 # in order for the test to succeed.456 found1 = True457 for patterns1 in patterns:458 found2 = False459 for patterns2 in patterns1:460 mo = re_.search(patterns2, target)461 if mo is not None and len(mo.group(0)) == len(target):462 found2 = True463 break464 if not found2:465 found1 = False466 break467 return found1468 @classmethod469 def gds_parse_time(cls, input_data):470 tz = None471 if input_data[-1] == 'Z':472 tz = GeneratedsSuper._FixedOffsetTZ(0, 'UTC')473 input_data = input_data[:-1]474 else:475 results = GeneratedsSuper.tzoff_pattern.search(input_data)476 if results is not None:477 tzoff_parts = results.group(2).split(':')478 tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1])479 if results.group(1) == '-':480 tzoff *= -1481 tz = GeneratedsSuper._FixedOffsetTZ(482 tzoff, results.group(0))483 input_data = input_data[:-6]484 if len(input_data.split('.')) > 1:485 dt = datetime_.datetime.strptime(input_data, '%H:%M:%S.%f')486 else:487 dt = datetime_.datetime.strptime(input_data, '%H:%M:%S')488 dt = dt.replace(tzinfo=tz)489 return dt.time()490 def gds_check_cardinality_(491 self, value, input_name,492 min_occurs=0, max_occurs=1, required=None):493 if value is None:494 length = 0495 elif isinstance(value, list):496 length = len(value)497 else:498 length = 1499 if required is not None :500 if required and length < 1:501 self.gds_collector_.add_message(502 "Required value {}{} is missing".format(503 input_name, self.gds_get_node_lineno_()))504 if length < min_occurs:505 self.gds_collector_.add_message(506 "Number of values for {}{} is below "507 "the minimum allowed, "508 "expected at least {}, found {}".format(509 input_name, self.gds_get_node_lineno_(),510 min_occurs, length))511 elif length > max_occurs:512 self.gds_collector_.add_message(513 "Number of values for {}{} is above "514 "the maximum allowed, "515 "expected at most {}, found {}".format(516 input_name, self.gds_get_node_lineno_(),517 max_occurs, length))518 def gds_validate_builtin_ST_(519 self, validator, value, input_name,520 min_occurs=None, max_occurs=None, required=None):521 if value is not None:522 try:523 validator(value, input_name=input_name)524 except GDSParseError as parse_error:525 self.gds_collector_.add_message(str(parse_error))526 def gds_validate_defined_ST_(527 self, validator, value, input_name,528 min_occurs=None, max_occurs=None, required=None):529 if value is not None:530 try:531 validator(value)532 except GDSParseError as parse_error:533 self.gds_collector_.add_message(str(parse_error))534 def gds_str_lower(self, instring):535 return instring.lower()536 def get_path_(self, node):537 path_list = []538 self.get_path_list_(node, path_list)539 path_list.reverse()540 path = '/'.join(path_list)541 return path542 Tag_strip_pattern_ = re_.compile(r'\{.*\}')543 def get_path_list_(self, node, path_list):544 if node is None:545 return546 tag = GeneratedsSuper.Tag_strip_pattern_.sub('', node.tag)547 if tag:548 path_list.append(tag)549 self.get_path_list_(node.getparent(), path_list)550 def get_class_obj_(self, node, default_class=None):551 class_obj1 = default_class552 if 'xsi' in node.nsmap:553 classname = node.get('{%s}type' % node.nsmap['xsi'])554 if classname is not None:555 names = classname.split(':')556 if len(names) == 2:557 classname = names[1]558 class_obj2 = globals().get(classname)559 if class_obj2 is not None:560 class_obj1 = class_obj2561 return class_obj1562 def gds_build_any(self, node, type_name=None):563 # provide default value in case option --disable-xml is used.564 content = ""565 content = etree_.tostring(node, encoding="unicode")566 return content567 @classmethod568 def gds_reverse_node_mapping(cls, mapping):569 return dict(((v, k) for k, v in mapping.items()))570 @staticmethod571 def gds_encode(instring):572 return instring573 @staticmethod574 def convert_unicode(instring):575 if isinstance(instring, str):576 result = quote_xml(instring)577 else:578 result = GeneratedsSuper.gds_encode(str(instring))579 return result580 def __eq__(self, other):581 def excl_select_objs_(obj):582 return (obj[0] != 'parent_object_' and583 obj[0] != 'gds_collector_')584 if type(self) != type(other):585 return False586 return all(x == y for x, y in zip_longest(587 filter(excl_select_objs_, self.__dict__.items()),588 filter(excl_select_objs_, other.__dict__.items())))589 def __ne__(self, other):590 return not self.__eq__(other)591 # Django ETL transform hooks.592 def gds_djo_etl_transform(self):593 pass594 def gds_djo_etl_transform_db_obj(self, dbobj):595 pass596 # SQLAlchemy ETL transform hooks.597 def gds_sqa_etl_transform(self):598 return 0, None599 def gds_sqa_etl_transform_db_obj(self, dbobj):600 pass601 def gds_get_node_lineno_(self):602 if (hasattr(self, "gds_elementtree_node_") and603 self.gds_elementtree_node_ is not None):604 return ' near line {}'.format(605 self.gds_elementtree_node_.sourceline)606 else:607 return ""608 609 610 def getSubclassFromModule_(module, class_):611 '''Get the subclass of a class from a specific module.'''612 name = class_.__name__ + 'Sub'613 if hasattr(module, name):614 return getattr(module, name)615 else:616 return None617#618# If you have installed IPython you can uncomment and use the following.619# IPython is available from http://ipython.scipy.org/.620#621## from IPython.Shell import IPShellEmbed622## args = ''623## ipshell = IPShellEmbed(args,624## banner = 'Dropping into IPython',625## exit_msg = 'Leaving Interpreter, back to program.')626# Then use the following line where and when you want to drop into the627# IPython shell:628# ipshell('<some message> -- Entering ipshell.\nHit Ctrl-D to exit')629#630# Globals631#632ExternalEncoding = ''633# Set this to false in order to deactivate during export, the use of634# name space prefixes captured from the input document.635UseCapturedNS_ = True636CapturedNsmap_ = {}637Tag_pattern_ = re_.compile(r'({.*})?(.*)')638String_cleanup_pat_ = re_.compile(r"[\n\r\s]+")639Namespace_extract_pat_ = re_.compile(r'{(.*)}(.*)')640CDATA_pattern_ = re_.compile(r"<!\[CDATA\[.*?\]\]>", re_.DOTALL)641# Change this to redirect the generated superclass module to use a642# specific subclass module.643CurrentSubclassModule_ = None644#645# Support/utility functions.646#647def showIndent(outfile, level, pretty_print=True):648 if pretty_print:649 for idx in range(level):650 outfile.write(' ')651def quote_xml(inStr):652 "Escape markup chars, but do not modify CDATA sections."653 if not inStr:654 return ''655 s1 = (isinstance(inStr, str) and inStr or '%s' % inStr)656 s2 = ''657 pos = 0658 matchobjects = CDATA_pattern_.finditer(s1)659 for mo in matchobjects:660 s3 = s1[pos:mo.start()]661 s2 += quote_xml_aux(s3)662 s2 += s1[mo.start():mo.end()]663 pos = mo.end()664 s3 = s1[pos:]665 s2 += quote_xml_aux(s3)666 return s2667def quote_xml_aux(inStr):668 s1 = inStr.replace('&', '&amp;')669 s1 = s1.replace('<', '&lt;')670 s1 = s1.replace('>', '&gt;')671 return s1672def quote_attrib(inStr):673 s1 = (isinstance(inStr, str) and inStr or '%s' % inStr)674 s1 = s1.replace('&', '&amp;')675 s1 = s1.replace('<', '&lt;')676 s1 = s1.replace('>', '&gt;')677 if '"' in s1:678 if "'" in s1:679 s1 = '"%s"' % s1.replace('"', "&quot;")680 else:681 s1 = "'%s'" % s1682 else:683 s1 = '"%s"' % s1684 return s1685def quote_python(inStr):686 s1 = inStr687 if s1.find("'") == -1:688 if s1.find('\n') == -1:689 return "'%s'" % s1690 else:691 return "'''%s'''" % s1692 else:693 if s1.find('"') != -1:694 s1 = s1.replace('"', '\\"')695 if s1.find('\n') == -1:696 return '"%s"' % s1697 else:698 return '"""%s"""' % s1699def get_all_text_(node):700 if node.text is not None:701 text = node.text702 else:703 text = ''704 for child in node:705 if child.tail is not None:706 text += child.tail707 return text708def find_attr_value_(attr_name, node):709 attrs = node.attrib710 attr_parts = attr_name.split(':')711 value = None712 if len(attr_parts) == 1:713 value = attrs.get(attr_name)714 elif len(attr_parts) == 2:715 prefix, name = attr_parts716 namespace = node.nsmap.get(prefix)717 if namespace is not None:718 value = attrs.get('{%s}%s' % (namespace, name, ))719 return value720def encode_str_2_3(instr):721 return instr722class GDSParseError(Exception):723 pass724def raise_parse_error(node, msg):725 if node is not None:726 msg = '%s (element %s/line %d)' % (msg, node.tag, node.sourceline, )727 raise GDSParseError(msg)728class MixedContainer:729 # Constants for category:730 CategoryNone = 0731 CategoryText = 1732 CategorySimple = 2733 CategoryComplex = 3734 # Constants for content_type:735 TypeNone = 0736 TypeText = 1737 TypeString = 2738 TypeInteger = 3739 TypeFloat = 4740 TypeDecimal = 5741 TypeDouble = 6742 TypeBoolean = 7743 TypeBase64 = 8744 def __init__(self, category, content_type, name, value):745 self.category = category746 self.content_type = content_type747 self.name = name748 self.value = value749 def getCategory(self):750 return self.category751 def getContenttype(self, content_type):752 return self.content_type753 def getValue(self):754 return self.value755 def getName(self):756 return self.name757 def export(self, outfile, level, name, namespace,758 pretty_print=True):759 if self.category == MixedContainer.CategoryText:760 # Prevent exporting empty content as empty lines.761 if self.value.strip():762 outfile.write(self.value)763 elif self.category == MixedContainer.CategorySimple:764 self.exportSimple(outfile, level, name)765 else: # category == MixedContainer.CategoryComplex766 self.value.export(767 outfile, level, namespace, name_=name,768 pretty_print=pretty_print)769 def exportSimple(self, outfile, level, name):770 if self.content_type == MixedContainer.TypeString:771 outfile.write('<%s>%s</%s>' % (772 self.name, self.value, self.name))773 elif self.content_type == MixedContainer.TypeInteger or \774 self.content_type == MixedContainer.TypeBoolean:775 outfile.write('<%s>%d</%s>' % (776 self.name, self.value, self.name))777 elif self.content_type == MixedContainer.TypeFloat or \778 self.content_type == MixedContainer.TypeDecimal:779 outfile.write('<%s>%f</%s>' % (780 self.name, self.value, self.name))781 elif self.content_type == MixedContainer.TypeDouble:782 outfile.write('<%s>%g</%s>' % (783 self.name, self.value, self.name))784 elif self.content_type == MixedContainer.TypeBase64:785 outfile.write('<%s>%s</%s>' % (786 self.name,787 base64.b64encode(self.value),788 self.name))789 def to_etree(self, element):790 if self.category == MixedContainer.CategoryText:791 # Prevent exporting empty content as empty lines.792 if self.value.strip():793 if len(element) > 0:794 if element[-1].tail is None:795 element[-1].tail = self.value796 else:797 element[-1].tail += self.value798 else:799 if element.text is None:800 element.text = self.value801 else:802 element.text += self.value803 elif self.category == MixedContainer.CategorySimple:804 subelement = etree_.SubElement(805 element, '%s' % self.name)806 subelement.text = self.to_etree_simple()807 else: # category == MixedContainer.CategoryComplex808 self.value.to_etree(element)809 def to_etree_simple(self):810 if self.content_type == MixedContainer.TypeString:811 text = self.value812 elif (self.content_type == MixedContainer.TypeInteger or813 self.content_type == MixedContainer.TypeBoolean):814 text = '%d' % self.value815 elif (self.content_type == MixedContainer.TypeFloat or816 self.content_type == MixedContainer.TypeDecimal):817 text = '%f' % self.value818 elif self.content_type == MixedContainer.TypeDouble:819 text = '%g' % self.value820 elif self.content_type == MixedContainer.TypeBase64:821 text = '%s' % base64.b64encode(self.value)822 return text823 def exportLiteral(self, outfile, level, name):824 if self.category == MixedContainer.CategoryText:825 showIndent(outfile, level)826 outfile.write(827 'model_.MixedContainer(%d, %d, "%s", "%s"),\n' % (828 self.category, self.content_type,829 self.name, self.value))830 elif self.category == MixedContainer.CategorySimple:831 showIndent(outfile, level)832 outfile.write(833 'model_.MixedContainer(%d, %d, "%s", "%s"),\n' % (834 self.category, self.content_type,835 self.name, self.value))836 else: # category == MixedContainer.CategoryComplex837 showIndent(outfile, level)838 outfile.write(839 'model_.MixedContainer(%d, %d, "%s",\n' % (840 self.category, self.content_type, self.name,))841 self.value.exportLiteral(outfile, level + 1)842 showIndent(outfile, level)843 outfile.write(')\n')844class MemberSpec_(object):845 def __init__(self, name='', data_type='', container=0,846 optional=0, child_attrs=None, choice=None):847 self.name = name848 self.data_type = data_type849 self.container = container850 self.child_attrs = child_attrs851 self.choice = choice852 self.optional = optional853 def set_name(self, name): self.name = name854 def get_name(self): return self.name855 def set_data_type(self, data_type): self.data_type = data_type856 def get_data_type_chain(self): return self.data_type857 def get_data_type(self):858 if isinstance(self.data_type, list):859 if len(self.data_type) > 0:860 return self.data_type[-1]861 else:862 return 'xs:string'863 else:864 return self.data_type865 def set_container(self, container): self.container = container866 def get_container(self): return self.container867 def set_child_attrs(self, child_attrs): self.child_attrs = child_attrs868 def get_child_attrs(self): return self.child_attrs869 def set_choice(self, choice): self.choice = choice870 def get_choice(self): return self.choice871 def set_optional(self, optional): self.optional = optional872 def get_optional(self): return self.optional873def _cast(typ, value):874 if typ is None or value is None:875 return value876 return typ(value)877#878# Data representation classes.879#880class datafile(GeneratedsSuper):881 __hash__ = GeneratedsSuper.__hash__882 subclass = None883 superclass = None884 def __init__(self, build_=None, debug='no', header=None, game=None, gds_collector_=None, **kwargs_):885 self.gds_collector_ = gds_collector_886 self.gds_elementtree_node_ = None887 self.original_tagname_ = None888 self.parent_object_ = kwargs_.get('parent_object_')889 self.ns_prefix_ = None890 self.build_ = _cast(None, build_)891 self.build__nsprefix_ = None892 self.debug = _cast(None, debug)893 self.debug_nsprefix_ = None894 self.header = header895 self.header_nsprefix_ = None896 if game is None:897 self.game = []898 else:899 self.game = game900 self.game_nsprefix_ = None901 def factory(*args_, **kwargs_):902 if CurrentSubclassModule_ is not None:903 subclass = getSubclassFromModule_(904 CurrentSubclassModule_, datafile)905 if subclass is not None:906 return subclass(*args_, **kwargs_)907 if datafile.subclass:908 return datafile.subclass(*args_, **kwargs_)909 else:910 return datafile(*args_, **kwargs_)911 factory = staticmethod(factory)912 def get_ns_prefix_(self):913 return self.ns_prefix_914 def set_ns_prefix_(self, ns_prefix):915 self.ns_prefix_ = ns_prefix916 def get_header(self):917 return self.header918 def set_header(self, header):919 self.header = header920 def get_game(self):921 return self.game922 def set_game(self, game):923 self.game = game924 def add_game(self, value):925 self.game.append(value)926 def insert_game_at(self, index, value):927 self.game.insert(index, value)928 def replace_game_at(self, index, value):929 self.game[index] = value930 def get_build(self):931 return self.build_932 def set_build(self, build_):933 self.build_ = build_934 def get_debug(self):935 return self.debug936 def set_debug(self, debug):937 self.debug = debug938 def hasContent_(self):939 if (940 self.header is not None or941 self.game942 ):943 return True944 else:945 return False946 def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='datafile', pretty_print=True):947 imported_ns_def_ = GenerateDSNamespaceDefs_.get('datafile')948 if imported_ns_def_ is not None:949 namespacedef_ = imported_ns_def_950 if pretty_print:951 eol_ = '\n'952 else:953 eol_ = ''954 if self.original_tagname_ is not None:955 name_ = self.original_tagname_956 if UseCapturedNS_ and self.ns_prefix_:957 namespaceprefix_ = self.ns_prefix_ + ':'958 showIndent(outfile, level, pretty_print)959 outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))960 already_processed = set()961 self.exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='datafile')962 if self.hasContent_():963 outfile.write('>%s' % (eol_, ))964 self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='datafile', pretty_print=pretty_print)965 showIndent(outfile, level, pretty_print)966 outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))967 else:968 outfile.write('/>%s' % (eol_, ))969 def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='datafile'):970 if self.build_ is not None and 'build_' not in already_processed:971 already_processed.add('build_')972 outfile.write(' build=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.build_), input_name='build')), ))973 if self.debug != "no" and 'debug' not in already_processed:974 already_processed.add('debug')975 outfile.write(' debug=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.debug), input_name='debug')), ))976 def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='datafile', fromsubclass_=False, pretty_print=True):977 if pretty_print:978 eol_ = '\n'979 else:980 eol_ = ''981 if self.header is not None:982 namespaceprefix_ = self.header_nsprefix_ + ':' if (UseCapturedNS_ and self.header_nsprefix_) else ''983 self.header.export(outfile, level, namespaceprefix_, namespacedef_='', name_='header', pretty_print=pretty_print)984 for game_ in self.game:985 namespaceprefix_ = self.game_nsprefix_ + ':' if (UseCapturedNS_ and self.game_nsprefix_) else ''986 game_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='game', pretty_print=pretty_print)987 def build(self, node, gds_collector_=None):988 self.gds_collector_ = gds_collector_989 if SaveElementTreeNode:990 self.gds_elementtree_node_ = node991 already_processed = set()992 self.ns_prefix_ = get_(node, 'prefix')993 self.buildAttributes(node, node.attrib, already_processed)994 for child in node:995 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]996 self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)997 return self998 def buildAttributes(self, node, attrs, already_processed):999 value = find_attr_value_('build', node)1000 if value is not None and 'build' not in already_processed:1001 already_processed.add('build')1002 self.build_ = value1003 value = find_attr_value_('debug', node)1004 if value is not None and 'debug' not in already_processed:1005 already_processed.add('debug')1006 self.debug = value1007 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):1008 if nodeName_ == 'header':1009 obj_ = header.factory(parent_object_=self)1010 obj_.build(child_, gds_collector_=gds_collector_)1011 self.header = obj_1012 obj_.original_tagname_ = 'header'1013 elif nodeName_ == 'game':1014 obj_ = game.factory(parent_object_=self)1015 obj_.build(child_, gds_collector_=gds_collector_)1016 self.game.append(obj_)1017 obj_.original_tagname_ = 'game'1018# end class datafile1019class header(GeneratedsSuper):1020 __hash__ = GeneratedsSuper.__hash__1021 subclass = None1022 superclass = None1023 def __init__(self, name=None, description=None, category=None, version=None, date=None, author=None, email=None, homepage=None, url=None, comment=None, clrmamepro=None, romcenter=None, gds_collector_=None, **kwargs_):1024 self.gds_collector_ = gds_collector_1025 self.gds_elementtree_node_ = None1026 self.original_tagname_ = None1027 self.parent_object_ = kwargs_.get('parent_object_')1028 self.ns_prefix_ = None1029 self.name = name1030 self.name_nsprefix_ = None1031 self.description = description1032 self.description_nsprefix_ = None1033 self.category = category1034 self.category_nsprefix_ = None1035 self.version = version1036 self.version_nsprefix_ = None1037 self.date = date1038 self.date_nsprefix_ = None1039 self.author = author1040 self.author_nsprefix_ = None1041 self.email = email1042 self.email_nsprefix_ = None1043 self.homepage = homepage1044 self.homepage_nsprefix_ = None1045 self.url = url1046 self.url_nsprefix_ = None1047 self.comment = comment1048 self.comment_nsprefix_ = None1049 self.clrmamepro = clrmamepro1050 self.clrmamepro_nsprefix_ = None1051 self.romcenter = romcenter1052 self.romcenter_nsprefix_ = None1053 def factory(*args_, **kwargs_):1054 if CurrentSubclassModule_ is not None:1055 subclass = getSubclassFromModule_(1056 CurrentSubclassModule_, header)1057 if subclass is not None:1058 return subclass(*args_, **kwargs_)1059 if header.subclass:1060 return header.subclass(*args_, **kwargs_)1061 else:1062 return header(*args_, **kwargs_)1063 factory = staticmethod(factory)1064 def get_ns_prefix_(self):1065 return self.ns_prefix_1066 def set_ns_prefix_(self, ns_prefix):1067 self.ns_prefix_ = ns_prefix1068 def get_name(self):1069 return self.name1070 def set_name(self, name):1071 self.name = name1072 def get_description(self):1073 return self.description1074 def set_description(self, description):1075 self.description = description1076 def get_category(self):1077 return self.category1078 def set_category(self, category):1079 self.category = category1080 def get_version(self):1081 return self.version1082 def set_version(self, version):1083 self.version = version1084 def get_date(self):1085 return self.date1086 def set_date(self, date):1087 self.date = date1088 def get_author(self):1089 return self.author1090 def set_author(self, author):1091 self.author = author1092 def get_email(self):1093 return self.email1094 def set_email(self, email):1095 self.email = email1096 def get_homepage(self):1097 return self.homepage1098 def set_homepage(self, homepage):1099 self.homepage = homepage1100 def get_url(self):1101 return self.url1102 def set_url(self, url):1103 self.url = url1104 def get_comment(self):1105 return self.comment1106 def set_comment(self, comment):1107 self.comment = comment1108 def get_clrmamepro(self):1109 return self.clrmamepro1110 def set_clrmamepro(self, clrmamepro):1111 self.clrmamepro = clrmamepro1112 def get_romcenter(self):1113 return self.romcenter1114 def set_romcenter(self, romcenter):1115 self.romcenter = romcenter1116 def hasContent_(self):1117 if (1118 self.name is not None or1119 self.description is not None or1120 self.category is not None or1121 self.version is not None or1122 self.date is not None or1123 self.author is not None or1124 self.email is not None or1125 self.homepage is not None or1126 self.url is not None or1127 self.comment is not None or1128 self.clrmamepro is not None or1129 self.romcenter is not None1130 ):1131 return True1132 else:1133 return False1134 def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='header', pretty_print=True):1135 imported_ns_def_ = GenerateDSNamespaceDefs_.get('header')1136 if imported_ns_def_ is not None:1137 namespacedef_ = imported_ns_def_1138 if pretty_print:1139 eol_ = '\n'1140 else:1141 eol_ = ''1142 if self.original_tagname_ is not None:1143 name_ = self.original_tagname_1144 if UseCapturedNS_ and self.ns_prefix_:1145 namespaceprefix_ = self.ns_prefix_ + ':'1146 showIndent(outfile, level, pretty_print)1147 outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))1148 already_processed = set()1149 self.exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='header')1150 if self.hasContent_():1151 outfile.write('>%s' % (eol_, ))1152 self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='header', pretty_print=pretty_print)1153 showIndent(outfile, level, pretty_print)1154 outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))1155 else:1156 outfile.write('/>%s' % (eol_, ))1157 def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='header'):1158 pass1159 def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='header', fromsubclass_=False, pretty_print=True):1160 if pretty_print:1161 eol_ = '\n'1162 else:1163 eol_ = ''1164 if self.name is not None:1165 namespaceprefix_ = self.name_nsprefix_ + ':' if (UseCapturedNS_ and self.name_nsprefix_) else ''1166 showIndent(outfile, level, pretty_print)1167 outfile.write('<%sname>%s</%sname>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.name), input_name='name')), namespaceprefix_ , eol_))1168 if self.description is not None:1169 namespaceprefix_ = self.description_nsprefix_ + ':' if (UseCapturedNS_ and self.description_nsprefix_) else ''1170 showIndent(outfile, level, pretty_print)1171 outfile.write('<%sdescription>%s</%sdescription>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.description), input_name='description')), namespaceprefix_ , eol_))1172 if self.category is not None:1173 namespaceprefix_ = self.category_nsprefix_ + ':' if (UseCapturedNS_ and self.category_nsprefix_) else ''1174 showIndent(outfile, level, pretty_print)1175 outfile.write('<%scategory>%s</%scategory>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.category), input_name='category')), namespaceprefix_ , eol_))1176 if self.version is not None:1177 namespaceprefix_ = self.version_nsprefix_ + ':' if (UseCapturedNS_ and self.version_nsprefix_) else ''1178 showIndent(outfile, level, pretty_print)1179 outfile.write('<%sversion>%s</%sversion>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.version), input_name='version')), namespaceprefix_ , eol_))1180 if self.date is not None:1181 namespaceprefix_ = self.date_nsprefix_ + ':' if (UseCapturedNS_ and self.date_nsprefix_) else ''1182 showIndent(outfile, level, pretty_print)1183 outfile.write('<%sdate>%s</%sdate>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.date), input_name='date')), namespaceprefix_ , eol_))1184 if self.author is not None:1185 namespaceprefix_ = self.author_nsprefix_ + ':' if (UseCapturedNS_ and self.author_nsprefix_) else ''1186 showIndent(outfile, level, pretty_print)1187 outfile.write('<%sauthor>%s</%sauthor>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.author), input_name='author')), namespaceprefix_ , eol_))1188 if self.email is not None:1189 namespaceprefix_ = self.email_nsprefix_ + ':' if (UseCapturedNS_ and self.email_nsprefix_) else ''1190 showIndent(outfile, level, pretty_print)1191 outfile.write('<%semail>%s</%semail>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.email), input_name='email')), namespaceprefix_ , eol_))1192 if self.homepage is not None:1193 namespaceprefix_ = self.homepage_nsprefix_ + ':' if (UseCapturedNS_ and self.homepage_nsprefix_) else ''1194 showIndent(outfile, level, pretty_print)1195 outfile.write('<%shomepage>%s</%shomepage>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.homepage), input_name='homepage')), namespaceprefix_ , eol_))1196 if self.url is not None:1197 namespaceprefix_ = self.url_nsprefix_ + ':' if (UseCapturedNS_ and self.url_nsprefix_) else ''1198 showIndent(outfile, level, pretty_print)1199 outfile.write('<%surl>%s</%surl>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.url), input_name='url')), namespaceprefix_ , eol_))1200 if self.comment is not None:1201 namespaceprefix_ = self.comment_nsprefix_ + ':' if (UseCapturedNS_ and self.comment_nsprefix_) else ''1202 showIndent(outfile, level, pretty_print)1203 outfile.write('<%scomment>%s</%scomment>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.comment), input_name='comment')), namespaceprefix_ , eol_))1204 if self.clrmamepro is not None:1205 namespaceprefix_ = self.clrmamepro_nsprefix_ + ':' if (UseCapturedNS_ and self.clrmamepro_nsprefix_) else ''1206 self.clrmamepro.export(outfile, level, namespaceprefix_, namespacedef_='', name_='clrmamepro', pretty_print=pretty_print)1207 if self.romcenter is not None:1208 namespaceprefix_ = self.romcenter_nsprefix_ + ':' if (UseCapturedNS_ and self.romcenter_nsprefix_) else ''1209 self.romcenter.export(outfile, level, namespaceprefix_, namespacedef_='', name_='romcenter', pretty_print=pretty_print)1210 def build(self, node, gds_collector_=None):1211 self.gds_collector_ = gds_collector_1212 if SaveElementTreeNode:1213 self.gds_elementtree_node_ = node1214 already_processed = set()1215 self.ns_prefix_ = get_(node, 'prefix')1216 self.buildAttributes(node, node.attrib, already_processed)1217 for child in node:1218 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]1219 self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)1220 return self1221 def buildAttributes(self, node, attrs, already_processed):1222 pass1223 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):1224 if nodeName_ == 'name':1225 value_ = child_.text1226 value_ = self.gds_parse_string(value_, node, 'name')1227 value_ = self.gds_validate_string(value_, node, 'name')1228 self.name = value_1229 self.name_nsprefix_ = get_(child_, 'prefix')1230 elif nodeName_ == 'description':1231 value_ = child_.text1232 value_ = self.gds_parse_string(value_, node, 'description')1233 value_ = self.gds_validate_string(value_, node, 'description')1234 self.description = value_1235 self.description_nsprefix_ = get_(child_, 'prefix')1236 elif nodeName_ == 'category':1237 value_ = child_.text1238 value_ = self.gds_parse_string(value_, node, 'category')1239 value_ = self.gds_validate_string(value_, node, 'category')1240 self.category = value_1241 self.category_nsprefix_ = get_(child_, 'prefix')1242 elif nodeName_ == 'version':1243 value_ = child_.text1244 value_ = self.gds_parse_string(value_, node, 'version')1245 value_ = self.gds_validate_string(value_, node, 'version')1246 self.version = value_1247 self.version_nsprefix_ = get_(child_, 'prefix')1248 elif nodeName_ == 'date':1249 value_ = child_.text1250 value_ = self.gds_parse_string(value_, node, 'date')1251 value_ = self.gds_validate_string(value_, node, 'date')1252 self.date = value_1253 self.date_nsprefix_ = get_(child_, 'prefix')1254 elif nodeName_ == 'author':1255 value_ = child_.text1256 value_ = self.gds_parse_string(value_, node, 'author')1257 value_ = self.gds_validate_string(value_, node, 'author')1258 self.author = value_1259 self.author_nsprefix_ = get_(child_, 'prefix')1260 elif nodeName_ == 'email':1261 value_ = child_.text1262 value_ = self.gds_parse_string(value_, node, 'email')1263 value_ = self.gds_validate_string(value_, node, 'email')1264 self.email = value_1265 self.email_nsprefix_ = get_(child_, 'prefix')1266 elif nodeName_ == 'homepage':1267 value_ = child_.text1268 value_ = self.gds_parse_string(value_, node, 'homepage')1269 value_ = self.gds_validate_string(value_, node, 'homepage')1270 self.homepage = value_1271 self.homepage_nsprefix_ = get_(child_, 'prefix')1272 elif nodeName_ == 'url':1273 value_ = child_.text1274 value_ = self.gds_parse_string(value_, node, 'url')1275 value_ = self.gds_validate_string(value_, node, 'url')1276 self.url = value_1277 self.url_nsprefix_ = get_(child_, 'prefix')1278 elif nodeName_ == 'comment':1279 value_ = child_.text1280 value_ = self.gds_parse_string(value_, node, 'comment')1281 value_ = self.gds_validate_string(value_, node, 'comment')1282 self.comment = value_1283 self.comment_nsprefix_ = get_(child_, 'prefix')1284 elif nodeName_ == 'clrmamepro':1285 obj_ = clrmamepro.factory(parent_object_=self)1286 obj_.build(child_, gds_collector_=gds_collector_)1287 self.clrmamepro = obj_1288 obj_.original_tagname_ = 'clrmamepro'1289 elif nodeName_ == 'romcenter':1290 obj_ = romcenter.factory(parent_object_=self)1291 obj_.build(child_, gds_collector_=gds_collector_)1292 self.romcenter = obj_1293 obj_.original_tagname_ = 'romcenter'1294# end class header1295class clrmamepro(GeneratedsSuper):1296 __hash__ = GeneratedsSuper.__hash__1297 subclass = None1298 superclass = None1299 def __init__(self, header=None, forcemerging='split', forcenodump='obsolete', forcepacking='zip', gds_collector_=None, **kwargs_):1300 self.gds_collector_ = gds_collector_1301 self.gds_elementtree_node_ = None1302 self.original_tagname_ = None1303 self.parent_object_ = kwargs_.get('parent_object_')1304 self.ns_prefix_ = None1305 self.header = _cast(None, header)1306 self.header_nsprefix_ = None1307 self.forcemerging = _cast(None, forcemerging)1308 self.forcemerging_nsprefix_ = None1309 self.forcenodump = _cast(None, forcenodump)1310 self.forcenodump_nsprefix_ = None1311 self.forcepacking = _cast(None, forcepacking)1312 self.forcepacking_nsprefix_ = None1313 def factory(*args_, **kwargs_):1314 if CurrentSubclassModule_ is not None:1315 subclass = getSubclassFromModule_(1316 CurrentSubclassModule_, clrmamepro)1317 if subclass is not None:1318 return subclass(*args_, **kwargs_)1319 if clrmamepro.subclass:1320 return clrmamepro.subclass(*args_, **kwargs_)1321 else:1322 return clrmamepro(*args_, **kwargs_)1323 factory = staticmethod(factory)1324 def get_ns_prefix_(self):1325 return self.ns_prefix_1326 def set_ns_prefix_(self, ns_prefix):1327 self.ns_prefix_ = ns_prefix1328 def get_header(self):1329 return self.header1330 def set_header(self, header):1331 self.header = header1332 def get_forcemerging(self):1333 return self.forcemerging1334 def set_forcemerging(self, forcemerging):1335 self.forcemerging = forcemerging1336 def get_forcenodump(self):1337 return self.forcenodump1338 def set_forcenodump(self, forcenodump):1339 self.forcenodump = forcenodump1340 def get_forcepacking(self):1341 return self.forcepacking1342 def set_forcepacking(self, forcepacking):1343 self.forcepacking = forcepacking1344 def hasContent_(self):1345 if (1346 ):1347 return True1348 else:1349 return False1350 def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='clrmamepro', pretty_print=True):1351 imported_ns_def_ = GenerateDSNamespaceDefs_.get('clrmamepro')1352 if imported_ns_def_ is not None:1353 namespacedef_ = imported_ns_def_1354 if pretty_print:1355 eol_ = '\n'1356 else:1357 eol_ = ''1358 if self.original_tagname_ is not None:1359 name_ = self.original_tagname_1360 if UseCapturedNS_ and self.ns_prefix_:1361 namespaceprefix_ = self.ns_prefix_ + ':'1362 showIndent(outfile, level, pretty_print)1363 outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))1364 already_processed = set()1365 self.exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='clrmamepro')1366 if self.hasContent_():1367 outfile.write('>%s' % (eol_, ))1368 self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='clrmamepro', pretty_print=pretty_print)1369 outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))1370 else:1371 outfile.write('/>%s' % (eol_, ))1372 def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='clrmamepro'):1373 if self.header is not None and 'header' not in already_processed:1374 already_processed.add('header')1375 outfile.write(' header=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.header), input_name='header')), ))1376 if self.forcemerging != "split" and 'forcemerging' not in already_processed:1377 already_processed.add('forcemerging')1378 outfile.write(' forcemerging=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.forcemerging), input_name='forcemerging')), ))1379 if self.forcenodump != "obsolete" and 'forcenodump' not in already_processed:1380 already_processed.add('forcenodump')1381 outfile.write(' forcenodump=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.forcenodump), input_name='forcenodump')), ))1382 if self.forcepacking != "zip" and 'forcepacking' not in already_processed:1383 already_processed.add('forcepacking')1384 outfile.write(' forcepacking=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.forcepacking), input_name='forcepacking')), ))1385 def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='clrmamepro', fromsubclass_=False, pretty_print=True):1386 pass1387 def build(self, node, gds_collector_=None):1388 self.gds_collector_ = gds_collector_1389 if SaveElementTreeNode:1390 self.gds_elementtree_node_ = node1391 already_processed = set()1392 self.ns_prefix_ = get_(node, 'prefix')1393 self.buildAttributes(node, node.attrib, already_processed)1394 for child in node:1395 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]1396 self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)1397 return self1398 def buildAttributes(self, node, attrs, already_processed):1399 value = find_attr_value_('header', node)1400 if value is not None and 'header' not in already_processed:1401 already_processed.add('header')1402 self.header = value1403 value = find_attr_value_('forcemerging', node)1404 if value is not None and 'forcemerging' not in already_processed:1405 already_processed.add('forcemerging')1406 self.forcemerging = value1407 value = find_attr_value_('forcenodump', node)1408 if value is not None and 'forcenodump' not in already_processed:1409 already_processed.add('forcenodump')1410 self.forcenodump = value1411 value = find_attr_value_('forcepacking', node)1412 if value is not None and 'forcepacking' not in already_processed:1413 already_processed.add('forcepacking')1414 self.forcepacking = value1415 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):1416 pass1417# end class clrmamepro1418class romcenter(GeneratedsSuper):1419 __hash__ = GeneratedsSuper.__hash__1420 subclass = None1421 superclass = None1422 def __init__(self, plugin=None, rommode='split', biosmode='split', samplemode='merged', lockrommode='no', lockbiosmode='no', locksamplemode='no', gds_collector_=None, **kwargs_):1423 self.gds_collector_ = gds_collector_1424 self.gds_elementtree_node_ = None1425 self.original_tagname_ = None1426 self.parent_object_ = kwargs_.get('parent_object_')1427 self.ns_prefix_ = None1428 self.plugin = _cast(None, plugin)1429 self.plugin_nsprefix_ = None1430 self.rommode = _cast(None, rommode)1431 self.rommode_nsprefix_ = None1432 self.biosmode = _cast(None, biosmode)1433 self.biosmode_nsprefix_ = None1434 self.samplemode = _cast(None, samplemode)1435 self.samplemode_nsprefix_ = None1436 self.lockrommode = _cast(None, lockrommode)1437 self.lockrommode_nsprefix_ = None1438 self.lockbiosmode = _cast(None, lockbiosmode)1439 self.lockbiosmode_nsprefix_ = None1440 self.locksamplemode = _cast(None, locksamplemode)1441 self.locksamplemode_nsprefix_ = None1442 def factory(*args_, **kwargs_):1443 if CurrentSubclassModule_ is not None:1444 subclass = getSubclassFromModule_(1445 CurrentSubclassModule_, romcenter)1446 if subclass is not None:1447 return subclass(*args_, **kwargs_)1448 if romcenter.subclass:1449 return romcenter.subclass(*args_, **kwargs_)1450 else:1451 return romcenter(*args_, **kwargs_)1452 factory = staticmethod(factory)1453 def get_ns_prefix_(self):1454 return self.ns_prefix_1455 def set_ns_prefix_(self, ns_prefix):1456 self.ns_prefix_ = ns_prefix1457 def get_plugin(self):1458 return self.plugin1459 def set_plugin(self, plugin):1460 self.plugin = plugin1461 def get_rommode(self):1462 return self.rommode1463 def set_rommode(self, rommode):1464 self.rommode = rommode1465 def get_biosmode(self):1466 return self.biosmode1467 def set_biosmode(self, biosmode):1468 self.biosmode = biosmode1469 def get_samplemode(self):1470 return self.samplemode1471 def set_samplemode(self, samplemode):1472 self.samplemode = samplemode1473 def get_lockrommode(self):1474 return self.lockrommode1475 def set_lockrommode(self, lockrommode):1476 self.lockrommode = lockrommode1477 def get_lockbiosmode(self):1478 return self.lockbiosmode1479 def set_lockbiosmode(self, lockbiosmode):1480 self.lockbiosmode = lockbiosmode1481 def get_locksamplemode(self):1482 return self.locksamplemode1483 def set_locksamplemode(self, locksamplemode):1484 self.locksamplemode = locksamplemode1485 def hasContent_(self):1486 if (1487 ):1488 return True1489 else:1490 return False1491 def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='romcenter', pretty_print=True):1492 imported_ns_def_ = GenerateDSNamespaceDefs_.get('romcenter')1493 if imported_ns_def_ is not None:1494 namespacedef_ = imported_ns_def_1495 if pretty_print:1496 eol_ = '\n'1497 else:1498 eol_ = ''1499 if self.original_tagname_ is not None:1500 name_ = self.original_tagname_1501 if UseCapturedNS_ and self.ns_prefix_:1502 namespaceprefix_ = self.ns_prefix_ + ':'1503 showIndent(outfile, level, pretty_print)1504 outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))1505 already_processed = set()1506 self.exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='romcenter')1507 if self.hasContent_():1508 outfile.write('>%s' % (eol_, ))1509 self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='romcenter', pretty_print=pretty_print)1510 outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))1511 else:1512 outfile.write('/>%s' % (eol_, ))1513 def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='romcenter'):1514 if self.plugin is not None and 'plugin' not in already_processed:1515 already_processed.add('plugin')1516 outfile.write(' plugin=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.plugin), input_name='plugin')), ))1517 if self.rommode != "split" and 'rommode' not in already_processed:1518 already_processed.add('rommode')1519 outfile.write(' rommode=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.rommode), input_name='rommode')), ))1520 if self.biosmode != "split" and 'biosmode' not in already_processed:1521 already_processed.add('biosmode')1522 outfile.write(' biosmode=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.biosmode), input_name='biosmode')), ))1523 if self.samplemode != "merged" and 'samplemode' not in already_processed:1524 already_processed.add('samplemode')1525 outfile.write(' samplemode=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.samplemode), input_name='samplemode')), ))1526 if self.lockrommode != "no" and 'lockrommode' not in already_processed:1527 already_processed.add('lockrommode')1528 outfile.write(' lockrommode=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.lockrommode), input_name='lockrommode')), ))1529 if self.lockbiosmode != "no" and 'lockbiosmode' not in already_processed:1530 already_processed.add('lockbiosmode')1531 outfile.write(' lockbiosmode=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.lockbiosmode), input_name='lockbiosmode')), ))1532 if self.locksamplemode != "no" and 'locksamplemode' not in already_processed:1533 already_processed.add('locksamplemode')1534 outfile.write(' locksamplemode=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.locksamplemode), input_name='locksamplemode')), ))1535 def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='romcenter', fromsubclass_=False, pretty_print=True):1536 pass1537 def build(self, node, gds_collector_=None):1538 self.gds_collector_ = gds_collector_1539 if SaveElementTreeNode:1540 self.gds_elementtree_node_ = node1541 already_processed = set()1542 self.ns_prefix_ = get_(node, 'prefix')1543 self.buildAttributes(node, node.attrib, already_processed)1544 for child in node:1545 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]1546 self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)1547 return self1548 def buildAttributes(self, node, attrs, already_processed):1549 value = find_attr_value_('plugin', node)1550 if value is not None and 'plugin' not in already_processed:1551 already_processed.add('plugin')1552 self.plugin = value1553 value = find_attr_value_('rommode', node)1554 if value is not None and 'rommode' not in already_processed:1555 already_processed.add('rommode')1556 self.rommode = value1557 value = find_attr_value_('biosmode', node)1558 if value is not None and 'biosmode' not in already_processed:1559 already_processed.add('biosmode')1560 self.biosmode = value1561 value = find_attr_value_('samplemode', node)1562 if value is not None and 'samplemode' not in already_processed:1563 already_processed.add('samplemode')1564 self.samplemode = value1565 value = find_attr_value_('lockrommode', node)1566 if value is not None and 'lockrommode' not in already_processed:1567 already_processed.add('lockrommode')1568 self.lockrommode = value1569 value = find_attr_value_('lockbiosmode', node)1570 if value is not None and 'lockbiosmode' not in already_processed:1571 already_processed.add('lockbiosmode')1572 self.lockbiosmode = value1573 value = find_attr_value_('locksamplemode', node)1574 if value is not None and 'locksamplemode' not in already_processed:1575 already_processed.add('locksamplemode')1576 self.locksamplemode = value1577 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):1578 pass1579# end class romcenter1580class game(GeneratedsSuper):1581 __hash__ = GeneratedsSuper.__hash__1582 subclass = None1583 superclass = None1584 def __init__(self, name=None, sourcefile=None, isbios='no', cloneof=None, romof=None, sampleof=None, board=None, rebuildto=None, comment=None, description=None, year=None, manufacturer=None, release=None, biosset=None, rom=None, disk=None, sample=None, archive=None, gds_collector_=None, **kwargs_):1585 self.gds_collector_ = gds_collector_1586 self.gds_elementtree_node_ = None1587 self.original_tagname_ = None1588 self.parent_object_ = kwargs_.get('parent_object_')1589 self.ns_prefix_ = None1590 self.name = _cast(None, name)1591 self.name_nsprefix_ = None1592 self.sourcefile = _cast(None, sourcefile)1593 self.sourcefile_nsprefix_ = None1594 self.isbios = _cast(None, isbios)1595 self.isbios_nsprefix_ = None1596 self.cloneof = _cast(None, cloneof)1597 self.cloneof_nsprefix_ = None1598 self.romof = _cast(None, romof)1599 self.romof_nsprefix_ = None1600 self.sampleof = _cast(None, sampleof)1601 self.sampleof_nsprefix_ = None1602 self.board = _cast(None, board)1603 self.board_nsprefix_ = None1604 self.rebuildto = _cast(None, rebuildto)1605 self.rebuildto_nsprefix_ = None1606 if comment is None:1607 self.comment = []1608 else:1609 self.comment = comment1610 self.comment_nsprefix_ = None1611 self.description = description1612 self.description_nsprefix_ = None1613 self.year = year1614 self.year_nsprefix_ = None1615 self.manufacturer = manufacturer1616 self.manufacturer_nsprefix_ = None1617 if release is None:1618 self.release = []1619 else:1620 self.release = release1621 self.release_nsprefix_ = None1622 if biosset is None:1623 self.biosset = []1624 else:1625 self.biosset = biosset1626 self.biosset_nsprefix_ = None1627 if rom is None:1628 self.rom = []1629 else:1630 self.rom = rom1631 self.rom_nsprefix_ = None1632 if disk is None:1633 self.disk = []1634 else:1635 self.disk = disk1636 self.disk_nsprefix_ = None1637 if sample is None:1638 self.sample = []1639 else:1640 self.sample = sample1641 self.sample_nsprefix_ = None1642 if archive is None:1643 self.archive = []1644 else:1645 self.archive = archive1646 self.archive_nsprefix_ = None1647 def factory(*args_, **kwargs_):1648 if CurrentSubclassModule_ is not None:1649 subclass = getSubclassFromModule_(1650 CurrentSubclassModule_, game)1651 if subclass is not None:1652 return subclass(*args_, **kwargs_)1653 if game.subclass:1654 return game.subclass(*args_, **kwargs_)1655 else:1656 return game(*args_, **kwargs_)1657 factory = staticmethod(factory)1658 def get_ns_prefix_(self):1659 return self.ns_prefix_1660 def set_ns_prefix_(self, ns_prefix):1661 self.ns_prefix_ = ns_prefix1662 def get_comment(self):1663 return self.comment1664 def set_comment(self, comment):1665 self.comment = comment1666 def add_comment(self, value):1667 self.comment.append(value)1668 def insert_comment_at(self, index, value):1669 self.comment.insert(index, value)1670 def replace_comment_at(self, index, value):1671 self.comment[index] = value1672 def get_description(self):1673 return self.description1674 def set_description(self, description):1675 self.description = description1676 def get_year(self):1677 return self.year1678 def set_year(self, year):1679 self.year = year1680 def get_manufacturer(self):1681 return self.manufacturer1682 def set_manufacturer(self, manufacturer):1683 self.manufacturer = manufacturer1684 def get_release(self):1685 return self.release1686 def set_release(self, release):1687 self.release = release1688 def add_release(self, value):1689 self.release.append(value)1690 def insert_release_at(self, index, value):1691 self.release.insert(index, value)1692 def replace_release_at(self, index, value):1693 self.release[index] = value1694 def get_biosset(self):1695 return self.biosset1696 def set_biosset(self, biosset):1697 self.biosset = biosset1698 def add_biosset(self, value):1699 self.biosset.append(value)1700 def insert_biosset_at(self, index, value):1701 self.biosset.insert(index, value)1702 def replace_biosset_at(self, index, value):1703 self.biosset[index] = value1704 def get_rom(self):1705 return self.rom1706 def set_rom(self, rom):1707 self.rom = rom1708 def add_rom(self, value):1709 self.rom.append(value)1710 def insert_rom_at(self, index, value):1711 self.rom.insert(index, value)1712 def replace_rom_at(self, index, value):1713 self.rom[index] = value1714 def get_disk(self):1715 return self.disk1716 def set_disk(self, disk):1717 self.disk = disk1718 def add_disk(self, value):1719 self.disk.append(value)1720 def insert_disk_at(self, index, value):1721 self.disk.insert(index, value)1722 def replace_disk_at(self, index, value):1723 self.disk[index] = value1724 def get_sample(self):1725 return self.sample1726 def set_sample(self, sample):1727 self.sample = sample1728 def add_sample(self, value):1729 self.sample.append(value)1730 def insert_sample_at(self, index, value):1731 self.sample.insert(index, value)1732 def replace_sample_at(self, index, value):1733 self.sample[index] = value1734 def get_archive(self):1735 return self.archive1736 def set_archive(self, archive):1737 self.archive = archive1738 def add_archive(self, value):1739 self.archive.append(value)1740 def insert_archive_at(self, index, value):1741 self.archive.insert(index, value)1742 def replace_archive_at(self, index, value):1743 self.archive[index] = value1744 def get_name(self):1745 return self.name1746 def set_name(self, name):1747 self.name = name1748 def get_sourcefile(self):1749 return self.sourcefile1750 def set_sourcefile(self, sourcefile):1751 self.sourcefile = sourcefile1752 def get_isbios(self):1753 return self.isbios1754 def set_isbios(self, isbios):1755 self.isbios = isbios1756 def get_cloneof(self):1757 return self.cloneof1758 def set_cloneof(self, cloneof):1759 self.cloneof = cloneof1760 def get_romof(self):1761 return self.romof1762 def set_romof(self, romof):1763 self.romof = romof1764 def get_sampleof(self):1765 return self.sampleof1766 def set_sampleof(self, sampleof):1767 self.sampleof = sampleof1768 def get_board(self):1769 return self.board1770 def set_board(self, board):1771 self.board = board1772 def get_rebuildto(self):1773 return self.rebuildto1774 def set_rebuildto(self, rebuildto):1775 self.rebuildto = rebuildto1776 def hasContent_(self):1777 if (1778 self.comment or1779 self.description is not None or1780 self.year is not None or1781 self.manufacturer is not None or1782 self.release or1783 self.biosset or1784 self.rom or1785 self.disk or1786 self.sample or1787 self.archive1788 ):1789 return True1790 else:1791 return False1792 def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='game', pretty_print=True):1793 imported_ns_def_ = GenerateDSNamespaceDefs_.get('game')1794 if imported_ns_def_ is not None:1795 namespacedef_ = imported_ns_def_1796 if pretty_print:1797 eol_ = '\n'1798 else:1799 eol_ = ''1800 if self.original_tagname_ is not None:1801 name_ = self.original_tagname_1802 if UseCapturedNS_ and self.ns_prefix_:1803 namespaceprefix_ = self.ns_prefix_ + ':'1804 showIndent(outfile, level, pretty_print)1805 outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))1806 already_processed = set()1807 self.exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='game')1808 if self.hasContent_():1809 outfile.write('>%s' % (eol_, ))1810 self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='game', pretty_print=pretty_print)1811 showIndent(outfile, level, pretty_print)1812 outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))1813 else:1814 outfile.write('/>%s' % (eol_, ))1815 def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='game'):1816 if self.name is not None and 'name' not in already_processed:1817 already_processed.add('name')1818 outfile.write(' name=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.name), input_name='name')), ))1819 if self.sourcefile is not None and 'sourcefile' not in already_processed:1820 already_processed.add('sourcefile')1821 outfile.write(' sourcefile=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.sourcefile), input_name='sourcefile')), ))1822 if self.isbios != "no" and 'isbios' not in already_processed:1823 already_processed.add('isbios')1824 outfile.write(' isbios=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.isbios), input_name='isbios')), ))1825 if self.cloneof is not None and 'cloneof' not in already_processed:1826 already_processed.add('cloneof')1827 outfile.write(' cloneof=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.cloneof), input_name='cloneof')), ))1828 if self.romof is not None and 'romof' not in already_processed:1829 already_processed.add('romof')1830 outfile.write(' romof=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.romof), input_name='romof')), ))1831 if self.sampleof is not None and 'sampleof' not in already_processed:1832 already_processed.add('sampleof')1833 outfile.write(' sampleof=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.sampleof), input_name='sampleof')), ))1834 if self.board is not None and 'board' not in already_processed:1835 already_processed.add('board')1836 outfile.write(' board=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.board), input_name='board')), ))1837 if self.rebuildto is not None and 'rebuildto' not in already_processed:1838 already_processed.add('rebuildto')1839 outfile.write(' rebuildto=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.rebuildto), input_name='rebuildto')), ))1840 def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='game', fromsubclass_=False, pretty_print=True):1841 if pretty_print:1842 eol_ = '\n'1843 else:1844 eol_ = ''1845 for comment_ in self.comment:1846 namespaceprefix_ = self.comment_nsprefix_ + ':' if (UseCapturedNS_ and self.comment_nsprefix_) else ''1847 showIndent(outfile, level, pretty_print)1848 outfile.write('<%scomment>%s</%scomment>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(comment_), input_name='comment')), namespaceprefix_ , eol_))1849 if self.description is not None:1850 namespaceprefix_ = self.description_nsprefix_ + ':' if (UseCapturedNS_ and self.description_nsprefix_) else ''1851 showIndent(outfile, level, pretty_print)1852 outfile.write('<%sdescription>%s</%sdescription>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.description), input_name='description')), namespaceprefix_ , eol_))1853 if self.year is not None:1854 namespaceprefix_ = self.year_nsprefix_ + ':' if (UseCapturedNS_ and self.year_nsprefix_) else ''1855 showIndent(outfile, level, pretty_print)1856 outfile.write('<%syear>%s</%syear>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.year), input_name='year')), namespaceprefix_ , eol_))1857 if self.manufacturer is not None:1858 namespaceprefix_ = self.manufacturer_nsprefix_ + ':' if (UseCapturedNS_ and self.manufacturer_nsprefix_) else ''1859 showIndent(outfile, level, pretty_print)1860 outfile.write('<%smanufacturer>%s</%smanufacturer>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.manufacturer), input_name='manufacturer')), namespaceprefix_ , eol_))1861 for release_ in self.release:1862 namespaceprefix_ = self.release_nsprefix_ + ':' if (UseCapturedNS_ and self.release_nsprefix_) else ''1863 release_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='release', pretty_print=pretty_print)1864 for biosset_ in self.biosset:1865 namespaceprefix_ = self.biosset_nsprefix_ + ':' if (UseCapturedNS_ and self.biosset_nsprefix_) else ''1866 biosset_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='biosset', pretty_print=pretty_print)1867 for rom_ in self.rom:1868 namespaceprefix_ = self.rom_nsprefix_ + ':' if (UseCapturedNS_ and self.rom_nsprefix_) else ''1869 rom_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='rom', pretty_print=pretty_print)1870 for disk_ in self.disk:1871 namespaceprefix_ = self.disk_nsprefix_ + ':' if (UseCapturedNS_ and self.disk_nsprefix_) else ''1872 disk_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='disk', pretty_print=pretty_print)1873 for sample_ in self.sample:1874 namespaceprefix_ = self.sample_nsprefix_ + ':' if (UseCapturedNS_ and self.sample_nsprefix_) else ''1875 sample_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='sample', pretty_print=pretty_print)1876 for archive_ in self.archive:1877 namespaceprefix_ = self.archive_nsprefix_ + ':' if (UseCapturedNS_ and self.archive_nsprefix_) else ''1878 archive_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='archive', pretty_print=pretty_print)1879 def build(self, node, gds_collector_=None):1880 self.gds_collector_ = gds_collector_1881 if SaveElementTreeNode:1882 self.gds_elementtree_node_ = node1883 already_processed = set()1884 self.ns_prefix_ = get_(node, 'prefix')1885 self.buildAttributes(node, node.attrib, already_processed)1886 for child in node:1887 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]1888 self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)1889 return self1890 def buildAttributes(self, node, attrs, already_processed):1891 value = find_attr_value_('name', node)1892 if value is not None and 'name' not in already_processed:1893 already_processed.add('name')1894 self.name = value1895 value = find_attr_value_('sourcefile', node)1896 if value is not None and 'sourcefile' not in already_processed:1897 already_processed.add('sourcefile')1898 self.sourcefile = value1899 value = find_attr_value_('isbios', node)1900 if value is not None and 'isbios' not in already_processed:1901 already_processed.add('isbios')1902 self.isbios = value1903 value = find_attr_value_('cloneof', node)1904 if value is not None and 'cloneof' not in already_processed:1905 already_processed.add('cloneof')1906 self.cloneof = value1907 value = find_attr_value_('romof', node)1908 if value is not None and 'romof' not in already_processed:1909 already_processed.add('romof')1910 self.romof = value1911 value = find_attr_value_('sampleof', node)1912 if value is not None and 'sampleof' not in already_processed:1913 already_processed.add('sampleof')1914 self.sampleof = value1915 value = find_attr_value_('board', node)1916 if value is not None and 'board' not in already_processed:1917 already_processed.add('board')1918 self.board = value1919 value = find_attr_value_('rebuildto', node)1920 if value is not None and 'rebuildto' not in already_processed:1921 already_processed.add('rebuildto')1922 self.rebuildto = value1923 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):1924 if nodeName_ == 'comment':1925 value_ = child_.text1926 value_ = self.gds_parse_string(value_, node, 'comment')1927 value_ = self.gds_validate_string(value_, node, 'comment')1928 self.comment.append(value_)1929 self.comment_nsprefix_ = get_(child_, 'prefix')1930 elif nodeName_ == 'description':1931 value_ = child_.text1932 value_ = self.gds_parse_string(value_, node, 'description')1933 value_ = self.gds_validate_string(value_, node, 'description')1934 self.description = value_1935 self.description_nsprefix_ = get_(child_, 'prefix')1936 elif nodeName_ == 'year':1937 value_ = child_.text1938 value_ = self.gds_parse_string(value_, node, 'year')1939 value_ = self.gds_validate_string(value_, node, 'year')1940 self.year = value_1941 self.year_nsprefix_ = get_(child_, 'prefix')1942 elif nodeName_ == 'manufacturer':1943 value_ = child_.text1944 value_ = self.gds_parse_string(value_, node, 'manufacturer')1945 value_ = self.gds_validate_string(value_, node, 'manufacturer')1946 self.manufacturer = value_1947 self.manufacturer_nsprefix_ = get_(child_, 'prefix')1948 elif nodeName_ == 'release':1949 obj_ = release.factory(parent_object_=self)1950 obj_.build(child_, gds_collector_=gds_collector_)1951 self.release.append(obj_)1952 obj_.original_tagname_ = 'release'1953 elif nodeName_ == 'biosset':1954 obj_ = biosset.factory(parent_object_=self)1955 obj_.build(child_, gds_collector_=gds_collector_)1956 self.biosset.append(obj_)1957 obj_.original_tagname_ = 'biosset'1958 elif nodeName_ == 'rom':1959 obj_ = rom.factory(parent_object_=self)1960 obj_.build(child_, gds_collector_=gds_collector_)1961 self.rom.append(obj_)1962 obj_.original_tagname_ = 'rom'1963 elif nodeName_ == 'disk':1964 obj_ = disk.factory(parent_object_=self)1965 obj_.build(child_, gds_collector_=gds_collector_)1966 self.disk.append(obj_)1967 obj_.original_tagname_ = 'disk'1968 elif nodeName_ == 'sample':1969 obj_ = sample.factory(parent_object_=self)1970 obj_.build(child_, gds_collector_=gds_collector_)1971 self.sample.append(obj_)1972 obj_.original_tagname_ = 'sample'1973 elif nodeName_ == 'archive':1974 obj_ = archive.factory(parent_object_=self)1975 obj_.build(child_, gds_collector_=gds_collector_)1976 self.archive.append(obj_)1977 obj_.original_tagname_ = 'archive'1978# end class game1979class release(GeneratedsSuper):1980 __hash__ = GeneratedsSuper.__hash__1981 subclass = None1982 superclass = None1983 def __init__(self, name=None, region=None, language=None, date=None, default='no', gds_collector_=None, **kwargs_):1984 self.gds_collector_ = gds_collector_1985 self.gds_elementtree_node_ = None1986 self.original_tagname_ = None1987 self.parent_object_ = kwargs_.get('parent_object_')1988 self.ns_prefix_ = None1989 self.name = _cast(None, name)1990 self.name_nsprefix_ = None1991 self.region = _cast(None, region)1992 self.region_nsprefix_ = None1993 self.language = _cast(None, language)1994 self.language_nsprefix_ = None1995 self.date = _cast(None, date)1996 self.date_nsprefix_ = None1997 self.default = _cast(None, default)1998 self.default_nsprefix_ = None1999 def factory(*args_, **kwargs_):2000 if CurrentSubclassModule_ is not None:2001 subclass = getSubclassFromModule_(2002 CurrentSubclassModule_, release)2003 if subclass is not None:2004 return subclass(*args_, **kwargs_)2005 if release.subclass:2006 return release.subclass(*args_, **kwargs_)2007 else:2008 return release(*args_, **kwargs_)2009 factory = staticmethod(factory)2010 def get_ns_prefix_(self):2011 return self.ns_prefix_2012 def set_ns_prefix_(self, ns_prefix):2013 self.ns_prefix_ = ns_prefix2014 def get_name(self):2015 return self.name2016 def set_name(self, name):2017 self.name = name2018 def get_region(self):2019 return self.region2020 def set_region(self, region):2021 self.region = region2022 def get_language(self):2023 return self.language2024 def set_language(self, language):2025 self.language = language2026 def get_date(self):2027 return self.date2028 def set_date(self, date):2029 self.date = date2030 def get_default(self):2031 return self.default2032 def set_default(self, default):2033 self.default = default2034 def hasContent_(self):2035 if (2036 ):2037 return True2038 else:2039 return False2040 def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='release', pretty_print=True):2041 imported_ns_def_ = GenerateDSNamespaceDefs_.get('release')2042 if imported_ns_def_ is not None:2043 namespacedef_ = imported_ns_def_2044 if pretty_print:2045 eol_ = '\n'2046 else:2047 eol_ = ''2048 if self.original_tagname_ is not None:2049 name_ = self.original_tagname_2050 if UseCapturedNS_ and self.ns_prefix_:2051 namespaceprefix_ = self.ns_prefix_ + ':'2052 showIndent(outfile, level, pretty_print)2053 outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))2054 already_processed = set()2055 self.exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='release')2056 if self.hasContent_():2057 outfile.write('>%s' % (eol_, ))2058 self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='release', pretty_print=pretty_print)2059 outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))2060 else:2061 outfile.write('/>%s' % (eol_, ))2062 def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='release'):2063 if self.name is not None and 'name' not in already_processed:2064 already_processed.add('name')2065 outfile.write(' name=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.name), input_name='name')), ))2066 if self.region is not None and 'region' not in already_processed:2067 already_processed.add('region')2068 outfile.write(' region=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.region), input_name='region')), ))2069 if self.language is not None and 'language' not in already_processed:2070 already_processed.add('language')2071 outfile.write(' language=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.language), input_name='language')), ))2072 if self.date is not None and 'date' not in already_processed:2073 already_processed.add('date')2074 outfile.write(' date=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.date), input_name='date')), ))2075 if self.default != "no" and 'default' not in already_processed:2076 already_processed.add('default')2077 outfile.write(' default=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.default), input_name='default')), ))2078 def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='release', fromsubclass_=False, pretty_print=True):2079 pass2080 def build(self, node, gds_collector_=None):2081 self.gds_collector_ = gds_collector_2082 if SaveElementTreeNode:2083 self.gds_elementtree_node_ = node2084 already_processed = set()2085 self.ns_prefix_ = get_(node, 'prefix')2086 self.buildAttributes(node, node.attrib, already_processed)2087 for child in node:2088 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]2089 self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)2090 return self2091 def buildAttributes(self, node, attrs, already_processed):2092 value = find_attr_value_('name', node)2093 if value is not None and 'name' not in already_processed:2094 already_processed.add('name')2095 self.name = value2096 value = find_attr_value_('region', node)2097 if value is not None and 'region' not in already_processed:2098 already_processed.add('region')2099 self.region = value2100 value = find_attr_value_('language', node)2101 if value is not None and 'language' not in already_processed:2102 already_processed.add('language')2103 self.language = value2104 value = find_attr_value_('date', node)2105 if value is not None and 'date' not in already_processed:2106 already_processed.add('date')2107 self.date = value2108 value = find_attr_value_('default', node)2109 if value is not None and 'default' not in already_processed:2110 already_processed.add('default')2111 self.default = value2112 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):2113 pass2114# end class release2115class biosset(GeneratedsSuper):2116 __hash__ = GeneratedsSuper.__hash__2117 subclass = None2118 superclass = None2119 def __init__(self, name=None, description=None, default='no', gds_collector_=None, **kwargs_):2120 self.gds_collector_ = gds_collector_2121 self.gds_elementtree_node_ = None2122 self.original_tagname_ = None2123 self.parent_object_ = kwargs_.get('parent_object_')2124 self.ns_prefix_ = None2125 self.name = _cast(None, name)2126 self.name_nsprefix_ = None2127 self.description = _cast(None, description)2128 self.description_nsprefix_ = None2129 self.default = _cast(None, default)2130 self.default_nsprefix_ = None2131 def factory(*args_, **kwargs_):2132 if CurrentSubclassModule_ is not None:2133 subclass = getSubclassFromModule_(2134 CurrentSubclassModule_, biosset)2135 if subclass is not None:2136 return subclass(*args_, **kwargs_)2137 if biosset.subclass:2138 return biosset.subclass(*args_, **kwargs_)2139 else:2140 return biosset(*args_, **kwargs_)2141 factory = staticmethod(factory)2142 def get_ns_prefix_(self):2143 return self.ns_prefix_2144 def set_ns_prefix_(self, ns_prefix):2145 self.ns_prefix_ = ns_prefix2146 def get_name(self):2147 return self.name2148 def set_name(self, name):2149 self.name = name2150 def get_description(self):2151 return self.description2152 def set_description(self, description):2153 self.description = description2154 def get_default(self):2155 return self.default2156 def set_default(self, default):2157 self.default = default2158 def hasContent_(self):2159 if (2160 ):2161 return True2162 else:2163 return False2164 def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='biosset', pretty_print=True):2165 imported_ns_def_ = GenerateDSNamespaceDefs_.get('biosset')2166 if imported_ns_def_ is not None:2167 namespacedef_ = imported_ns_def_2168 if pretty_print:2169 eol_ = '\n'2170 else:2171 eol_ = ''2172 if self.original_tagname_ is not None:2173 name_ = self.original_tagname_2174 if UseCapturedNS_ and self.ns_prefix_:2175 namespaceprefix_ = self.ns_prefix_ + ':'2176 showIndent(outfile, level, pretty_print)2177 outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))2178 already_processed = set()2179 self.exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='biosset')2180 if self.hasContent_():2181 outfile.write('>%s' % (eol_, ))2182 self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='biosset', pretty_print=pretty_print)2183 outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))2184 else:2185 outfile.write('/>%s' % (eol_, ))2186 def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='biosset'):2187 if self.name is not None and 'name' not in already_processed:2188 already_processed.add('name')2189 outfile.write(' name=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.name), input_name='name')), ))2190 if self.description is not None and 'description' not in already_processed:2191 already_processed.add('description')2192 outfile.write(' description=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.description), input_name='description')), ))2193 if self.default != "no" and 'default' not in already_processed:2194 already_processed.add('default')2195 outfile.write(' default=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.default), input_name='default')), ))2196 def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='biosset', fromsubclass_=False, pretty_print=True):2197 pass2198 def build(self, node, gds_collector_=None):2199 self.gds_collector_ = gds_collector_2200 if SaveElementTreeNode:2201 self.gds_elementtree_node_ = node2202 already_processed = set()2203 self.ns_prefix_ = get_(node, 'prefix')2204 self.buildAttributes(node, node.attrib, already_processed)2205 for child in node:2206 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]2207 self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)2208 return self2209 def buildAttributes(self, node, attrs, already_processed):2210 value = find_attr_value_('name', node)2211 if value is not None and 'name' not in already_processed:2212 already_processed.add('name')2213 self.name = value2214 value = find_attr_value_('description', node)2215 if value is not None and 'description' not in already_processed:2216 already_processed.add('description')2217 self.description = value2218 value = find_attr_value_('default', node)2219 if value is not None and 'default' not in already_processed:2220 already_processed.add('default')2221 self.default = value2222 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):2223 pass2224# end class biosset2225class rom(GeneratedsSuper):2226 __hash__ = GeneratedsSuper.__hash__2227 subclass = None2228 superclass = None2229 def __init__(self, name=None, size=None, crc=None, sha1=None, md5=None, merge=None, status='good', date=None, gds_collector_=None, **kwargs_):2230 self.gds_collector_ = gds_collector_2231 self.gds_elementtree_node_ = None2232 self.original_tagname_ = None2233 self.parent_object_ = kwargs_.get('parent_object_')2234 self.ns_prefix_ = None2235 self.name = _cast(None, name)2236 self.name_nsprefix_ = None2237 self.size = _cast(None, size)2238 self.size_nsprefix_ = None2239 self.crc = _cast(None, crc)2240 self.crc_nsprefix_ = None2241 self.sha1 = _cast(None, sha1)2242 self.sha1_nsprefix_ = None2243 self.md5 = _cast(None, md5)2244 self.md5_nsprefix_ = None2245 self.merge = _cast(None, merge)2246 self.merge_nsprefix_ = None2247 self.status = _cast(None, status)2248 self.status_nsprefix_ = None2249 self.date = _cast(None, date)2250 self.date_nsprefix_ = None2251 def factory(*args_, **kwargs_):2252 if CurrentSubclassModule_ is not None:2253 subclass = getSubclassFromModule_(2254 CurrentSubclassModule_, rom)2255 if subclass is not None:2256 return subclass(*args_, **kwargs_)2257 if rom.subclass:2258 return rom.subclass(*args_, **kwargs_)2259 else:2260 return rom(*args_, **kwargs_)2261 factory = staticmethod(factory)2262 def get_ns_prefix_(self):2263 return self.ns_prefix_2264 def set_ns_prefix_(self, ns_prefix):2265 self.ns_prefix_ = ns_prefix2266 def get_name(self):2267 return self.name2268 def set_name(self, name):2269 self.name = name2270 def get_size(self):2271 return self.size2272 def set_size(self, size):2273 self.size = size2274 def get_crc(self):2275 return self.crc2276 def set_crc(self, crc):2277 self.crc = crc2278 def get_sha1(self):2279 return self.sha12280 def set_sha1(self, sha1):2281 self.sha1 = sha12282 def get_md5(self):2283 return self.md52284 def set_md5(self, md5):2285 self.md5 = md52286 def get_merge(self):2287 return self.merge2288 def set_merge(self, merge):2289 self.merge = merge2290 def get_status(self):2291 return self.status2292 def set_status(self, status):2293 self.status = status2294 def get_date(self):2295 return self.date2296 def set_date(self, date):2297 self.date = date2298 def hasContent_(self):2299 if (2300 ):2301 return True2302 else:2303 return False2304 def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='rom', pretty_print=True):2305 imported_ns_def_ = GenerateDSNamespaceDefs_.get('rom')2306 if imported_ns_def_ is not None:2307 namespacedef_ = imported_ns_def_2308 if pretty_print:2309 eol_ = '\n'2310 else:2311 eol_ = ''2312 if self.original_tagname_ is not None:2313 name_ = self.original_tagname_2314 if UseCapturedNS_ and self.ns_prefix_:2315 namespaceprefix_ = self.ns_prefix_ + ':'2316 showIndent(outfile, level, pretty_print)2317 outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))2318 already_processed = set()2319 self.exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='rom')2320 if self.hasContent_():2321 outfile.write('>%s' % (eol_, ))2322 self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='rom', pretty_print=pretty_print)2323 outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))2324 else:2325 outfile.write('/>%s' % (eol_, ))2326 def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='rom'):2327 if self.name is not None and 'name' not in already_processed:2328 already_processed.add('name')2329 outfile.write(' name=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.name), input_name='name')), ))2330 if self.size is not None and 'size' not in already_processed:2331 already_processed.add('size')2332 outfile.write(' size=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.size), input_name='size')), ))2333 if self.crc is not None and 'crc' not in already_processed:2334 already_processed.add('crc')2335 outfile.write(' crc=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.crc), input_name='crc')), ))2336 if self.sha1 is not None and 'sha1' not in already_processed:2337 already_processed.add('sha1')2338 outfile.write(' sha1=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.sha1), input_name='sha1')), ))2339 if self.md5 is not None and 'md5' not in already_processed:2340 already_processed.add('md5')2341 outfile.write(' md5=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.md5), input_name='md5')), ))2342 if self.merge is not None and 'merge' not in already_processed:2343 already_processed.add('merge')2344 outfile.write(' merge=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.merge), input_name='merge')), ))2345 if self.status != "good" and 'status' not in already_processed:2346 already_processed.add('status')2347 outfile.write(' status=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.status), input_name='status')), ))2348 if self.date is not None and 'date' not in already_processed:2349 already_processed.add('date')2350 outfile.write(' date=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.date), input_name='date')), ))2351 def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='rom', fromsubclass_=False, pretty_print=True):2352 pass2353 def build(self, node, gds_collector_=None):2354 self.gds_collector_ = gds_collector_2355 if SaveElementTreeNode:2356 self.gds_elementtree_node_ = node2357 already_processed = set()2358 self.ns_prefix_ = get_(node, 'prefix')2359 self.buildAttributes(node, node.attrib, already_processed)2360 for child in node:2361 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]2362 self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)2363 return self2364 def buildAttributes(self, node, attrs, already_processed):2365 value = find_attr_value_('name', node)2366 if value is not None and 'name' not in already_processed:2367 already_processed.add('name')2368 self.name = value2369 value = find_attr_value_('size', node)2370 if value is not None and 'size' not in already_processed:2371 already_processed.add('size')2372 self.size = value2373 value = find_attr_value_('crc', node)2374 if value is not None and 'crc' not in already_processed:2375 already_processed.add('crc')2376 self.crc = value2377 value = find_attr_value_('sha1', node)2378 if value is not None and 'sha1' not in already_processed:2379 already_processed.add('sha1')2380 self.sha1 = value2381 value = find_attr_value_('md5', node)2382 if value is not None and 'md5' not in already_processed:2383 already_processed.add('md5')2384 self.md5 = value2385 value = find_attr_value_('merge', node)2386 if value is not None and 'merge' not in already_processed:2387 already_processed.add('merge')2388 self.merge = value2389 value = find_attr_value_('status', node)2390 if value is not None and 'status' not in already_processed:2391 already_processed.add('status')2392 self.status = value2393 value = find_attr_value_('date', node)2394 if value is not None and 'date' not in already_processed:2395 already_processed.add('date')2396 self.date = value2397 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):2398 pass2399# end class rom2400class disk(GeneratedsSuper):2401 __hash__ = GeneratedsSuper.__hash__2402 subclass = None2403 superclass = None2404 def __init__(self, name=None, sha1=None, md5=None, merge=None, status='good', gds_collector_=None, **kwargs_):2405 self.gds_collector_ = gds_collector_2406 self.gds_elementtree_node_ = None2407 self.original_tagname_ = None2408 self.parent_object_ = kwargs_.get('parent_object_')2409 self.ns_prefix_ = None2410 self.name = _cast(None, name)2411 self.name_nsprefix_ = None2412 self.sha1 = _cast(None, sha1)2413 self.sha1_nsprefix_ = None2414 self.md5 = _cast(None, md5)2415 self.md5_nsprefix_ = None2416 self.merge = _cast(None, merge)2417 self.merge_nsprefix_ = None2418 self.status = _cast(None, status)2419 self.status_nsprefix_ = None2420 def factory(*args_, **kwargs_):2421 if CurrentSubclassModule_ is not None:2422 subclass = getSubclassFromModule_(2423 CurrentSubclassModule_, disk)2424 if subclass is not None:2425 return subclass(*args_, **kwargs_)2426 if disk.subclass:2427 return disk.subclass(*args_, **kwargs_)2428 else:2429 return disk(*args_, **kwargs_)2430 factory = staticmethod(factory)2431 def get_ns_prefix_(self):2432 return self.ns_prefix_2433 def set_ns_prefix_(self, ns_prefix):2434 self.ns_prefix_ = ns_prefix2435 def get_name(self):2436 return self.name2437 def set_name(self, name):2438 self.name = name2439 def get_sha1(self):2440 return self.sha12441 def set_sha1(self, sha1):2442 self.sha1 = sha12443 def get_md5(self):2444 return self.md52445 def set_md5(self, md5):2446 self.md5 = md52447 def get_merge(self):2448 return self.merge2449 def set_merge(self, merge):2450 self.merge = merge2451 def get_status(self):2452 return self.status2453 def set_status(self, status):2454 self.status = status2455 def hasContent_(self):2456 if (2457 ):2458 return True2459 else:2460 return False2461 def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='disk', pretty_print=True):2462 imported_ns_def_ = GenerateDSNamespaceDefs_.get('disk')2463 if imported_ns_def_ is not None:2464 namespacedef_ = imported_ns_def_2465 if pretty_print:2466 eol_ = '\n'2467 else:2468 eol_ = ''2469 if self.original_tagname_ is not None:2470 name_ = self.original_tagname_2471 if UseCapturedNS_ and self.ns_prefix_:2472 namespaceprefix_ = self.ns_prefix_ + ':'2473 showIndent(outfile, level, pretty_print)2474 outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))2475 already_processed = set()2476 self.exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='disk')2477 if self.hasContent_():2478 outfile.write('>%s' % (eol_, ))2479 self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='disk', pretty_print=pretty_print)2480 outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))2481 else:2482 outfile.write('/>%s' % (eol_, ))2483 def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='disk'):2484 if self.name is not None and 'name' not in already_processed:2485 already_processed.add('name')2486 outfile.write(' name=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.name), input_name='name')), ))2487 if self.sha1 is not None and 'sha1' not in already_processed:2488 already_processed.add('sha1')2489 outfile.write(' sha1=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.sha1), input_name='sha1')), ))2490 if self.md5 is not None and 'md5' not in already_processed:2491 already_processed.add('md5')2492 outfile.write(' md5=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.md5), input_name='md5')), ))2493 if self.merge is not None and 'merge' not in already_processed:2494 already_processed.add('merge')2495 outfile.write(' merge=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.merge), input_name='merge')), ))2496 if self.status != "good" and 'status' not in already_processed:2497 already_processed.add('status')2498 outfile.write(' status=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.status), input_name='status')), ))2499 def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='disk', fromsubclass_=False, pretty_print=True):2500 pass2501 def build(self, node, gds_collector_=None):2502 self.gds_collector_ = gds_collector_2503 if SaveElementTreeNode:2504 self.gds_elementtree_node_ = node2505 already_processed = set()2506 self.ns_prefix_ = get_(node, 'prefix')2507 self.buildAttributes(node, node.attrib, already_processed)2508 for child in node:2509 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]2510 self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)2511 return self2512 def buildAttributes(self, node, attrs, already_processed):2513 value = find_attr_value_('name', node)2514 if value is not None and 'name' not in already_processed:2515 already_processed.add('name')2516 self.name = value2517 value = find_attr_value_('sha1', node)2518 if value is not None and 'sha1' not in already_processed:2519 already_processed.add('sha1')2520 self.sha1 = value2521 value = find_attr_value_('md5', node)2522 if value is not None and 'md5' not in already_processed:2523 already_processed.add('md5')2524 self.md5 = value2525 value = find_attr_value_('merge', node)2526 if value is not None and 'merge' not in already_processed:2527 already_processed.add('merge')2528 self.merge = value2529 value = find_attr_value_('status', node)2530 if value is not None and 'status' not in already_processed:2531 already_processed.add('status')2532 self.status = value2533 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):2534 pass2535# end class disk2536class sample(GeneratedsSuper):2537 __hash__ = GeneratedsSuper.__hash__2538 subclass = None2539 superclass = None2540 def __init__(self, name=None, gds_collector_=None, **kwargs_):2541 self.gds_collector_ = gds_collector_2542 self.gds_elementtree_node_ = None2543 self.original_tagname_ = None2544 self.parent_object_ = kwargs_.get('parent_object_')2545 self.ns_prefix_ = None2546 self.name = _cast(None, name)2547 self.name_nsprefix_ = None2548 def factory(*args_, **kwargs_):2549 if CurrentSubclassModule_ is not None:2550 subclass = getSubclassFromModule_(2551 CurrentSubclassModule_, sample)2552 if subclass is not None:2553 return subclass(*args_, **kwargs_)2554 if sample.subclass:2555 return sample.subclass(*args_, **kwargs_)2556 else:2557 return sample(*args_, **kwargs_)2558 factory = staticmethod(factory)2559 def get_ns_prefix_(self):2560 return self.ns_prefix_2561 def set_ns_prefix_(self, ns_prefix):2562 self.ns_prefix_ = ns_prefix2563 def get_name(self):2564 return self.name2565 def set_name(self, name):2566 self.name = name2567 def hasContent_(self):2568 if (2569 ):2570 return True2571 else:2572 return False2573 def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='sample', pretty_print=True):2574 imported_ns_def_ = GenerateDSNamespaceDefs_.get('sample')2575 if imported_ns_def_ is not None:2576 namespacedef_ = imported_ns_def_2577 if pretty_print:2578 eol_ = '\n'2579 else:2580 eol_ = ''2581 if self.original_tagname_ is not None:2582 name_ = self.original_tagname_2583 if UseCapturedNS_ and self.ns_prefix_:2584 namespaceprefix_ = self.ns_prefix_ + ':'2585 showIndent(outfile, level, pretty_print)2586 outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))2587 already_processed = set()2588 self.exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='sample')2589 if self.hasContent_():2590 outfile.write('>%s' % (eol_, ))2591 self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='sample', pretty_print=pretty_print)2592 outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))2593 else:2594 outfile.write('/>%s' % (eol_, ))2595 def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='sample'):2596 if self.name is not None and 'name' not in already_processed:2597 already_processed.add('name')2598 outfile.write(' name=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.name), input_name='name')), ))2599 def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='sample', fromsubclass_=False, pretty_print=True):2600 pass2601 def build(self, node, gds_collector_=None):2602 self.gds_collector_ = gds_collector_2603 if SaveElementTreeNode:2604 self.gds_elementtree_node_ = node2605 already_processed = set()2606 self.ns_prefix_ = get_(node, 'prefix')2607 self.buildAttributes(node, node.attrib, already_processed)2608 for child in node:2609 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]2610 self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)2611 return self2612 def buildAttributes(self, node, attrs, already_processed):2613 value = find_attr_value_('name', node)2614 if value is not None and 'name' not in already_processed:2615 already_processed.add('name')2616 self.name = value2617 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):2618 pass2619# end class sample2620class archive(GeneratedsSuper):2621 __hash__ = GeneratedsSuper.__hash__2622 subclass = None2623 superclass = None2624 def __init__(self, name=None, gds_collector_=None, **kwargs_):2625 self.gds_collector_ = gds_collector_2626 self.gds_elementtree_node_ = None2627 self.original_tagname_ = None2628 self.parent_object_ = kwargs_.get('parent_object_')2629 self.ns_prefix_ = None2630 self.name = _cast(None, name)2631 self.name_nsprefix_ = None2632 def factory(*args_, **kwargs_):2633 if CurrentSubclassModule_ is not None:2634 subclass = getSubclassFromModule_(2635 CurrentSubclassModule_, archive)2636 if subclass is not None:2637 return subclass(*args_, **kwargs_)2638 if archive.subclass:2639 return archive.subclass(*args_, **kwargs_)2640 else:2641 return archive(*args_, **kwargs_)2642 factory = staticmethod(factory)2643 def get_ns_prefix_(self):2644 return self.ns_prefix_2645 def set_ns_prefix_(self, ns_prefix):2646 self.ns_prefix_ = ns_prefix2647 def get_name(self):2648 return self.name2649 def set_name(self, name):2650 self.name = name2651 def hasContent_(self):2652 if (2653 ):2654 return True2655 else:2656 return False2657 def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='archive', pretty_print=True):2658 imported_ns_def_ = GenerateDSNamespaceDefs_.get('archive')2659 if imported_ns_def_ is not None:2660 namespacedef_ = imported_ns_def_2661 if pretty_print:2662 eol_ = '\n'2663 else:2664 eol_ = ''2665 if self.original_tagname_ is not None:2666 name_ = self.original_tagname_2667 if UseCapturedNS_ and self.ns_prefix_:2668 namespaceprefix_ = self.ns_prefix_ + ':'2669 showIndent(outfile, level, pretty_print)2670 outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))2671 already_processed = set()2672 self.exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='archive')2673 if self.hasContent_():2674 outfile.write('>%s' % (eol_, ))2675 self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='archive', pretty_print=pretty_print)2676 outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))2677 else:2678 outfile.write('/>%s' % (eol_, ))2679 def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='archive'):2680 if self.name is not None and 'name' not in already_processed:2681 already_processed.add('name')2682 outfile.write(' name=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.name), input_name='name')), ))2683 def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='archive', fromsubclass_=False, pretty_print=True):2684 pass2685 def build(self, node, gds_collector_=None):2686 self.gds_collector_ = gds_collector_2687 if SaveElementTreeNode:2688 self.gds_elementtree_node_ = node2689 already_processed = set()2690 self.ns_prefix_ = get_(node, 'prefix')2691 self.buildAttributes(node, node.attrib, already_processed)2692 for child in node:2693 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]2694 self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)2695 return self2696 def buildAttributes(self, node, attrs, already_processed):...

Full Screen

Full Screen

Automation Testing Tutorials

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

LambdaTest Learning Hubs:

YouTube

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

Run autotest automation tests on LambdaTest cloud grid

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

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful