Utilities

This is just internal stuff for now.

Declare

mdiocre.utils.declare(var_, type_)

A substitute for static type-checking.

Parameters
  • var – The contents to check.

  • type (class) – A class type to check for.

Color Checking

Really just a helper function for Logger.

mdiocre.utils.has_color()

Borrowed from the Django project.

Returns

True if the running system’s terminal supports color, and False otherwise.

Remove Outer Quotes

mdiocre.utils.remove_inner_outer_quotes(string)

Remove any quotes around the text, with additional checking

Parameters

string (string) – Text with quotes.

Returns

Text with removed quotes. Raises SyntaxError when there is no matching quotes.

Logger

class mdiocre.utils.Logger

A color-enabled logger object.

eprint(*args, level=0, severity='info', **kwargs)

Convenience function to print(), only that it outputs to stderr instead of stdout.

Parameters
  • level (int) – How much to indent

  • severity (str) –

    Severity of the log. These can be:

    • info : Default terminal color.

    • serious : Red.

    • warning : Yellow.

    • ok : Green.

Returns

None.

print(*args, level=0, severity='info', **kwargs)

Color and log enabled print function.

Parameters
  • level (int) – How much to indent

  • severity (str) –

    Severity of the log. These can be:

    • info : Default terminal color.

    • serious : Red.

    • warning : Yellow.

    • ok : Green.

Returns

None.