From a569bb6206b1e31da838b57f6aea59373544d2a1 Mon Sep 17 00:00:00 2001 From: "Max P." Date: Wed, 30 Apr 2025 15:03:51 +0200 Subject: [PATCH] refactor(configuration): use pathlib for config path handling - Replace `os` with `pathlib` for defining the default config path. - Simplify configuration file path management for readability. - Improve code maintainability by centralizing the default path. Signed-off-by: Max P. --- src/pyvtt/configuration.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pyvtt/configuration.py b/src/pyvtt/configuration.py index b042e9d..cdcac36 100644 --- a/src/pyvtt/configuration.py +++ b/src/pyvtt/configuration.py @@ -1,5 +1,8 @@ import json import os +from pathlib import Path + +DEFAULT_CONFIG_PATH = Path.home() / ".pyvtt.json" def read_configurations(): """ @@ -13,10 +16,8 @@ def read_configurations(): Exception: If there is an error reading or parsing the JSON file, an exception is raised with the error details. """ - script_dir = os.path.dirname(os.path.abspath(__file__)) - settings_path = os.path.join(script_dir, "pyvtt.settings.json") try: - with open(settings_path) as f: + with open(DEFAULT_CONFIG_PATH) as f: return json.load(f) except Exception as e: print(f"Error reading configurations: {e}")