diff --git a/README.rst b/README.rst index a1a35b2..946ca21 100644 --- a/README.rst +++ b/README.rst @@ -3,10 +3,14 @@ README .. image:: https://travis-ci.org/Styria-Digital/django-unload.svg?branch=master :target: https://travis-ci.org/Styria-Digital/django-unload - + .. image:: https://coveralls.io/repos/github/Styria-Digital/django-unload/badge.svg?branch=master :target: https://coveralls.io/github/Styria-Digital/django-unload?branch=master +.. image:: https://img.shields.io/pypi/v/django-unload.svg + :target: https://pypi.python.org/pypi/django-unload + :alt: Version + Requirements ------------ @@ -16,6 +20,12 @@ Requirements * Tabulate +Installation +------------ +To install the package, type: + + ``$ pip install django-unload`` + Setup ----- @@ -35,6 +45,12 @@ Scan all template files in the project: ``$ python manage.py find_unnecessary_lo Scan all template files in the specified app: ``$ python manage.py find_unnecessary_loads --app ``. +**Warning** + +1. The assumption is that all your 3rd party packages located in the *INSTALLED_APPS* setting (e.g. django-debug-toolbar) are installed using *pip*. The plugin uses *pip* to differentiate the project's templates from the templates located in the installed apps; + +2. If you get a *TemplateSyntaxError*, the template in question is probably outdated and/or has not been used in a while; + Output ------ The output is sent to the console. Although all template files are scanned, only templates with issues and the issues in question are displayed. The issues are displayed in two tables: diff --git a/demo/app/templates/app/templates/something b/demo/app/templates/app/templates/something new file mode 100644 index 0000000..e69de29 diff --git a/setup.py b/setup.py index 13db8e5..d689fa5 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name='django-unload', - version='0.3.1', + version='0.3.2', url="https://github.com/Styria-Digital/django-unload", author='Styria Digital Services', description='Remove unused custom Django template tags and filters', diff --git a/unload/utils.py b/unload/utils.py index 25a73f6..960ce74 100644 --- a/unload/utils.py +++ b/unload/utils.py @@ -152,9 +152,10 @@ def get_template_files(template_dir): for dirpath, dirnames, filenames in os.walk(template_dir): for filename in filenames: filetype = guess_type(filename) - maintype, subtype = filetype[0].split('/') - if maintype == 'text': - templates.append(os.path.join(dirpath, filename)) + if filetype != (None, None): + maintype, subtype = filetype[0].split('/') + if maintype == 'text': + templates.append(os.path.join(dirpath, filename)) return templates @@ -189,7 +190,7 @@ def output_template_name(template_name, output=sys.stdout): :template_name: String :output: output destination (console=sys.stdout; testing=StringIO) """ - output.write('-' * len(template_name) + '\n') + output.write('=' * len(template_name) + '\n') output.write(template_name + '\n')