Skip to main content

diogi

Diog means to laze in Welsh. This package is to help me do less.

Most of the functions and decorators included in the diog package could be easily implemented with a single line of obscure python but then I would have to implement (and test) them again and again.

I'd rather not. I'm lazy.

Functions

always_a_list(obj: any) -> list with alias aal takes any object and if it isn't a list already, it wraps it up in one. It is also available as @always_a_list decorator.

default_if_none(obj: any, default: any) -> any: with alias din acts as a null coalescence.

first_or_default(lst: list, default: any=None) -> any: with alias fod returns the first element of a list if there is at least one element, or the default value.

get_if_exists(obj: any, key: str, default: any=None) -> any with alias gie. attempts to get a property of a dictionary or an attribute of an object, and if it doesn't exist or is None the default value is returned.

list_is_optional(obj: any) -> any with alias lio takes any object and if it is a list with a single element then it returns just the element, otherwise the list is returned. It is also available as @list_is_optional decorator.

list_without_nones(lst: list) -> list with alias lwn returns copy of the list without any None values. It is also available as @list_without_nones decorator.

none_if_empty(obj: any) -> any with alias nie returns copy of the object unless it is an empty list or an empty directory

append_if_not_none(obj: any, value: any, key: str) -> any with alias ainn

get_if_exists(obj: any, key: str) -> any with alias gie

set_if_not_none(obj: any, value: any, key: str) -> any with alias sinn

Conventions

to_data sometimes the object needs to be converted to a simpler data representation of dicts and lists. In those cases my objects implement a public method as_data(self). The diog.conventions.to_data(obj: any) takes an object or a list of object, and reduces the input to data.

Development

This repository uses uv for environment and dependency management.

Install the project and development dependencies:

uv sync --group dev

Run the test suite:

uv run pytest

Build the source distribution and wheel:

uv build

To Publish

uv sync --group dev
uv run pytest
uv build

Metadata

Release files for diogi 0.1.2

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

Source distribution (sdist)

Source distribution for diogi 0.1.2
File Size Uploaded
diogi-0.1.2.tar.gz 5.4 kB Details

Built distribution (wheel)

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

Total release size: 10.7 kB

Release files / diogi-0.1.2.tar.gz

Download URL diogi-0.1.2.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
859600e101231e03d6d256e037a225c0ffccda3cea9ace4322f712cd59da2caa
BLAKE2b-256 checksum
How to use checksums
d8bb68504c6bc442807164c465985b351329598dcb35c1558d8935e0a03d1bef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 18, 2026.

Transparency log

Release files / diogi-0.1.2-py3-none-any.whl

Download URL diogi-0.1.2-py3-none-any.whl
Size 5.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
12aa722699c8b0a250adcdd94d9d7bd4bf2f5b90935f668fafceddd77deef327
BLAKE2b-256 checksum
How to use checksums
8b01bdb11dc957c4fc3569304537a15e36a14f68985bcb385969be638603e101
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 18, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

1 release file

0.0.9

1 release file

0.0.8

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

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