Blame SOURCES/gedit-disable-python3.patch

d01dba
From 7feb8e11020bd14e85339c64e5e547e02755ce74 Mon Sep 17 00:00:00 2001
d01dba
From: =?UTF-8?q?Mat=C4=9Bj=20Cepl?= <mcepl@redhat.com>
d01dba
Date: Fri, 15 May 2015 11:00:19 -0400
d01dba
Subject: [PATCH] Switch from python3 to python2
d01dba
d01dba
---
d01dba
 configure.ac                                       |  2 +-
d01dba
 gedit/gedit-plugins-engine.c                       |  2 +-
d01dba
 plugins/externaltools/data/send-to-fpaste.tool.in  |  2 +-
d01dba
 .../externaltools/externaltools.plugin.desktop.in  |  2 +-
d01dba
 plugins/externaltools/tools/capture.py             |  8 ++++++-
d01dba
 plugins/externaltools/tools/library.py             | 27 ++++++++++++++++------
d01dba
 .../pythonconsole/pythonconsole.plugin.desktop.in  |  2 +-
d01dba
 plugins/quickopen/quickopen.plugin.desktop.in      |  2 +-
d01dba
 plugins/quickopen/quickopen/__init__.py            |  5 ++--
d01dba
 plugins/snippets/snippets.plugin.desktop.in        |  2 +-
d01dba
 plugins/snippets/snippets/helper.py                |  5 +++-
d01dba
 plugins/snippets/snippets/library.py               |  3 ++-
d01dba
 plugins/snippets/snippets/shareddata.py            |  3 ++-
d01dba
 plugins/snippets/snippets/signals.py               |  2 +-
d01dba
 14 files changed, 46 insertions(+), 21 deletions(-)
d01dba
d01dba
diff --git a/configure.ac b/configure.ac
d01dba
index 4f19eb4..0a00552 100644
d01dba
--- a/configure.ac
d01dba
+++ b/configure.ac
d01dba
@@ -267,7 +267,7 @@ if test "x$enable_python" = "xauto"; then
d01dba
 fi
d01dba
 
d01dba
 if test "x$enable_python" = "xyes"; then
d01dba
-	AM_PATH_PYTHON(3.2.3)
d01dba
+	AM_PATH_PYTHON
d01dba
 	PKG_CHECK_MODULES(PYTHON, [pygobject-3.0 >= $PYGOBJECT_REQUIRED])
d01dba
 
d01dba
 	pyoverridesdir="\$(pyexecdir)/gi/overrides"
d01dba
diff --git a/gedit/gedit-plugins-engine.c b/gedit/gedit-plugins-engine.c
d01dba
index d3e9dbb..9ac98cd 100644
d01dba
--- a/gedit/gedit-plugins-engine.c
d01dba
+++ b/gedit/gedit-plugins-engine.c
d01dba
@@ -51,7 +51,7 @@ gedit_plugins_engine_init (GeditPluginsEngine *engine)
d01dba
 
d01dba
 	gedit_debug (DEBUG_PLUGINS);
d01dba
 
d01dba
-	peas_engine_enable_loader (PEAS_ENGINE (engine), "python3");
d01dba
+	peas_engine_enable_loader (PEAS_ENGINE (engine), "python");
d01dba
 
d01dba
 	engine->plugin_settings = g_settings_new ("org.gnome.gedit.plugins");
d01dba
 
d01dba
diff --git a/plugins/externaltools/data/send-to-fpaste.tool.in b/plugins/externaltools/data/send-to-fpaste.tool.in
d01dba
index fb1fdf7..5eb8d8e 100755
d01dba
--- a/plugins/externaltools/data/send-to-fpaste.tool.in
d01dba
+++ b/plugins/externaltools/data/send-to-fpaste.tool.in
d01dba
@@ -1,4 +1,4 @@
d01dba
-#!/usr/bin/env python3
d01dba
+#!/usr/bin/env python
d01dba
 
d01dba
 import os, urllib, json, sys, urllib.request
d01dba
 from gi.repository import Gtk, Gdk
