Author: mtredinnick
Date: 2007-03-30 06:57:50 -0500 (Fri, 30 Mar 2007)
New Revision: 4870
Added:
django/trunk/tests/regressiontests/text/
django/trunk/tests/regressiontests/text/__init__.py
django/trunk/tests/regressiontests/text/models.py
django/trunk/tests/regressiontests/text/tests.py
Modified:
django/trunk/AUTHORS
django/trunk/django/utils/text.py
Log:
Fixed #3733 -- Fixed up quote parsing in smart_split(). Thanks, Ivan Chelubeev.
Modified: django/trunk/AUTHORS
===================================================================
--- django/trunk/AUTHORS 2007-03-30 11:49:28 UTC (rev 4869)
+++ django/trunk/AUTHORS 2007-03-30 11:57:50 UTC (rev 4870)
@@ -64,6 +64,7 @@
Chris Chamberlin <[EMAIL PROTECTED]>
Amit Chakradeo <http://amit.chakradeo.net/>
ChaosKCW
+ [EMAIL PROTECTED]
Ian Clelland <[EMAIL PROTECTED]>
[EMAIL PROTECTED]
Matt Croydon <http://www.postneo.com/>
Modified: django/trunk/django/utils/text.py
===================================================================
--- django/trunk/django/utils/text.py 2007-03-30 11:49:28 UTC (rev 4869)
+++ django/trunk/django/utils/text.py 2007-03-30 11:57:50 UTC (rev 4870)
@@ -191,14 +191,15 @@
Supports both single and double quotes, and supports escaping quotes with
backslashes. In the output, strings will keep their initial and trailing
quote marks.
- >>> list(smart_split('This is "a person\'s" test.'))
- ['This', 'is', '"a person\'s"', 'test.']
+
+ >>> list(smart_split('This is "a person\'s" test.'))
+ ['This', 'is', '"a person\'s"', 'test.']
"""
for bit in smart_split_re.finditer(text):
bit = bit.group(0)
- if bit[0] == '"':
+ if bit[0] == '"' and bit[-1] == '"':
yield '"' + bit[1:-1].replace('\\"', '"').replace('\\\\', '\\') +
'"'
- elif bit[0] == "'":
+ elif bit[0] == "'" and bit[-1] == "'":
yield "'" + bit[1:-1].replace("\\'", "'").replace("\\\\", "\\") +
"'"
else:
yield bit
Added: django/trunk/tests/regressiontests/text/__init__.py
===================================================================
Added: django/trunk/tests/regressiontests/text/models.py
===================================================================
Added: django/trunk/tests/regressiontests/text/tests.py
===================================================================
--- django/trunk/tests/regressiontests/text/tests.py
(rev 0)
+++ django/trunk/tests/regressiontests/text/tests.py 2007-03-30 11:57:50 UTC
(rev 4870)
@@ -0,0 +1,17 @@
+"""
+# Tests for stuff in django.utils.text.
+
+>>> from django.utils.text import *
+
+### smart_split ###########################################################
+>>> list(smart_split(r'''This is "a person" test.'''))
+['This', 'is', '"a person"', 'test.']
+>>> print list(smart_split(r'''This is "a person's" test.'''))[2]
+"a person's"
+>>> print list(smart_split(r'''This is "a person\\"s" test.'''))[2]
+"a person"s"
+>>> list(smart_split('''"a 'one'''))
+['"a', "'one"]
+>>> print list(smart_split(r'''all friends' tests'''))[1]
+friends'
+"""
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---