Diff for /documentViewer/documentViewer.py between versions 1.175.2.7 and 1.175.2.9

version 1.175.2.7, 2011/07/20 19:36:57 version 1.175.2.9, 2011/07/27 19:09:44
Line 102  def getParentDir(path): Line 102  def getParentDir(path):
     """returns pathname shortened by one"""      """returns pathname shortened by one"""
     return '/'.join(path.split('/')[0:-1])      return '/'.join(path.split('/')[0:-1])
                   
 def normalizeBibtype(bt):  def normalizeBibField(bt, underscore=True):
     """returns normalised bib type for looking up mappings"""      """returns normalised bib type for looking up mappings"""
     bt = bt.strip().replace(' ', '-').lower()      bt = bt.strip().replace(' ', '-').lower()
       if underscore:
           bt = bt.replace('_', '-')
           
     return bt      return bt
   
 def getBibdataFromDom(dom):  def getBibdataFromDom(dom):
Line 114  def getBibdataFromDom(dom): Line 117  def getBibdataFromDom(dom):
     if bib is not None:      if bib is not None:
         # put type in @type          # put type in @type
         type = bib.get('type')          type = bib.get('type')
         bibinfo['@type'] = normalizeBibtype(type)          bibinfo['@type'] = normalizeBibField(type)
         # put all subelements in dict          # put all subelements in dict
         for e in bib:          for e in bib:
             bibinfo[e.tag] = getText(e)              bibinfo[normalizeBibField(e.tag)] = getText(e)
                           
     return bibinfo      return bibinfo
   
   
 ##  ##
 ## documentViewer class  ## documentViewer class
 ##  ##
Line 577  class documentViewer(Folder): Line 581  class documentViewer(Folder):
         docinfo['indexMetaPath']=self.getIndexMetaPath(path);          docinfo['indexMetaPath']=self.getIndexMetaPath(path);
                   
         logging.debug("documentViewer (getbibinfofromindexmeta cutted) path: %s"%(path))          logging.debug("documentViewer (getbibinfofromindexmeta cutted) path: %s"%(path))
           # try to get MetaDataFolder
           metadata = getattr(self, 'metadata')
           if metadata is not None:
         # put all raw bib fields in dict "bib"          # put all raw bib fields in dict "bib"
         bib = getBibdataFromDom(dom)              bib = metadata.getBibdataFromDom(dom)
         docinfo['bib'] = bib          docinfo['bib'] = bib
         bibtype = bib.get('@type', None)          bibtype = bib.get('@type', None)
         docinfo['bib_type'] = bibtype          docinfo['bib_type'] = bibtype
         if bibtype:              # also store DC metadata for convenience
             # also store standard mapped metadata for convenience              dc = metadata.getDCMappedData(bib)
             try:              docinfo['creator'] = dc.get('creator',None)
                 stdbib = self.metadata.getStdMappedHash(bib)              docinfo['title'] = dc.get('title',None)
                 docinfo['std_bib'] = stdbib              docinfo['date'] = dc.get('date',None)
                 docinfo['author'] = stdbib['author']          else:
                 docinfo['title'] = stdbib['title']              logging.error("MetaDataFolder 'metadata' not found!")
                 docinfo['year'] = stdbib['year']              #TODO: remove
             except:              bib = getBibdataFromDom(dom)
                 pass  
   
         return docinfo          return docinfo
           
           

Removed from v.1.175.2.7  
changed lines
  Added in v.1.175.2.9


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>