d01dba
diff --git a/plugins/externaltools/externaltools.plugin.desktop.in b/plugins/externaltools/externaltools.plugin.desktop.in
d01dba
index cc7a4da..c56e4e3 100644
d01dba
--- a/plugins/externaltools/externaltools.plugin.desktop.in
d01dba
+++ b/plugins/externaltools/externaltools.plugin.desktop.in
d01dba
@@ -1,5 +1,5 @@
d01dba
 [Plugin]
d01dba
-Loader=python3
d01dba
+Loader=python
d01dba
 Module=externaltools
d01dba
 IAge=3
d01dba
 _Name=External Tools
d01dba
diff --git a/plugins/externaltools/tools/capture.py b/plugins/externaltools/tools/capture.py
d01dba
index e2e35b4..d5cf9a6 100644
d01dba
--- a/plugins/externaltools/tools/capture.py
d01dba
+++ b/plugins/externaltools/tools/capture.py
d01dba
@@ -61,7 +61,13 @@ class Capture(GObject.Object):
d01dba
         self.flags = flags
d01dba
 
d01dba
     def set_input(self, text):
d01dba
-        self.input_text = text.encode("UTF-8") if text else None
d01dba
+        if text:
d01dba
+            if isinstance(text, bytes):
d01dba
+                self.input_text = text
d01dba
+            else:
d01dba
+                self.input_text = text.encode("UTF-8")
d01dba
+        else:
d01dba
+            self.input_text = None
d01dba
 
d01dba
     def set_cwd(self, cwd):
d01dba
         self.cwd = cwd
d01dba
diff --git a/plugins/externaltools/tools/library.py b/plugins/externaltools/tools/library.py
d01dba
index adfd943..761337c 100644
d01dba
--- a/plugins/externaltools/tools/library.py
d01dba
+++ b/plugins/externaltools/tools/library.py
d01dba
@@ -16,6 +16,7 @@
d01dba
 #    along with this program; if not, write to the Free Software
d01dba
 #    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
d01dba
 
d01dba
+import io
d01dba
 import os
d01dba
 import re
d01dba
 import locale
d01dba
@@ -246,7 +247,7 @@ class Tool(object):
d01dba
         if filename is None:
d01dba
             return
d01dba
 
d01dba
-        fp = open(filename, 'r', 1, encoding='utf-8')
d01dba
+        fp = io.open(filename, 'r', 1, encoding='utf-8')
d01dba
         in_block = False
d01dba
         lang = locale.getlocale(locale.LC_MESSAGES)[0]
d01dba
 
d01dba
@@ -395,7 +396,7 @@ class Tool(object):
d01dba
         if filename is None:
d01dba
             return True
d01dba
 
d01dba
-        fp = open(filename, 'r', 1, encoding='utf-8')
d01dba
+        fp = io.open(filename, 'r', 1, encoding='utf-8')
d01dba
         for line in fp:
d01dba
             if line.strip() == '':
d01dba
                 continue
d01dba
@@ -411,7 +412,7 @@ class Tool(object):
d01dba
         if filename is None:
d01dba
             return ["#!/bin/sh\n"]
d01dba
 
d01dba
-        fp = open(filename, 'r', 1, encoding='utf-8')
d01dba
+        fp = io.open(filename, 'r', 1, encoding='utf-8')
d01dba
         lines = list()
d01dba
 
d01dba
         # before entering the data block
d01dba
@@ -445,7 +446,7 @@ class Tool(object):
d01dba
 
d01dba
     def save_with_script(self, script):
d01dba
         filename = self.library.get_full_path(self.filename, 'w')
d01dba
-        fp = open(filename, 'w', 1, encoding='utf-8')
d01dba
+        fp = io.open(filename, 'w', 1, encoding='utf-8')
d01dba
 
d01dba
         # Make sure to first print header (shebang, modeline), then
d01dba
         # properties, and then actual content
d01dba
@@ -470,12 +471,24 @@ class Tool(object):
d01dba
         # Write out header
d01dba
         for line in header:
