예제 #1
0
파일: BibTeX.py 프로젝트: zkota/pyblio-1.3
    def __parsefile__(self):
	self.dict = {}
	# Ouvrir le fichier associe
	self.parser = _bibtex.open_file(Open.url_to_local(self.key),
                                        Config.get ('bibtex/strict').data)
	# Incorporer les definitions de l'utilisateur
	if not Config.get('bibtex+/override').data:
	    user = Config.get('bibtex/macros').data
	    valid = re.compile('^\w+$')
	    for k in user.keys():
		if not valid.match(k):
		    raise TypeError, _("key `%s' is malformed") % k
		_bibtex.set_string(self.parser, k,
                                   _bibtex.reverse(_base_fieldtype[Text],
                                                   Config.get('bibtex+/braces').data,
                                                   user [k][0]))
	finished = 0
	errors = []

	# Creer la base de cles
	iter = BibtexIterator(self, self.parser)
        try:
            entry = iter.first()
            if entry is not None:
                if entry.key is None:
                    self.add(entry)
                else:
                    if self.dict.has_key(entry.key):
                        errors.append(_("%s:%d: key `%s' already defined") % (
                            str(self.key), entry.line, entry.key.key))
                    else:
                        self.dict [entry.key] = entry
        except Exceptions.ParserError, err:
            errors.append (str (err))
예제 #2
0
파일: isifile.py 프로젝트: zkota/pyblio-1.3
def iterator (url, check):
        ''' This methods returns an iterator that will parse the
        database on the fly (useful for merging or to parse broken
        databases '''

        if check and url.url [2] [-4:] != '.isi': return
        
        return IsifileIterator (open (Open.url_to_local (url), 'r'))
예제 #3
0
파일: Ovid.py 프로젝트: zkota/pyblio-1.3
def iterator (url, check):
    ''' This methods returns an iterator that will parse the
    database on the fly (useful for merging or to parse broken
    databases '''

    if check and url.url [2] [-5:] != '.ovid': return

    file = open (Open.url_to_local (url))

    return  OvidLike.OvidLike (
        file,
        Config.get ('ovid/mapping').data,
        Config.get ('ovid/deftype').data
        )
예제 #4
0
파일: BibTeX.py 프로젝트: zkota/pyblio-1.3
def iterator (url, check):
    ''' This methods returns an iterator that will parse the
    database on the fly (useful for merging or to parse broken
    databases '''

    if check and url.url [2] [-4:] != '.bib': return None

    # Ouvrir le fichier associe
    parser = _bibtex.open_file (Open.url_to_local (url),
				Config.get ('bibtex/strict').data)

    # create a database to generate correct keys
    db = Base.DataBase (url)

    return BibtexIterator (db, parser)
예제 #5
0
파일: Parser.py 프로젝트: zkota/pyblio-1.3
    def __init__ (self, url):

        # each hash value contains a 2-uplet (opener, closer)
        
        self.format = None
        self.top    = []
        self.data   = []
        self.config = []

        self.methods = {}
        
        fh = open (Open.url_to_local (url))

        parser = sax.make_parser ()
        parser.setFeature (sax.handler.feature_validation, False)
        parser.setContentHandler (self)
        
        parser.parse (fh)
        fh.close ()
        
        return
예제 #6
0
파일: Refer.py 프로젝트: zkota/pyblio-1.3
def iterator (url, check):
    if check and url.url [2] [-6:] != '.refer': return

    file = open (Open.url_to_local (url))

    return  ReferIterator (file)