Skip to content

Commit

Permalink
Read clir confoig file using importlib
Browse files Browse the repository at this point in the history
  • Loading branch information
elkinaguas authored Aug 17, 2024
1 parent da895af commit e670dea
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions clir/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit e670dea

Please sign in to comment.