[pybliographer] Set explicit unicode strings when using Unicode



commit 1d39a7198a4f27aadb1e3f2a1fa3855f96e05def
Author: Germán Poo-Caamaño <gpoo gnome org>
Date:   Wed Mar 28 09:39:15 2018 -0300

    Set explicit unicode strings when using Unicode

 Pyblio/Autoload.py         |    6 +++---
 Pyblio/Config.py           |    8 ++++----
 Pyblio/Format/BibTeX.py    |   12 ++++++------
 Pyblio/GnomeUI/Document.py |   42 +++++++++++++++++++++---------------------
 Pyblio/GnomeUI/Editor.py   |    6 +++---
 Pyblio/LyX.py              |    8 ++++----
 Pyblio/Open.py             |   16 ++++++++--------
 Pyblio/Style/Parser.py     |    6 +++---
 pybliographer.py           |   13 +++++++------
 scripts/pybliocheck.py     |    8 ++++----
 scripts/pybliocompact.py   |   10 +++++-----
 scripts/pyblioformat.py    |   26 +++++++++++++-------------
 scripts/pybliotex.py       |    8 ++++----
 scripts/pybliotext.py      |   36 ++++++++++++++++++------------------
 14 files changed, 103 insertions(+), 102 deletions(-)
---
diff --git a/Pyblio/Autoload.py b/Pyblio/Autoload.py
index 1080766..ccb17a2 100644
--- a/Pyblio/Autoload.py
+++ b/Pyblio/Autoload.py
@@ -1,8 +1,8 @@
 # -*- coding: utf-8 -*-
 # This file is part of pybliographer
 # 
-# Copyright (C) 1998-2004 Frederic GOBRY
-# Email : gobry pybliographer org
+# Copyirhgt (C) 2018 Germán Poo-Caamaño <gpoo gnome org>
+# Copyright (C) 1998-2004 Frederic GOBRY <gobry pybliographer org>
 #         
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -76,7 +76,7 @@ class Loader:
             import locale
             charset = locale.getlocale () [1] or 'ascii'
             
