Skip to main content

Arg Cat Package

This is a package for read params from args and env.

How to Use

argcat.add_key("env")

This will find args -e or --env, or find environment ENV.

  • Only read arg: argcat.from_arg()
  • Only read environment: argcat.from_environ()
  • Read both arg and environment: argcat.from_arg_and_environ()
  • Remove arg: argcat.remove("env")

Example

from arg_cat import ArgCat
argcat = ArgCat()
argcat.add_key("env")
argcat.add_key("release", is_a_bool=True)
argcat.add_key("some_path", is_a_path=True)
argcat.from_arg_and_environ(environ_override_all=False)
print(f'env: {argcat.get_string("env")}')
print(f'release: {argcat.get_bool("release")}')
print(f'some_path: {argcat.get_string("some_path")}')
  • This example will get 3 params, env, release and some_path.
  • ArgCat will find -e or --env in args for env.
  • ArgCat will find -r or --release in args for release.
  • ArgCat will find -s or --some_path in args for some_path.
  • ArgCat will find ENV in environment for env.
  • ArgCat will find RELEASE in environment for release.
  • ArgCat will find SOME_PATH in environment for some_path.
  • from_arg_and_environ will using environment first, then using the args value to override those values. Sometimes, you may want to use environment value to override the args value, you should let environ_override_all to be Ture. environ_override_all default value is False.
  • Running this will be like: python3 demo.py --env dev -r -s ./this/is/path

Situation 1

environ_override_all=False

Environment:

ENV=this is from env
RELEASE=False

Args:

--env "from arg" -s ./hello

Result:

env: from arg
release: False
some_path: YOUR_WORK_PATH/./hello

Situation 2

environ_override_all=True

Environment:

ENV=this is from env
RELEASE=False

Args:

--env "from arg" -s ./hello

Result:

env: this is from env
release: False
some_path: YOUR_WORK_PATH/./hello

Sync File

Default, we using ./params.json file to be the params file. sync_from_file will remove all of exist values, and load those params json file's values.

argcat = ArgCat(params_file='YOUR_CUSTOM_PARAMS_FILE.json')
argcat.sync_to_file()
argcat.sync_from_file()

Note for owner

Build

python -m build 

Release To Test

python3 -m twine upload --repository testpypi dist/*

Release To Release

python3 -m twine upload dist/*

Metadata

Release files for arg-cat 1.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for arg-cat 1.0.4
File Size Uploaded
arg_cat-1.0.4.tar.gz 4.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for arg-cat 1.0.4
File Interpreter ABI Platform
arg_cat-1.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 9.5 kB

Release files / arg_cat-1.0.4.tar.gz

Download URL arg_cat-1.0.4.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
1dd2158ac0fe1e5f8492a02024dadb331b27b3fc18e5cad9fee5c2b97d886b75
BLAKE2b-256 checksum
How to use checksums
989e3256eed75d597c09924de25b36a890e58b7b71f5c1942f9e8f9226c36589
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.2

Release files / arg_cat-1.0.4-py3-none-any.whl

Download URL arg_cat-1.0.4-py3-none-any.whl
Size 4.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2710fdc29641d219701277af81cd1a60ab546455858b85e751732b58873b5576
BLAKE2b-256 checksum
How to use checksums
77c6f65a406a67086250124223f0626b82b14680117a9c95c849a14bb9e0b692
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.2

Release history Release notifications | RSS feed

This release

1.0.4 This release

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page