summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--poezio/core/core.py4
-rw-r--r--poezio/poezio.py4
-rw-r--r--poezio/singleton.py8
-rw-r--r--poezio/tabs/basetabs.py8
-rw-r--r--poezio/windows/base_wins.py3
5 files changed, 12 insertions, 15 deletions
diff --git a/poezio/core/core.py b/poezio/core/core.py
index fec2c7e5..b0bb33b2 100644
--- a/poezio/core/core.py
+++ b/poezio/core/core.py
@@ -23,7 +23,6 @@ from .. import connection
from .. import decorators
from .. import events
from .. import multiuserchat as muc
-from .. import singleton
from .. import tabs
from .. import theming
from .. import timed_events
@@ -38,6 +37,7 @@ from .. fifo import Fifo
from .. logger import logger
from .. plugin_manager import PluginManager
from .. roster import roster
+from .. singleton import Singleton
from .. size_manager import SizeManager
from .. text_buffer import TextBuffer
from .. theming import get_theme
@@ -69,7 +69,7 @@ class Core(object):
self.status = Status(show=status,
message=config.get('status_message'))
self.running = True
- self.xmpp = singleton.Singleton(connection.Connection)
+ self.xmpp = Singleton(connection.Connection)
self.xmpp.core = self
self.keyboard = keyboard.Keyboard()
roster.set_node(self.xmpp.client_roster)
diff --git a/poezio/poezio.py b/poezio/poezio.py
index 15da5334..c0ec64e0 100644
--- a/poezio/poezio.py
+++ b/poezio/poezio.py
@@ -17,7 +17,7 @@ import logging
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
-from . import singleton
+from . singleton import Singleton
def test_curses():
"""
@@ -77,7 +77,7 @@ def main():
log = logging.getLogger('')
signal.signal(signal.SIGINT, signal.SIG_IGN) # ignore ctrl-c
- cocore = singleton.Singleton(core.Core)
+ cocore = Singleton(core.Core)
signal.signal(signal.SIGUSR1, cocore.sigusr_handler) # reload the config
signal.signal(signal.SIGHUP, cocore.exit_from_signal)
signal.signal(signal.SIGTERM, cocore.exit_from_signal)
diff --git a/poezio/singleton.py b/poezio/singleton.py
index 9133012b..7f12796b 100644
--- a/poezio/singleton.py
+++ b/poezio/singleton.py
@@ -13,8 +13,8 @@ This method is the only one that I can come up with that do not call
__init__() each time.
"""
-instances = {}
+_instances = {}
def Singleton(cls, *args, **kwargs):
- if not cls in instances:
- instances[cls] = cls(*args, **kwargs)
- return instances[cls]
+ if not cls in _instances:
+ _instances[cls] = cls(*args, **kwargs)
+ return _instances[cls]
diff --git a/poezio/tabs/basetabs.py b/poezio/tabs/basetabs.py
index 8a5c48ea..658c3feb 100644
--- a/poezio/tabs/basetabs.py
+++ b/poezio/tabs/basetabs.py
@@ -16,7 +16,6 @@ revolving around chats.
import logging
log = logging.getLogger(__name__)
-from .. import singleton
import string
import time
import weakref
@@ -31,6 +30,7 @@ from .. common import safeJID
from .. config import config
from .. decorators import refresh_wrapper
from .. logger import logger
+from .. singleton import Singleton
from .. text_buffer import TextBuffer
from .. theming import get_theme, dump_tuple
from .. decorators import command_args_parser
@@ -109,7 +109,7 @@ class Tab(object):
@property
def core(self):
if not Tab.tab_core:
- Tab.tab_core = singleton.Singleton(core.Core)
+ Tab.tab_core = Singleton(core.Core)
return Tab.tab_core
@property
@@ -122,13 +122,13 @@ class Tab(object):
@property
def tab_win(self):
if not Tab.tab_core:
- Tab.tab_core = singleton.Singleton(core.Core)
+ Tab.tab_core = Singleton(core.Core)
return Tab.tab_core.tab_win
@property
def left_tab_win(self):
if not Tab.tab_core:
- Tab.tab_core = singleton.Singleton(core.Core)
+ Tab.tab_core = Singleton(core.Core)
return Tab.tab_core.left_tab_win
@staticmethod
diff --git a/poezio/windows/base_wins.py b/poezio/windows/base_wins.py
index 613e2e3d..f1f9b84b 100644
--- a/poezio/windows/base_wins.py
+++ b/poezio/windows/base_wins.py
@@ -10,12 +10,9 @@ A Tab (see the poezio.tabs module) is composed of multiple Windows
import logging
log = logging.getLogger(__name__)
-import collections
import curses
import string
-from .. import core
-from .. import singleton
from .. theming import to_curses_attr, read_tuple
FORMAT_CHAR = '\x19'