Skip to main content

A standard library used by me frequently. A gift from me, to me, by me.

Project description

stdlib

A standard library used by me frequently. A gift from me, to me, by me. 🎁

stdlib is my personal collection of Python functions, utilities, and snippets that I frequently use in my projects.

Features

Utility Library

This library provides a set of utility functions for common tasks such as date manipulation, random data generation, and validation.

help()

Prints a list of all available functions in the module.

get_countries()

Returns a list of countries in alphabetical order.

get_currencies()

Returns a list of currencies with their symbols.

get_payment_terms()

Returns a list of common payment terms.

get_shipping_metrics()

Returns a list of common shipping metrics.

get_current_timestamp(timezone="Europe/Amsterdam")

Returns the current timestamp in the specified timezone (default is Europe/Amsterdam) in ISO string format.

add_business_hours(start: datetime, hours: int) -> datetime

Adds business hours to a given datetime, excluding weekends.

get_user_timestamp(user_timezone)

Returns a datetime stamp based on the user's timezone.

generate_uuid()

Generates a unique UUID.

generate_hashed_password(password)

Generates a hashed version of the given password.

get_seasonal_message(today=None)

Generates a seasonal message based on the current date.

get_today_day()

Returns the current day of the week as a string.

validate_email(email: str) -> bool

Validates an email address using a regular expression.

get_weekday_number(date: datetime) -> int

Returns the day of the week as a number (Monday is 0, Sunday is 6).

get_first_day_of_month(year: int, month: int) -> date

Returns the first day of the specified month.

get_random_color() -> str

Generates and returns a random color in hexadecimal format.

is_weekend(date: datetime) -> bool

Returns True if the given date is a weekend (Saturday or Sunday), False otherwise.

generate_unique_filename(filename: str) -> str

Generates a unique filename using a UUID and the original file extension.

extract_domain_from_email(email: str) -> str

Extracts and returns the domain from an email address.

get_day_of_year(date: date) -> int

Returns the day of the year (1 to 365 or 366).

get_file_size(file_path: str) -> str

Returns the size of a file at the given path as a human-readable string.

generate_random_string(length: int = 8) -> str

Generates a random alphanumeric string of a specified length.

get_time_difference(start_time: datetime, end_time: datetime) -> timedelta

Returns the difference between two datetime objects as a timedelta.

convert_timezone(dt: datetime, from_tz: str, to_tz: str) -> datetime

Converts a datetime object from one timezone to another.

get_days_in_month(year: int, month: int) -> int

Returns the number of days in a specified month of a given year.

get_age(birthdate: date) -> int

Calculates the age based on the provided birthdate.

get_day_from_string(get_current_timestamp())

Returns the day of a given timestamp in the format of: 2025-04-23T14:47:45.437576+02:00

This format is being returned by get_current_timestamp() so best to use it together

Installation

You can install stdlib directly from your local repository and import it as 'import stdlib':

pip install hwl-stdlib

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

hwl_stdlib-0.0.4-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file hwl_stdlib-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: hwl_stdlib-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for hwl_stdlib-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 dc35aa00933679e0074b531ea29cf51988127a12775d4ae3fb5209ee1b1eff42
MD5 5a6261fb79979c89b90ef210acd5325b
BLAKE2b-256 3f83bf779165fef01de3a26f110d3f4bdc0d4f25c20c6190657204dfee286740

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