Beispiel #1
0
    def setUp(self):
        Config.parse_directory(os.path.join(basedir, 'ConfDir'))
        Config.load_user()
	print 'CONFIGURATION'
	print 50*'-'
	for i in Config.domains ():
	    print i, Config.keys_in_domain (i)
	print 'END', 50*'-'
        self.db = Base.DataBase ('//localhost/Internal')
        self.output = cStringIO.StringIO()
Beispiel #2
0
def find_entries(auxfile, bibtex):
    """ Parse an auxiliary file and extract the entries from the given BibTeX databases """

    entries, data, style = list_entries(auxfile)

    if not bibtex:
        bibtex = data

    # we have to create a Reference database to hold the entries contained in the
    # current database.
    r = Base.DataBase(None)
    keys = copy.copy(entries)

    # is there something to do ?
    if len(entries) == 0: return r, style, entries

    # use the bibliographic databases in order of declaration
    # to solve the references

    for bib in bibtex:
        (root, ext) = os.path.splitext(bib)
        if not ext: ext = '.bib'

        # open the database
        db = Open.bibopen(root + ext)

        # as we are modifying the list of entries in this loop, we make a copy
        # of it in order to avoir strange behaviors
        orig = copy.copy(entries)

        # loop over the expected entries
        for e in orig:

            # create a key in the current database
            key = Key.Key(db, e)

            # does the database provide the key ?
            if db.has_key(key):

                # yes, add it to the reference
                r[Key.Key(None, e)] = db[key]

                # and remove it from the list
                entries.remove(e)

        # is it finished ?
        if len(entries) == 0: break

    # return the reference on all the entries, plus the missing ones
    keys = filter(lambda x, entries=entries: not entries.count(x), keys)
    keys = map(lambda x, r=r: Key.Key(r, x), keys)

    return r, keys, style, entries
    def new_document(self, *arg):
        db = Base.DataBase(None)
        doc = Document.Document(db)

        # register several callbacks
        doc.Subscribe('new-document', self.new_document)
        doc.Subscribe('open-in-new', self.open_document)
        doc.Subscribe('open-document', self.cb_open_document)
        doc.Subscribe('close-document', self.close_document)
        doc.Subscribe('exit-application', self.exit_application)
        doc.update_history(self.opened)

        self.documents.append(doc)
        return doc
Beispiel #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:] != '.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)
Beispiel #5
0
 def setUp(self):
     Config.parse_directory(os.path.join(basedir, 'ConfDir'))
     Config.load_user()
     self.db = Base.DataBase('//localhost/Internal')
     self.output = cStringIO.StringIO()
Beispiel #6
0
# use the bibliographic databases in order of declaration
# to solve the references

for bib in bibtex:

    # open the database
    db = bibopen(bib)

    # as we are modifying the list of entries in this loop, we make a copy
    # of it in order to avoir strange behaviors
    orig = copy.copy(entries)

    # we have to create a new database to hold the entries contained in the
    # current database.

    r = Base.DataBase(None)

    # loop over the expected entries
    for e in orig:

        # create a key in the current database
        key = Key.Key(db, e)

        # does the database provide the key ?
        if db.has_key(key):

            # yes, add it to the reference
            v = db[key]

            r[key] = v