diff options
| author | Tom Christie | 2011-06-02 12:58:10 +0100 | 
|---|---|---|
| committer | Tom Christie | 2011-06-02 12:58:10 +0100 | 
| commit | b50492853f537a2473bb0a9eea86c8b0ed6b8824 (patch) | |
| tree | d289d39aacf187a8a0696a4c1c863aabe1472c3a /djangorestframework/description.py | |
| parent | 7ee9adbe5c03c29cd4a894dd476548f7fe73b5e4 (diff) | |
| parent | fc1640de75511006e89f033c9270ec91a9f1e4d4 (diff) | |
| download | django-rest-framework-b50492853f537a2473bb0a9eea86c8b0ed6b8824.tar.bz2 | |
pull in -dev as 0.2.0
Diffstat (limited to 'djangorestframework/description.py')
| -rw-r--r-- | djangorestframework/description.py | 37 | 
1 files changed, 0 insertions, 37 deletions
| diff --git a/djangorestframework/description.py b/djangorestframework/description.py deleted file mode 100644 index f7145c0f..00000000 --- a/djangorestframework/description.py +++ /dev/null @@ -1,37 +0,0 @@ -"""Get a descriptive name and description for a view, -based on class name and docstring, and override-able by 'name' and 'description' attributes""" -import re - -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'.""" -    if getattr(view, 'name', None) is not None: -        return view.name - -    if getattr(view, '__name__', None) is not None: -        name = view.__name__ -    elif getattr(view, '__class__', None) is not None:  # TODO: should be able to get rid of this case once refactoring to 1.3 class views is complete -        name = view.__class__.__name__ -    else: -        return '' - -    return re.sub('(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|$)))', ' \\1', name).strip() - -def get_description(view): -    """Provide a description for the view. - -    By default this is the view's docstring with nice unindention applied.""" -    if getattr(view, 'description', None) is not None: -        return getattr(view, 'description') - -    if getattr(view, '__doc__', None) is not None: -        whitespace_counts = [len(line) - len(line.lstrip(' ')) for line in view.__doc__.splitlines()[1:] if line.lstrip()] - -        if whitespace_counts: -            whitespace_pattern = '^' + (' ' * min(whitespace_counts)) -            return re.sub(re.compile(whitespace_pattern, re.MULTILINE), '', view.__doc__) - -        return view.__doc__ -     -    return ''
\ No newline at end of file | 
