How to use gds_format_string method in autotest

Best Python code snippet using autotest_python Github


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 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 = 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.value,331 elif self.content_type == MixedContainer.TypeInteger \333 or self.content_type == MixedContainer.TypeBoolean:334 outfile.write('<%s>%d</%s>' % (, self.value,335 elif self.content_type == MixedContainer.TypeFloat \337 or self.content_type == MixedContainer.TypeDecimal:338 outfile.write('<%s>%f</%s>' % (, self.value,339 elif self.content_type == MixedContainer.TypeDouble:341 outfile.write('<%s>%g</%s>' % (, self.value,342 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.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.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.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 = name376 self.data_type = data_type377 self.container = container378 def set_name(self, name):379 = 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 self.set_metsHdr(obj_)780 elif nodeName_ == 'dmdSec':781 obj_ = mdSecType.factory()782 self.dmdSec.append(obj_)784 elif nodeName_ == 'amdSec':785 obj_ = amdSecType.factory()786 self.amdSec.append(obj_)788 elif nodeName_ == 'fileSec':789 obj_ = fileSec.factory()790 self.set_fileSec(obj_)792 elif nodeName_ == 'structMap':793 obj_ = structMapType.factory()794 self.structMap.append(obj_)796 elif nodeName_ == 'structLink':797 obj_ = structLink.factory()798 self.set_structLink(obj_)800 elif nodeName_ == 'behaviorSec':801 obj_ = behaviorSecType.factory()802 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 self.agent.append(obj_)1099 elif nodeName_ == 'altRecordID':1100 obj_ = altRecordID.factory()1101 self.altRecordID.append(obj_)1103 elif nodeName_ == 'metsDocumentID':1104 obj_ = metsDocumentID.factory()1105 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 = 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 = 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 is not None:1266 showIndent(outfile, level)1267 outfile.write('<%sname>%s</%sname>\n' % (namespace_,1268 self.gds_format_string(quote_xml(,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 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 is not None:1326 showIndent(outfile, level)1327 outfile.write('name=%s,\n'1328 % quote_python( 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 = 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 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 self.techMD.append(obj_)2086 elif nodeName_ == 'rightsMD':2087 obj_ = mdSecType.factory()2088 self.rightsMD.append(obj_)2090 elif nodeName_ == 'sourceMD':2091 obj_ = mdSecType.factory()2092 self.sourceMD.append(obj_)2094 elif nodeName_ == 'digiprovMD':2095 obj_ = mdSecType.factory()2096 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 self.fileGrp.append(obj_)2360 elif nodeName_ == 'file':2361 obj_ = fileType.factory()2362 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 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 self.mptr.append(obj_)2987 elif nodeName_ == 'fptr':2988 obj_ = fptr.factory()2989 self.fptr.append(obj_)2991 elif nodeName_ == 'div':2992 obj_ = divType.factory()2993 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 = _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 = 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 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(,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 is not None and 'show' not in already_processed:3232 already_processed.append('show')3233 showIndent(outfile, level)3234 outfile.write('show = "%s",\n' % (, ))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 = 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 self.set_par(obj_)3583 elif nodeName_ == 'seq':3584 obj_ = seqType.factory()3585 self.set_seq(obj_)3587 elif nodeName_ == 'area':3588 obj_ = areaType.factory()3589 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 self.area.append(obj_)3772 elif nodeName_ == 'seq':3773 obj_ = seqType.factory()3774 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 self.area.append(obj_)3957 elif nodeName_ == 'par':3958 obj_ = parType.factory()3959 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 self.smLink.append(obj_)4566 elif nodeName_ == 'smLinkGrp':4567 obj_ = smLinkGrp.factory()4568 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 xlink:title - a title for the link4586 (if needed), as per the xlink specification. See4587 xlink:show - see the xlink4588 specification at xlink:actuate - see4589 the xlink specification at 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 = _cast(None, show)4608 self.title = _cast(None, title)4609 self.actuate = _cast(None, actuate)4610 = _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 = 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 = 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 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(,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 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(,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 is not None and 'show' not in already_processed:4756 already_processed.append('show')4757 showIndent(outfile, level)4758 outfile.write('show = "%s",\n' % (, ))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 is not None and 'to' not in already_processed:4769 already_processed.append('to')4770 showIndent(outfile, level)4771 outfile.write('to = "%s",\n' % (, ))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 = 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 = 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 self.smLocatorLink.append(obj_)5111 elif nodeName_ == 'smArcLink':5112 obj_ = smArcLink.factory()5113 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 = _cast(None, show)5406 self.actuate = _cast(None, actuate)5407 self.ARCTYPE = _cast(None, ARCTYPE)5408 = _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 = 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 = 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 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(,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 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(,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 is not None and 'show' not in already_processed:5589 already_processed.append('show')5590 showIndent(outfile, level)5591 outfile.write('show = "%s",\n' % (, ))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 is not None and 'to' not in already_processed:5603 already_processed.append('to')5604 showIndent(outfile, level)5605 outfile.write('to = "%s",\n' % (, ))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 = 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 = 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 self.behaviorSec.append(obj_)5915 elif nodeName_ == 'behavior':5916 obj_ = behaviorType.factory()5917 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: