diff options
| author | CoprDistGit <infra@openeuler.org> | 2023-05-05 06:33:25 +0000 |
|---|---|---|
| committer | CoprDistGit <infra@openeuler.org> | 2023-05-05 06:33:25 +0000 |
| commit | 9dc6f19c76a30af26a9b7df614ca25c89b7c4e0f (patch) | |
| tree | 860d7329fb2dcb869d8267136b6bb407704af30c /python-config-env.spec | |
| parent | c1b71a1eb0e04d6845be9b671ed7088dcb37526d (diff) | |
automatic import of python-config-envopeneuler20.03
Diffstat (limited to 'python-config-env.spec')
| -rw-r--r-- | python-config-env.spec | 360 |
1 files changed, 360 insertions, 0 deletions
diff --git a/python-config-env.spec b/python-config-env.spec new file mode 100644 index 0000000..51b69f4 --- /dev/null +++ b/python-config-env.spec @@ -0,0 +1,360 @@ +%global _empty_manifest_terminate_build 0 +Name: python-config-env +Version: 0.0.19 +Release: 1 +Summary: Manage enviroment variables +License: MIT License +URL: https://github.com/raslanribeiro/config_env +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/12/17/beb20010a1799e1be22c6fa4a9a0896a8407f670c2af19729c294aef52dd/config_env-0.0.19.tar.gz +BuildArch: noarch + + +%description +# About + +Package to manage environment variables similar to npm config from nodejs + +## Start + +```bash +pip install config_env +mkdir configenv +vi configenv/default.json +``` + +```json +// default.json +{ + // Customer module configs + "Customer": { + "dbConfig": { + "host": "localhost", + "port": 5984, + "dbName": "customers" + }, + "credit": { + "initialLimit": 100, + // Set low for development + "initialDays": 1 + } + } +} +``` + +```bash +vi configenv/production.json +``` + +```json +{ + "Customer": { + "dbConfig": { + "host": "prod-db-server" + }, + "credit": { + "initialDays": 30 + } + } +} +``` + +And if is necessary to hide secret values, it is recommended to use custom_environment_varibles.json to get environment variables: + +```bash +vi configenv/custom_environment_varibles.json +``` + +```json +{ + "Customer": { + "dbConfig": { + "user": "MY_USERNAME", + "password": "MY_PASSWORD" + } + } +} +``` + +Values preference order: + +- custom_environment_varibles -> production -> default + +If custom_environment_varibles.json file does not exist or do not contain some key:value, it will come from produciton.json. + +If producion.json file does not exist or do not contain some key:value, it will come from default.json. + +## Using config_env + +The name of the environment variable PYTHON_ENV must be the same as your json file created. +If PYTHON_ENV is not defined, the values defined in default.json will be used. + +Example: + +```bash +export PYTHON_ENV=production +``` + +```python +# app.py +from config_env import ConfigEnv + +config = ConfigEnv() + +customer_host = config.get("Customer.dbConfig.host") + +customer_credit = config.get("Customer.credit") +``` + + + + +%package -n python3-config-env +Summary: Manage enviroment variables +Provides: python-config-env +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-config-env +# About + +Package to manage environment variables similar to npm config from nodejs + +## Start + +```bash +pip install config_env +mkdir configenv +vi configenv/default.json +``` + +```json +// default.json +{ + // Customer module configs + "Customer": { + "dbConfig": { + "host": "localhost", + "port": 5984, + "dbName": "customers" + }, + "credit": { + "initialLimit": 100, + // Set low for development + "initialDays": 1 + } + } +} +``` + +```bash +vi configenv/production.json +``` + +```json +{ + "Customer": { + "dbConfig": { + "host": "prod-db-server" + }, + "credit": { + "initialDays": 30 + } + } +} +``` + +And if is necessary to hide secret values, it is recommended to use custom_environment_varibles.json to get environment variables: + +```bash +vi configenv/custom_environment_varibles.json +``` + +```json +{ + "Customer": { + "dbConfig": { + "user": "MY_USERNAME", + "password": "MY_PASSWORD" + } + } +} +``` + +Values preference order: + +- custom_environment_varibles -> production -> default + +If custom_environment_varibles.json file does not exist or do not contain some key:value, it will come from produciton.json. + +If producion.json file does not exist or do not contain some key:value, it will come from default.json. + +## Using config_env + +The name of the environment variable PYTHON_ENV must be the same as your json file created. +If PYTHON_ENV is not defined, the values defined in default.json will be used. + +Example: + +```bash +export PYTHON_ENV=production +``` + +```python +# app.py +from config_env import ConfigEnv + +config = ConfigEnv() + +customer_host = config.get("Customer.dbConfig.host") + +customer_credit = config.get("Customer.credit") +``` + + + + +%package help +Summary: Development documents and examples for config-env +Provides: python3-config-env-doc +%description help +# About + +Package to manage environment variables similar to npm config from nodejs + +## Start + +```bash +pip install config_env +mkdir configenv +vi configenv/default.json +``` + +```json +// default.json +{ + // Customer module configs + "Customer": { + "dbConfig": { + "host": "localhost", + "port": 5984, + "dbName": "customers" + }, + "credit": { + "initialLimit": 100, + // Set low for development + "initialDays": 1 + } + } +} +``` + +```bash +vi configenv/production.json +``` + +```json +{ + "Customer": { + "dbConfig": { + "host": "prod-db-server" + }, + "credit": { + "initialDays": 30 + } + } +} +``` + +And if is necessary to hide secret values, it is recommended to use custom_environment_varibles.json to get environment variables: + +```bash +vi configenv/custom_environment_varibles.json +``` + +```json +{ + "Customer": { + "dbConfig": { + "user": "MY_USERNAME", + "password": "MY_PASSWORD" + } + } +} +``` + +Values preference order: + +- custom_environment_varibles -> production -> default + +If custom_environment_varibles.json file does not exist or do not contain some key:value, it will come from produciton.json. + +If producion.json file does not exist or do not contain some key:value, it will come from default.json. + +## Using config_env + +The name of the environment variable PYTHON_ENV must be the same as your json file created. +If PYTHON_ENV is not defined, the values defined in default.json will be used. + +Example: + +```bash +export PYTHON_ENV=production +``` + +```python +# app.py +from config_env import ConfigEnv + +config = ConfigEnv() + +customer_host = config.get("Customer.dbConfig.host") + +customer_credit = config.get("Customer.credit") +``` + + + + +%prep +%autosetup -n config-env-0.0.19 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-config-env -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Fri May 05 2023 Python_Bot <Python_Bot@openeuler.org> - 0.0.19-1 +- Package Spec generated |