d01dba
             fp.write(line + "\n")
d01dba
+            if isinstance(line, bytes):
d01dba
+                line = unicode(line + "\n", 'utf8')
d01dba
+            else:
d01dba
+                line += u"\n"
d01dba
+            fp.write(line)
d01dba
 
d01dba
-        fp.write(self._dump_properties())
d01dba
-        fp.write("\n")
d01dba
+        outstr = self._dump_properties()
d01dba
+        if isinstance(outstr, bytes):
d01dba
+            outstr = unicode(outstr, 'utf8')
d01dba
+        fp.write(outstr)
d01dba
+        fp.write(u"\n")
d01dba
 
d01dba
         for line in content:
d01dba
-            fp.write(line + "\n")
d01dba
+            if isinstance(line, bytes):
d01dba
+                line = unicode(line + "\n", 'utf8')
d01dba
+            else:
d01dba
+                line += u"\n"
d01dba
+            fp.write(line)
d01dba
 
d01dba
         fp.close()
d01dba
         os.chmod(filename, 0o750)
d01dba
diff --git a/plugins/pythonconsole/pythonconsole.plugin.desktop.in b/plugins/pythonconsole/pythonconsole.plugin.desktop.in
d01dba
index 21283e8..4309667 100644
d01dba
--- a/plugins/pythonconsole/pythonconsole.plugin.desktop.in
d01dba
+++ b/plugins/pythonconsole/pythonconsole.plugin.desktop.in
d01dba
@@ -1,5 +1,5 @@
d01dba
 [Plugin]
d01dba
-Loader=python3
d01dba
+Loader=python
d01dba
 Module=pythonconsole
d01dba
 IAge=3
d01dba
 _Name=Python Console
d01dba
diff --git a/plugins/quickopen/quickopen.plugin.desktop.in b/plugins/quickopen/quickopen.plugin.desktop.in
d01dba
index 68b6faa..17edecc 100644
d01dba
--- a/plugins/quickopen/quickopen.plugin.desktop.in
d01dba
+++ b/plugins/quickopen/quickopen.plugin.desktop.in
d01dba
@@ -1,5 +1,5 @@
d01dba
 [Plugin]
d01dba
-Loader=python3
d01dba
+Loader=python
d01dba
 Module=quickopen
d01dba
 IAge=3
d01dba
 _Name=Quick Open
d01dba
diff --git a/plugins/quickopen/quickopen/__init__.py b/plugins/quickopen/quickopen/__init__.py
d01dba
index 7d63126..4f612da 100644
d01dba
--- a/plugins/quickopen/quickopen/__init__.py
d01dba
+++ b/plugins/quickopen/quickopen/__init__.py
d01dba
@@ -15,6 +15,7 @@
d01dba
 #  You should have received a copy of the GNU General Public License
d01dba
 #  along with this program; if not, see <http://www.gnu.org/licenses/>.
d01dba
 
d01dba
+import io
d01dba
 import os
d01dba
 
d01dba
 import gi
d01dba
@@ -126,7 +127,7 @@ class QuickOpenPlugin(GObject.Object, Gedit.WindowActivatable):
d01dba
 
d01dba
         paths = []
d01dba
 
d01dba
-        for line in open(filename, 'r', encoding='utf-8'):
d01dba
+        for line in io.open(filename, 'r', encoding='utf-8'):
d01dba
             uri = line.strip().split(" ")[0]
d01dba
             f = Gio.file_new_for_uri(uri)
d01dba
 
d01dba
@@ -153,7 +154,7 @@ class QuickOpenPlugin(GObject.Object, Gedit.WindowActivatable):
d01dba
         desktopdir = None
d01dba
 
d01dba
         if os.path.isfile(config):
d01dba
-            for line in open(config, 'r', encoding='utf-8'):
d01dba
+            for line in io.open(config, 'r', encoding='utf-8'):
d01dba
                 line = line.strip()
d01dba
 
d01dba
                 if line.startswith('XDG_DESKTOP_DIR'):
