Completed
Push — main ( 25807a...2ed45a )
by Jochen
01:37
created

weitersager.util   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 77.78%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 25
ccs 7
cts 9
cp 0.7778
rs 10
c 0
b 0
f 0
wmc 2

2 Functions

Rating   Name   Duplication   Size   Complexity  
A start_thread() 0 4 1
A log() 0 3 1
1
"""
2
weitersager.util
3
~~~~~~~~~~~~~~~~
4
5
Utilities
6
7
:Copyright: 2007-2020 Jochen Kupperschmidt
8
:License: MIT, see LICENSE for details.
9
"""
10
11 1
from datetime import datetime
12 1
from threading import Thread
13 1
from typing import Any, Callable, Dict, Sequence
14
15
16 1
def log(message: str, *args: Any, **kwargs: Dict[str, Any]) -> None:
17 1
    timestamp = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
18 1
    print(timestamp, message.format(*args, **kwargs))
19
20
21 1
def start_thread(target: Callable, name: str) -> None:
22
    """Create, configure, and start a new thread."""
23
    t = Thread(target=target, name=name, daemon=True)
24
    t.start()
25