sferriol-python 0.4.1__tar.gz → 0.5.0__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sferriol-python
3
- Version: 0.4.1
3
+ Version: 0.5.0
4
4
  Summary: python utilities
5
5
  Home-page: https://gitlab.in2p3.fr/sferriol-ip2i/sferriol-python
6
6
  Author: Sylvain Ferriol
@@ -10,6 +10,9 @@ Classifier: Operating System :: OS Independent
10
10
  Classifier: Programming Language :: Python :: 3
11
11
  Description-Content-Type: text/markdown
12
12
  License-File: LICENSE
13
+ Provides-Extra: dev
14
+ Requires-Dist: click; extra == "dev"
15
+ Requires-Dist: yapf; extra == "dev"
13
16
 
14
17
  # sferriol-python
15
18
 
@@ -18,6 +18,11 @@ packages = find_namespace:
18
18
  exclude = *.test
19
19
  include = sferriol.*
20
20
 
21
+ [options.extras_require]
22
+ dev =
23
+ click
24
+ yapf
25
+
21
26
  [egg_info]
22
27
  tag_build =
23
28
  tag_date = 0
@@ -0,0 +1,28 @@
1
+ import os
2
+ import tomllib
3
+
4
+
5
+ def load(default=None, os_env_prefix=None):
6
+ """
7
+ Return env dictionary loaded from, in order:
8
+ 1. a default dictionary
9
+ 2. a toml file where path is, in order, in default['env_file'] or in OS_ENV_PREFIX__ENV_FILE os env. variable
10
+ 3. os env. variables OS_ENV_PREFIX__K where K is each key in previous dictionary in uppercase
11
+ """
12
+ di = default.copy() if default else dict()
13
+ os_env_prefix = os_env_prefix.upper() + '__' if os_env_prefix else None
14
+
15
+ # from the env file
16
+ env_file = di.get('env_file', None)
17
+ if os_env_prefix:
18
+ env_file = os.getenv(os_env_prefix + 'ENV_FILE', env_file)
19
+ if env_file is not None:
20
+ with open(env_file, "rb") as f:
21
+ di.update(tomllib.load(f))
22
+
23
+ # from os env variables
24
+ if os_env_prefix:
25
+ for k in di.keys():
26
+ di[k] = os.getenv(os_env_prefix + str(k).upper(), di[k])
27
+
28
+ return di
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sferriol-python
3
- Version: 0.4.1
3
+ Version: 0.5.0
4
4
  Summary: python utilities
5
5
  Home-page: https://gitlab.in2p3.fr/sferriol-ip2i/sferriol-python
6
6
  Author: Sylvain Ferriol
@@ -10,6 +10,9 @@ Classifier: Operating System :: OS Independent
10
10
  Classifier: Programming Language :: Python :: 3
11
11
  Description-Content-Type: text/markdown
12
12
  License-File: LICENSE
13
+ Provides-Extra: dev
14
+ Requires-Dist: click; extra == "dev"
15
+ Requires-Dist: yapf; extra == "dev"
13
16
 
14
17
  # sferriol-python
15
18
 
@@ -4,6 +4,7 @@ pyproject.toml
4
4
  setup.cfg
5
5
  setup.py
6
6
  sferriol/python/__init__.py
7
+ sferriol/python/env.py
7
8
  sferriol/python/json.py
8
9
  sferriol/python/net.py
9
10
  sferriol/python/object.py
@@ -12,4 +13,5 @@ sferriol/python/dictionary/__init__.py
12
13
  sferriol_python.egg-info/PKG-INFO
13
14
  sferriol_python.egg-info/SOURCES.txt
14
15
  sferriol_python.egg-info/dependency_links.txt
16
+ sferriol_python.egg-info/requires.txt
15
17
  sferriol_python.egg-info/top_level.txt
@@ -0,0 +1,4 @@
1
+
2
+ [dev]
3
+ click
4
+ yapf
File without changes