d01dba
diff --git a/plugins/snippets/snippets.plugin.desktop.in b/plugins/snippets/snippets.plugin.desktop.in
d01dba
index 8551b6b..f41a626 100644
d01dba
--- a/plugins/snippets/snippets.plugin.desktop.in
d01dba
+++ b/plugins/snippets/snippets.plugin.desktop.in
d01dba
@@ -1,5 +1,5 @@
d01dba
 [Plugin]
d01dba
-Loader=python3
d01dba
+Loader=python
d01dba
 Module=snippets
d01dba
 IAge=3
d01dba
 _Name=Snippets
d01dba
diff --git a/plugins/snippets/snippets/helper.py b/plugins/snippets/snippets/helper.py
d01dba
index 2fa3b3f..ee3f3b7 100644
d01dba
--- a/plugins/snippets/snippets/helper.py
d01dba
+++ b/plugins/snippets/snippets/helper.py
d01dba
@@ -124,8 +124,11 @@ def _write_node(node, file, cdata_nodes=(), indent=0):
d01dba
             if node.text or len(node):
d01dba
                 file.write(">")
d01dba
                 if node.text and node.text.strip() != "":
d01dba
+                    node_txt = node.text
d01dba
+                    if isinstance(node_txt, unicode):
d01dba
+                        node_txt = node_txt.encode('utf8')
d01dba
                     if tag in cdata_nodes:
d01dba
-                        file.write(_cdata(node.text))
d01dba
+                        file.write(_cdata(node_txt))
d01dba
                     else:
d01dba
                         file.write(saxutils.escape(node.text))
d01dba
                 else:
d01dba
diff --git a/plugins/snippets/snippets/library.py b/plugins/snippets/snippets/library.py
d01dba
index 455ac91..1b454f3 100644
d01dba
--- a/plugins/snippets/snippets/library.py
d01dba
+++ b/plugins/snippets/snippets/library.py
d01dba
@@ -15,6 +15,7 @@
d01dba
 #    along with this program; if not, write to the Free Software
d01dba
 #    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
d01dba
 
d01dba
+import io
d01dba
 import os
d01dba
 import weakref
d01dba
 import sys
d01dba
@@ -453,7 +454,7 @@ class SnippetsSystemFile:
d01dba
         self.insnippet = False
d01dba
 
d01dba
         try:
d01dba
-            f = open(self.path, "r", encoding='utf-8')
d01dba
+            f = io.open(self.path, "r", encoding='utf-8')
d01dba
         except IOError:
d01dba
             self.ok = False
d01dba
             return
d01dba
diff --git a/plugins/snippets/snippets/shareddata.py b/plugins/snippets/snippets/shareddata.py
d01dba
index be6fd14..64ffcc4 100644
d01dba
--- a/plugins/snippets/snippets/shareddata.py
d01dba
+++ b/plugins/snippets/snippets/shareddata.py
d01dba
@@ -23,7 +23,8 @@ from gi.repository import Gtk
d01dba
 # To register the GeditSnippetsManager type
d01dba
 from .manager import Manager
d01dba
 
d01dba
-class SharedData(object, metaclass=Singleton):
d01dba
+class SharedData(object):
d01dba
+    __metaclass__ = Singleton
d01dba
     def __init__(self):
d01dba
         self.dlg = None
d01dba
         self.dlg_default_size = None
d01dba
diff --git a/plugins/snippets/snippets/signals.py b/plugins/snippets/snippets/signals.py
d01dba
index 647b616..9aaa95a 100644
d01dba
--- a/plugins/snippets/snippets/signals.py
d01dba
+++ b/plugins/snippets/snippets/signals.py
d01dba
@@ -17,7 +17,7 @@
d01dba
 #  You should have received a copy of the GNU General Public License
d01dba
 #  along with this program; if not, see <http://www.gnu.org/licenses/>.
d01dba
 
d01dba
-class Signals:
d01dba
+class Signals(object):
d01dba
     def __init__(self):
d01dba
         self._signals = {}
d01dba
 
d01dba
-- 
d01dba
1.8.3.1
d01dba