Пример #1
0
def get_by_name (entity, method):
    ''' returns a specific field of the given entity '''

    meth = Autoload.get_by_name ("format", entity)

    if meth and meth.data.has_key (method):
	return meth.data [method]

    return None
Пример #2
0
    def _on_validate (self, * arg):

        style  = self._w_style_entry.get_full_path (False)
        output = self._w_output_entry.get_full_path (False)

        FormatDialog.style  = style
        FormatDialog.output = output
        
        format = Autoload.get_by_name ('output', self.menu_item).data

        if style is None or output is None: return
        self._w_format.destroy ()

        self.issue ('format-query', style, format, output)
        return
Пример #3
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 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
Пример #4
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 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
Пример #5
0
    def _on_validate(self, *arg):
        style = self._w_style.get_filename()
        output = self._w_output.get_filename()

        FormatDialog.style  = style
        FormatDialog.output = output
        
        format = Autoload.get_by_name ('output', self.menu_item).data

        # FIXME: We can't use GtkFileChooserButton for saving a file
        # So, now we are not saving anything
        if output is None:
            import inspect
            fname, lineno, funcname = inspect.getframeinfo(inspect.currentframe())[:3]
            print 'FIXME: Data not saved. %s:%d (%s)' % (fname, lineno, funcname)

        if style is None or output is None: return
        self._w_format.destroy ()

        self.issue ('format-query', style, format, output)
Пример #6
0
    def _on_validate(self, *arg):
        style = self._w_style.get_filename()
        output = self._w_output.get_filename()

        FormatDialog.style = style
        FormatDialog.output = output

        format = Autoload.get_by_name('output', self.menu_item).data

        # FIXME: We can't use GtkFileChooserButton for saving a file
        # So, now we are not saving anything
        if output is None:
            import inspect
            fname, lineno, funcname = inspect.getframeinfo(
                inspect.currentframe())[:3]
            print 'FIXME: Data not saved. %s:%d (%s)' % (fname, lineno,
                                                         funcname)

        if style is None or output is None: return
        self._w_format.destroy()

        self.issue('format-query', style, format, output)
Пример #7
0
    def configure(self):
        fmeth = {}

        module = None
        for mod in self.config:
            module = Autoload.get_by_name('style', mod.module).data
            if module is None:
                raise RuntimeError, "unknown module `%s'" % mod.module

            for item in mod.data:
                if item.att.has_key('method'):
                    meth = item.att['method']
                    if module.has_key(item.data):
                        self.methods[meth] = module[item.data]
                    continue

                if item.att.has_key('field'):
                    field = item.att['field']
                    if module.has_key(item.data):
                        fmeth[field] = module[item.data]
                    continue

        self.format.meth = fmeth
        return
Пример #8
0
    def configure (self):
        fmeth = {}
        
        module = None
        for mod in self.config:
            module = Autoload.get_by_name ('style', mod.module).data
            if module is None:
                raise RuntimeError, "unknown module `%s'" % mod.module

            for item in mod.data:
                if item.att.has_key ('method'):
                    meth = item.att ['method']
                    if module.has_key (item.data):
                        self.methods [meth] = module [item.data]
                    continue
                
                if item.att.has_key ('field'):
                    field = item.att ['field']
                    if module.has_key (item.data):
                        fmeth [field] = module [item.data]
                    continue

        self.format.meth = fmeth
        return
Пример #9
0
if missing:
    # warn the user that some entries were not found
    print _("pybliotex: warning: the following keys were not resolved").encode (charset)
    print '	' + string.join (missing, '\n	') + '\n'

if style is None:
    # If the LaTeX document declares no style...
    error (_("no style defined"))

# --------------------------------------------------
# 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)
Пример #10
0
 def generate_key(self, entry):
     # call a key generator
     keytype = Config.get('base/keyformat').data
     return Autoload.get_by_name('key', keytype).data(entry, self)
Пример #11
0
# adjust parameters to the chosen style
if spstyle == 'abbrvau':
    sep = '; '
    format = 'textau'

elif spstyle == 'abbrvnum':
    sep = ', '
    format = 'textnum'
else:
    sep = ', '
    format = 'text'


# get the specified output
output = Autoload.get_by_name ('output', format)

if output is None:
    error (_("unknown output format `%s'") % format)



reffile = outfile + '.ref'

if os.path.exists(outfile):
    error (_("File already exists: `%s'") % outfile)

if os.path.exists(reffile):
    error (_("A file with the same name already exists: `%s'") % reffile)

textfile = args [0]
Пример #12
0
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)

Пример #13
0
spstyle = os.path.split(style)[1]

# adjust parameters to the chosen style
if spstyle == 'abbrvau':
    sep = '; '
    format = 'textau'

elif spstyle == 'abbrvnum':
    sep = ', '
    format = 'textnum'
else:
    sep = ', '
    format = 'text'

# get the specified output
output = Autoload.get_by_name('output', format)

if output is None:
    error(_(u"unknown output format “%s”") % format)

reffile = outfile + '.ref'

if os.path.exists(outfile):
    error(_(u"File already exists: “%s”") % outfile)

if os.path.exists(reffile):
    error(_(u"A file with the same name already exists: “%s”") % reffile)

textfile = args[0]
bibfile = args[1:]
Пример #14
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)
Пример #15
0
if missing:
    # warn the user that some entries were not found
    print _("pybliotex: warning: the following keys were not resolved").encode(
        charset)
    print '	' + string.join(missing, '\n	') + '\n'

if style is None:
    # If the LaTeX document declares no style...
    error(_("no style defined"))

# --------------------------------------------------
# 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)