config2py 0.1.33__py3-none-any.whl → 0.1.34__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/tools.py CHANGED
@@ -27,7 +27,7 @@ def get_configs_local_store(
27
27
  If it's a file, it's assumed to be an ini or cfg file.
28
28
  If it's a string, it's assumed to be an app name, from which to create a folder
29
29
  """
30
- if os.path.isdir(config_src):
30
+ if os.path.sep in config_src and os.path.isdir(config_src):
31
31
  # TODO: This was a quick fix to avoid unknowingly making directories in the
32
32
  # wrong place. Broke stuff so leaving this for later.
33
33
  # if os.path.sep not in config_src:
@@ -76,7 +76,7 @@ def simple_config_getter(
76
76
  default) asks the user for the value and stores it in the central config store.
77
77
 
78
78
  :param configs_src: A specification of the central config store. By default:
79
- If it's a directory, it's assumed to be a folder of text files.
79
+ If it's a directory (with at least a slash), it's assumed to be a folder of text files.
80
80
  If it's a file, it's assumed to be an ini or cfg file.
81
81
  If it's a string, it's assumed to be an app name, from which to create a folder
82
82
  :param first_look_in_env_vars: Whether to look in environment variables first
config2py/util.py CHANGED
@@ -182,6 +182,8 @@ def process_path(
182
182
  ensure_endswith_slash=False,
183
183
  ensure_does_not_end_with_slash=False,
184
184
  expanduser=True,
185
+ expandvars=True,
186
+ abspath=True,
185
187
  rootdir: str = '',
186
188
  ) -> str:
187
189
  """
@@ -194,12 +196,15 @@ def process_path(
194
196
  ensure_endswith_slash (bool): Whether to ensure the path ends with a slash.
195
197
  ensure_does_not_end_with_slash (bool): Whether to ensure the path does not end with a slash.
196
198
  expanduser (bool): Whether to expand the user in the path.
199
+ expandvars (bool): Whether to expand environment variables in the path.
200
+ abspath (bool): Whether to convert the path to an absolute path.
201
+ rootdir (str): The root directory to prepend to the path.
197
202
 
198
203
  Returns:
199
204
  str: The processed path.
200
205
 
201
- >>> process_path('a', 'b', 'c')
202
- 'a/b/c'
206
+ >>> process_path('a', 'b', 'c') # doctest: +ELLIPSIS
207
+ '...a/b/c'
203
208
  >>> from functools import partial
204
209
  >>> process_path('a', 'b', 'c', rootdir='/root/dir/', ensure_endswith_slash=True)
205
210
  '/root/dir/a/b/c/'
@@ -214,6 +219,10 @@ def process_path(
214
219
  path = os.path.join(rootdir, path)
215
220
  if expanduser:
216
221
  path = os.path.expanduser(path)
222
+ if expandvars:
223
+ path = os.path.expandvars(path)
224
+ if abspath:
225
+ path = os.path.abspath(path)
217
226
  if ensure_endswith_slash:
218
227
  if not path.endswith('/'):
219
228
  path = path + '/'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: config2py
3
- Version: 0.1.33
3
+ Version: 0.1.34
4
4
  Summary: Simplified reading and writing configurations from various sources and formats
5
5
  Home-page: https://github.com/i2mint/config2py
6
6
  Author: OtoSense
@@ -2,14 +2,14 @@ config2py/__init__.py,sha256=ru-bUQk5EuOLzHmNAcElSN8P2saSUEb5KFRkfTkzsUo,770
2
2
  config2py/base.py,sha256=saq1YVbeRg8jBoXcmc0y-maNJ5vHHeWwu5tc_EbOetE,15895
3
3
  config2py/errors.py,sha256=QdwGsoJhv6LHDHp-_yyz4oUg1Fgu4S-S7O2nuA0a5cw,203
4
4
  config2py/s_configparser.py,sha256=XhxFz6-PG4-QsecJfbjLFdBWHcPU6dwgqwkTZyY_y3E,15873
5
- config2py/tools.py,sha256=6wPAdnossxMPeQ6T0eqUilP3VnHAfbrJcFsg4xmaahA,9137
6
- config2py/util.py,sha256=mzIsU2ozkatWx61NphsbD502IrwuI2Vi0V8NEjpNRXQ,15745
5
+ config2py/tools.py,sha256=W2YQm-PerKRN8prsxVfcBCChx75pZ9H8UqWH8pGxECE,9191
6
+ config2py/util.py,sha256=cYD2O1FCYelvYsjy-bODxuQpR-NvgbCi9YEVBiQi4c4,16140
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=T0rBy8s6wHgQXnnr7Z1xkF1so3XkdGVASerEQ27ByxE,1950
10
10
  config2py/tests/util.py,sha256=vO1VIepbH6vY2e-VHP7HX6jnVzzIDyFsp6md_uBnIXw,1351
11
- config2py-0.1.33.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
12
- config2py-0.1.33.dist-info/METADATA,sha256=kg26LOTcSczZ0pjFwn6sHUtnJDPI6UO-Bhf8qDO0-2Q,14559
13
- config2py-0.1.33.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
14
- config2py-0.1.33.dist-info/top_level.txt,sha256=DFnlOIKMIGWQRROr3voJFhWFViHaWgTTeWZjC5YC9QQ,10
15
- config2py-0.1.33.dist-info/RECORD,,
11
+ config2py-0.1.34.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
12
+ config2py-0.1.34.dist-info/METADATA,sha256=iy8k91WeXwgGBoMCLcovds5WdIKmcqyRi5QACQ6Gi5s,14559
13
+ config2py-0.1.34.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
14
+ config2py-0.1.34.dist-info/top_level.txt,sha256=DFnlOIKMIGWQRROr3voJFhWFViHaWgTTeWZjC5YC9QQ,10
15
+ config2py-0.1.34.dist-info/RECORD,,