Import Singleton instead of its module, and remove unused imports.
This commit is contained in:
parent
36377f78ba
commit
29ac9ec597
5 changed files with 12 additions and 15 deletions
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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'
|
||||
|
|
Loading…
Reference in a new issue