Skip to content

misc. utilities and imports for boilerplate reduction

License

Notifications You must be signed in to change notification settings

runsascoded/utz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

utz

("yoots"): imports and utilities for easy wildcard-importing + boilerplate-reduction

Install

pip install utz

Use

Import everything:

from utz import *

See __init__.py, which imports many of the modules below, as well as many standard-library methods and objects (via the stdlb package).

Features

Some noteworthy modules:

  • cd: "change directory" contextmanager
  • o: dict wrapper exposing keys as attrs (e.g.: o({'a':1}).a == 1)
  • process: subprocess wrappers; shell out to commands, parse output
  • docker: DSL for programmatically creating Dockerfiles (and building images from them)
  • ssh: SSH tunnel wrapped in a context manager
  • time: now()/today() helpers with convenient / no-nonsense ISO string serialization and UTC bias
  • bases: intstr codecs with improvements over standard base64 et al.
  • tmpdir: make temporary directories with a specific basename
  • context: contextmanager helpers, including ctxs for composing multiple context managers
  • escape: escaping split/join helpers
  • backoff: exponential-backoff utility
  • git: Git helpers, wrappers around GitPython
  • pnds: pandas imports and helpers
  • collections: collection/list helpers
  • plots: plotly helpers

auto-setup.py

utz/setup.py provides defaults for various setuptools.setup() params:

  • name: use parent directory name
  • version: parse from git tag (otherwise from git describe --tags)
  • author_{name,email}: infer from last commit
  • long_description: parse README.md (and set `long_description_content_type)
  • description: parse first <p> under opening <h1> from README.md
  • license: parse from LICENSE file (MIT and Apache v2 supported)

For an example, see gsmo==0.0.1 (and corresponding release).

This library also "self-hosts" using its own setup helper; see pyproject.toml:

[build-system]
requires = ["setuptools", "utz[setup]==0.4.2", "wheel"]
build-backend = "setuptools.build_meta"

and setup.py:

from utz.setup import setup

extras_require = {
    # …
}

# Various fields auto-populated from git, README.md, requirements.txt, …
setup(
    name="utz",
    version="0.8.0",
    extras_require=extras_require,
    url="https://github.com/runsascoded/utz",
    python_requires=">=3.10",
)

The setup helper can be installed via a pip "extra":

pip install utz[setup]

About

misc. utilities and imports for boilerplate reduction

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages