Changeset 561:9255acc4518d in documentViewer for documentViewer.py
- Timestamp:
- Oct 1, 2012, 4:09:01 PM (12 years ago)
- Branch:
- default
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
documentViewer.py
r560 r561 33 33 # stream.close() 34 34 return s 35 36 def getMDText(node): 37 """returns the @text content from the MetaDataProvider metadata node""" 38 if isinstance(node, dict): 39 return node.get('@text', None) 40 41 return node 35 42 36 43 def browserCheck(self): … … 220 227 return self.template.fulltextclient.getTocPage(**args) 221 228 229 def getRepositoryType(self, **args): 230 """get repository type""" 231 return self.template.fulltextclient.getRepositoryType(**args) 232 222 233 def getTextDownloadUrl(self, **args): 223 234 """get list of gis places on one page""" … … 571 582 572 583 # texttool info 573 texttool = self.metadataService.getTexttoolData(dom=metaDom )584 texttool = self.metadataService.getTexttoolData(dom=metaDom, recursive=1, all=True) 574 585 if texttool: 575 586 docinfo = self.getDocinfoFromTexttool(docinfo, texttool) … … 676 687 def getDocinfoFromTexttool(self, docinfo, texttool): 677 688 """reads contents of texttool element into docinfo""" 689 logging.debug("texttool=%s"%repr(texttool)) 690 # unpack list if necessary 691 if isinstance(texttool, list): 692 texttool = texttool[0] 693 678 694 # image dir 679 imageDir = texttool.get('image', None)680 docPath = docinfo.get('documentPath', None)695 imageDir = getMDText(texttool.get('image', None)) 696 docPath = getMDText(docinfo.get('documentPath', None)) 681 697 if imageDir and docPath: 682 698 #print "image: ", imageDir, " archivepath: ", archivePath … … 686 702 687 703 # old style text URL 688 textUrl = texttool.get('text', None)704 textUrl = getMDText(texttool.get('text', None)) 689 705 if textUrl and docPath: 690 706 if urlparse.urlparse(textUrl)[0] == "": #keine url … … 693 709 docinfo['textURL'] = textUrl 694 710 695 # new style text-url-path 696 textUrl = texttool.get('text-url-path', None) 697 if textUrl: 698 docinfo['textURLPath'] = textUrl 711 # new style text-url-path (can be more than one with "repository" attribute) 712 textUrlNode = texttool.get('text-url-path', None) 713 if not isinstance(textUrlNode, list): 714 textUrlNode = [textUrlNode] 715 716 for tun in textUrlNode: 717 textUrl = getMDText(tun) 718 if textUrl: 719 textUrlAtts = tun.get('@attr') 720 if (textUrlAtts and 'repository' in textUrlAtts): 721 textRepo = textUrlAtts['repository'] 722 # use matching repository 723 if self.getRepositoryType() == textRepo: 724 docinfo['textURLPath'] = textUrl 725 docinfo['textURLRepository'] = textRepo 726 727 else: 728 # no repo attribute - use always 729 docinfo['textURLPath'] = textUrl 699 730 700 731 # page flow 701 docinfo['pageFlow'] = texttool.get('page-flow', 'ltr')732 docinfo['pageFlow'] = getMDText(texttool.get('page-flow', 'ltr')) 702 733 703 734 # odd pages are left 704 docinfo['oddPage'] = texttool.get('odd-scan-position', 'left')735 docinfo['oddPage'] = getMDText(texttool.get('odd-scan-position', 'left')) 705 736 706 737 # number of title page (default 1) 707 docinfo['titlePage'] = texttool.get('title-scan-no', 1)738 docinfo['titlePage'] = getMDText(texttool.get('title-scan-no', 1)) 708 739 709 740 # old presentation stuff 710 presentation = texttool.get('presentation', None)741 presentation = getMDText(texttool.get('presentation', None)) 711 742 if presentation and docPath: 712 743 if presentation.startswith('http:'):
Note: See TracChangeset
for help on using the changeset viewer.