Skip to content

Commit

Permalink
fixed pep8 compliance in doctests
Browse files Browse the repository at this point in the history
  • Loading branch information
wolph committed Aug 27, 2013
1 parent be415ef commit 0924ef8
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions django_utils/templatetags/debug.py
Expand Up @@ -13,8 +13,9 @@ class _Formatter(object):
formatters_type = {}
formatters_instance = []


class Formatter(_Formatter):
MAX_LENGTH = 100
MAX_LENGTH_DOTS = 3

def __init__(self, max_depth=3):
'''Initialize the formatter with a given maximum default depth
Expand Down Expand Up @@ -77,11 +78,15 @@ def format_unicode(self, value, depth):
:return: a formatted string
>>> formatter = Formatter()
>>> formatter('x' * 101)
u'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...'
>>> old_max_length = formatter.MAX_LENGTH
>>> formatter.MAX_LENGTH = 10
>>> formatter('x' * 11)
u'xxxxxxx...'
>>> formatter.MAX_LENGTH = old_max_length
'''
if value[100:]:
value = value[:97] + '...'
if value[self.MAX_LENGTH:]:
value = value[:self.MAX_LENGTH - self.MAX_LENGTH_DOTS]
value += self.MAX_LENGTH_DOTS * '.'
return value

@_register(list)
Expand Down

0 comments on commit 0924ef8

Please sign in to comment.