Beispiel #1
0
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 Legacy 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
Beispiel #2
0
            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)))

        
Beispiel #3
0
from Legacy import Fields, Autoload
from Legacy.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)
Beispiel #4
0
           % 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')
Beispiel #5
0
# --------------------------------------------------
# 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 Legacy 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 ()