From b61cceccee28d1c9ab44615d501e55dd237379a8 Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Fri, 22 Mar 2019 19:32:01 +0100 Subject: [PATCH] added basic docstrings --- pype/avalon_apps/avalon_app.py | 2 +- pype/ftrack/ftrack_module.py | 1 - pype/services/idle_manager/idle_manager.py | 14 +++++++++++ .../services/timers_manager/timers_manager.py | 25 ++++++++++++++++++- 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/pype/avalon_apps/avalon_app.py b/pype/avalon_apps/avalon_app.py index 072d7fbb3f..efad3f3ce0 100644 --- a/pype/avalon_apps/avalon_app.py +++ b/pype/avalon_apps/avalon_app.py @@ -29,7 +29,7 @@ class AvalonApps: icon = QtGui.QIcon(launcher_lib.resource("icon", "main.png")) aShowLauncher = QtWidgets.QAction(icon, "&Launcher", parent_menu) - aLibraryLoader = QtWidgets.QAction("&Library", parent_menu) + aLibraryLoader = QtWidgets.QAction("Library", parent_menu) aShowLauncher.triggered.connect(self.show_launcher) aLibraryLoader.triggered.connect(self.show_library_loader) diff --git a/pype/ftrack/ftrack_module.py b/pype/ftrack/ftrack_module.py index a68bc2ac26..127b39d2fc 100644 --- a/pype/ftrack/ftrack_module.py +++ b/pype/ftrack/ftrack_module.py @@ -117,7 +117,6 @@ class FtrackModule: # Menu for Tray App self.menu = QtWidgets.QMenu('Ftrack', parent_menu) self.menu.setProperty('submenu', 'on') - self.menu.setStyleSheet(style.load_stylesheet()) # Actions - server self.smActionS = self.menu.addMenu("Action server") diff --git a/pype/services/idle_manager/idle_manager.py b/pype/services/idle_manager/idle_manager.py index cc6e177916..e8ba246121 100644 --- a/pype/services/idle_manager/idle_manager.py +++ b/pype/services/idle_manager/idle_manager.py @@ -5,6 +5,10 @@ from pypeapp import Logger class IdleManager(QtCore.QThread): + """ Measure user's idle time in seconds. + Idle time resets on keyboard/mouse input. + Is able to emit signals at specific time idle. + """ time_signals = {} idle_time = 0 signal_reset_timer = QtCore.Signal() @@ -16,6 +20,12 @@ class IdleManager(QtCore.QThread): self._is_running = False def add_time_signal(self, emit_time, signal): + """ If any module want to use IdleManager, need to use add_time_signal + :param emit_time: time when signal will be emitted + :type emit_time: int + :param signal: signal that will be emitted (without objects) + :type signal: QtCore.Signal + """ if emit_time not in self.time_signals: self.time_signals[emit_time] = [] self.time_signals[emit_time].append(signal) @@ -54,6 +64,8 @@ class IdleManager(QtCore.QThread): class MouseThread(QtCore.QThread): + """Listens user's mouse movement + """ signal_stop = QtCore.Signal() def __init__(self, signal): @@ -76,6 +88,8 @@ class MouseThread(QtCore.QThread): class KeyboardThread(QtCore.QThread): + """Listens user's keyboard input + """ signal_stop = QtCore.Signal() def __init__(self, signal): diff --git a/pype/services/timers_manager/timers_manager.py b/pype/services/timers_manager/timers_manager.py index 5d324ef453..6f10a0ec68 100644 --- a/pype/services/timers_manager/timers_manager.py +++ b/pype/services/timers_manager/timers_manager.py @@ -5,6 +5,8 @@ from pypeapp import Logger class Singleton(type): + """ Signleton implementation + """ _instances = {} def __call__(cls, *args, **kwargs): @@ -16,6 +18,12 @@ class Singleton(type): class TimersManager(metaclass=Singleton): + """ Handles about Timers. + + Should be able to start/stop all timers at once. + If IdleManager is imported then is able to handle about stop timers + when user idles for a long time (set in presets). + """ modules = [] is_running = False last_task = None @@ -39,11 +47,20 @@ class TimersManager(metaclass=Singleton): return False def add_module(self, module): + """ Adds module to context + + Module must have implemented methods: + - ``start_timer_manager(data)`` + - ``stop_timer_manager()`` + """ self.modules.append(module) def start_timers(self, data): ''' - Dictionary "data" should contain: + :param data: basic information needed to start any timer + :type data: dict + ..note:: + Dictionary "data" should contain: - project_name(str) - Name of Project - hierarchy(list/tuple) - list of parents(except project) - task_type(str) @@ -53,6 +70,7 @@ class TimersManager(metaclass=Singleton): - to run timers for task in 'C001_BackToPast/assets/characters/villian/Lookdev BG' - input data should contain: + .. code-block:: Python data = { 'project_name': 'C001_BackToPast', 'hierarchy': ['assets', 'characters', 'villian'], @@ -79,6 +97,11 @@ class TimersManager(metaclass=Singleton): self.is_running = False def process_modules(self, modules): + """ Gives ability to connect with imported modules from TrayManager. + + :param modules: All imported modules from TrayManager + :type modules: dict + """ self.s_handler = SignalHandler(self) if 'IdleManager' in modules: