Skip to content

Commit e3c0b7d

Browse files
author
Jakub Klimczak
committed
tools: Move message formatting functions to a new file
1 parent f1b78d3 commit e3c0b7d

File tree

8 files changed

+31
-31
lines changed

8 files changed

+31
-31
lines changed

protoplaster/api/v1/execution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from flask import Blueprint, jsonify, request
22
import importlib
3-
from protoplaster.tools.tools import error
3+
from protoplaster.tools.log import error
44

55
execution_blueprint: Blueprint = Blueprint("protoplaster-execution", __name__)
66

protoplaster/conf/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import yaml
88

99
import protoplaster.tests
10-
from protoplaster.tools.tools import pr_err, pr_info, pr_warn
10+
from protoplaster.tools.log import pr_err, pr_info, pr_warn
1111

1212
StrPath = str | Path
1313

protoplaster/conf/plugin_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import importlib
44

55
from protoplaster.conf.consts import PROTOPLASTER
6-
from protoplaster.tools.tools import pr_warn, pr_info
6+
from protoplaster.tools.log import pr_warn, pr_info
77

88
hookspec = HookspecMarker(PROTOPLASTER)
99
hookimpl = HookimplMarker(PROTOPLASTER)

protoplaster/protoplaster.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from protoplaster.runner.manager import RunManager
1818
from protoplaster.runner.runner import list_tests, list_test_suites, run_tests
1919
from protoplaster.report_generators.system_report.protoplaster_system_report import __file__ as system_report_file
20-
from protoplaster.tools.tools import error, info
20+
from protoplaster.tools.log import error, info
2121

2222

2323
def create_docs_app() -> Flask:

protoplaster/runner/runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from protoplaster.conf.parser import TestFile, load_yaml
2222
from protoplaster.report_generators.test_report.protoplaster_test_report import generate_test_report
2323
from protoplaster.report_generators.system_report.protoplaster_system_report import generate_system_report, CommandConfig, run_command
24-
from protoplaster.tools.tools import error, pr_warn, pr_err, warning
24+
from protoplaster.tools.log import error, pr_warn, pr_err, warning
2525
from protoplaster.webui.devices import get_all_devices
2626
from protoplaster.conf.consts import REMOTE_RUN_TRIGGER_TIMEOUT, SERVE_IP, WEBUI_POLLING_INTERVAL, LOCAL_DEVICE_HOST
2727
from protoplaster import __file__ as protoplaster_root

protoplaster/tools/log.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from colorama import Fore, Style
2+
3+
4+
def warning(text):
5+
return Fore.YELLOW + f"[WARNING] {text}" + Style.RESET_ALL
6+
7+
8+
def pr_warn(text):
9+
print(warning(text))
10+
11+
12+
def error(text):
13+
return Fore.RED + f"[ERROR] {text}" + Style.RESET_ALL
14+
15+
16+
def pr_err(text):
17+
print(error(text))
18+
19+
20+
def info(text):
21+
return f"[INFO] {text}"
22+
23+
24+
def pr_info(text):
25+
print(info(text))

protoplaster/tools/tools.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import requests
2-
from colorama import Fore, Style
32
from typing import Callable, Optional, List, Any, Union
43
from concurrent.futures import ThreadPoolExecutor, Future
54

@@ -20,30 +19,6 @@ def assert_user_input(user_message,
2019
assert answer.lower() == possible_answers[correct_answer].lower()
2120

2221

23-
def warning(text):
24-
return Fore.YELLOW + f"[WARNING] {text}" + Style.RESET_ALL
25-
26-
27-
def pr_warn(text):
28-
print(warning(text))
29-
30-
31-
def error(text):
32-
return Fore.RED + f"[ERROR] {text}" + Style.RESET_ALL
33-
34-
35-
def pr_err(text):
36-
print(error(text))
37-
38-
39-
def info(text):
40-
return f"[INFO] {text}"
41-
42-
43-
def pr_info(text):
44-
print(info(text))
45-
46-
4722
def _execute_request(url: str, method: Callable, args: List[Any]) -> Any:
4823
payload = {
4924
"module": method.__module__,

protoplaster/webui/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import requests
44
from protoplaster.webui.devices import get_all_devices, get_device_by_name, add_device, remove_device
55
from protoplaster.conf.consts import WEBUI_POLLING_INTERVAL
6-
from protoplaster.tools.tools import error
6+
from protoplaster.tools.log import error
77

88

99
@webui_blueprint.route("/")

0 commit comments

Comments
 (0)