Skip to main content

Console printer with linenumbers, stacktraces, logging, conversions and coloring..

Project description

Console printer with linenumbers, stacktraces, logging, conversions and coloring.

Active8 BV
Active8 (05-03-15)
license: GNU-GPL2

.. figure:: res/consoleprinter.gif
   :alt: animation

   animation

example

Add a method call to console somewhere in your code, for example

console(os, print_stack=True, color="red")

.. figure:: res/code.png
   :alt: code

   code

It will give a stacktrace in the terminal

tterminal

tterminal

If the printer detects an object it will try to do a dir an give the layout with values

class MyObject(object):
    """
    MyObject
    """
    m_float = 8.0
    m_string = "hello"
    m_int = 8

    @staticmethod
    def foo():
        """
        foo
        """
        pass

    def __str__(self):
        """
        __str__
        """
        return "My Little Object"

mo = MyObject()
console(mo)

.. figure:: res/object.png
   :alt: object

   object
0.17 | arguments/__init__.py", line 957 (print_commandline_help) | <arguments.Arguments.print_commandline_help.<locals.MyObject object at 0x1034026d8>: My Little Object
     | MyObject                          type                           value
     | ------------------------------------------------------------------------------------------
     | foo                               function
     | m_float                           float                          8.0
     | m_int                             int                            8
     | m_string                          str                            hello

install

pip install consoleprinter

contains

Utility functions for working with commandline applications. Logging Printing Exception parsing Stacktracing Object reflection printing

usage

from consoleprinter import console

colors = ['black', 'blue', 'cyan', 'default', 'green', 'grey', 'magenta', 'orange', 'red', 'white', 'yellow']

for color in colors:
    console(color, color=color)

PyCharm

Console detects when run in PyCharm or Intellij, and adds links to the orinating line

if len(suite._tests) == 0:
    console_warning("Can't find tests, looked in test*.py")

`bash 2.48 | unittester.py:85 | == | Can't find tests, looked in test*.py | File "/Users/rabshakeh/workspace/unittester/unittester/unittester.py", line 85 (run_unit_test) | ==

Reflection

with zipfile.ZipFile(zippath) as zf:
    for member in zf.infolist():
        console(member)

.. figure:: res/Screen%20Shot%202015-03-17%20at%2017.45.50.png
   :alt: console

   console

Project details


Download files

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

Source Distribution

consoleprinter-32.tar.gz (16.3 kB view details)

Uploaded Source

File details

Details for the file consoleprinter-32.tar.gz.

File metadata

  • Download URL: consoleprinter-32.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for consoleprinter-32.tar.gz
Algorithm Hash digest
SHA256 9c61d05d03bc04ecacc7fbe6dc3ea09152abbd80f9fd08a785472006685cdc86
MD5 d62da9766ba83d5c9eb3e5f2f8752f91
BLAKE2b-256 22ed7bf6e5f4da3ea0f27ce026bb35ae9181ec16cae31318c3a1290336f5b004

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page