diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-08-04 11:12:21 +0200 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-08-07 12:00:24 +0200 |
| commit | 17da0aa893d4933bef52151243a72d90ad16d5de (patch) | |
| tree | 6e5328fa927224ff008107af4bd0754c190c8a77 /django/utils/regex_helper.py | |
| parent | fe8484efda257e151d9c1ca5151e546c9262bf0f (diff) | |
[py3] Ported django.utils.regex_helper.
Diffstat (limited to 'django/utils/regex_helper.py')
| -rw-r--r-- | django/utils/regex_helper.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/django/utils/regex_helper.py b/django/utils/regex_helper.py index 8953a21e95..7b40d141de 100644 --- a/django/utils/regex_helper.py +++ b/django/utils/regex_helper.py @@ -8,6 +8,7 @@ should be good enough for a large class of URLS, however. 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): """ |
