diff options
| author | Robin Munn <robin.munn@gmail.com> | 2006-09-25 15:39:20 +0000 |
|---|---|---|
| committer | Robin Munn <robin.munn@gmail.com> | 2006-09-25 15:39:20 +0000 |
| commit | 1bb4fa2cb66269b1eff3b7d73f8c7864c0622368 (patch) | |
| tree | 99ebf72b9983e35e50e65d0d421949a2740bf105 /django/utils | |
| parent | 8afc419b123f315d724cbefdbc4c07f0982627a9 (diff) | |
sqlalchemy: Merged revisions 3770 to 3831 from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/sqlalchemy@3832 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/utils')
| -rw-r--r-- | django/utils/datastructures.py | 3 | ||||
| -rw-r--r-- | django/utils/simplejson/scanner.py | 3 | ||||
| -rw-r--r-- | django/utils/text.py | 6 |
3 files changed, 9 insertions, 3 deletions
diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py index 6aef313d35..cecb4da170 100644 --- a/django/utils/datastructures.py +++ b/django/utils/datastructures.py @@ -14,6 +14,9 @@ class MergeDict(object): pass raise KeyError + def __contains__(self, key): + return self.has_key(key) + def get(self, key, default): try: return self[key] diff --git a/django/utils/simplejson/scanner.py b/django/utils/simplejson/scanner.py index c2e9b6eb89..b9244cfed1 100644 --- a/django/utils/simplejson/scanner.py +++ b/django/utils/simplejson/scanner.py @@ -3,12 +3,11 @@ Iterator based sre token scanner """ import sre_parse, sre_compile, sre_constants from sre_constants import BRANCH, SUBPATTERN -from sre import VERBOSE, MULTILINE, DOTALL import re __all__ = ['Scanner', 'pattern'] -FLAGS = (VERBOSE | MULTILINE | DOTALL) +FLAGS = (re.VERBOSE | re.MULTILINE | re.DOTALL) class Scanner(object): def __init__(self, lexicon, flags=FLAGS): self.actions = [None] diff --git a/django/utils/text.py b/django/utils/text.py index 7df9bc03b7..9e7bb3b6c4 100644 --- a/django/utils/text.py +++ b/django/utils/text.py @@ -94,7 +94,8 @@ def compress_string(s): return zbuf.getvalue() ustring_re = re.compile(u"([\u0080-\uffff])") -def javascript_quote(s): + +def javascript_quote(s, quote_double_quotes=False): def fix(match): return r"\u%04x" % ord(match.group(1)) @@ -104,9 +105,12 @@ def javascript_quote(s): elif type(s) != unicode: raise TypeError, s s = s.replace('\\', '\\\\') + s = s.replace('\r', '\\r') s = s.replace('\n', '\\n') s = s.replace('\t', '\\t') s = s.replace("'", "\\'") + if quote_double_quotes: + s = s.replace('"', '"') return str(ustring_re.sub(fix, s)) smart_split_re = re.compile('("(?:[^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'(?:[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'|[^\\s]+)') |
