File tree 1 file changed +6
-12
lines changed 1 file changed +6
-12
lines changed Original file line number Diff line number Diff line change 22
22
from collections .abc import Mapping
23
23
from textwrap import dedent
24
24
25
+ import platformdirs
26
+
25
27
from .commands import (
26
28
CommandError ,
27
29
do_connect ,
@@ -396,18 +398,8 @@ def load_user_config():
396
398
# Create empty config object.
397
399
config = __build_class__ (lambda : None , "Config" )()
398
400
config .commands = {}
399
-
400
- # Get config file name.
401
- path = os .getenv ("XDG_CONFIG_HOME" )
402
- if path is None :
403
- path = os .getenv ("HOME" )
404
- if path is None :
405
- return config
406
- path = os .path .join (path , ".config" )
407
- path = os .path .join (path , _PROG )
401
+ path = platformdirs .user_config_dir (appname = _PROG , appauthor = False )
408
402
config_file = os .path .join (path , "config.py" )
409
-
410
- # Check if config file exists.
411
403
if not os .path .exists (config_file ):
412
404
return config
413
405
@@ -416,9 +408,11 @@ def load_user_config():
416
408
config_data = f .read ()
417
409
prev_cwd = os .getcwd ()
418
410
os .chdir (path )
411
+ # pass in the config path so that the config file can use it
412
+ config .__dict__ ["config_path" ] = path
413
+ config .__dict__ ["__file__" ] = config_file
419
414
exec (config_data , config .__dict__ )
420
415
os .chdir (prev_cwd )
421
-
422
416
return config
423
417
424
418
You can’t perform that action at this time.
0 commit comments