File: timers.py

package info (click to toggle)
freeorion 0.5.1-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 194,940 kB
  • sloc: cpp: 186,508; python: 40,969; ansic: 1,164; xml: 719; makefile: 32; sh: 7
file content (31 lines) | stat: -rw-r--r-- 600 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from common.option_tools import TIMERS_USE_TIMERS, check_bool, get_option_dict
from common.timers import Timer

# setup module
options = get_option_dict()

try:
    USE_TIMERS = check_bool(options[TIMERS_USE_TIMERS])
except KeyError:
    USE_TIMERS = False


class DummyTimer:
    """
    Dummy timer to be used if timers are disabled.
    """

    def __init__(self, *args, **kwargs):
        pass

    def stop(self, *args, **kwargs):
        pass

    def start(self, *args, **kwargs):
        pass

    def stop_print_and_clear(self):
        pass


AITimer = Timer if USE_TIMERS else DummyTimer