Utility programms
Project description
Library of darklab utility programms
contains:
Scripts:
A package built on top of argparse. intended usage to be a python version of makefile, for uniform command acceess to run tests/lints in dev env and CI
code example:
import darklab_utils as utils
class InputDataFactory(utils.AbstractInputDataFactory):
@staticmethod
def register_cli_arguments(argpase_reader: utils.ArgparseReader) -> utils.ArgparseReader:
return argpase_reader \
.add_argument("--cli_argument", type=str, default="example")
@staticmethod
def register_env_arguments(env_reader: utils.EnvReader) -> utils.EnvReader:
return env_reader.add_arguments(
env_argument1=env_reader["PWD"],
env_argument2=env_reader.get("NOT_EXISTING_VAR", "default_value"),
)
class MyScripts(utils.AbstractScripts):
input_data_factory = InputDataFactory
@utils.registered_action
def env_example(self):
self.shell(f"echo {self.globals.env_argument2}")
@utils.registered_action
def cli_example(self):
self.shell(f"echo {self.globals.cli_argument}")
@utils.registered_action
def cli_extra_arg_example(self):
args = self.globals.cli_reader \
.add_argument("--argument", type=int, default=456) \
.get_data()
self.shell(f"echo debug_{args.argument}")
if __name__=="__main__":
MyScripts().process()
# run with `python scripts.py cli_example`, `python scripts.py cli_extra_arg_example --argument=123`
Link to Pypi
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
darklab_utils-0.0.3.tar.gz
(18.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file darklab_utils-0.0.3.tar.gz.
File metadata
- Download URL: darklab_utils-0.0.3.tar.gz
- Upload date:
- Size: 18.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd4f016fb633ce1a1172789ea095aa80034b5616f2fe6906bc99542b1be63aa3
|
|
| MD5 |
14da387446b589f49ddde3ad2404acbd
|
|
| BLAKE2b-256 |
2053fb74e59c4d34359e9c18ad5e4a53993baec0e9cb7648932a195d476b5788
|
File details
Details for the file darklab_utils-0.0.3-py3-none-any.whl.
File metadata
- Download URL: darklab_utils-0.0.3-py3-none-any.whl
- Upload date:
- Size: 21.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
63731d606f8cd6754aae4ddbc32c3180fd4434fa2c2e585abc8ef18412fe7dbe
|
|
| MD5 |
024e22ab2085c69be610a9eef3ea2a89
|
|
| BLAKE2b-256 |
7c3b7a11011011d5f46f3a219891b95b0385f2dfc7863947dbcb73b6d889ac03
|