Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[py3] Ported django.utils.regex_helper.

  • Loading branch information...
commit 17da0aa893d4933bef52151243a72d90ad16d5de 1 parent fe8484e
Aymeric Augustin authored August 04, 2012

Showing 1 changed file with 6 additions and 5 deletions. Show diff stats Hide diff stats

  1. 11  django/utils/regex_helper.py
11  django/utils/regex_helper.py
@@ -8,6 +8,7 @@
8 8
 from __future__ import unicode_literals
9 9
 
10 10
 from django.utils import six
  11
+from django.utils.six.moves import zip
11 12
 
12 13
 # Mapping of an escape character to a representative of that class. So, e.g.,
13 14
 # "\w" is replaced by "x" in a reverse URL. A value of None means to ignore
@@ -44,8 +45,8 @@ class NonCapture(list):
44 45
 
45 46
 def normalize(pattern):
46 47
     """
47  
-    Given a reg-exp pattern, normalizes it to a list of forms that suffice for
48  
-    reverse matching. This does the following:
  48
+    Given a reg-exp pattern, normalizes it to an iterable of forms that
  49
+    suffice for reverse matching. This does the following:
49 50
 
50 51
     (1) For any repeating sections, keeps the minimum number of occurrences
51 52
         permitted (this means zero for optional groups).
@@ -80,7 +81,7 @@ def normalize(pattern):
80 81
     try:
81 82
         ch, escaped = next(pattern_iter)
82 83
     except StopIteration:
83  
-        return zip([''],  [[]])
  84
+        return [('', [])]
84 85
 
85 86
     try:
86 87
         while True:
@@ -193,9 +194,9 @@ def normalize(pattern):
193 194
         pass
194 195
     except NotImplementedError:
195 196
         # A case of using the disjunctive form. No results for you!
196  
-        return zip([''],  [[]])
  197
+        return [('', [])]
197 198
 
198  
-    return zip(*flatten_result(result))
  199
+    return list(zip(*flatten_result(result)))
199 200
 
200 201
 def next_char(input_iter):
201 202
     """

0 notes on commit 17da0aa

Please sign in to comment.
Something went wrong with that request. Please try again.