11"""Configuration file loading and saving."""
2+
23from __future__ import annotations
34
45import json
@@ -35,7 +36,9 @@ def load_config(config_path: str | Path) -> Config:
3536 raw_settings = data .get ("settings" , {})
3637 settings = Settings (
3738 encoding = raw_settings .get ("encoding" , DEFAULT_SETTINGS ["encoding" ]),
38- max_lines_per_file = raw_settings .get ("max_lines_per_file" , DEFAULT_SETTINGS ["max_lines_per_file" ]),
39+ max_lines_per_file = raw_settings .get (
40+ "max_lines_per_file" , DEFAULT_SETTINGS ["max_lines_per_file" ]
41+ ),
3942 show_summary = raw_settings .get ("show_summary" , DEFAULT_SETTINGS ["show_summary" ]),
4043 url_timeout = raw_settings .get ("url_timeout" , DEFAULT_SETTINGS ["url_timeout" ]),
4144 mode = raw_settings .get ("mode" , DEFAULT_SETTINGS ["mode" ]),
@@ -47,15 +50,17 @@ def load_config(config_path: str | Path) -> Config:
4750 # Build Source list
4851 sources = []
4952 for s in data ["sources" ]:
50- sources .append (Source (
51- id = s .get ("id" , s .get ("path" , "" )),
52- label = s .get ("label" , s .get ("path" , "" )),
53- path = s ["path" ],
54- type = s .get ("type" , "auto" ),
55- enabled = s .get ("enabled" , True ),
56- description = s .get ("description" , "" ),
57- priority = s .get ("priority" , "normal" ),
58- ))
53+ sources .append (
54+ Source (
55+ id = s .get ("id" , s .get ("path" , "" )),
56+ label = s .get ("label" , s .get ("path" , "" )),
57+ path = s ["path" ],
58+ type = s .get ("type" , "auto" ),
59+ enabled = s .get ("enabled" , True ),
60+ description = s .get ("description" , "" ),
61+ priority = s .get ("priority" , "normal" ),
62+ )
63+ )
5964
6065 return Config (
6166 version = data .get ("version" , "1.0.0" ),
@@ -117,15 +122,17 @@ def load_profile_sources(profile_path: str | Path) -> list[Source]:
117122
118123 sources = []
119124 for s in data .get ("sources" , []):
120- sources .append (Source (
121- id = s .get ("id" , s .get ("path" , "" )),
122- label = s .get ("label" , s .get ("path" , "" )),
123- path = s ["path" ],
124- type = s .get ("type" , "auto" ),
125- enabled = s .get ("enabled" , True ),
126- description = s .get ("description" , "" ),
127- priority = s .get ("priority" , "normal" ),
128- ))
125+ sources .append (
126+ Source (
127+ id = s .get ("id" , s .get ("path" , "" )),
128+ label = s .get ("label" , s .get ("path" , "" )),
129+ path = s ["path" ],
130+ type = s .get ("type" , "auto" ),
131+ enabled = s .get ("enabled" , True ),
132+ description = s .get ("description" , "" ),
133+ priority = s .get ("priority" , "normal" ),
134+ )
135+ )
129136 return sources
130137
131138
@@ -134,6 +141,4 @@ def list_profiles(profiles_dir: str | Path) -> list[str]:
134141 profiles_dir = Path (profiles_dir )
135142 if not profiles_dir .exists ():
136143 return []
137- return [
138- p .stem for p in sorted (profiles_dir .glob ("*.json" ))
139- ]
144+ return [p .stem for p in sorted (profiles_dir .glob ("*.json" ))]
0 commit comments