Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[py3] Ported django.utils.regex_helper.

  • Loading branch information...
commit 17da0aa893d4933bef52151243a72d90ad16d5de 1 parent fe8484e
@aaugustin aaugustin authored
Showing with 6 additions and 5 deletions.
  1. +6 −5 django/utils/regex_helper.py
View
11 django/utils/regex_helper.py
@@ -8,6 +8,7 @@
from __future__ import unicode_literals
from django.utils import six
+from django.utils.six.moves import zip
# Mapping of an escape character to a representative of that class. So, e.g.,
# "\w" is replaced by "x" in a reverse URL. A value of None means to ignore
@@ -44,8 +45,8 @@ class NonCapture(list):
def normalize(pattern):
"""
- Given a reg-exp pattern, normalizes it to a list of forms that suffice for
- reverse matching. This does the following:
+ Given a reg-exp pattern, normalizes it to an iterable of forms that
+ suffice for reverse matching. This does the following:
(1) For any repeating sections, keeps the minimum number of occurrences
permitted (this means zero for optional groups).
@@ -80,7 +81,7 @@ def normalize(pattern):
try:
ch, escaped = next(pattern_iter)
except StopIteration:
- return zip([''], [[]])
+ return [('', [])]
try:
while True:
@@ -193,9 +194,9 @@ def normalize(pattern):
pass
except NotImplementedError:
# A case of using the disjunctive form. No results for you!
- return zip([''], [[]])
+ return [('', [])]
- return zip(*flatten_result(result))
+ return list(zip(*flatten_result(result)))
def next_char(input_iter):
"""
Please sign in to comment.
Something went wrong with that request. Please try again.