Skip to main content

a personal, opinionated python app initializer

Project description

mswappinit

This package is expected to only be used by @mwartell for personal development projects. I've published it only after copying it into my third new project and figured an import would be easier. Others are certainly welcome to use it, but I'd be surprised.

This library provides three application bootstrap utilities

  1. project - a configuration dotenv loader that makes nice parameter accessors
  2. log - a logger that is pleasing to the author
  3. quick_db - a pickledb instance for quick and dirty persistence

project

dotenv is used to load environment variables from a file named .env these could be something like: AWS_PROFILE=cluster and these will all be loaded into the environment as expected.

this module provides convenience attribute access to project specific log variables that are loaded from the dotenv file. A PROJECT_NAME must be defined and then all other variables of the form {PROJECT_NAME}_{VAR} can be accessed as attributes of the project object.

For example, if the PROJECT_NAME is "rag" and the dotenv file contains RAG_DATA=/path/to/data then the value of project.data will be the Path object /path/to/data.

For convenience, the values are upcast to the most likely type. For example, if the value is "true" or "false" it will be converted to a boolean. If the value is a number it will be converted to an int or float. If the value is a

log

Using from mswappinit import log creates a development simple logger with log.debug, log.info and so on. Logs only go to stderr.

quick_db

If quick_db is imported, a [pickleDB][https://patx.github.io/pickledb/] instance will be created in project.data. This is a json backed key-value store. Writes should use the context manager:

from mswappinit.quick_db import quick_db
with quick_db:
    db.set("Cyclopedidae", ["Palaeomyrmidon", "Cyclopes didactylus"])

which ensures a quick_db.save() when the context exits.

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

mswappinit-2025.4.25.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

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

mswappinit-2025.4.25-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file mswappinit-2025.4.25.tar.gz.

File metadata

  • Download URL: mswappinit-2025.4.25.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.14

File hashes

Hashes for mswappinit-2025.4.25.tar.gz
Algorithm Hash digest
SHA256 6ac426441e8d4055489ad5449c61fb6fe8777f0186e4382d72474d51bf22b34b
MD5 37eec39550a5fb867d5c8ee420b66821
BLAKE2b-256 a64eb07aae44b8dfe451cc294bc9e8240cc09009760c360e83301718af0bdfb8

See more details on using hashes here.

File details

Details for the file mswappinit-2025.4.25-py3-none-any.whl.

File metadata

File hashes

Hashes for mswappinit-2025.4.25-py3-none-any.whl
Algorithm Hash digest
SHA256 85ecd54f638a9b84f2c72b822a4cc17c919e6410dbd4da83142992e77c2d9482
MD5 7efb50735373d6e3885c61b81ddf1297
BLAKE2b-256 884545b0f2c7b9ea4ed04020ef21b5107153ba4cef5c135e91ce5228025b268a

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