Blame SOURCES/gedit-disable-python3.patch

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