ClickUtils
Extra utils for click library
Examples
Loading click groups and commands from filepath or directory
Directory structure
_ cwd
|_ __init__.py (contains code below)
|_ plugins/
|_ group_or_command_folder
|_ *groups (this folder must exists to find click groups or commands)
|_ __init__.py (any click groups or commands will be pulled from this location)
...
import os
import click
from clickutils import click_loader
@click.group()
@click.option('--verbose', '-v', type=bool, is_flag=True, default=False,
help='Print more verbose output')
def cli(verbose: bool):
'''click_plugins'''
click_loader.load(plugins_group, os.path.dirname(os.path.abspath(__file__)), verbose=verbose)
@click.group()
def plugins_group():
'''click_plugins test plugins'''
pass
cli.add_command(plugins_group, name='plugins')
if __name__ == '__main__':
cli()
Same example using decorator
import os
import click
from clickutils import click_loader
@click.group()
def cli(verbose: bool):
'''click_plugins'''
@click_loader.group(os.path.dirname(os.path.abspath(__file__)), name='plugins')
def plugins_group():
'''click_plugins test plugins'''
pass
cli.add_command(plugins_group)
if __name__ == '__main__':
cli()
Early example of ClickViewset
import click
from clickutils.viewsets import AbstractClickViewset, clickmixins
from clickutils.viewsets import AbstractClickViewset, clickmixins
class UserDictViewset(AbstractClickViewset):
Name = 'DictionaryViewset'
Version = '1.0.0'
Viewset = {'users': ['user1', 'user2', 'user3']}
commands = ('list', 'version', 'another_command', 'echo')
hidden_commands = ('echo', )
@clickmixins.command(name='another_command')
def another_command(self):
print('defined another user command that can interact with object (self) which contains Viewset attributes')
"""
overloading convert function in BaseClickViewset;
this is a custom way to add the Viewset into the command class attributes
"""
def convert(self):
if isinstance(self.Viewset, dict):
for key, value in self.Viewset.items():
setattr(self, key, value)
@UserDictViewset(name='test_command2')
def test_command_group2():
"""Test command2 plugin"""
pass
Metadata
Release files for clickutils 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| clickutils-0.1.6.tar.gz | 8.2 kB | Without provenance | Details for clickutils-0.1.6.tar.gz |
Release files / clickutils-0.1.6.tar.gz
| Download URL | clickutils-0.1.6.tar.gz |
|---|---|
| Size | 8.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
acd071c3204719a824c5c86bcce0db50a6f697cd9506bc2145fa5f744271328d
|
|
BLAKE2b-256 checksum How to use checksums |
e6ffa3c2d8698f314466b199a0345ec34d7dfcaaabe3293f8237ce673db03af4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.4
|
Security for clickutils 0.1.6
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.