Esempio n. 1
0
    def _parseAuthors(self, line ) :
      """split out the authors/editors
      """
      ed = False
      comp = False

      if line.endswith('ed.') :
        ed = True
        line = line.replace('ed.', '   ')
      elif line.endswith('comp.') :
        comp = True
        line = line.replace('comp.', '    ')

      names = utils.makeNameList( line )

      if ed:
        self['Editors'] = names
      elif comp :
        self['Compilers'] = names
      else :
        self['Authors'] = names
Esempio n. 2
0
    def _parseComments( self, field ):
        
        cParser = comments.Comment.parser()
        results = cParser.parse_text(field, reset=True, multi=True)
        #
        # Look for translators, language, edition, and other publishers
        #
        if results:
             for result in results:
                grmName = result.elements[0].grammar_name
                if 'Edition' ==  grmName:
                    self['Edition'] = result.elements[0].edition_num

                elif 'Reference' == grmName:
                    self['Reference'] = str(result.find(comments.AJBNum)).strip()

                elif 'Reprint' == grmName:
                    tmp = result.find(comments.AJBNum)
                    if tmp:
                        self['Reprint'] = str(tmp).strip()
                    tmp = result.find(comments.Year)
                    if tmp:
                        self['Reprint'] = str(tmp).strip()

                elif 'Editors' == grmName:
                    line = str(result.find(comments.NameList))
                    nm = utils.makeNameList( line )
                    if self.notEmpty('Editors'):
                        self['Editors'].extend( nm )
                    else:
                        self['Editors'] = nm

                elif 'Contributors' == grmName:
                    line = str(result.find(comments.NameList))
                    nm = utils.makeNameList( line )
                    if self.notEmpty('Contributors'):
                        self['Contributors'].extend( nm )
                    else:
                        self['Contributors'] = nm

                elif 'Compilers' == grmName:
                    line = str(result.find(comments.NameList))
                    nm = utils.makeNameList( line )
                    if self.notEmpty('Compilers'):
                        self['Compilers'].extend( nm )
                    else:
                        self['Compilers'] = nm

                elif 'Translation' == grmName :
                    tmp = result.find(comments.FromLanguage)
                    if tmp:
                        self['TranslatedFrom'] = str(tmp.elements[1]).strip()

                    tmp = result.find(comments.ToLanguage)
                    if tmp:
                        self['Language'] = str(tmp.elements[1]).strip()

                    tmp = result.find(comments.NameList)
                    if tmp:
                        nm = utils.makeNameList(str(tmp))
                        if self.notEmpty('Translators'):
                            self['Translators'].extend( nm )
                        else:
                            self['Translators'] = nm 

                elif 'Publishers' == grmName:
                    tmp = str(result.find(comments.PublisherList))
                    # the space chars in the split avoids problems with 
                    # e.g. Rand McNally & Sons
                    list = tmp.split(' and ')
                    for l in list:
                        p = l.split(':')
                        self['Publishers'].append( {'Place' : p[0].strip(),
                                                    'PublisherName': p[1].strip()})

                elif 'Language' == grmName:
                    self['Language'] = str(result.find(comments.uWord)).strip()

                elif 'Other' == grmName:
                    nm = str(result.find(comments.uWords)).strip()
                    if not self.notEmpty('Others'):
                        self['Others'] = []
                    self['Others'].append( nm )

                else:
                    print('Unknown grammer name %s' % grmName)