Code cleanup

This commit is contained in:
Manuel Cortez 2022-03-24 10:39:20 -06:00
parent b35cdbd7b4
commit 485b4c3c6c
No known key found for this signature in database
GPG Key ID: 9E0735CA15EFE790
2 changed files with 11 additions and 5 deletions

View File

@ -1,13 +1,15 @@
# -*- coding: cp1252 -*- # -*- coding: cp1252 -*-
import config """ Lightweigth module that saves session position across global config and performs validation of config files. """
import paths
import os import os
import logging import logging
import config
import paths
log = logging.getLogger("sessionmanager.manager") log = logging.getLogger("sessionmanager.manager")
from sessions import session_exceptions from sessions import session_exceptions
manager = None manager = None
def setup(): def setup():
""" Creates the singleton instance used within TWBlue to access this object. """
global manager global manager
if not manager: if not manager:
manager = sessionManager() manager = sessionManager()
@ -15,12 +17,16 @@ def setup():
class sessionManager(object): class sessionManager(object):
def get_current_session(self): def get_current_session(self):
""" Returns the currently focused session, if valid. """
if self.is_valid(config.app["sessions"]["current_session"]): if self.is_valid(config.app["sessions"]["current_session"]):
return config.app["sessions"]["current_session"] return config.app["sessions"]["current_session"]
else:
return False
def add_session(self, id): def add_session(self, id):
""" Adds a new session to the global config, so it will be taken into account for all operations.
:param id: Session identified.
:param id: str.
"""
log.debug("Adding a new session: %s" % (id,)) log.debug("Adding a new session: %s" % (id,))
path = os.path.join(paths.config_path(), id) path = os.path.join(paths.config_path(), id)
if not os.path.exists(path): if not os.path.exists(path):

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" Module to perform session actions such as adddition, removal or display of the global settings dialogue. """ """ Module to perform session actions such as addition, removal or display of the global settings dialogue. """
import shutil import shutil
import time import time
import os import os