added basic docstrings

This commit is contained in:
Jakub Trllo 2019-03-22 19:32:01 +01:00
parent fc01a4240b
commit b61cceccee
4 changed files with 39 additions and 3 deletions

View file

@ -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):

View file

@ -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: