diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c8ed32b --- /dev/null +++ b/.gitignore @@ -0,0 +1,107 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ + + +.idea/ \ No newline at end of file diff --git a/Pipfile b/Pipfile new file mode 100644 index 0000000..9534830 --- /dev/null +++ b/Pipfile @@ -0,0 +1,11 @@ +[[source]] +name = "pypi" +url = "https://pypi.org/simple" +verify_ssl = true + +[dev-packages] + +[packages] + +[requires] +python_version = "3.6" diff --git a/django_test_prettify/__init__.py b/django_test_prettify/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/django_test_prettify/colorize.py b/django_test_prettify/colorize.py new file mode 100644 index 0000000..e4b7d1d --- /dev/null +++ b/django_test_prettify/colorize.py @@ -0,0 +1,32 @@ +import inspect + + +RED = "\u001b[31m" +GREEN = "\u001b[32m" +YELLOW = "\u001b[33m" +BLUE = "\u001b[34m" +MAGENTA = "\u001b[35m" +WHITE = "\u001b[37m" +RESET = "\u001b[0m" + + +def colorize(color=WHITE): + def wrap(something): + if inspect.isclass(something): + _handle_class(something, color) + else: + _handle_function(something, color) + + return something + return wrap + + +def _handle_class(_class, color): + for _, v in _class.__dict__.items(): + _handle_function(v, color) + + +def _handle_function(_member, color): + if inspect.ismethod(_member) or inspect.isfunction(_member): + if _member.__doc__: + _member.__doc__ = f"{color}{_member.__doc__.strip()}{RESET}"