44from cf_remote .paths import path_append
55
66
7- def cfengine_dir (subdir = None ):
7+ def cfengine_cache_dir (subdir = None ):
88 """
9- Returns the directory used by the Python tools for temporary files,
10- global config , downloads, etc.
9+ Returns the directory used by the Python tools for temporary
10+ files , downloads, etc.
1111
12- Defaults to ~/.cfengine/, but can be overridden via the CFENGINE_DIR
12+ Defaults to ~/.cache/ cfengine/, but can be overridden via the CFENGINE_DIR
1313 environment variable.
1414 """
1515 override_dir = os .getenv ("CFENGINE_DIR" )
@@ -27,7 +27,32 @@ def cfengine_dir(subdir=None):
2727
2828 return path_append (override_dir , subdir )
2929
30- return path_append ("~/.cfengine/" , subdir )
30+ return path_append ("~/.cache/cfengine/" , subdir )
31+
32+
33+ def cfengine_config_dir (subdir = None ):
34+ """
35+ Returns the directory used by the Python tools for config/persistent files.
36+
37+ Defaults to ~/.config/cfengine/, but can be overridden via the CFENGINE_DIR
38+ environment variable.
39+ """
40+ override_dir = os .getenv ("CFENGINE_DIR" )
41+
42+ if override_dir :
43+ override_dir = os .path .normpath (override_dir )
44+ parent = os .path .dirname (override_dir )
45+
46+ if not os .path .exists (parent ):
47+ raise UserError (
48+ "'{}' doesn't exist. Make sure this path is correct and exists." .format (
49+ parent
50+ )
51+ )
52+
53+ return path_append (override_dir , subdir )
54+
55+ return path_append ("~/.config/cfengine/" , subdir )
3156
3257
3358def bin (component : str ) -> str :
0 commit comments