Logo Search packages:      
Sourcecode: zope-cmfbibliographyat version File versions  Download package

def CMFBibliographyAT::tool::parsers::ibss::IBSSParser::parseEntry (   self,
  entry 
)

parses a single entry

returns a dictionary to be passed to
BibliographyEntry's edit method

Definition at line 101 of file ibss.py.

00101                                :
        """
        parses a single entry
        
        returns a dictionary to be passed to
        BibliographyEntry's edit method
        """
        if isinstance(entry, StringType):
            entry = StringIO(entry)
        key = ''
        val = []
        record = {}
        for line in entry.readlines():
            # XXX This should be made to work when there is not indentation!
            if line[8] == ':':
                record[key] = '\n'.join(val)
                key = line[6:8]
                val = []
                val.append(line[10:].strip())
            else:
                val.append(line.strip())

        result = {}

        result['authors'] = self._parseAU(record['AU'])

        for key in key_mapping.keys():
            if record.has_key(key):
                result[key_mapping[key]] = record[key]

        try:
            if record.has_key('JN'):
                result['publication_type'] = 'ArticleReference'
                r = self._parseJN(record['JN'])
            elif record.has_key('BN'):
                if record['DT'] == 'Chapter':
                    result['publication_type'] = 'InbookReference'
                    #r = self._parseBNCH(record['BN'])
                else:
                    result['publication_type'] = 'BookReference'
                r = self._parseBN(record['BN'])

            for key in parse_key_list:
                if r.has_key(key):
                    result[key] = r[key]
        except ParseException:
            # can be thrown by the _parseXX methods too
            # Must catch TypeError to stop it propagating up to masquerade as a checkFormat error <grr />
            entry.seek(0)
            result = EntryParseError(entry.read().replace('\n', '\\n'))
        except TypeError:
            entry.seek(0)
            result = EntryParseError('TYPEERROR: %s' % entry.read().replace('\n', '\\n'))

        return result

    def _parseAU(self, s):


Generated by  Doxygen 1.6.0   Back to index