@@ -11,20 +11,47 @@ def load_toml(settings):
1111 fname = "kci-dev.toml"
1212 config = None
1313
14- global_path = os .path .join ("/" , "etc" , fname )
15- if os .path .exists (global_path ):
16- with open (global_path , "r" ) as f :
14+ if os .path .exists (settings ):
15+ with open (settings , "r" ) as f :
1716 config = toml .load (f )
17+ return config
1818
1919 home_dir = os .path .expanduser ("~" )
2020 user_path = os .path .join (home_dir , ".config" , "kci-dev" , fname )
2121 if os .path .exists (user_path ):
2222 with open (user_path , "r" ) as f :
2323 config = toml .load (f )
24+ return config
2425
25- if os .path .exists (settings ):
26- with open (settings , "r" ) as f :
26+ global_path = os .path .join ("/" , "etc" , fname )
27+ if os .path .exists (global_path ):
28+ with open (global_path , "r" ) as f :
29+ config = toml .load (f )
30+ return config
31+
32+ example_configuration = ".kci-dev.toml.example"
33+ # Installed with Poetry
34+ poetry_example_configuration = os .path .join (
35+ os .path .dirname (__file__ ), "../.." , example_configuration
36+ )
37+ if os .path .exists (poetry_example_configuration ):
38+ kci_err (
39+ f"Using Poetry example configuration in: " + poetry_example_configuration
40+ )
41+ with open (poetry_example_configuration , "r" ) as f :
42+ config = toml .load (f )
43+ return config
44+
45+ # Installed with PyPI
46+ kci_err (f"Configuration not found" )
47+ pypi_example_configuration = os .path .join (
48+ os .path .dirname (__file__ ), ".." , example_configuration
49+ )
50+ if os .path .exists (pypi_example_configuration ):
51+ kci_err (f"Using PyPI example configuration in: " + pypi_example_configuration )
52+ with open (pypi_example_configuration , "r" ) as f :
2753 config = toml .load (f )
54+ return config
2855
2956 if not config :
3057 kci_err (
0 commit comments