Changeset 631:0c3aab828864 in documentViewer
- Timestamp:
- Jul 2, 2015, 8:27:05 AM (9 years ago)
- Branch:
- default
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
documentViewer.py
r629 r631 19 19 from SrvTxtUtils import getInt, utf8ify, getText, getHttpData, refreshingImageFileIndexHtml, sslifyUrl 20 20 21 22 INDEXMETA_NS="http://md.mpiwg-berlin.mpg.de/ns/indexMeta#" 23 24 def removeINDEXMETA_NS(root): #entfernt den namespace von indexmeta aus dem dom #TODO evertyhing should be changed that it can deal with NS 25 for elem in root.getiterator(): 26 print ("ETAG") 27 print(elem.tag) 28 if not hasattr(elem.tag, 'find'): continue # (1) 29 30 i = elem.tag.find('{%s}'%INDEXMETA_NS) 31 if i >= 0: 32 elem.tag = elem.tag[i+len(('{%s}'%INDEXMETA_NS)):] 33 34 print(elem.tag) 21 35 22 36 def getMDText(node): … … 530 544 # url points to document dir or index.meta 531 545 metaDom = self.metadataService.getDomFromPathOrUrl(url) 546 removeINDEXMETA_NS(metaDom) 547 532 548 if metaDom is None: 533 549 raise IOError("Unable to find index.meta for mode=texttool!") … … 536 552 if url.startswith('/mpiwg/online/'): 537 553 docUrl = url.replace('/mpiwg/online/', '', 1) 554 elif mode=="textpath": 555 #url points to an textfile 556 #index.meta optional 557 #assume index.meta in parent dir 558 docUrl = getParentPath(url) 559 docinfo['viewmode'] = "text" 560 561 try: 562 metaDom = self.metadataService.getDomFromPathOrUrl(docUrl) 563 564 removeINDEXMETA_NS(metaDom) 565 566 567 568 except: 569 metaDom = None 570 #metaDom = self.metadataService.getDomFromPathOrUrl(docUrl) 571 #docinfo['imagePath'] = url.replace('/mpiwg/online', '', 1) 572 docinfo['textURLPath'] = url.replace('/mpiwg/online', '', 1) 573 docinfo['textURL'] = url 574 if docinfo.get("creator", None) is None: 575 docinfo['creator'] = "" 576 577 if docinfo.get("title", None) is None: 578 docinfo['title'] = "" 579 580 if docinfo.get("documentPath", None) is None: 581 docinfo['documentPath'] = url.replace('/mpiwg/online', '', 1) 582 docinfo['documentPath'] = url.replace('/pages', '', 1) 583 584 docinfo['numPages'] = 1 538 585 539 586 elif mode=="imagepath": 540 587 # url points to folder with images, index.meta optional 541 588 # asssume index.meta in parent dir 542 docUrl = getParentPath(url)589 543 590 metaDom = self.metadataService.getDomFromPathOrUrl(docUrl) 591 544 592 docinfo['imagePath'] = url.replace('/mpiwg/online', '', 1) 545 593 … … 575 623 docinfo['documentUrl'] = docUrl 576 624 # process index.meta contents 577 if metaDom is not None and metaDom.tag == 'resource': 625 626 if metaDom is not None and (metaDom.tag == 'resource' or metaDom.tag == "{%s}resource"%INDEXMETA_NS): 627 print("MD") 578 628 # document directory name and path 579 629 resource = self.metadataService.getResourceData(dom=metaDom, recursive=1) 580 630 if resource: 581 631 docinfo = self.getDocinfoFromResource(docinfo, resource) 582 632 583 633 # texttool info 584 634 texttool = self.metadataService.getTexttoolData(dom=metaDom, recursive=1, all=True)
Note: See TracChangeset
for help on using the changeset viewer.