Exemple #1
0
import sys
from Pyblio import Selection, Sort
from Pyblio.Open import bibopen, bibwrite

a = bibopen (sys.argv [2])
f = open (sys.argv [3], 'w')

# write out in the key order
sel = Selection.Selection (sort = Sort.Sort ([Sort.KeySort ()]))
it  = sel.iterator (a.iterator ())

bibwrite (it, out = f, how = a.id)
Exemple #2
0
# check for the crossref field
field_table = Config.get('base/fields').data
crossref = None

for key in field_table.keys():
    if field_table[key].type == Fields.Reference:
        crossref = key
        break

# 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)
Exemple #3
0
import sys
from Pyblio import Selection, Sort
from Pyblio.Open import bibopen, bibwrite

how = sys.argv [2]

if how == '': how = None

a = bibopen (sys.argv [3], how)

f = open (sys.argv [4], 'w')

# write out in the key order
sel = Selection.Selection (sort = Sort.Sort ([Sort.KeySort ()]))
it  = sel.iterator (a.iterator ())

bibwrite (it, out = f, how = a.id)
Exemple #4
0
formatter = output.data


# we have to create a new database to hold the entries found in the
# given databases

r = Base.DataBase (None)

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

for bib in bibfile:

    # 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 avoid 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
Exemple #5
0
import sys
from Pyblio import Selection, Sort
from Pyblio.Open import bibopen, bibwrite

how = sys.argv[2]

if how == '': how = None

a = bibopen(sys.argv[3], how)

f = open(sys.argv[4], 'w')

# write out in the key order
sel = Selection.Selection(sort=Sort.Sort([Sort.KeySort()]))
it = sel.iterator(a.iterator())

bibwrite(it, out=f, how=a.id)
Exemple #6
0
for dir in sys.argv [2:]:

    # eventually expand directories to their content
    if os.path.isdir (dir):
        files = map (lambda x, dir = dir: \
                     os.path.join (dir, x), os.listdir (dir))

        # in the case of a directory, use only .bib extension...
        files = filter (lambda f: os.path.splitext (f) [1] == '.bib',
                        files)
    else:
        files = [dir]


    # loop over the files
    for f in files:
        # try to open the database
        try:
            b = bibopen (f)
            print (_n(u"file “%s” is ok [%d entry]",
                      u"file “%s” is ok [%d entries]",
                      len(b))
                   % (f, len (b))).encode(charset)
        except (Exceptions.ParserError, KeyError), err:
            broken.append (str (err))

# write the error messages (expected to be well formated)
if len (broken) > 0:
    print string.join (broken, "\n")
    sys.exit (1)
Exemple #7
0
import sys

from Pyblio import Fields, Autoload
from Pyblio.Open import bibopen
from Pyblio.Style import Utils

db = bibopen(sys.argv[2])
keys = db.keys()
keys.sort()
url = Fields.URL(sys.argv[3])

Utils.generate(url,
               Autoload.get_by_name('output', sys.argv[4]).data, db, keys,
               sys.stdout)
Exemple #8
0
    try:
        h = open (header, 'r')
        line = '\n'
        while line:
            line = h.readline ()
            if line:
                outfile.write (line)
        h.close ()
    except IOError, err:
        error (_(u"can’t open header “%s”: %s") % (header, str (err).decode (charset)))

# write the data
for file in files:

    try:
        db = bibopen (file)
    except IOError, err:
        error (_(u"can’t open database: %s") % file)

    Utils.generate (url, formatter, db, db.keys (), outfile)
    
# last, write the footer
if footer:
    try:
        h = open (footer, 'r')
        line = '\n'
        while line:
            line = h.readline ()
            if line:
                outfile.write (line)
        h.close ()