My friendly library base class - for Python.
Project description
mybase
My friendly library base class - for Python.
Introduction
One in general tend to need a library specific base class, but creating one for every new library with some common logger customization means redundant work every time. This library base class right now don't do much now beside setting up a default logger, but keeps library code a bit cleaner.
NOTE: Possibly should support being used as a mixin (e.g. @mybase.mixin
) optionally, but not yet implemented.
Install
Install using pip:
$ pip install mybase
Use
Very basic example:
from mybase import Base
class Foo(Base):
def hello():
self.logger.log('hello from instance: `{0}`'.format(self))
foo = Foo()
# logs using default logger - with colors unless disabled via `COLORS` / `LOGGER_COLORS` env variables
foo.hello()
foo.logger.log('hello world 1')
print(foo.name)
print(repr(foo))
print(str(foo))
import logging
foo2 = Foo(logger = logging.get_logger('custom'))
# logs using custom logger
foo.hello()
foo.logger.log('hello world 2')
foo3 = Foo(logger = False)
# logs nothing
foo.hello()
foo.logger.log('hello world 3')
Test
Clone down source code:
$ make install
Run colorful tests, with only native environment (dependency sandboxing up to you):
$ make test
Run less colorful tests, with multi-environment (using tox):
$ make test-tox
Related
mybad
- "My error base class - for Python"
About
This project was mainly initiated - in lack of solid existing alternatives - to be used at our work at Markable.ai to have common code conventions between various programming environments where Python (research, CV, AI) is heavily used.
License
Released under the MIT license.
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
File details
Details for the file mybase-0.1.1.tar.gz
.
File metadata
- Download URL: mybase-0.1.1.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.20.1 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06d3fb155a5e4be50bfb56c9de1efce6c1785aa2bf15f1fb2b28a144e3fd9ca3 |
|
MD5 | 78d475a6ecc2aaed8a3913e13454d5fb |
|
BLAKE2b-256 | bc9adde83f4604d1e3922348c4f3d3b6553fc996f6107a70e0365cddcf477318 |
File details
Details for the file mybase-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: mybase-0.1.1-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.20.1 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49983c79fbabffcb4b1a4905ad6832a0b03313abb653ffd3ad125b1498a0ef48 |
|
MD5 | 6a0ea8c5c7785fd9fb85542a75f447fe |
|
BLAKE2b-256 | 50758a5726df672fe34f4e8e65db8b84e8df528005b949be4585e39525af8c82 |