Simplified chained comparisons and minor code fixes (#5276)

This commit is contained in:
Erick Delfin 2017-07-16 09:12:29 -07:00 committed by Tom Christie
parent 2a1fd3b45a
commit 089887d56e
3 changed files with 9 additions and 9 deletions

View File

@ -31,7 +31,7 @@ def _positive_int(integer_string, strict=False, cutoff=None):
if ret < 0 or (ret == 0 and strict): if ret < 0 or (ret == 0 and strict):
raise ValueError() raise ValueError()
if cutoff: if cutoff:
ret = min(ret, cutoff) return min(ret, cutoff)
return ret return ret
@ -95,7 +95,7 @@ def _get_displayed_page_numbers(current, final):
# Now sort the page numbers and drop anything outside the limits. # Now sort the page numbers and drop anything outside the limits.
included = [ included = [
idx for idx in sorted(list(included)) idx for idx in sorted(list(included))
if idx > 0 and idx <= final if 0 < idx <= final
] ]
# Finally insert any `...` breaks # Finally insert any `...` breaks

View File

@ -9,23 +9,23 @@ from __future__ import unicode_literals
def is_informational(code): def is_informational(code):
return code >= 100 and code <= 199 return 100 <= code <= 199
def is_success(code): def is_success(code):
return code >= 200 and code <= 299 return 200 <= code <= 299
def is_redirect(code): def is_redirect(code):
return code >= 300 and code <= 399 return 300 <= code <= 399
def is_client_error(code): def is_client_error(code):
return code >= 400 and code <= 499 return 400 <= code <= 499
def is_server_error(code): def is_server_error(code):
return code >= 500 and code <= 599 return 500 <= code <= 599
HTTP_100_CONTINUE = 100 HTTP_100_CONTINUE = 100

View File

@ -52,8 +52,8 @@ def camelcase_to_spaces(content):
Translate 'CamelCaseNames' to 'Camel Case Names'. Translate 'CamelCaseNames' to 'Camel Case Names'.
Used when generating names from view classes. Used when generating names from view classes.
""" """
camelcase_boundry = '(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|$)))' camelcase_boundary = '(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|$)))'
content = re.sub(camelcase_boundry, ' \\1', content).strip() content = re.sub(camelcase_boundary, ' \\1', content).strip()
return ' '.join(content.split('_')).title() return ' '.join(content.split('_')).title()