Skip to main content

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


Download files

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

Source Distribution

python_technical_primitives-0.1.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

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

python_technical_primitives-0.1.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file python_technical_primitives-0.1.0.tar.gz.

File metadata

File hashes

Hashes for python_technical_primitives-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c333450c9a39363a32e5833bfd8e2056ffba305aa63b61533a4ac7cf718826d1
MD5 891ba636e71dcd1afb5951eba207abd6
BLAKE2b-256 a40709b88fa62a5f75abe02a87d9f6c135318cd0efebaccf44bd7792abfee629

See more details on using hashes here.

File details

Details for the file python_technical_primitives-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for python_technical_primitives-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f3837461c53cd6c75144dc532dd04ec5655c1aa5ac34c142230928bc66498fc3
MD5 971905d1b6c57e1fc4b76c3686f8d01d
BLAKE2b-256 d9042f8d4d4a8daf111716bb10bff00184c5d2bf0478067eaca40faf48075986

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