urlpatterns: Remove unnecessary branching

Functions path and register_converter are constants.
This commit is contained in:
John Vandenberg 2020-07-11 16:14:30 +07:00
parent 76232437d4
commit 722ef93c7f

View File

@ -105,12 +105,9 @@ def format_suffix_patterns(urlpatterns, suffix_required=False, allowed=None):
else: else:
suffix_pattern = r'\.(?P<%s>[a-z0-9]+)/?$' % suffix_kwarg suffix_pattern = r'\.(?P<%s>[a-z0-9]+)/?$' % suffix_kwarg
if path and register_converter: converter_name, suffix_converter = _get_format_path_converter(suffix_kwarg, allowed)
converter_name, suffix_converter = _get_format_path_converter(suffix_kwarg, allowed) register_converter(suffix_converter, converter_name)
register_converter(suffix_converter, converter_name)
suffix_route = '<%s:%s>' % (converter_name, suffix_kwarg) suffix_route = '<%s:%s>' % (converter_name, suffix_kwarg)
else:
suffix_route = None
return apply_suffix_patterns(urlpatterns, suffix_pattern, suffix_required, suffix_route) return apply_suffix_patterns(urlpatterns, suffix_pattern, suffix_required, suffix_route)