def __init__(self, parent=None, has_auto=True): Utils.Builder.__init__(self, parent) liststore = gtk.ListStore(gobject.TYPE_STRING) menu = self._w_combobox menu.set_model(liststore) cell = gtk.CellRendererText() menu.pack_start(cell, True) menu.add_attribute(cell, 'text', 0) liste = Autoload.available('format') liste.sort() self.formats = [None] if has_auto: iter = liststore.append() liststore.set(iter, 0, _(' — According to file suffix — ')) self.ftype = None else: self.ftype = liste[0] for avail in liste: iter = liststore.append() liststore.set(iter, 0, avail) self.formats += liste menu.set_active(0) menu.connect("changed", self.menu_select) return
def __init__ (self, parent = None): Utils.GladeWindow.__init__ (self, parent) # Fill the output format drop-down menu menu = gtk.Menu () self._w_menu.set_menu (menu) outlist = Autoload.available ('output') outlist.sort () for avail in outlist: Utils.popup_add (menu, avail, self._menu_select, avail) self._w_menu.set_history (0) self.menu_item = outlist [0] self._w_style_entry.set_default_path (FormatDialog.style) self._w_style.set_text (FormatDialog.style) if FormatDialog.output: self._w_output_entry.set_default_path (FormatDialog.output) self._w_output.set_text (FormatDialog.output) self._w_format.show () return
def __init__ (self, parent = None, has_auto = True): Utils.GladeWindow.__init__ (self, parent) liststore = gtk.ListStore (gobject.TYPE_STRING) menu = self._w_combobox menu.set_model (liststore) cell = gtk.CellRendererText() menu.pack_start(cell, True) menu.add_attribute(cell, 'text', 0) liste = Autoload.available ('format') liste.sort () self.formats = [ None ] if has_auto: iter = liststore.append () liststore.set (iter, 0, _(' - According to file suffix - ')) self.ftype = None else: self.ftype = liste [0] for avail in liste: iter = liststore.append () liststore.set (iter, 0, avail) self.formats += liste menu.set_active (0) menu.connect ("changed", self.menu_select) return
def get_by_regexp (entity, method): ''' returns a specific field of the given entity ''' meth = Autoload.get_by_regexp ("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 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
def bibopen (entity, how = None): ''' Generic function to open a bibliographic database ''' def simple_try (url, how): # url is Fields.URL instance, only to be passed to opener base = None if how == None: listedmethods = Autoload.available ("format") for method in listedmethods: opener = get_by_name (method, 'open') if opener: base = opener (url, 1) if base is not None: return base return None opener = get_by_name (how, 'open') if opener: base = opener (url, 0) else: raise Exceptions.FormatError (_(u"method “%s” provides no opener") % how) return base # Consider the reference as an URL: url is an Fields.URL instance url = Fields.URL (entity) if url.url [0] == 'file' and not os.path.exists (url.url [2]): raise Exceptions.FileError (_(u"File “%s” does not exist") % url.get_url ()) # eventually load a new module if how is None: handler = Autoload.get_by_regexp ("format", url.get_url ()) if handler: how = handler.name base = simple_try (url, how) if base is None: raise Exceptions.FormatError (_(u"don’t know how to open “%s”") % entity) return base
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)
def __init__ (self, parent=None): Utils.Builder.__init__(self, parent) cell = gtk.CellRendererText() self._w_menu.pack_start (cell, True) self._w_menu.add_attribute (cell, 'text', 0) outlist = Autoload.available ('output') outlist.sort () for avail in outlist: self._w_menu.append_text(avail) self._w_menu.set_active(0) self.menu_item = outlist[0] self._w_style.set_filename(FormatDialog.style) if FormatDialog.output: self._w_output.set_filename(FormatDialog.output) self._w_format.show ()
def __init__(self, parent=None): Utils.Builder.__init__(self, parent) cell = gtk.CellRendererText() self._w_menu.pack_start(cell, True) self._w_menu.add_attribute(cell, 'text', 0) outlist = Autoload.available('output') outlist.sort() for avail in outlist: self._w_menu.append_text(avail) self._w_menu.set_active(0) self.menu_item = outlist[0] self._w_style.set_filename(FormatDialog.style) if FormatDialog.output: self._w_output.set_filename(FormatDialog.output) self._w_format.show()
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)
def simple_try (url, how): # url is Fields.URL instance, only to be passed to opener base = None if how == None: listedmethods = Autoload.available ("format") for method in listedmethods: opener = get_by_name (method, 'open') if opener: base = opener (url, 1) if base is not None: return base return None opener = get_by_name (how, 'open') if opener: base = opener (url, 0) else: raise Exceptions.FormatError (_(u"method “%s” provides no opener") % how) return base
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
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
# Site configuration from Pyblio import Autoload, Config, version from Pyblio.TextUI import * # ================================================== import string, os # define autoloaded formats Autoload.preregister ('format', 'BibTeX', 'Pyblio.Format.BibTeX', '.*\.bib') Autoload.preregister ('format', 'Ovid', 'Pyblio.Format.Ovid', '.*\.ovid') Autoload.preregister ('format', 'Medline', 'Pyblio.Format.Medline', '.*\.med') Autoload.preregister ('format', 'Refer', 'Pyblio.Format.Refer', '.*\.refer') Autoload.preregister ('format', 'ISIFile', 'Pyblio.Format.isifile', '.*\.isi') # define styles and outputs Autoload.preregister ('style', 'Generic', 'Pyblio.Style.Generic') Autoload.preregister ('style', 'apa4e', 'Pyblio.Style.apa4e') Autoload.preregister ('style', 'abbrv', 'Pyblio.Style.abbrv') Autoload.preregister ('output', 'Text', 'Pyblio.Output.text') Autoload.preregister ('output', 'Raw', 'Pyblio.Output.raw') Autoload.preregister ('output', 'HTML', 'Pyblio.Output.html') Autoload.preregister ('output', 'LaTeX', 'Pyblio.Output.LaTeX') Autoload.preregister ('output', 'Textnum', 'Pyblio.Output.textnum') Autoload.preregister ('output', 'Textau', 'Pyblio.Output.textau')
return author_desc (entry, coding, 0, 1) def first_last_full_authors (entry, coding): return author_desc (entry, coding, 0, -1) def full_authors (entry, coding): return author_desc (entry, coding, 0, 0) def initials_authors (entry, coding): return author_desc (entry, coding, 1, 0) def first_last_initials_authors (entry, coding): return author_desc (entry, coding, 1, -1) def last_first_initials_authors (entry, coding): return author_desc (entry, coding, 1, 1) # Line below changed Autoload.register ('style', 'apa4e', { 'first_last_full_authors' : first_last_full_authors, 'last_first_full_authors' : last_first_full_authors, 'full_authors' : full_authors, 'first_last_initials_authors' : first_last_initials_authors, 'last_first_initials_authors' : last_first_initials_authors, 'initials_authors' : initials_authors, 'string_keys' : create_string_key, 'numeric_keys' : create_numeric_key, 'european_date' : standard_date, })
self.out.write ('<i>%s</i>' % text) elif style == 'emph': self.out.write ('<em>%s</em>' % text) else: self.out.write (text) def start_group (self, id, table = None): self.out.write ('<dl>\n') return def end_group (self): self.out.write ('</dl>\n') self.out.write ('<p align="right"><small>') self.out.write ('Generated by Pybliographer') self.out.write ('</small></p>\n') return def start (self, key, entry): if key is None: key = self.next_key () self.out.write ('<dt>[%s]<dd>' % key) return def separator (self): self.out.write (" ") return Autoload.register ('output', 'HTML', HTML)
return base def iterator(url, check): ''' This methods returns an iterator that will parse the database on the fly (useful for merging or to parse broken databases ''' if check and url.url[2][-5:] != '.ovid': return file = open(Open.url_to_local(url)) return OvidLike.OvidLike(file, Config.get('ovid/mapping').data, Config.get('ovid/deftype').data) def writer(iter, output, **argh): mapping = Config.get('ovid/mapping').data OvidLike.writer(iter, output, mapping) return Autoload.register('format', 'Ovid', { 'open': opener, 'write': writer, 'iter': iterator })
# Site configuration import os from Pyblio import Autoload, Config, version # define autoloaded formats Autoload.preregister ('format', 'BibTeX', 'Pyblio.Format.BibTeX', '.*\.bib') Autoload.preregister ('format', 'Ovid', 'Pyblio.Format.Ovid', '.*\.ovid') Autoload.preregister ('format', 'Medline', 'Pyblio.Format.Medline', '.*\.med') Autoload.preregister ('format', 'Refer', 'Pyblio.Format.Refer', '.*\.refer') Autoload.preregister ('format', 'ISIFile', 'Pyblio.Format.isifile', '.*\.isi') # define styles and outputs Autoload.preregister ('style', 'Generic', 'Pyblio.Style.Generic') Autoload.preregister ('style', 'apa4e', 'Pyblio.Style.apa4e') Autoload.preregister ('style', 'abbrv', 'Pyblio.Style.abbrv') Autoload.preregister ('output', 'Text', 'Pyblio.Output.text') Autoload.preregister ('output', 'Raw', 'Pyblio.Output.raw') Autoload.preregister ('output', 'HTML', 'Pyblio.Output.html') Autoload.preregister ('output', 'LaTeX', 'Pyblio.Output.LaTeX') Autoload.preregister ('output', 'Textnum', 'Pyblio.Output.textnum') Autoload.preregister ('output', 'Textau', 'Pyblio.Output.textau') # define key formats Autoload.preregister ('key', 'Default', 'Pyblio.Utils') # Parse the configuration directory
if table.has_key (key): suff = ord ('a') while table.has_key (key): suff = suff + 1 if suff > ord ('z'): suff = ord ('a') base = base + 'a' key = Key.Key (table, base + chr (suff)) return Key.Key (table, key) Autoload.register ('key', 'Default', generate_key) class StringStream: ''' This class simulates a stream and stores it into a simple string. ''' def __init__ (self): self.text = '' return def write (self, text): self.text = self.text + text return
def first_last_full_authors (entry, coding): return author_desc (entry, coding, 0, -1) def full_authors (entry, coding): return author_desc (entry, coding, 0, 0) def initials_authors (entry, coding): return author_desc (entry, coding, 1, 0) def first_last_initials_authors (entry, coding): return author_desc (entry, coding, 1, -1) def last_first_initials_authors (entry, coding): return author_desc (entry, coding, 1, 1) Autoload.register ('style', 'abbrv', { 'first_last_full_authors' : first_last_full_authors, 'last_first_full_authors' : last_first_full_authors, 'full_authors' : full_authors, 'first_last_initials_authors' : first_last_initials_authors, 'last_first_initials_authors' : last_first_initials_authors, 'initials_authors' : initials_authors, 'string_keys' : create_string_key, 'bibdb_keys' : create_bibdb_key, 'authoryear_keys' : create_authoryear_key, 'unsrtnum_keys' : create_unsrtnum_key, 'european_date' : standard_date, })
# 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]
self.out.write ("\n") pass def start (self, key, entry): if key is None: key = self.next_key () self.data = "" self.key = '[%s] ' % key extra = self.length - len (self.key) if extra > 0: self.key = self.key + ' ' * extra return def write (self, text, style = None): self.data = self.data + text return def separator (self): self.write (" ") return def end (self): self.data = string.strip (self.data) text = Utils.format (self.data, 79, self.length, self.length) self.out.write (self.key + text [self.length:] + '\n\n') return Autoload.register ('output', 'text', TextFormat)
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)
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)
def _get_keytypes(): return Autoload.available('key')
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)
w = w + .5 else: w = w + 1 if w > l: id = k l = w else: id = 'KEY99' self.out.write('\\begin{thebibliography}{%s}\n' % id) return def separator(self): self.out.write('\n\\newblock ') return def end_group(self): self.out.write('\\end{thebibliography}\n') return def start(self, key, entry): if key is None: key = self.next_key() self.out.write('\\bibitem[%s]{%s}\n' % (key, entry.key.key)) return Autoload.register('output', 'LaTeX', LaTeX)
continue if opt == '-F' or opt == '--footer': footer = value continue if opt == '-o' or opt == '--output': try: outfile = open (value, 'w') except IOError, err: error (_("can't open `%s': %s") % (value, str (err).decode (charset))) continue if opt == '-l' or opt == '--list': try: list = Autoload.available (value) except KeyError: error (_("unknown list `%s'") % value) if list: print (_("pyblioformat: available values for `%s':") % value).encode (charset) print " " + string.join (list, ", ") sys.exit (0) else: warning (_("empty value list `%s'") % value) sys.exit (0) if opt == '-h' or opt == '--help': usage () sys.exit (0) continue
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)
else: w = w + 1 if w > l: id = k l = w else: id = 'KEY99' self.out.write ('\\begin{thebibliography}{%s}\n' % id) return def separator (self): self.out.write ('\n\\newblock ') return def end_group (self): self.out.write ('\\end{thebibliography}\n') return def start (self, key, entry): if key is None: key = self.next_key () self.out.write ('\\bibitem[%s]{%s}\n' % (key, entry.key.key)) return Autoload.register ('output', 'LaTeX', LaTeX)
return base def iterator (url, check): ''' This methods returns an iterator that will parse the database on the fly (useful for merging or to parse broken databases ''' if check and url.url [2] [-4:] != '.bib': return None # Ouvrir le fichier associe parser = _bibtex.open_file (Open.url_to_local (url), Config.get ('bibtex/strict').data) # create a database to generate correct keys db = Base.DataBase (url) return BibtexIterator (db, parser) Autoload.register ('format', 'BibTeX', {'open' : opener, 'write' : writer, 'iter' : iterator}) ### Local Variables: ### Mode: python ### py-master-file : "ut_bibtex.py" ### End:
def full_authors(entry, coding): return author_desc(entry, coding, 0, 0) def initials_authors(entry, coding): return author_desc(entry, coding, 1, 0) def first_last_initials_authors(entry, coding): return author_desc(entry, coding, 1, -1) def last_first_initials_authors(entry, coding): return author_desc(entry, coding, 1, 1) # Line below changed Autoload.register( 'style', 'apa4e', { 'first_last_full_authors': first_last_full_authors, 'last_first_full_authors': last_first_full_authors, 'full_authors': full_authors, 'first_last_initials_authors': first_last_initials_authors, 'last_first_initials_authors': last_first_initials_authors, 'initials_authors': initials_authors, 'string_keys': create_string_key, 'numeric_keys': create_numeric_key, 'european_date': standard_date, })
def opener (url, check): base = None if (not check) or (url.url [2] [-4:] == '.med'): base = Medline (url) return base def iterator (url, check): ''' This methods returns an iterator that will parse the database on the fly (useful for merging or to parse broken databases ''' if check and url.url [2] [-4:] != '.med': return return MedlineIterator (open (Open.url_to_local (url), 'r')) Autoload.register ('format', 'Medline', {'open' : opener, 'write' : writer, 'iter' : iterator}) ### Local Variables: ### Mode: python ### py-master-file : "test_medline.py" ### End:
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:]
def _get_keytypes (): return Autoload.available ('key')
def __init__(self, title=_("File"), modal=True, has_auto=True, is_save=False, directory=None, show_type=True, parent=None): gtk.FileChooserDialog.__init__(self, parent=parent) accelerator = gtk.AccelGroup() self.add_accel_group(accelerator) b = self.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK) b.add_accelerator('clicked', accelerator, gtk.keysyms.Return, 0, 0) b = self.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT) b.add_accelerator('clicked', accelerator, gtk.keysyms.Escape, 0, 0) if is_save: self.set_action(gtk.FILE_CHOOSER_ACTION_SAVE) self.set_local_only(False) self.set_title(title) if directory: self.set_current_folder(directory) elif self.defaultdir: self.set_current_folder(self.defaultdir) self.ret = None self.ftype = None if show_type: # type selector hbox = gtk.HBox() hbox.set_spacing(5) hbox.set_border_width(5) hbox.pack_start(gtk.Label(_("Bibliography type:")), expand=False, fill=False) self.menu = gtk.combo_box_new_text() hbox.pack_start(self.menu) self.set_extra_widget(hbox) # menu content liste = Autoload.available('format') liste.sort() self.formats = [] if has_auto: self.menu.append_text(_(' — According to file suffix — ')) self.ftype = None self.formats.append(None) else: self.ftype = liste[0] for avail in liste: self.menu.append_text(avail) self.formats += liste self.menu.set_active(0) self.menu.connect("changed", self.menu_select) hbox.show_all() return
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)
def __init__(self, title=_("File"), modal=True, has_auto=True, is_save=False, directory=None, show_type=True, parent=None): gtk.FileChooserDialog.__init__(self, parent=parent) accelerator = gtk.AccelGroup () self.add_accel_group (accelerator) b = self.add_button (gtk.STOCK_OK, gtk.RESPONSE_OK) b.add_accelerator ('clicked', accelerator, gtk.keysyms.Return, 0, 0) b = self.add_button (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT) b.add_accelerator ('clicked', accelerator, gtk.keysyms.Escape, 0, 0) if is_save: self.set_action(gtk.FILE_CHOOSER_ACTION_SAVE) self.set_local_only (False) self.set_title (title) if directory: self.set_current_folder (directory) elif self.defaultdir: self.set_current_folder (self.defaultdir) self.ret = None self.ftype = None if show_type: # type selector hbox = gtk.HBox () hbox.set_spacing (5) hbox.set_border_width (5) hbox.pack_start (gtk.Label (_("Bibliography type:")), expand = False, fill = False) self.menu = gtk.combo_box_new_text () hbox.pack_start (self.menu) self.set_extra_widget (hbox) # menu content liste = Autoload.available ('format') liste.sort () self.formats = [] if has_auto: self.menu.append_text (_(' — According to file suffix — ')) self.ftype = None self.formats.append(None) else: self.ftype = liste [0] for avail in liste: self.menu.append_text (avail) self.formats += liste self.menu.set_active (0) self.menu.connect ("changed", self.menu_select) hbox.show_all () return
continue if opt == '-F' or opt == '--footer': footer = value continue if opt == '-o' or opt == '--output': try: outfile = open (value, 'w') except IOError, err: error (_(u"can’t open “%s”: %s") % (value, str (err).decode (charset))) continue if opt == '-l' or opt == '--list': try: list = Autoload.available (value) except KeyError: error (_(u"unknown list “%s”") % value) if list: print (_(u"pyblioformat: available values for “%s”:") % value).encode (charset) print " " + string.join (list, ", ") sys.exit (0) else: warning (_(u"empty value list “%s”") % value) sys.exit (0) if opt == '-h' or opt == '--help': usage () sys.exit (0) continue