Convenience tool: wrapper around regular/gzip files, Logger, text colors
Project description
Convenience
Tools for everyday use.
Source and install files are available under BSD License here: https://gitlab.com/sylvainraybaud/convenience
This package HAS NOT been tested with Python 2.
API
-
xopen: a wrapper aroundopenandgzip.openreturning anXFileobject, which is a wrapper aroundFileandgzip.GzipFile.XFileimplements methodsopen,close,read,readline,readlines,writewith the same parameters asFilemethods. It also implements__iter__and__next__to make it iterable and__enter__and__exit__to make it usable inwithstatements. Files whose names end with .gz are treated as gzip files, all other files are treated as uncompressed files. -
Logger: a wrapper aroundloggingmodule. ALoggerobject is intialized with averbosityparameter which is translated into aloggingvalue (WARNING,INFOorDEBUG). It implementsdebug,info,warninganderrormethods. They all take a string as first argument argument.errortakes an extra argument,code. When called,errorprint its first parameter then callsexit(code). -
header, blue, green, yellow, orange, red, bold, underline: apply decoration to string (seeexample.py)
Using
A good example being worth a thousand words, please see example.py
Installing
pip install convenience
TODO
- Use magic number instead of file extension to detected gzipped files, when applicable.
- Handle more compression format.
- Double check handling of various text encodings.
- Python 2 compatibility.
- Add more magic.
Contributing
Please make a pull request on gitlab. You can mail me at
first_name [dot] family_name [at] crans [dot] org
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file convenience-0.2.tar.gz.
File metadata
- Download URL: convenience-0.2.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7448f0ef2ccc8d19f5433389aca948bcb4f945c28ba666cb3da51bbac4715d6a
|
|
| MD5 |
4e7adfdcdd7d7374293900b1fefb1d6c
|
|
| BLAKE2b-256 |
59722c21786fb34ea2cd9143687c965480527bc13f56ce22c597695480ee5a4d
|
File details
Details for the file convenience-0.2-py3-none-any.whl.
File metadata
- Download URL: convenience-0.2-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ea89dd6d3034ca594a09f6a25da51c7fcc5d3d0c6756b5ff5be963eba281c45
|
|
| MD5 |
668f3710f5a16136ba8ede9a25de462f
|
|
| BLAKE2b-256 |
2a9f6bc4fc10ea93d4b4f36793bd3e925453361d7423b26866213ddeb0b77bf7
|