Skip to main content

Basic Python utilities

Reason this release was yanked:

Superseded

Project description

Latest release: 0.2.0-dev8 (NOT YET RELEASED)

lockss-pybasic provides basic utilities for various LOCKSS projects written in Python.

Modules

lockss.pybasic.cliutil

Command line utilities.

  • BaseCli is a base class for command line interfaces that uses pydantic-argparse to define arguments and subcommands, and rich-argparse to display help messages. For each command x-y-z induced by a pydantic-argparse field named x_y_z deriving from BaseModel , the dispatch() method expects a method named _x_y_z.

  • StringCommand provides a pydantic-argparse way to define a subcommand whose only purpose is printing a string, with COPYRIGHT_DESCRIPTION, LICENSE_DESCRIPTION and VERSION_DESCRIPTION constants provided for convenience. Example:

    class MyCliModel(BaseModel):
        copyright: Optional[StringCommand.type(my_copyright_string)] = Field(description=COPYRIGHT_DESCRIPTION)
  • at_most_one_from_enum and get_from_enum provide a facility for defining a pydantic-argparse model that defines one command line option per constant of an Enum, using an enum keyword argument in the Field definition. Example:

    class Orientation(Enum):
        horizontal = 1
        vertical = 2
        diagonal = 3
    
    DEFAULT_ORIENTATION = Orientation.horizontal
    
    class MyCliModel(BaseModel):
        diagonal: Optional[bool] = Field(False, description='display diagonally', enum=Orientation)
        horizontal: Optional[bool] = Field(False, description='display horizontally', enum=Orientation)
        unrelated: Optional[bool] = Field(...)
        vertical: Optional[bool] = Field(False, description='display vertically', enum=Orientation)
    
        @root_validator
        def _at_most_one_orientation(cls, values):
            return at_most_one_from_enum(cls, values, Orientation)
    
        def get_orientation(self) -> Orientation:
            return get_from_enum(self, Orientation, DEFAULT_ORIENTATION)
lockss.pybasic.errorutil

Error and exception utilities.

  • InternalError is a no-arg subclass of RuntimeError.

lockss.pybasic.fileutil

File and path utilities.

  • file_lines returns the non-empty lines of a file stripped of comments that begin with # and run to the end of a line.

  • path takes a string or PurePath and returns a Path for which Path.expanduser() and Path.resolve() have been called.

lockss.pybasic.outpututil

Utilities to work with tabulate.

  • OutputFormat is an Enum of all the output formats from tabulate.tabulate_formats.

  • OutputFormatOptions defines a pydantic-argparse model for setting an output format from OutputFormat.

Release Notes

See CHANGELOG.rst.

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

lockss_pybasic-0.2.0.dev8.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

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

lockss_pybasic-0.2.0.dev8-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

Details for the file lockss_pybasic-0.2.0.dev8.tar.gz.

File metadata

  • Download URL: lockss_pybasic-0.2.0.dev8.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.13.11 Linux/6.18.2-arch2-1

File hashes

Hashes for lockss_pybasic-0.2.0.dev8.tar.gz
Algorithm Hash digest
SHA256 d8c308452906c6024dc4852222a0e4bb851a5d01fb7060b4220f27b956af2cb2
MD5 da37411034ff7c8f1a35873ce8931b73
BLAKE2b-256 264d03ccd6640f61139c16e727d9ca4fb2ba054e0d1ef5d94d46188d54750b87

See more details on using hashes here.

File details

Details for the file lockss_pybasic-0.2.0.dev8-py3-none-any.whl.

File metadata

  • Download URL: lockss_pybasic-0.2.0.dev8-py3-none-any.whl
  • Upload date:
  • Size: 16.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.13.11 Linux/6.18.2-arch2-1

File hashes

Hashes for lockss_pybasic-0.2.0.dev8-py3-none-any.whl
Algorithm Hash digest
SHA256 53ec5123be1e86c5d781450bc79a40bdf37be2e7ce60c4fa6bd6a6f9d6f8444a
MD5 60e9b3d5bd9cff51c8d8867eed80f651
BLAKE2b-256 e2ac89861e858e0552f14140546363bfc31eb2409468855d042daa1e14c42d44

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