Revert "♻ refactor: rename package"

This reverts commit 55796828dd.
This commit is contained in:
Florian Hönicke
2023-04-24 23:20:09 +02:00
parent 9ee674817f
commit 0339b24353
33 changed files with 1940 additions and 7 deletions

0
src/utils/__init__.py Normal file
View File

51
src/utils/io.py Normal file
View File

@@ -0,0 +1,51 @@
import os
import subprocess
import sys
from contextlib import contextmanager
def get_microservice_path(path, microservice_name, packages, num_approach, version):
package_path = '_'.join(packages)
return os.path.join(path, microservice_name, f'{num_approach}_{package_path}', f'v{version}')
def persist_file(file_content, file_path):
with open(file_path, 'w', encoding='utf-8') as f:
f.write(file_content)
def get_all_microservice_files_with_content(folder_path):
file_name_to_content = {}
for filename in os.listdir(folder_path):
file_path = os.path.join(folder_path, filename)
if os.path.isfile(file_path):
with open(file_path, 'r', encoding='utf-8') as file:
content = file.read()
file_name_to_content[filename] = content
return file_name_to_content
@contextmanager
def suppress_stdout():
original_stdout = sys.stdout
sys.stdout = open(os.devnull, 'w')
try:
yield
finally:
sys.stdout.close()
sys.stdout = original_stdout
def is_docker_running():
try:
if sys.platform.startswith('win'):
command = 'docker info'
else:
command = 'docker info 2> /dev/null'
subprocess.check_output(command, shell=True)
return True
except subprocess.CalledProcessError:
return False

29
src/utils/string_tools.py Normal file
View File

@@ -0,0 +1,29 @@
import os
import platform
if platform.system() == "Windows":
os.system("color")
def print_colored(headline, text, color_code, end='\n'):
if color_code == 'black':
color_code = '30'
elif color_code == 'red':
color_code = '31'
elif color_code == 'green':
color_code = '32'
elif color_code == 'yellow':
color_code = '33'
elif color_code == 'blue':
color_code = '34'
elif color_code == 'magenta':
color_code = '35'
elif color_code == 'cyan':
color_code = '36'
elif color_code == 'white':
color_code = '37'
color_start = f"\033[{color_code}m"
reset = "\033[0m"
bold_start = "\033[1m"
if headline:
print(f"{bold_start}{color_start}{headline}{reset}")
print(f"{color_start}{text}{reset}", end=end)