Skip to content

Commit

Permalink
Merge pull request #16 from Styria-Digital/hotfix/template_mimetype
Browse files Browse the repository at this point in the history
Fix: template without filetype
  • Loading branch information
mislavcimpersak committed Sep 13, 2016
2 parents 7b25ed8 + e90ac93 commit 1ac6ff2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
18 changes: 17 additions & 1 deletion README.rst
Expand Up @@ -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
------------
Expand All @@ -16,6 +20,12 @@ Requirements
* Tabulate


Installation
------------
To install the package, type:

``$ pip install django-unload``

Setup
-----

Expand All @@ -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 <app_name>``.

**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:
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -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',
Expand Down
9 changes: 5 additions & 4 deletions unload/utils.py
Expand Up @@ -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

Expand Down Expand Up @@ -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')


Expand Down

0 comments on commit 1ac6ff2

Please sign in to comment.