General-purpose Python utilities (datetime, text, patterns)
Project description
python-technical-primitives
General-purpose Python utilities (datetime, text, patterns).
Installation
pip install python-technical-primitives
Usage
Datetime Utilities
from python_technical_primitives.datetime import utc_now, add_days, is_expired
now = utc_now()
future = add_days(now, 7)
expired = is_expired(now) # False
Text Utilities
from python_technical_primitives.text import to_snake_case, sanitize_filename
snake = to_snake_case("HelloWorld") # "hello_world"
safe = sanitize_filename("my file?.txt") # "my_file.txt"
Specification Pattern
from python_technical_primitives.patterns import Specification
class AdultSpec(Specification[User]):
description = "User must be 18+"
def is_satisfied_by(self, user):
return user.age >= 18
class VerifiedSpec(Specification[User]):
description = "User must be verified"
def is_satisfied_by(self, user):
return user.verified
# Combine specifications
spec = AdultSpec() & VerifiedSpec()
if spec(user):
print("User is adult and verified")
else:
print(f"Errors: {spec.errors}")
Features
- ✅ Zero dependencies
- ✅ Framework-agnostic
- ✅ Type-safe
- ✅ Well-tested utilities
License
MIT
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_technical_primitives-0.1.0.tar.gz.
File metadata
- Download URL: python_technical_primitives-0.1.0.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c333450c9a39363a32e5833bfd8e2056ffba305aa63b61533a4ac7cf718826d1
|
|
| MD5 |
891ba636e71dcd1afb5951eba207abd6
|
|
| BLAKE2b-256 |
a40709b88fa62a5f75abe02a87d9f6c135318cd0efebaccf44bd7792abfee629
|
File details
Details for the file python_technical_primitives-0.1.0-py3-none-any.whl.
File metadata
- Download URL: python_technical_primitives-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3837461c53cd6c75144dc532dd04ec5655c1aa5ac34c142230928bc66498fc3
|
|
| MD5 |
971905d1b6c57e1fc4b76c3686f8d01d
|
|
| BLAKE2b-256 |
d9042f8d4d4a8daf111716bb10bff00184c5d2bf0478067eaca40faf48075986
|