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 Distribution

hwl_stdlib-1.1.0.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

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

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

Uploaded Python 3

File details

Details for the file hwl_stdlib-1.1.0.tar.gz.

File metadata

  • Download URL: hwl_stdlib-1.1.0.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for hwl_stdlib-1.1.0.tar.gz
Algorithm Hash digest
SHA256 b104d3bd203bde4eba1bf3e5775520980337b236badcba4d3f0d6f1bce27a238
MD5 d01f707f3387483af3e4651a86b60168
BLAKE2b-256 6e579add4cccfd2bd4e07b83316dae9e83d864fc04c2aa820d50e51a54618014

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hwl_stdlib-1.1.0-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-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4d60bea354aa2251583f9c3db8aec6f9a04ed895b831f13b9ca638a2d1ed5dbd
MD5 732cc41bf90070cc76df3f3a01c8b1a6
BLAKE2b-256 36e84043cfe6e3291b64cba1edf9502dd44b1529ec9e85b3ff14a53b7f6c18f0

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