-            print (_("warning: can’t import %s: %s") %
+            print (_(u"warning: can’t import %s: %s") %
                    (self.module, str (err))).encode (charset)
             return 0
         
diff --git a/Pyblio/Config.py b/Pyblio/Config.py
index 71f31b5..842bb34 100644
--- a/Pyblio/Config.py
+++ b/Pyblio/Config.py
@@ -1,8 +1,8 @@
 # -*- coding: utf-8 -*-
 # This file is part of pybliographer
 #  
-# Copyright (C) 1998-2004 Frederic GOBRY
-# Email : gobry pybliographer org
+# Copyright (C) 2018 Germán Poo-Caamaño <gpoo gnome org>
+# Copyright (C) 1998-2004 Frederic GOBRY <gobry pybliographer org>
 #         
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -50,7 +50,7 @@ class ConfigItem:
         if self.type:
             if not self.type.match (value):
                 raise ValueError(
-                    _("value of “%s” should be of type %s") % (
+                    _(u"value of “%s” should be of type %s") % (
                     self.name, str (self.type)))
             
         # eventually call the hook
@@ -256,7 +256,7 @@ class Element:
         return value in self.get()
 
     def __str__ (self):
-        return _("Element in “%s”") % str (self.get ())
+        return _(u"Element in “%s”") % str (self.get ())
 
     
 class Tuple:
diff --git a/Pyblio/Format/BibTeX.py b/Pyblio/Format/BibTeX.py
index d5611bd..91a8aaf 100644
--- a/Pyblio/Format/BibTeX.py
+++ b/Pyblio/Format/BibTeX.py
@@ -1,8 +1,8 @@
 # -*- coding: utf-8 -*-
 # This file is part of pybliographer
 # 
-# Copyright (C) 1998-2004 Frederic GOBRY
-# Email : gobry pybliographer org
+# Copyright (C) 2018 Germán Poo-Caamaño <gpoo gnome org>
+# Copyright (C) 1998-2004 Frederic GOBRY <gobry pybliographer org>
 #         
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -321,7 +321,7 @@ class DataBase(Base.DataBase):
            valid = re.compile('^\w+$')
            for k in user.keys():
                if not valid.match(k):
-                   raise TypeError, _("key “%s” is malformed") % k
+                   raise TypeError, _(u"key “%s” is malformed") % k
                _bibtex.set_string(self.parser, k,
                                    _bibtex.reverse(_base_fieldtype[Text],
                                                    Config.get('bibtex+/braces').data,
@@ -338,7 +338,7 @@ class DataBase(Base.DataBase):
                     self.add(entry)
                 else:
                     if self.dict.has_key(entry.key):
-                        errors.append(_("%s:%d: key “%s” already defined") % (
+                        errors.append(_(u"%s:%d: key “%s” already defined") % (
                             str(self.key), entry.line, entry.key.key))
                     else:
                         self.dict [entry.key] = entry
@@ -357,7 +357,7 @@ class DataBase(Base.DataBase):
                 self.add(entry)
             else:
                 if self.dict.has_key(entry.key):
-                    errors.append(_("%s:%d: key “%s” already defined") % (
+                    errors.append(_(u"%s:%d: key “%s” already defined") % (
                         repr(self.key), entry.line, repr(entry.key.key)))
                 else:
                     self.dict[entry.key] = entry
@@ -369,7 +369,7 @@ class DataBase(Base.DataBase):
            valid = re.compile('^\w+$')
            for k in user.keys():
                if not valid.match(k):
-                   raise TypeError, _("key “%s” is malformed") % k
+                   raise TypeError, _(u"key “%s” is malformed") % k
                _bibtex.set_string(self.parser, k,
                                    _bibtex.reverse(_base_fieldtype[Text],
                                                    Config.get('bibtex+/braces').data,
diff --git a/Pyblio/GnomeUI/Document.py b/Pyblio/GnomeUI/Document.py
index da35bb6..4d89bfa 100644
--- a/Pyblio/GnomeUI/Document.py
+++ b/Pyblio/GnomeUI/Document.py
@@ -146,14 +146,14 @@ class Document (Connector.Publisher):
             
             ('New',  gtk.STOCK_NEW,   None,         None,   None,     self.new_document),
             ('Open', gtk.STOCK_OPEN,  None,         None,   _('Open a file'), self.ui_open_document),
-            ('Open_URL', None, _('Open _Location…'), '<control>l',   None, self.ui_open_location),
+            ('Open_URL', None, _(u'Open _Location…'), '<control>l',   None, self.ui_open_location),
             ('Save', gtk.STOCK_SAVE,  None,         None,   _('Save the current file'), self.save_document),
             ('Save_As', gtk.STOCK_SAVE_AS,  None,         None,   None,     self.save_document_as),
             ('Close', gtk.STOCK_CLOSE,  None,         None,   None,     self.close_document),
             ('Quit', gtk.STOCK_QUIT,  None,         None,   None,     self.exit_application),
 
-            ('Merge',   None, _('Merge With…'),    '<control>g',  None, self.merge_database),
-            ('Medline', None, _('Medline Query…'), '<control>m',  None, self.query_database),
+            ('Merge',   None, _(u'Merge With…'),    '<control>g',  None, self.merge_database),
+            ('Medline', None, _(u'Medline Query…'), '<control>m',  None, self.query_database),
 
 
 
@@ -166,11 +166,11 @@ class Document (Connector.Publisher):
             ('Delete', gtk.STOCK_DELETE,  None,         None,   None,     self.delete_entry),
             ('Find', gtk.STOCK_FIND,  None,         None,   None,     self.find_entries),
             
-            ('Sort', None, _('S_ort…'), None,  None, self.sort_entries),
-            ('Cite', gtk.STOCK_JUMP_TO,   _('Cite…'), None,  _('Cite key(s)'), self.lyx_cite),
-            ('Format', gtk.STOCK_EXECUTE, _('Format…'), None,  None, self.format_entries),
+            ('Sort', None, _(u'S_ort…'), None,  None, self.sort_entries),
+            ('Cite', gtk.STOCK_JUMP_TO,   _(u'Cite…'), None,  _('Cite key(s)'), self.lyx_cite),
+            ('Format', gtk.STOCK_EXECUTE, _(u'Format…'), None,  None, self.format_entries),
 
-            ('Fields', None, _('Fields…'), None,  None, self.set_fields),
+            ('Fields', None, _(u'Fields…'), None,  None, self.set_fields),
             ('Preferences', gtk.STOCK_PREFERENCES,  None,         None,   None,     self.set_preferences),
             ('Forget', None, _('Forget all changes'),     None,   None,     self.forget_changes_cb),
             
@@ -388,7 +388,7 @@ class Document (Connector.Publisher):
         try:
             file = open (output, 'w')
         except IOError, err:
-            Utils.error_dialog_s(_("can’t open file “%s” for writing:\n%s")
+            Utils.error_dialog_s(_(u"can’t open file “%s” for writing:\n%s")
                                  % (output, str(err)))
             return
         
@@ -409,7 +409,7 @@ class Document (Connector.Publisher):
             Pyblio.Style.Utils.generate (url, format, self.data, entries, file)
         except RuntimeError, err:
             print err
-            Utils.error_dialog_s(_("Error while parsing “%s”:\n%s") % (style, err))
+            Utils.error_dialog_s(_(u"Error while parsing “%s”:\n%s") % (style, err))
         return
 
 
@@ -649,7 +649,7 @@ class Document (Connector.Publisher):
                         os.remove (old_auto_save)
                     except (OSError, IOError), error:
                         Utils.set_cursor (self.w, 'normal')
-                        Utils.error_dialog_s(_("Unable to remove autosave file “%s”:\n%s") % (str 
(old_auto_save), str (error)))
+                        Utils.error_dialog_s(_(u"Unable to remove autosave file “%s”:\n%s") % (str 
(old_auto_save), str (error)))
                         return
 
 
@@ -728,7 +728,7 @@ class Document (Connector.Publisher):
                 self.data.update (Sort.Sort([Sort.KeySort()]))
             except (OSError, IOError), error:
                 Utils.set_cursor (self.w, 'normal')
-                Utils.error_dialog_s(_("Unable to save “%s”:\n%s") % (str (self.data.key),
+                Utils.error_dialog_s(_(u"Unable to save “%s”:\n%s") % (str (self.data.key),
                                                                str (error)))
                 return
         except:
@@ -736,7 +736,7 @@ class Document (Connector.Publisher):
             traceback.print_exception (etype, value, tb)
             
             Utils.set_cursor (self.w, 'normal')
-            Utils.error_dialog_s(_("An internal error occurred during saving\nTry to Save As…"))
+            Utils.error_dialog_s(_(u"An internal error occurred during saving\nTry to Save As…"))
             return
 
         Utils.set_cursor (self.w, 'normal')
@@ -751,13 +751,13 @@ class Document (Connector.Publisher):
     def save_document_as (self, * arg):
         # get a new file name
         (url, how) = FileSelector.URLFileSelection (
-           _("Save As…"), has_auto = False, is_save = True).run ()
+           _(u"Save As…"), has_auto = False, is_save = True).run ()
         
         if url is None: return
 
         if os.path.exists (url):
             if not Utils.Callback (
-               _("The file “%s” already exists.\nOverwrite it?")
+               _(u"The file “%s” already exists.\nOverwrite it?")
                % url, parent = self.w).answer ():
                 return
 
@@ -790,7 +790,7 @@ class Document (Connector.Publisher):
                         os.remove (old_auto_save)
                     except (OSError, IOError), error:
                         Utils.set_cursor (self.w, 'normal')
-                        Utils.error_dialog_s(_("Unable to remove autosave file “%s”:\n%s") % (str 
(old_auto_save), str (error)))
+                        Utils.error_dialog_s(_(u"Unable to remove autosave file “%s”:\n%s") % (str 
(old_auto_save), str (error)))
                         return
 
         
@@ -850,7 +850,7 @@ class Document (Connector.Publisher):
                         os.remove (old_auto_save)
                     except (OSError, IOError), error:
                         Utils.set_cursor (self.w, 'normal')
-                        Utils.error_dialog_s(_("Unable to remove autosave file “%s”:\n%s") % (str 
(old_auto_save), str (error)))
+                        Utils.error_dialog_s(_(u"Unable to remove autosave file “%s”:\n%s") % (str 
(old_auto_save), str (error)))
                         return
 
         return answer
@@ -875,7 +875,7 @@ class Document (Connector.Publisher):
         for entry in entries:
             
             if self.data.would_have_key (entry.key):
-                if not Utils.Callback (_("An entry called “%s” already exists.\nRename and add it anyway?")
+                if not Utils.Callback (_(u"An entry called “%s” already exists.\nRename and add it anyway?")
                                        % entry.key.key, parent = self.w).answer ():
                     continue
                 
@@ -995,7 +995,7 @@ class Document (Connector.Publisher):
         if l > 1:
             question = _("Remove all the %d entries?") % len (entries)
         else:
-            question = _("Remove entry “%s”?") % entries [0].key.key
+            question = _(u"Remove entry “%s”?") % entries [0].key.key
             
         if not Utils.Callback (question,
                                parent = self.w).answer ():
@@ -1093,7 +1093,7 @@ class Document (Connector.Publisher):
             try:
                 self.lyx = LyX.LyXClient ()
             except IOError, msg:
-                Utils.error_dialog_s(_("Can’t connect to LyX:\n%s") % msg)
+                Utils.error_dialog_s(_(u"Can’t connect to LyX:\n%s") % msg)
                 return
 
         keys = string.join (map (lambda x: x.key.key, entries), ', ')
@@ -1101,7 +1101,7 @@ class Document (Connector.Publisher):
             self.lyx ('citation-insert', keys)
         except IOError, msg:
             msg = msg [1].decode (enc)
-            Utils.error_dialog_s(_("Can’t connect to LyX:\n%s") % msg)
+            Utils.error_dialog_s(_(u"Can’t connect to LyX:\n%s") % msg)
         return
     
 
@@ -1217,7 +1217,7 @@ class Document (Connector.Publisher):
             gtk.show_uri (None, "help:pybliographer", timestamp)
             
         except gobject.GError, msg:
-            Utils.error_dialog_s(_("Can’t display documentation:\n%s") % msg)
+            Utils.error_dialog_s(_(u"Can’t display documentation:\n%s") % msg)
             
         return
     
diff --git a/Pyblio/GnomeUI/Editor.py b/Pyblio/GnomeUI/Editor.py
index b656160..5bafefa 100644
--- a/Pyblio/GnomeUI/Editor.py
+++ b/Pyblio/GnomeUI/Editor.py
@@ -499,7 +499,7 @@ class URL (BaseField):
        self.old_url = self.string.decode ('latin-1')
        self.edit.set_text (self.old_url)
        self.box.pack_start (self.edit)
-       self.button = gtk.Button (_('Browse…'))
+       self.button = gtk.Button (_(u'Browse…'))
        self.button.connect ("clicked", self.cb_clicked)
        self.box.pack_start (self.button, False)
        h.pack_start (self.box)
@@ -911,7 +911,7 @@ class RealEditor (Connector.Publisher):
                 if database.has_key (key):
                      Utils.error_dialog_s(
                          self.w.get_toplevel(),
-                         _("Key “%s” already exists") % str (key.key))
+                         _(u"Key “%s” already exists") % str (key.key))
                      return None
                 
                 self.entry.key = key
@@ -928,7 +928,7 @@ class RealEditor (Connector.Publisher):
                 
                 Utils.error_dialog_s(
                     self.w.get_toplevel(),
-                    _("The “%s” field contains a non Latin-1 symbol") %
+                    _(u"The “%s” field contains a non Latin-1 symbol") %
                     f.name)
                 return None
             
diff --git a/Pyblio/LyX.py b/Pyblio/LyX.py
index 8b1f6be..2c3203e 100644
--- a/Pyblio/LyX.py
+++ b/Pyblio/LyX.py
@@ -1,8 +1,8 @@
 # -*- coding: utf-8 -*-
 # This file is part of pybliographer
 # 
-# Copyright (C) 1998-2004 Frederic GOBRY
-# Email : gobry pybliographer org
+# Copyright (C) Germán Poo-Caamaño <gpoo gnome org>
+# Copyright (C) 1998-2004 Frederic GOBRY <gobry pybliographer org>
 #         
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -35,13 +35,13 @@ class LyXClient:
         try:
             ans = os.stat (pin)
         except OSError, msg:
-            raise IOError (_("no input pipe “%s”") % pin)
+            raise IOError (_(u"no input pipe “%s”") % pin)
         
         pout = os.path.expanduser (base + '.out')
         try:
             ans = os.stat (pout)
         except os.error:
-            raise IOError (_("no output pipe “%s”") % pout)
+            raise IOError (_(u"no output pipe “%s”") % pout)
 
         def noaction (* arg): return
         
diff --git a/Pyblio/Open.py b/Pyblio/Open.py
index 9507a6b..364c9d5 100644
--- a/Pyblio/Open.py
+++ b/Pyblio/Open.py
@@ -1,8 +1,8 @@
 # -*- coding: utf-8 -*-
 # This file is part of pybliographer
 # 
-# Copyright (C) 1998-2004 Frederic GOBRY
-# Email : gobry pybliographer org
+# Copyright (C) 2018 Germán Poo-Caamaño <gpoo gnome org>
+# Copyright (C) 1998-2004 Frederic GOBRY <gobry pybliographer org>
 #         
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -94,7 +94,7 @@ def bibopen (entity, how = None):
        if opener:
            base = opener (url, 0)
        else:
-           raise Exceptions.FormatError (_("method “%s” provides no opener") % how)
+           raise Exceptions.FormatError (_(u"method “%s” provides no opener") % how)
 
        return base
 
@@ -102,7 +102,7 @@ def bibopen (entity, how = None):
     url = Fields.URL (entity)
 
     if url.url [0] == 'file' and not os.path.exists (url.url [2]):
-       raise Exceptions.FileError (_("File “%s” does not exist") % url.get_url ())
+       raise Exceptions.FileError (_(u"File “%s” does not exist") % url.get_url ())
 
     # eventually load a new module
     if how is None:
@@ -113,7 +113,7 @@ def bibopen (entity, how = None):
     base = simple_try (url, how)
 
     if base is None:
-       raise Exceptions.FormatError (_("don’t know how to open “%s”") % entity)
+       raise Exceptions.FormatError (_(u"don’t know how to open “%s”") % entity)
 
     return base
 
@@ -141,7 +141,7 @@ def bibiter (entity, how = None):
        if opener:
            base = opener (url, 0)
        else:
-           raise Exceptions.FormatError (_("method “%s” provides no iterator") % how)
+           raise Exceptions.FormatError (_(u"method “%s” provides no iterator") % how)
 
        return base
 
@@ -149,7 +149,7 @@ def bibiter (entity, how = None):
     url = Fields.URL (entity)
 
     if url.url [0] == 'file' and not os.path.exists (url.url [2]):
-       raise Exceptions.FileError (_("File “%s” does not exist") % str (url))
+       raise Exceptions.FileError (_(u"File “%s” does not exist") % str (url))
 
     # eventually load a new module
     if how is None:
@@ -160,7 +160,7 @@ def bibiter (entity, how = None):
     base = simple_try (url, how)
 
     if base is None:
-       raise Exceptions.FormatError (_("don’t know how to open “%s”") % entity)
+       raise Exceptions.FormatError (_(u"don’t know how to open “%s”") % entity)
 
     return base
 
diff --git a/Pyblio/Style/Parser.py b/Pyblio/Style/Parser.py
index 00d1bb9..90e4f30 100644
--- a/Pyblio/Style/Parser.py
+++ b/Pyblio/Style/Parser.py
@@ -1,8 +1,8 @@
 # -*- coding: utf-8 -*-
 # This file is part of pybliographer
 # 
-# Copyright (C) 1998-2004 Frederic GOBRY
-# Email : gobry pybliographer org
+# Copyright (C) 2018 Germán Poo-Caamaño <gpoo gnome org>
+# Copyright (C) 1998-2004 Frederic GOBRY <gobry pybliographer org>
 #         
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -259,7 +259,7 @@ class XMLBib (sax.handler.ContentHandler):
         try:
             val = attrs [attr]
         except KeyError:
-            self._error (_("missing “%s” attribute") % attr)
+            self._error (_(u"missing “%s” attribute") % attr)
 
         return val
 
diff --git a/pybliographer.py b/pybliographer.py
index 331a8f4..4b6f70d 100644
--- a/pybliographer.py
+++ b/pybliographer.py
@@ -2,8 +2,8 @@
 # -*- coding: utf-8 -*-
 # This file is part of pybliographer
 # 
-# Copyright (C) 1998-2004 Frederic GOBRY
-# Email : gobry pybliographer org
+# Copyright (C) 2018 Germán Poo-Caamaño <gpoo gnome org>
+# Copyright (C) 1998-2004 Frederic GOBRY <gobry pybliographer org>
 #         
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -46,10 +46,11 @@ def print_version ():
 def copyright ():
        print 'Copyright (C) 1998-2004 Frederic GOBRY'
        print _("This is free software with ABSOLUTELY NO WARRANTY.").encode (charset)
-       print _("For details, type “warranty”.").encode (charset)
+       print _(u"For details, type “warranty”.").encode (charset)
 
 def warranty ():
        print_version ()
+       print u'Copyright (C) 2018 Germán Poo-Caamaño'
        print 'Copyright (C) 1998-2004 Frederic GOBRY'
        
        print _("This is free software with ABSOLUTELY NO WARRANTY.").encode (charset)
@@ -109,7 +110,7 @@ for opt, value in optlist:
                try:
                        os.stat (value)
                except os.error:
-                       print (_("%s: error: can’t open file “%s”") \
+                       print (_(u"%s: error: can’t open file “%s”") \
                              % (progname, value)).encode (charset)
                        sys.exit (1)
                
@@ -122,7 +123,7 @@ for opt, value in optlist:
 
        if opt == '-h' or opt == '--help':
                print_version ()
-               print (_("For help, run %s and type “help” at the prompt") 
+               print (_(u"For help, run %s and type “help” at the prompt")
                       % progname).encode (charset)
                sys.exit (0)
                
@@ -161,7 +162,7 @@ if len (args) > 0 :
        try:
                os.stat (filename)
        except os.error:
-               print (_("%s: error: can’t open file “%s”") % (progname, filename)).encode (charset)
+               print (_(u"%s: error: can’t open file “%s”") % (progname, filename)).encode (charset)
                sys.exit (1)
        else:
                execfile (filename, user_global)
diff --git a/scripts/pybliocheck.py b/scripts/pybliocheck.py
index d4b3634..eb10d90 100644
--- a/scripts/pybliocheck.py
+++ b/scripts/pybliocheck.py
@@ -2,8 +2,8 @@
 # -*- coding: utf-8 -*-
 # This file is part of pybliographer
 # 
-# Copyright (C) 1998-2004 Frederic GOBRY
-# Email : gobry pybliographer org
+# Copyright (C) 2018 Germán Poo-Caamaño <gpoo gnome org>
+# Copyright (C) 1998-2004 Frederic GOBRY <gobry pybliographer org>
 #         
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -29,7 +29,7 @@ charset = locale.getlocale () [1] or 'ascii'
 
 # check the arguments
 if len (sys.argv) < 3:
-    print _("usage: pybliocheck <file | directory>…").encode (charset)
+    print _(u"usage: pybliocheck <file | directory>…").encode (charset)
     sys.exit (1)
 
 # list containing the broken entries
@@ -58,7 +58,7 @@ for dir in sys.argv [2:]:
         # try to open the database
         try:
             b = bibopen (f)
-            print (_("file “%s” is ok [%d entries]") % (f, len (b))).encode (charset)
+            print (_(u"file “%s” is ok [%d entries]") % (f, len (b))).encode (charset)
         except (Exceptions.ParserError, KeyError), err:
             broken.append (str (err))
 
diff --git a/scripts/pybliocompact.py b/scripts/pybliocompact.py
index 5011404..18d524a 100644
--- a/scripts/pybliocompact.py
+++ b/scripts/pybliocompact.py
@@ -2,8 +2,8 @@
 # -*- coding: utf-8 -*-
 # This file is part of pybliographer
 # 
-# Copyright (C) 1998-2004 Frederic GOBRY
-# Email : gobry pybliographer org
+# Copyright (C) 2018 Germán Poo-Caamaño <gpoo gnome org>
+# Copyright (C) 1998-2004 Frederic GOBRY <gobry pybliographer org>
 #         
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -28,7 +28,7 @@ import locale
 charset = locale.getlocale () [1] or 'ascii'
 
 def usage ():
-    print _("usage: pybliocompact <latexfile> <bibtexfiles…>").encode (charset)
+    print _(u"usage: pybliocompact <latexfile> <bibtexfiles…>").encode (charset)
     return
 
 def error (msg):
@@ -58,7 +58,7 @@ def list_entries (file):
     try:
         aux = open (auxfile, 'r')
     except IOError, err:
-        error ("`%s': %s" % (auxfile, str (err).decode (charset)))
+        error (u"“%s”: %s" % (auxfile, str (err).decode (charset)))
 
     citations = []
 
@@ -160,6 +160,6 @@ for bib in bibtex:
 
 # check if we were able to solve all the citations
 if len (entries) > 0:
-    error (_("can’t find the following entries: %s")
+    error (_(u"can’t find the following entries: %s")
            % string.join (entries, ", "))
 
diff --git a/scripts/pyblioformat.py b/scripts/pyblioformat.py
index 0680f3f..e90a069 100644
--- a/scripts/pyblioformat.py
+++ b/scripts/pyblioformat.py
@@ -2,8 +2,8 @@
 # -*- coding: utf-8 -*-
 # This file is part of pybliographer
 # 
-# Copyright (C) 1998-2004 Frederic GOBRY
-# Email : gobry pybliographer org
+# Copyright (C) 2018 Germán Poo-Caamaño <gpoo gnome org>
+# Copyright (C) 1998-2004 Frederic GOBRY <gobry pybliographer org>
 #         
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -32,7 +32,7 @@ import locale
 charset = locale.getlocale () [1] or 'ascii'
 
 def usage ():
-    print _("""usage: pyblioformat [options] <database…>
+    print _(u"""usage: pyblioformat [options] <database…>
 
     options:
       -o file, --output=file           specify an output filename
@@ -91,21 +91,21 @@ for opt, value in optlist:
         try:
             outfile = open (value, 'w')
         except IOError, err:
-            error (_("can’t open “%s”: %s") % (value, str (err).decode (charset)))
+            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 (_("unknown list “%s”") % value)
+            error (_(u"unknown list “%s”") % value)
             
         if list:
-            print (_("pyblioformat: available values for “%s”:") % value).encode (charset)
+            print (_(u"pyblioformat: available values for “%s”:") % value).encode (charset)
             print "  " + string.join (list, ", ")
             sys.exit (0)
         else:
-            warning (_("empty value list “%s”") % value)
+            warning (_(u"empty value list “%s”") % value)
             sys.exit (0)
             
     if opt == '-h' or opt == '--help':
@@ -134,7 +134,7 @@ 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)
+    error (_(u"unknown output format “%s”") % format)
 
 url = None
 style = os.path.splitext (style) [0]
@@ -147,10 +147,10 @@ else:
     if os.path.exists (full): url = Fields.URL (full)
 
 if not url:
-    error (_("can’t find style “%s”") % style)
+    error (_(u"can’t find style “%s”") % style)
 
 
-sys.stderr.write ((_("pyblioformat: using style “%s”, format “%s”\n") % (style, output.name)).encode 
(charset))
+sys.stderr.write ((_(u"pyblioformat: using style “%s”, format “%s”\n") % (style, output.name)).encode 
(charset))
 
 formatter = output.data
 
@@ -165,7 +165,7 @@ if header:
                 outfile.write (line)
         h.close ()
     except IOError, err:
-        error (_("can’t open header “%s”: %s") % (header, str (err).decode (charset)))
+        error (_(u"can’t open header “%s”: %s") % (header, str (err).decode (charset)))
 
 # write the data
 for file in files:
@@ -173,7 +173,7 @@ for file in files:
     try:
         db = bibopen (file)
     except IOError, err:
-        error (_("can’t open database: %s") % file)
+        error (_(u"can’t open database: %s") % file)
 
     Utils.generate (url, formatter, db, db.keys (), outfile)
     
@@ -188,7 +188,7 @@ if footer:
                 outfile.write (line)
         h.close ()
     except IOError, err:
-        error (_("can’t open footer “%s”: %s") % (footer, str (err).decode (charset)))
+        error (_(u"can’t open footer “%s”: %s") % (footer, str (err).decode (charset)))
 
         
 outfile.close ()
diff --git a/scripts/pybliotex.py b/scripts/pybliotex.py
index 983e460..7e72620 100644
--- a/scripts/pybliotex.py
+++ b/scripts/pybliotex.py
@@ -2,8 +2,8 @@
 # -*- coding: utf-8 -*-
 # This file is part of pybliographer
 # 
-# Copyright (C) 1998-2004 Frederic GOBRY
-# Email : gobry pybliographer org
+# Copyright (C) 2018 Germán Poo-Caamaño <gpoo gnome org>
+# Copyright (C) 1998-2004 Frederic GOBRY <gobry pybliographer org>
 #         
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -32,7 +32,7 @@ import locale
 charset = locale.getlocale () [1] or 'ascii'
 
 def usage ():
-    print _("usage: pybliotex <latexfile> [bibtexfiles…]").encode (charset)
+    print _(u"usage: pybliotex <latexfile> [bibtexfiles…]").encode (charset)
     return
 
 def error (message):
@@ -84,7 +84,7 @@ else:
     if os.path.exists (full): url = Fields.URL (full)
 
 if not url:
-    error (_("can’t find style “%s”") % style)
+    error (_(u"can’t find style “%s”") % style)
 
 # open the .bbl file
 bblfile = os.path.splitext (os.path.split (latex) [1]) [0] + '.bbl'
diff --git a/scripts/pybliotext.py b/scripts/pybliotext.py
index f12046c..d1b870c 100644
--- a/scripts/pybliotext.py
+++ b/scripts/pybliotext.py
@@ -1,9 +1,9 @@
-# -*- coding: UTF-8 -*-
 # -*- python -*-
+# -*- coding: utf-8 -*-
 # This file is part of pybliographer
 # 
-# Copyright (C) 1998-2004 Frederic GOBRY
-# Email : gobry pybliographer org
+# Copyright (C) 2018 Germán Poo-Caamaño <gpoo gnome org>
+# Copyright (C) 1998-2004 Frederic GOBRY <gobry pybliographer org>
 #         
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -38,7 +38,7 @@ import locale
 charset = locale.getlocale () [1] or 'ascii'
 
 def usage ():
-    print _("usage: pybliotext [-o outputfile] [-s style] <textfile> <bibfiles…>").encode (charset)
+    print _(u"usage: pybliotext [-o outputfile] [-s style] <textfile> <bibfiles…>").encode (charset)
     return
 
 def error (msg):
@@ -91,7 +91,7 @@ else:
     if os.path.exists (full): url = Fields.URL (full)
 
 if not url:
-    error (_("can’t find style “%s”") % style)
+    error (_(u"can’t find style “%s”") % style)
 
 
 spstyle = os.path.split (style) [1]
@@ -114,17 +114,17 @@ else:
 output = Autoload.get_by_name ('output', format)
 
 if output is None:
-    error (_("unknown output format “%s”") % format)
+    error (_(u"unknown output format “%s”") % format)
 
 
 
 reffile = outfile + '.ref'
 
 if os.path.exists(outfile):
-    error (_("File already exists: “%s”") % outfile)
+    error (_(u"File already exists: “%s”") % outfile)
 
 if os.path.exists(reffile):
-    error (_("A file with the same name already exists: “%s”") % reffile)
+    error (_(u"A file with the same name already exists: “%s”") % reffile)
 
 textfile = args [0]
 bibfile = args [1:]
@@ -140,7 +140,7 @@ def list_entries (file):
     try:
         txt = open (textfile, 'r')
     except IOError, err:
-        error ("`%s': %s" % (textfile, str (err).decode (charset)))
+        error (u"“%s”: %s" % (textfile, str (err).decode (charset)))
     
     citations = []
 
@@ -190,7 +190,7 @@ entries = h
 order = copy.copy (entries)
 
 
-sys.stderr.write ((_("pybliotext: using style “%s”, format “%s”\n") % (style, output.name)).encode (charset))
+sys.stderr.write ((_(u"pybliotext: using style “%s”, format “%s”\n") % (style, output.name)).encode 
(charset))
 
 formatter = output.data
 
@@ -237,7 +237,7 @@ for bib in bibfile:
 
 # check if we were able to solve all the citations
 if len (entries) > 0:
-    error (_("can’t find the following entries: %s")
+    error (_(u"can’t find the following entries: %s")
            % string.join (entries, ", "))
 
 
@@ -249,7 +249,7 @@ keys = map (lambda x: Key.Key (r, x), order)
 try:
     refs = open (reffile, 'w')
 except IOError, err:
-    error (_("can’t open “%s”: %s") % (reffile, str (err).decode (charset)))
+    error (_(u"can’t open “%s”: %s") % (reffile, str (err).decode (charset)))
 
 refs.write ("\n\nReferences:\n")
 
@@ -270,12 +270,12 @@ if oldnew:
     try:
         txt = open (textfile, 'r')
     except IOError, err:
-        error ("`%s': %s" % (textfile, str (err).decode (charset)))
+        error (u"“%s”': %s" % (textfile, str (err).decode (charset)))
 
     try:
         dest = open (outfile, 'a')
     except IOError, err:
-        error (_("can’t open “%s”: %s") % (outfile, str (err).decode (charset)))
+        error (_(u"can’t open “%s”: %s") % (outfile, str (err).decode (charset)))
 
     citations = []
     
@@ -313,19 +313,19 @@ else:
     try:
         copyfile (textfile, outfile)
     except:
-        error (_("can’t create “%s”") % outfile)
+        error (_(u"can’t create “%s”") % outfile)
 
     try:
         dest = open (outfile, 'a')
     except IOError, err:
-        error (_("can’t open “%s”: %s") % (outfile, str (err).decode (charset)))
+        error (_(u"can’t open “%s”: %s") % (outfile, str (err).decode (charset)))
 
 
 # appending the reference list
 try:
     refs = open (reffile, 'r')
 except IOError, err:
-    error ("`%s': %s" % (reffile, str (err).decode (charset)))
+    error (u"“%s”: %s" % (reffile, str (err).decode (charset)))
 
 while 1:
     line = refs.readline ()
@@ -339,6 +339,6 @@ dest.close ()
 try:
     os.remove (reffile)
 except:
-    warning (_("can’t remove “%s”") % reffile)
+    warning (_(u"can’t remove “%s”") % reffile)
 
 print _("Done").encode (charset)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]