From bc71828f6103b4ec3a3e46df03e94824108de9f2 Mon Sep 17 00:00:00 2001 From: Sergej Chodarev Date: Mon, 8 Jul 2013 15:16:31 +0200 Subject: [PATCH] Port to Python 3 and Gedit 3.8 --- indentation_settings.plugin | 2 +- indentation_settings/__init__.py | 4 ++-- indentation_settings/dialog.py | 2 +- indentation_settings/settings.py | 9 ++++----- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/indentation_settings.plugin b/indentation_settings.plugin index 1a61ffd..05d7d55 100644 --- a/indentation_settings.plugin +++ b/indentation_settings.plugin @@ -1,5 +1,5 @@ [Plugin] -Loader=python +Loader=python3 Module=indentation_settings IAge=3 Name=Indentation Settings diff --git a/indentation_settings/__init__.py b/indentation_settings/__init__.py index f9b1924..3a71c4b 100644 --- a/indentation_settings/__init__.py +++ b/indentation_settings/__init__.py @@ -23,8 +23,8 @@ from gi.repository import GObject, Gedit, PeasGtk -import settings -from dialog import IndentationSettingsDialog +from . import settings +from .dialog import IndentationSettingsDialog class IndentationSettingsApp(GObject.Object, Gedit.AppActivatable, PeasGtk.Configurable): diff --git a/indentation_settings/dialog.py b/indentation_settings/dialog.py index fa9565d..4b4f2cd 100644 --- a/indentation_settings/dialog.py +++ b/indentation_settings/dialog.py @@ -24,7 +24,7 @@ from contextlib import contextmanager from gi.repository import Gtk, GtkSource -import settings +from . import settings class IndentationSettingsDialog(object): def __init__(self, datadir): diff --git a/indentation_settings/settings.py b/indentation_settings/settings.py index deee916..6b9e2d0 100644 --- a/indentation_settings/settings.py +++ b/indentation_settings/settings.py @@ -25,14 +25,13 @@ """ import os -import glib -from gi.repository import Gio +from gi.repository import Gio, GLib SETTINGS_KEY = "org.gnome.gedit.preferences.editor" TABS = 0 # Initialze module -filename = os.path.join(glib.get_user_config_dir(), +filename = os.path.join(GLib.get_user_config_dir(), "gedit", "indentation-settings") settings = {} gedit_settings = Gio.Settings(SETTINGS_KEY) @@ -58,7 +57,7 @@ def indent_from_string(string): def read(): """Read configuration file.""" try: - f = file(filename, "r") + f = open(filename, "r") except IOError: # No settings settings['makefile'] = TABS return @@ -71,7 +70,7 @@ def read(): pass def write(): - f = file(filename, "w") + f = open(filename, "w") for lang, indent in sorted(settings.items()): indent_s = str(indent) if indent > 0 else "tabs" f.write(lang + ":" + indent_s + "\n")