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 contains
code examples:
from types import SimpleNamespace
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 build(self, input_: SimpleNamespace):
self.shell(f"echo {input_.cli_argument}")
@utils.registered_action
def print(self, input_: SimpleNamespace):
self.shell(f"echo {input_.env_argument1}")
@utils.registered_action
def example(self, input_: SimpleNamespace):
args = input_.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 build`, `python scripts.py example --argument=123`
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.1.dev1.tar.gz
(16.5 kB
view hashes)
Built Distribution
Close
Hashes for darklab_utils-0.0.1.dev1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1960e2212713fa54932ba56f0b4036649782bc8f7e130d19ea713f86e401074b |
|
MD5 | 8d06458ab092077b219c58ce5f249b88 |
|
BLAKE2b-256 | c61440a41af918198574341b3009b51feaa4b7fdc67431ab4c632667bbc1e4b2 |