From 3c195dd9ccef1adbb59ad8db7fcc7086fd01b667 Mon Sep 17 00:00:00 2001 From: mathieui Date: Sat, 20 Dec 2014 23:32:56 +0100 Subject: Remove the remaining pre-3.4 compatibility hacks --- src/bookmark.py | 11 ++--------- src/plugin_manager.py | 30 +++++++----------------------- src/theming.py | 23 ++++++----------------- 3 files changed, 15 insertions(+), 49 deletions(-) diff --git a/src/bookmark.py b/src/bookmark.py index 68e97aa6..7c519db2 100644 --- a/src/bookmark.py +++ b/src/bookmark.py @@ -11,7 +11,6 @@ bookmarks, both local and remote. import functools import logging -from sys import version_info from slixmpp.plugins.xep_0048 import Bookmarks, Conference, URL from common import safeJID @@ -19,12 +18,6 @@ from config import config log = logging.getLogger(__name__) -def xml_iter(xml, tag=''): - if version_info[1] >= 2: - return xml.iter(tag) - else: - return xml.getiterator(tag) - preferred = config.get('use_bookmarks_method').lower() if preferred not in ('pep', 'privatexml'): preferred = 'privatexml' @@ -101,10 +94,10 @@ class Bookmark(object): name = el.get('name') autojoin = True if el.get('autojoin', 'false').lower() in ('true', '1') else False nick = None - for n in xml_iter(el, 'nick'): + for n in xml.iter(el, 'nick'): nick = n.text password = None - for p in xml_iter(el, 'password'): + for p in xml.iter(el, 'password'): password = p.text return Bookmark(jid, name, autojoin, nick, password, method) diff --git a/src/plugin_manager.py b/src/plugin_manager.py index d4cc7384..7e3659e4 100644 --- a/src/plugin_manager.py +++ b/src/plugin_manager.py @@ -5,12 +5,10 @@ the API together. Defines also a bunch of variables related to the plugin env. """ -import imp import os from os import path import logging from gettext import gettext as _ -from sys import version_info import core import tabs @@ -44,9 +42,8 @@ class PluginManager(object): self.tab_keys = {} self.roster_elements = {} - if version_info[1] >= 3: # 3.3 & > - from importlib import machinery - self.finder = machinery.PathFinder() + from importlib import machinery + self.finder = machinery.PathFinder() self.initial_set_plugins_dir() self.initial_set_plugins_conf_dir() @@ -70,29 +67,16 @@ class PluginManager(object): try: module = None - if version_info[1] < 3: # < 3.3 - if name in self.modules: - imp.acquire_lock() - module = imp.reload(self.modules[name]) - else: - file, filename, info = imp.find_module(name, - self.load_path) - imp.acquire_lock() - module = imp.load_module(name, file, filename, info) - else: # 3.3 & > - loader = self.finder.find_module(name, self.load_path) - if not loader: - self.core.information('Could not find plugin: %s' % name) - return - module = loader.load_module() - + loader = self.finder.find_module(name, self.load_path) + if not loader: + self.core.information('Could not find plugin: %s' % name) + return + module = loader.load_module() except Exception as e: log.debug("Could not load plugin %s", name, exc_info=True) self.core.information("Could not load plugin %s: %s" % (name, e), 'Error') finally: - if version_info[1] < 3 and imp.lock_held(): - imp.release_lock() if not module: return diff --git a/src/theming.py b/src/theming.py index 3ca1a89f..ecbff5a5 100755 --- a/src/theming.py +++ b/src/theming.py @@ -69,14 +69,11 @@ log = logging.getLogger(__name__) from config import config import curses -import imp import os from os import path -from sys import version_info -if version_info[1] >= 3: - from importlib import machinery - finder = machinery.PathFinder() +from importlib import machinery +finder = machinery.PathFinder() class Theme(object): """ @@ -500,21 +497,13 @@ def reload_theme(): new_theme = None exc = None try: - if version_info[1] < 3: - file, filename, info = imp.find_module(theme_name, load_path) - imp.acquire_lock() - new_theme = imp.load_module(theme_name, file, filename, info) - else: - loader = finder.find_module(theme_name, load_path) - if not loader: - return 'Failed to load the theme %s' % theme_name - new_theme = loader.load_module() + loader = finder.find_module(theme_name, load_path) + if not loader: + return 'Failed to load the theme %s' % theme_name + new_theme = loader.load_module() except Exception as e: log.error('Failed to load the theme %s', theme_name, exc_info=True) exc = e - finally: - if version_info[1] < 3 and imp.lock_held(): - imp.release_lock() if not new_theme: return 'Failed to load theme: %s' % exc -- cgit v1.2.3