config2py 0.1.37__py3-none-any.whl → 0.1.39__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/util.py CHANGED
@@ -5,7 +5,7 @@ import os
5
5
  import ast
6
6
  from collections import ChainMap
7
7
  from pathlib import Path
8
- from typing import Optional, Union, Any, Callable, Set, Iterable
8
+ from typing import Optional, Union, Any, Callable, Set, Literal, Iterable
9
9
  import getpass
10
10
 
11
11
  from dol import process_path
@@ -18,6 +18,8 @@ from i2 import mk_sentinel # TODO: Only i2 dependency. Consider replacing.
18
18
  DFLT_APP_NAME = "config2py"
19
19
  DFLT_MASKING_INPUT = False
20
20
 
21
+ AppFolderKind = Literal["data", "config", "cache"]
22
+
21
23
  not_found = mk_sentinel("not_found")
22
24
  no_default = mk_sentinel("no_default")
23
25
 
@@ -273,7 +275,7 @@ def create_directories(dirpath, max_dirs_to_make=None):
273
275
 
274
276
 
275
277
  # Note: First possible i2 dependency -- vendoring for now
276
- def get_app_data_rootdir(*, ensure_exists=False) -> str:
278
+ def get_app_rootdir(*, ensure_exists=True) -> str:
277
279
  """
278
280
  Returns the full path of a directory suitable for storing application-specific data.
279
281
 
@@ -286,12 +288,13 @@ def get_app_data_rootdir(*, ensure_exists=False) -> str:
286
288
 
287
289
  See https://github.com/i2mint/i2mint/issues/1.
288
290
 
289
- >>> get_app_data_rootdir() # doctest: +SKIP
291
+ >>> get_app_rootdir() # doctest: +SKIP
290
292
  '/Users/.../.config'
291
293
 
292
- If ``ensure_exists`` is ``True``, the folder will be created if it doesn't exist.
294
+ If ``ensure_exists`` is ``True`` (the default), the folder will be created if
295
+ it doesn't exist.
293
296
 
294
- >>> get_app_data_rootdir(ensure_exists=True) # doctest: +SKIP
297
+ >>> get_app_rootdir(ensure_exists=True) # doctest: +SKIP
295
298
  '/Users/.../.config'
296
299
 
297
300
  Note: The default app data folder is the system default for the current operating
@@ -300,7 +303,11 @@ def get_app_data_rootdir(*, ensure_exists=False) -> str:
300
303
  to use.
301
304
 
302
305
  """
303
- return process_path(DFLT_APP_DATA_FOLDER, ensure_dir_exists=True)
306
+ return process_path(DFLT_APP_DATA_FOLDER, ensure_dir_exists=ensure_exists)
307
+
308
+
309
+ # renaming get_app_data_rootdir to get_app_rootdir
310
+ _legacy_app_data_rootdir = get_app_rootdir # backwards compatibility alias
304
311
 
305
312
 
306
313
  def _default_folder_setup(directory_path: str) -> None:
@@ -322,11 +329,15 @@ def _default_folder_setup(directory_path: str) -> None:
322
329
  (Path(directory_path) / ".config2py").write_text("Created by config2py.")
323
330
 
324
331
 
332
+ DFLT_APP_FOLDER_KIND: AppFolderKind = "config"
333
+
334
+
325
335
  def get_app_data_folder(
326
336
  app_name: str = DFLT_APP_NAME,
327
337
  *,
328
338
  setup_callback: Callable[[str], None] = _default_folder_setup,
329
339
  ensure_exists: bool = False,
340
+ folder_kind: AppFolderKind = DFLT_APP_FOLDER_KIND,
330
341
  ) -> str:
331
342
  """
332
343
  Retrieve or create the app data directory specific to the given app name.
@@ -361,9 +372,7 @@ def get_app_data_folder(
361
372
  '/Users/.../.config/another/app/and/subfolder'
362
373
 
363
374
  """
364
- app_data_path = os.path.join(
365
- get_app_data_rootdir(ensure_exists=ensure_exists), app_name
366
- )
375
+ app_data_path = os.path.join(get_app_rootdir(ensure_exists=ensure_exists), app_name)
367
376
  app_data_folder_did_not_exist = not os.path.isdir(app_data_path)
368
377
  process_path(app_data_path, ensure_dir_exists=True)
369
378
 
@@ -1,9 +1,8 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: config2py
3
- Version: 0.1.37
3
+ Version: 0.1.39
4
4
  Summary: Simplified reading and writing configurations from various sources and formats
5
5
  Home-page: https://github.com/i2mint/config2py
6
- Author: OtoSense
7
6
  License: apache-2.0
8
7
  Platform: any
9
8
  Description-Content-Type: text/markdown
@@ -3,13 +3,13 @@ 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=bchsJjaMnsfnplCJsg7i0Osyzuha3N-hExuc6gmS-7I,17188
6
+ config2py/util.py,sha256=a3ynnasuO9DztfgAVmWwJfDVvfudKrWdFtJqxLIGbI8,17474
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.37.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
12
- config2py-0.1.37.dist-info/METADATA,sha256=oVY9jkk7t4epX9WoV1luTW6z2E-enwqfm92p2M9xyQU,14558
13
- config2py-0.1.37.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
14
- config2py-0.1.37.dist-info/top_level.txt,sha256=DFnlOIKMIGWQRROr3voJFhWFViHaWgTTeWZjC5YC9QQ,10
15
- config2py-0.1.37.dist-info/RECORD,,
11
+ config2py-0.1.39.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
12
+ config2py-0.1.39.dist-info/METADATA,sha256=Uvu5Fe6r2JteTAlVeGJgTQaPd61daxtXOMmapyPYh90,14541
13
+ config2py-0.1.39.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
14
+ config2py-0.1.39.dist-info/top_level.txt,sha256=DFnlOIKMIGWQRROr3voJFhWFViHaWgTTeWZjC5YC9QQ,10
15
+ config2py-0.1.39.dist-info/RECORD,,