config2py 0.1.40__py3-none-any.whl → 0.1.41__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- config2py/__init__.py +1 -1
- config2py/util.py +8 -8
- {config2py-0.1.40.dist-info → config2py-0.1.41.dist-info}/METADATA +2 -2
- {config2py-0.1.40.dist-info → config2py-0.1.41.dist-info}/RECORD +7 -7
- {config2py-0.1.40.dist-info → config2py-0.1.41.dist-info}/LICENSE +0 -0
- {config2py-0.1.40.dist-info → config2py-0.1.41.dist-info}/WHEEL +0 -0
- {config2py-0.1.40.dist-info → config2py-0.1.41.dist-info}/top_level.txt +0 -0
config2py/__init__.py
CHANGED
|
@@ -15,7 +15,7 @@ from config2py.base import get_config, user_gettable, sources_chainmap
|
|
|
15
15
|
from config2py.util import (
|
|
16
16
|
envvar, # os.environ, but with dict display override to hide secrets
|
|
17
17
|
ask_user_for_input,
|
|
18
|
-
|
|
18
|
+
get_app_config_folder,
|
|
19
19
|
get_configs_folder_for_app,
|
|
20
20
|
is_repl,
|
|
21
21
|
parse_assignments_from_py_source,
|
config2py/util.py
CHANGED
|
@@ -395,7 +395,7 @@ def _default_folder_setup(directory_path: str) -> None:
|
|
|
395
395
|
(Path(directory_path) / ".config2py").write_text("Created by config2py.")
|
|
396
396
|
|
|
397
397
|
|
|
398
|
-
def
|
|
398
|
+
def get_app_config_folder(
|
|
399
399
|
app_name: str = DFLT_APP_NAME,
|
|
400
400
|
*,
|
|
401
401
|
setup_callback: Callable[[str], None] = _default_folder_setup,
|
|
@@ -423,25 +423,25 @@ def get_app_data_folder(
|
|
|
423
423
|
|
|
424
424
|
By default, the app will be "config2py" and folder_kind will be "config":
|
|
425
425
|
|
|
426
|
-
>>>
|
|
426
|
+
>>> get_app_config_folder() # doctest: +ELLIPSIS
|
|
427
427
|
'.../.config/config2py'
|
|
428
428
|
|
|
429
429
|
You can specify a different app name and folder kind:
|
|
430
430
|
|
|
431
|
-
>>>
|
|
431
|
+
>>> get_app_config_folder('my_app', folder_kind='data') # doctest: +SKIP
|
|
432
432
|
'/Users/.../.local/share/my_app'
|
|
433
|
-
>>>
|
|
433
|
+
>>> get_app_config_folder('my_app', folder_kind='cache') # doctest: +SKIP
|
|
434
434
|
'/Users/.../.cache/my_app'
|
|
435
435
|
|
|
436
436
|
You can also specify a path relative to the app root directory:
|
|
437
437
|
|
|
438
|
-
>>>
|
|
438
|
+
>>> get_app_config_folder('another/app/subfolder', folder_kind='data') # doctest: +SKIP
|
|
439
439
|
'/Users/.../.local/share/another/app/subfolder'
|
|
440
440
|
|
|
441
441
|
If ensure_exists is True, the directory will be created and initialized
|
|
442
442
|
with the setup_callback:
|
|
443
443
|
|
|
444
|
-
>>> path =
|
|
444
|
+
>>> path = get_app_config_folder('my_app', ensure_exists=True) # doctest: +SKIP
|
|
445
445
|
>>> os.path.exists(path) # doctest: +SKIP
|
|
446
446
|
True
|
|
447
447
|
"""
|
|
@@ -478,13 +478,13 @@ def get_configs_folder_for_app(
|
|
|
478
478
|
- config_dir_setup_callback (Callable[[str], None]): A callback function to initialize the configs directory.
|
|
479
479
|
Default is _default_folder_setup.
|
|
480
480
|
"""
|
|
481
|
-
app_dir =
|
|
481
|
+
app_dir = get_app_config_folder(app_name, setup_callback=app_dir_setup_callback)
|
|
482
482
|
configs_dir = os.path.join(app_dir, configs_name)
|
|
483
483
|
config_dir_setup_callback(configs_dir)
|
|
484
484
|
return configs_dir
|
|
485
485
|
|
|
486
486
|
|
|
487
|
-
get_app_data_directory =
|
|
487
|
+
get_app_data_directory = get_app_config_folder # backwards compatibility alias
|
|
488
488
|
get_configs_directory_for_app = (
|
|
489
489
|
get_configs_folder_for_app # backwards compatibility alias
|
|
490
490
|
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: config2py
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.41
|
|
4
4
|
Summary: Simplified reading and writing configurations from various sources and formats
|
|
5
5
|
Home-page: https://github.com/i2mint/config2py
|
|
6
6
|
License: apache-2.0
|
|
@@ -215,7 +215,7 @@ user again.
|
|
|
215
215
|
* `get_config`: Get a config value from a list of sources. See more below.
|
|
216
216
|
* `user_gettable`: Create a ``GettableContainer`` that asks the user for a value, optionally saving it.
|
|
217
217
|
* `ask_user_for_input`: Ask the user for input, optionally masking, validating and transforming the input.
|
|
218
|
-
* `
|
|
218
|
+
* `get_app_config_folder`: Returns the full path of a directory suitable for storing application-specific data for a given app name.
|
|
219
219
|
* `get_configs_local_store`: Get a local store (mapping interface of local files) of configs for a given app or package name
|
|
220
220
|
* `configs`: A default store instance for configs, defaulting to a local store under a default configuration local directory.
|
|
221
221
|
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
config2py/__init__.py,sha256=
|
|
1
|
+
config2py/__init__.py,sha256=CMW0A9HFvihk_ezZ5Jh1XPWo14hE9S-oC4eZFl0AnAo,846
|
|
2
2
|
config2py/base.py,sha256=eQpRQjZYT-z6GhBemepaPUEyVVP8e_l04dghYeBBJdI,15880
|
|
3
3
|
config2py/errors.py,sha256=QdwGsoJhv6LHDHp-_yyz4oUg1Fgu4S-S7O2nuA0a5cw,203
|
|
4
4
|
config2py/s_configparser.py,sha256=-Sl2-J-QOLUiahwhCTiPsmjs4cKc79JuTbQ9gQcOiGY,15871
|
|
5
5
|
config2py/tools.py,sha256=goDuHHXKJzdFgmHzDnLBGMZEhp0kKU-aK47c1-MpJT8,9199
|
|
6
|
-
config2py/util.py,sha256=
|
|
6
|
+
config2py/util.py,sha256=kW7C1rCNtatHajJitgrKdSXSE5hmpFTjsDyShtOS_80,20933
|
|
7
7
|
config2py/scrap/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
8
|
config2py/tests/__init__.py,sha256=sk-yGJQOZES2z70M4xmZB57tsxSktX_84ybDuV8Cz5Q,297
|
|
9
9
|
config2py/tests/test_tools.py,sha256=sdiBNTavuzxW2AsqBRTO9U21iWig5DEyV38r6lmaZak,3728
|
|
10
10
|
config2py/tests/utils_for_testing.py,sha256=RcMiVtKK39rc8BsgIXQH3RCkd8qKo2o2MT7Rt0dJF2E,162
|
|
11
|
-
config2py-0.1.
|
|
12
|
-
config2py-0.1.
|
|
13
|
-
config2py-0.1.
|
|
14
|
-
config2py-0.1.
|
|
15
|
-
config2py-0.1.
|
|
11
|
+
config2py-0.1.41.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
12
|
+
config2py-0.1.41.dist-info/METADATA,sha256=9v8fwUQ7kIlWxazlPsaWUV9iWaECMxos6cqaZw36bjM,14543
|
|
13
|
+
config2py-0.1.41.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
|
14
|
+
config2py-0.1.41.dist-info/top_level.txt,sha256=DFnlOIKMIGWQRROr3voJFhWFViHaWgTTeWZjC5YC9QQ,10
|
|
15
|
+
config2py-0.1.41.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|