mirror of
				https://github.com/MCV-Software/TWBlue.git
				synced 2025-10-31 04:12:00 +00:00 
			
		
		
		
	Code cleanup
This commit is contained in:
		| @@ -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): | ||||||
|   | |||||||
| @@ -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 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user