Code Monkey home page Code Monkey logo

pysanity's Introduction

pysanity

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)

Installation

pip install pysanity

Running tests

Tox is used to handle testing multiple python versions.

tox

pysanity's People

Contributors

akatrevorjay avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

trevorj

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.