Skip to main content

A Python package containing a small set of utility functions not found in Python's standard library. It is lightweight, written in pure Python, and has no dependencies.

Project description

Lint and Test

Orval (beta)

A Python package containing a small set of utility functions not found in Python's standard library. It is lightweight, written in pure Python, and has no dependencies.

Why is it named orval? Because other utility names are boring and it's a tasty Belgian beer 🤘❤️

🚀 Using

To install this package, run:

pip install orval

String utils

from orval import kebab_case
kebab_case("Great Scott")
# Output: great-scott
kebab_case("Gréat Scött")
# Output: gréat-scött
# Slightly different from kebab_case. It does not allow Unicode characters.
# Slugify is well-suited for URL paths or infrastructure resource names (e.g., database names).
from orval import slugify
slugify("Great scott !! 🤘")
# Output: great-scott
slugify("Gréat scött !! 🤘")
# Output: great-scott
from orval import camel_case
camel_case(" Great scott ")
# Output: greatScott
from orval import snake_case
snake_case(" Great  Scott ")
# Output: great_scott
# Train-Case is well-suited for HTTP headers.
from orval import train_case
train_case(" content type ")
# Output: Content-Type

Array utils

from orval import chunkify
chunkify([1, 2, 3, 4, 5, 6], 2)
# Output: [[1, 2], [3, 4], [5, 6]]
from orval import flatten
list(flatten([[1, 2], [3, [4]]]))
# Output: [1, 2, 3, 4]
list(flatten([[1, 2], [3, [4]]], depth=1))
# Output: [1, 2, 3, [4]]
list(flatten([{1, 2}, [{3}, (4,)]]))
# Output: [1, 2, 3, 4]

Misc utils

# Hash any Python object.
from orval import hashify
hashify("great scott")
# Output: 6617ae826b0b76ba9f3a568a2bbf6c67aec8f575eec69badaf7110091d3f5cc6
hashify({"great": "scott"})
# Output: 1d63b966aa065f76392c3e4a7caa7b1bfce39c889e5faf0df0198b9ff5d0f434
def marty():
    return "McFly"
hashify(marty)
# Output: f2f21c93c543f023db0ab78ded26bbc5dabb59bb65b0b458b503cdcb0c3389e4
from orval import pretty_bytes
pretty_bytes(1000)
# Output: 1.00 KB (The "human" decimal format, using base 1000)
pretty_bytes(1000, "bs")
# Output: 1000.00 B (Binary format, using base 1024)
pretty_bytes(20000000, "dl", precision=0)
# Output: 20 Megabytes
pretty_bytes(20000000, "dl", precision=0)
# Output: 19 Mebibytes

See all available functions in __init__.py.

🧑‍💻 Contributing

Prerequisites
1. Install Docker
  1. Go to Docker, download and install docker.
  2. Configure Docker to use the BuildKit build system. On macOS and Windows, BuildKit is enabled by default in Docker Desktop.
2. Install VS Code

Go to VS Code, download and install VS Code.

1. Open DevContainer with VS Code

Open this repository with VS Code, and run Ctrl/⌘ + + PDev Containers: Reopen in Container.

The following commands can be used inside a DevContainer.

2. Run linters

poe lint

3. Run tests

poe test

4. Update poetry lock file

poetry lock --no-update

See how to develop with PyCharm or any other IDE.


️⚡️ Scaffolded with Poetry Copier.
🛠️ Open an issue if you have any questions or suggestions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

orval-0.0.8.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.

orval-0.0.8-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file orval-0.0.8.tar.gz.

File metadata

  • Download URL: orval-0.0.8.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.13.0 Linux/6.5.0-1025-azure

File hashes

Hashes for orval-0.0.8.tar.gz
Algorithm Hash digest
SHA256 69e99f40f052750dfd75bcb4f3a333b7e30c5e9b3eeb346f4f1d1aa2275154b0
MD5 485df05090500abcd8bd8ff7124ba16b
BLAKE2b-256 02a7b7db8ead5232fb978849640ac98f3fd65e935261511f92a5eb03ed3d1507

See more details on using hashes here.

File details

Details for the file orval-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: orval-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.13.0 Linux/6.5.0-1025-azure

File hashes

Hashes for orval-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 9900537b65fc409d88c59093367f040cef3839daab948fd9b631817ba3a1b640
MD5 2704a3974897b654a2c104d089eb8173
BLAKE2b-256 058eec5457a2a3ad37d1e003d67320f89c7dc299229614c77b0c8f6bfd7995a3

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