From e670dea5b2b27ac8394c39a19e9a9c24a16e2458 Mon Sep 17 00:00:00 2001 From: Elkin Aguas Date: Sat, 17 Aug 2024 11:56:47 +0200 Subject: [PATCH] Read clir confoig file using importlib --- clir/utils/config.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/clir/utils/config.py b/clir/utils/config.py index 8dd7cca..0a06e3c 100644 --- a/clir/utils/config.py +++ b/clir/utils/config.py @@ -5,6 +5,7 @@ from clir.utils.db import create_database from clir.utils.core import get_commands from clir.utils.db import insert_command_db +import importlib.resources config_directory = "clir/config/" env_path = Path('~').expanduser() / Path(".clir") @@ -70,11 +71,11 @@ def copy_config_files(): # Check if the file already exists for file in files: + with importlib.resources.open_text('clir.config', 'clir.conf') as f: + conf = f.read() + with open(f"{env_path}/{file}", "w") as file: + file.write(conf) - source_file = f"{config_directory}/{file}" - destination_file = f"{env_path}/{file}" - - shutil.copyfile(source_file, destination_file) print(f"Copying {file} file to {env_path}") def init_config():