55"""
66
77import json
8- import os
98from pathlib import Path
109
1110
@@ -14,11 +13,13 @@ class Config:
1413
1514 def __init__ (self , config_dir = None ):
1615 """Initialize the configuration manager.
17-
16+
1817 Args:
1918 config_dir (Path, optional): Override default config directory for testing.
2019 """
21- self .config_dir = Path (config_dir ) if config_dir else Path .home () / ".openapi_cli_generator"
20+ self .config_dir = (
21+ Path (config_dir ) if config_dir else Path .home () / ".openapi_cli_generator"
22+ )
2223 self .config_file = self .config_dir / "config.json"
2324 self ._ensure_config_exists ()
2425 self .load_config ()
@@ -31,7 +32,7 @@ def _ensure_config_exists(self):
3132 default_config = {
3233 "aliases" : {},
3334 "version" : "1.0.0" ,
34- "created_at" : None # Will be set on first alias addition
35+ "created_at" : None , # Will be set on first alias addition
3536 }
3637 with open (self .config_file , "w" ) as f :
3738 json .dump (default_config , f , indent = 2 )
@@ -40,7 +41,7 @@ def load_config(self):
4041 """Load configuration from file."""
4142 with open (self .config_file ) as f :
4243 self .config = json .load (f )
43-
44+
4445 # Ensure basic structure exists
4546 if "aliases" not in self .config :
4647 self .config ["aliases" ] = {}
@@ -50,13 +51,14 @@ def save_config(self):
5051 """Save configuration to file."""
5152 # Create backup before saving
5253 if self .config_file .exists ():
53- backup_file = self .config_file .with_suffix (' .json.bak' )
54+ backup_file = self .config_file .with_suffix (" .json.bak" )
5455 try :
5556 import shutil
57+
5658 shutil .copy2 (self .config_file , backup_file )
5759 except Exception :
5860 pass # Ignore backup errors
59-
61+
6062 with open (self .config_file , "w" ) as f :
6163 json .dump (self .config , f , indent = 2 )
6264
0 commit comments