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. <Mail@MPassarello.de>
This commit is contained in:
@@ -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}")
|
||||
|
Reference in New Issue
Block a user