Remove the remaining pre-3.4 compatibility hacks
This commit is contained in:
parent
2452706b90
commit
3c195dd9cc
3 changed files with 15 additions and 49 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue