Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

Emulates sanity for other people's dirty ass non-pep compliant code via only the /dirtiest/ of means.

Project description

Emulates sanity for other people’s dirty ass non-pep compliant code via only the /dirtiest/ of means.

Tested with Python 2.7, 3.5.

Test Status Coverage Status Documentation Status

And that means?

Hi! I’m pysanity and I turn:

import logging
log = logging.getLogger(__name__)

Into the much less brain numbing:

from pysanity import logging
log = logging.get_logger(__name__)

All the while keeping your precious code completion working as expected thanks to a not grossly over-dynamic nature.

You’re welcome for my existence on PyPi.

Logging you say?

Hint: Try this out and stop accepting needless boilerplate in your code, stdlib or not:

import logging
import logging.config
import inspect

def _namespace_from_calling_context():
    Derive a namespace from the module containing the caller's caller.

    :return str: the fully qualified python name of a module.
    return inspect.currentframe().f_back.f_back.f_globals['__name__']

def get_logger(name=None):
    Gets a logger instance with sensible defaults according to caller context.

    :param str name: Logger name. Defaults to caller's `__name__`.
    :return logging.Logger: Logger instance
    if not name:
        name = _namespace_from_calling_context()

    return logging.getLogger(name)


pip install pysanity

Running tests

Tox is used to handle testing multiple python versions.


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pysanity, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size pysanity-0.0.1-py2-none-any.whl (8.0 kB) File type Wheel Python version 2.7 Upload date Hashes View
Filename, size pysanity-0.0.1.tar.gz (18.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page