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
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
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
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
if opt == '-v' or opt == '--version': usage () sys.exit (0) continue # test input arguments if len (args) < 1: # user gave wrong arguments... usage () error (_("too few arguments")) files = args # get the specified style and the output output = Autoload.get_by_name ('output', format) if output is None: error (_("unknown output format `%s'") % format) 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) if not url: error (_("can't find style `%s'") % style)
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)
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)
if missing: # warn the user that some entries were not found print _("pybtex: 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 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)