Skip to main content

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 build(self):
        self.shell(f"echo {self.globals.cli_argument}")

    @utils.registered_action
    def print(self):
        self.shell(f"echo {self.globals.env_argument1}")

    @utils.registered_action
    def 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 build`, `python scripts.py example --argument=123`

Link to Pypi

https://pypi.org/project/darklab-utils/

Project details


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.dev3.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

darklab_utils-0.0.1.dev3-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file darklab_utils-0.0.1.dev3.tar.gz.

File metadata

  • Download URL: darklab_utils-0.0.1.dev3.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for darklab_utils-0.0.1.dev3.tar.gz
Algorithm Hash digest
SHA256 f378d5f80284f3f3fa14e8ae6760b2129d06de952d9a3701b8a733e1cc8feb39
MD5 bc251074094eb9a12985114233b75538
BLAKE2b-256 65cbc60afefb7e42d627f5f8fc43b063515050d17a87def5139a464a7db1ff56

See more details on using hashes here.

File details

Details for the file darklab_utils-0.0.1.dev3-py3-none-any.whl.

File metadata

File hashes

Hashes for darklab_utils-0.0.1.dev3-py3-none-any.whl
Algorithm Hash digest
SHA256 58cf4afa3231b6893e9852bc4482c922971f96fbba87fce91ab1ef854daf68dd
MD5 3d61ed841792ee1408a914738e40acdc
BLAKE2b-256 cde478ddbb9cd63c73443e87889267469331380307bd7a2c3660151b23caba79

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page