[eog-plugins] pythonconsole: Convert to Python 3



commit 937aa88022239edc2cdcac22bd4867752e9aed14
Author: Felix Riemann <friemann gnome org>
Date:   Tue Jan 7 22:01:44 2014 +0100

    pythonconsole: Convert to Python 3

 plugins/pythonconsole/__init__.py                  |   16 ++++++++--------
 plugins/pythonconsole/console.py                   |    5 -----
 .../pythonconsole/pythonconsole.plugin.desktop.in  |    2 +-
 3 files changed, 9 insertions(+), 14 deletions(-)
---
diff --git a/plugins/pythonconsole/__init__.py b/plugins/pythonconsole/__init__.py
index c4eb640..16855c4 100644
--- a/plugins/pythonconsole/__init__.py
+++ b/plugins/pythonconsole/__init__.py
@@ -27,13 +27,13 @@
 
 from gi.repository import GObject, Gtk, Eog, PeasGtk
 
-from console import PythonConsole
-from config import PythonConsoleConfigWidget
+from .console import PythonConsole
+from .config import PythonConsoleConfigWidget
 
 import gettext
-_ = gettext.translation('eog-plugins', fallback=True).ugettext
+_ = gettext.translation('eog-plugins', fallback=True).gettext
 
-ui_str = """
+_UI_STR = """
     <ui>
         <menubar name="MainMenu">
             <menu name="ToolsMenu" action="Tools">
@@ -63,7 +63,7 @@ class PythonConsolePlugin(GObject.Object, Eog.WindowActivatable, PeasGtk.Configu
         self.action_group.add_actions([('PythonConsole', None, \
             _('P_ython Console'), None, None, self.console_cb)], self.window)
         ui_manager.insert_action_group(self.action_group, 0)
-        self.ui_id = ui_manager.add_ui_from_string(ui_str)
+        self.ui_id = ui_manager.add_ui_from_string(_UI_STR)
 
     def do_deactivate(self):
         ui_manager = self.window.get_ui_manager()
@@ -82,11 +82,11 @@ class PythonConsolePlugin(GObject.Object, Eog.WindowActivatable, PeasGtk.Configu
                                                  'Eog' : Eog,
                                                  'window' : window})
             console.set_size_request(600, 400)
-            console.eval('print "You can access the main window through ' \
-                         '\'window\' :\\n%s" % window', False)
-
+            console.eval('print("You can access the main window through ' \
+                         '\'window\' :\\n%s" % window)', False)
             self.console_window.set_title(_('Python Console'))
             self.console_window.add(console)
+
             self.console_window.connect('delete-event', self.on_delete_cb)
             self.console_window.show_all()
             self.console_window.set_transient_for(window)
diff --git a/plugins/pythonconsole/console.py b/plugins/pythonconsole/console.py
index 8e13ddc..325b93f 100644
--- a/plugins/pythonconsole/console.py
+++ b/plugins/pythonconsole/console.py
@@ -373,11 +373,6 @@ class PythonConsole(Gtk.ScrolledWindow):
         sys.stdout, self.stdout = self.stdout, sys.stdout
         sys.stderr, self.stderr = self.stderr, sys.stderr
 
-        # eval and exec are broken in how they deal with utf8-encoded
-        # strings so we have to explicitly decode the command before
-        # passing it along
-        command = command.decode('utf8')
-
         try:
             try:
                 r = eval(command, self.namespace, self.namespace)
diff --git a/plugins/pythonconsole/pythonconsole.plugin.desktop.in 
b/plugins/pythonconsole/pythonconsole.plugin.desktop.in
index e4e486c..b9d2816 100644
--- a/plugins/pythonconsole/pythonconsole.plugin.desktop.in
+++ b/plugins/pythonconsole/pythonconsole.plugin.desktop.in
@@ -1,5 +1,5 @@
 [Plugin]
-Loader=python
+Loader=python3
 Module=pythonconsole
 IAge=2
 _Name=Python Console


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