Ejemplo n.º 1
0
    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, _(u"key “%s” is malformed") % k
                _bibtex.set_string(
                    self.parser, k,
                    _bibtex.reverse(_base_fieldtype[Text],
                                    Config.get('bibtex+/braces').data,
                                    user[k][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(
                            _(u"%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))
Ejemplo n.º 2
0
    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))
Ejemplo n.º 3
0
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:] != '.med': return

        return MedlineIterator (open (Open.url_to_local (url), 'r'))
Ejemplo n.º 4
0
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:] != '.med': return

    return MedlineIterator(open(Open.url_to_local(url), 'r'))
Ejemplo n.º 5
0
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)
Ejemplo n.º 6
0
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
        )
Ejemplo n.º 7
0
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)
Ejemplo n.º 8
0
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)
Ejemplo n.º 9
0
    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
Ejemplo n.º 10
0
    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
Ejemplo n.º 11
0
def iterator (url, check):
    if check and url.url [2] [-6:] != '.refer': return

    file = open (Open.url_to_local (url))

    return  ReferIterator (file)
Ejemplo n.º 12
0
def iterator(url, check):
    if check and url.url[2][-6:] != '.refer': return

    file = open(Open.url_to_local(url))

    return ReferIterator(file)