def format (database, style, output, file = sys.stdout, id = 'Bibliography'): output = Autoload.get_by_name ("output", output).data url = None style = os.path.splitext (style) [0] if os.path.exists (style + '.xml'): url = Fields.URL (style + '.xml') else: from Pyblio import version full = os.path.join (version.pybdir, 'Styles', style) full = full + '.xml' if os.path.exists (full): url = Fields.URL (full) Utils.generate (url, output, database, database.keys (), file) return
def format(database, style, output, file=sys.stdout, id='Bibliography'): output = Autoload.get_by_name("output", output).data url = None style = os.path.splitext(style)[0] if os.path.exists(style + '.xml'): url = Fields.URL(style + '.xml') else: from Pyblio import version full = os.path.join(version.pybdir, 'Styles', style) full = full + '.xml' if os.path.exists(full): url = Fields.URL(full) Utils.generate(url, output, database, database.keys(), file) return
# -------------------------------------------------- # generate the latex bibliography # -------------------------------------------------- # Create a formatter that writes in the .bbl file formatter = Autoload.get_by_name ('output', 'LaTeX').data # Search style in local path and standard installation url = None if os.path.exists (style + '.xml'): url = Fields.URL (style + '.xml') else: from Pyblio import version full = os.path.join (version.pybdir, 'Styles', style) full = full + '.xml' if os.path.exists (full): url = Fields.URL (full) if not url: error (_("can't find style `%s'") % style) # open the .bbl file bblfile = os.path.splitext (os.path.split (latex) [1]) [0] + '.bbl' bbl = open (bblfile, 'w') Utils.generate (url, formatter, db, keys, bbl) bbl.close ()
% string.join (entries, ", ")) # creating an ordered list of database keys to pass through keys = map (lambda x: Key.Key (r, x), order) # creating the reference list try: refs = open (reffile, 'w') except IOError, err: error (_("can't open `%s': %s") % (reffile, str (err).decode (charset))) refs.write ("\n\nReferences:\n") Utils.generate (url, formatter, r, keys, refs) refs.close () # getting the old-new key pairs oldnew = pybtextvar.oldnew # Now we check the textfile again to replace bibdb keys # to the new keys if it is needed if oldnew: try: txt = open (textfile, 'r')
line = h.readline () if line: outfile.write (line) h.close () except IOError, err: error (_("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 (_("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 () except IOError, err: error (_("can't open footer `%s': %s") % (footer, str (err).decode (charset)))
from Pyblio import Fields, Autoload from Pyblio.Style import Utils import sys 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)
error( _(u"can’t find the following entries: %s") % string.join(entries, ", ")) # creating an ordered list of database keys to pass through keys = map(lambda x: Key.Key(r, x), order) # creating the reference list try: refs = open(reffile, 'w') except IOError, err: error(_(u"can’t open “%s”: %s") % (reffile, str(err).decode(charset))) refs.write("\n\nReferences:\n") Utils.generate(url, formatter, r, keys, refs) refs.close() # getting the old-new key pairs oldnew = pybtextvar.oldnew # Now we check the textfile again to replace bibdb keys # to the new keys if it is needed if oldnew: try: txt = open(textfile, 'r') except IOError, err: error(u"“%s”': %s" % (textfile, str(err).decode(charset)))
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)
# -------------------------------------------------- # generate the latex bibliography # -------------------------------------------------- # Create a formatter that writes in the .bbl file formatter = Autoload.get_by_name('output', 'LaTeX').data # Search style in local path and standard installation url = None if os.path.exists(style + '.xml'): url = Fields.URL(style + '.xml') else: from Pyblio import version full = os.path.join(version.pybdir, 'Styles', style) full = full + '.xml' if os.path.exists(full): url = Fields.URL(full) if not url: error(_(u"can’t find style “%s”") % style) # open the .bbl file bblfile = os.path.splitext(os.path.split(latex)[1])[0] + '.bbl' bbl = open(bblfile, 'w') Utils.generate(url, formatter, db, keys, bbl) bbl.close()
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 () except IOError, err: error (_(u"can’t open footer “%s”: %s") % (footer, str (err).decode (charset)))