Dagwood
Dagwood is a Swiss Army knife for Python, a collection of small utilities that I find myself using over and over again. It's named after Dagwood Bumstead, the sandwich-loving husband of Blondie in the eponymous comic strip.
Why "Dagwood"? Because a.) I like sandwiches, and b.) the name was available on PyPI.
To install Dagwood, run:
pip install dagwood
Available Utilities
Logging
To quickly set up a logger:
import dagwood
logger = dagwood.assemble()
This will create a logger with default settings: log level set to INFO and log messages formatted as '%(asctime)s - %(levelname)s - %(message)s'. Logs will be written to a folder named logs.
You can customize the log folder, log file name, log level, and log format by passing optional parameters to assemble.
folder_name: The name of the folder to store log files (default:'logs')file_name: The name of the log file (default:None, which generates a log file with a timestamp)level: The log level (default:logging.INFO)format: The log format (default:'%(asctime)s - %(levelname)s - %(message)s')
logger = dagwood.assemble(folder_name='my_logs', file_name='app.log', level=logging.DEBUG, format='%(levelname)s - %(message)s')
HTTP Codes
An easy way to check the meaning of an HTTP status code:
from dagwood import http_codes
# Example of interpreting an HTTP code
CODE = 500
response = http_codes.interpret(CODE)
print(response.message) # 'Internal Server Error'
print(response.explanation) # 'The server has encountered a situation it does not know how to handle.'
# Checking the type of the response
types = http_codes.get_enums()
if response.type == types.SERVER_ERROR:
# Handle server error
pass
You can also retrieve the different types of HTTP responses:
types = http_codes.get_enums()
print(types) # ['Informational', 'Success', 'Redirection', 'Client Error', 'Server Error']
Contributing
Feel free to open an issue or submit a pull request.
To publish a new version to PyPI:
pip install twine # if you don't have it already
python setup.py sdist bdist_wheel # build the package
twine upload dist/* # upload to PyPI
Development
Running Tests
The test suite can be run using Python's built-in unittest framework.
Navigate to the tests directory and run:
python -m unittest test_dagwood.py
Or, if you're in the root directory:
python -m unittest tests/test_dagwood.py
Metadata
Release files for dagwood 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dagwood-2.0.0.tar.gz | 7.4 kB | Without provenance | Details for dagwood-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dagwood-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for dagwood-2.0.0-py3-none-any.whl |
Total release size: 16.1 kB
Release files / dagwood-2.0.0.tar.gz
| Download URL | dagwood-2.0.0.tar.gz |
|---|---|
| Size | 7.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a07f7c2141a6724c65d800e08064e6bb3259bcea20737eaf29426e219bdf85d4
|
|
BLAKE2b-256 checksum How to use checksums |
04486d32612436a356abb6d59a36dbfda8e9a0cce88388784898fb0c868e7d11
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.12
|
Release files / dagwood-2.0.0-py3-none-any.whl
| Download URL | dagwood-2.0.0-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
aa110b036f9dfe28bcf9e5e7519a8e0662437369d1c7f02a3b44e6c912251084
|
|
BLAKE2b-256 checksum How to use checksums |
c89b846b3da0210389e4771fa92171038d03bb78a6607fb3c4722af84e1607e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.12
|
Security for dagwood 2.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.