Skip to main content

clientwrapper (licensed under Apache 2.0)

Util class enabled CLI/dictionary syntax: allows separation of concerns between CLI and Python code.

installation

pip install clientwrapper

usage

overview

ClientWrapper is a class that allows you to define functions that can be run in both CLI and Python syntax.

run in CLI

Running as a CLI requires all functions with arguments to run in one combined function. The below command will not run as a CLI.

python3 -m yourmodule authenticate --arg1 value1 --arg2 value2
# self.attributes like authentication tokens are erased every time the CLI is run; combine your functions to avoid NullPointerExceptions
python3 -m yourmodule query --argument value # will not work: relying on any attributes in self

Below is an example of how to run as a CLI.

python3 -m yourmodule authenticate_and_query --arg1 value1 --arg2 value2 --argument value

usage example

Define your class here and inherit from ClientWrapper; combined function is required to run as a CLI.

class Impl(ClientWrapper):
    def __init__(self):
        super().__init__("Some API Requests")

    def login(self, username, password):
        print("login called with username: " + username + " and password: " + password)

    def getRequest(self, argument):
        print("getRequest called with argument: " + argument)

    def postRequest(self, **kwargs):
        print("postRequest called with arguments: " + str(kwargs))  

    def login_and_get_request_and_post_request(self, username, password, argument, **kwargs):
        self.login(username, password)
        self.getRequest(argument)
        self.postRequest(**kwargs)

test in CLI

Use CLI syntax to run your functions.

python3 -m yourmodule login_and_get_request_and_post_request --username myusername --password mypassword --argument [1, 2] --arg1 value1 --arg2 value2

test in Python

Use argparse-like syntax in Python for testing purposes. Note that Clientwrapper takes strings, ints, lists, tuples, and dictionaries as arguments but containers must be passed as strings.

impl = Impl()
impl.run([
    'login_and_get_request_and_post_request --username myusername --password mypassword --argument "[1, 2]" --arg1 value1 --arg2 value2'.split()
])
>>> login called with username: myusername and password: mypassword
>>> getRequest called with argument: [1, 2]
>>> postRequest called with arguments: {'arg1': 'value1', 'arg2': 'value2'}

test in CMD prompt as CLI

Your module will require a main.py in order to run as a CLI; here is a simple example.

from src.etc.package import Impl

def main():
    impl = Impl()
    impl.run()

if __name__ == '__main__':
    main()

Metadata

Release files for clientwrapper 1.0.1

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

Source distribution (sdist)

Source distribution for clientwrapper 1.0.1
File Size Uploaded Provenance
clientwrapper-1.0.1.tar.gz 9.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for clientwrapper 1.0.1
File Interpreter ABI Platform
clientwrapper-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 21.8 kB

Release files / clientwrapper-1.0.1.tar.gz

Download URL clientwrapper-1.0.1.tar.gz
Size 9.8 kB
Tags Source
SHA-256 checksum
How to use checksums
3bf3150b899e3f2dcc9c72cee4d9ca71b169058f36dc5d934013185aad7662be
BLAKE2b-256 checksum
How to use checksums
a95a570b61158b6080628ed8e9671526c506e9bb2325ddd34838f626b9b99726
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.6

Release files / clientwrapper-1.0.1-py3-none-any.whl

Download URL clientwrapper-1.0.1-py3-none-any.whl
Size 12.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0857a1ded3a653b23b1f9244a73a5be23759ef7373cac9cc92bc5529272e4622
BLAKE2b-256 checksum
How to use checksums
6fd3762e232ed6c33c98db05c03aa49f9f95fb08582dae076dc82ff0b2fa8db6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.6

Security for clientwrapper 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

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