aboutsummaryrefslogtreecommitdiffstats
path: root/djangorestframework/utils/description.py
diff options
context:
space:
mode:
authorTom Christie2011-12-29 13:31:12 +0000
committerTom Christie2011-12-29 13:31:12 +0000
commit07349597ab936dc9887caa70b5d7d2860c897b12 (patch)
treedb1fdb8934e4d8dc8d3afe8d1e9fd076e3a4e27d /djangorestframework/utils/description.py
parent1bdc5eacc6290c486796eb5ab8fa29092137dab6 (diff)
downloaddjango-rest-framework-07349597ab936dc9887caa70b5d7d2860c897b12.tar.bz2
whitespace fixes
Diffstat (limited to 'djangorestframework/utils/description.py')
-rw-r--r--djangorestframework/utils/description.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/djangorestframework/utils/description.py b/djangorestframework/utils/description.py
index 25bef80b..ce61e558 100644
--- a/djangorestframework/utils/description.py
+++ b/djangorestframework/utils/description.py
@@ -10,7 +10,7 @@ from djangorestframework.resources import Resource, FormResource, ModelResource
def get_name(view):
"""
Return a name for the view.
-
+
If view has a name attribute, use that, otherwise use the view's class name, with 'CamelCaseNames' converted to 'Camel Case Names'.
"""
@@ -22,7 +22,7 @@ def get_name(view):
# If this view has a resource that's been overridden, then use that resource for the name
if getattr(view, 'resource', None) not in (None, Resource, FormResource, ModelResource):
name = view.resource.__name__
-
+
# Chomp of any non-descriptive trailing part of the resource class name
if name.endswith('Resource') and name != 'Resource':
name = name[:-len('Resource')]
@@ -30,7 +30,7 @@ def get_name(view):
# If the view has a descriptive suffix, eg '*** List', '*** Instance'
if getattr(view, '_suffix', None):
name += view._suffix
-
+
# Otherwise if it's a function view use the function's name
elif getattr(view, '__name__', None) is not None:
name = view.__name__
@@ -62,12 +62,12 @@ def get_description(view):
# grok the class instance that we stored when as_view was called.
if getattr(view, 'cls_instance', None):
view = view.cls_instance
-
+
# If this view has a resource that's been overridden, then use the resource's doctring
if getattr(view, 'resource', None) not in (None, Resource, FormResource, ModelResource):
doc = view.resource.__doc__
-
+
# Otherwise use the view doctring
elif getattr(view, '__doc__', None):
doc = view.__doc__
@@ -81,11 +81,11 @@ def get_description(view):
whitespace_counts = [len(line) - len(line.lstrip(' ')) for line in doc.splitlines()[1:] if line.lstrip()]
- # unindent the docstring if needed
+ # unindent the docstring if needed
if whitespace_counts:
whitespace_pattern = '^' + (' ' * min(whitespace_counts))
return re.sub(re.compile(whitespace_pattern, re.MULTILINE), '', doc)
# otherwise return it as-is
return doc
-
+