|
From: David H. <neg...@gm...> - 2009-02-19 20:26:09
|
Index: validate.py
===================================================================
--- validate.py (revision 106)
+++ validate.py (working copy)
@@ -130,7 +130,7 @@
__docformat__ = "restructuredtext en"
-__version__ = '0.3.2'
+__version__ = '0.3.3'
__revision__ = '$Id: validate.py 123 2005-09-08 08:54:28Z fuzzyman $'
@@ -183,15 +183,15 @@
(?:
\s*
(?:
- (?:".*?")| # double quotes
- (?:'.*?')| # single quotes
+ (?s)(?:".*?")| # double quotes
+ (?s)(?:'.*?')| # single quotes
(?:[^'",\s\)][^,\)]*?) # unquoted
)
\s*,\s*
)*
(?:
- (?:".*?")| # double quotes
- (?:'.*?')| # single quotes
+ (?s)(?:".*?")| # double quotes
+ (?s)(?:'.*?')| # single quotes
(?:[^'",\s\)][^,\)]*?) # unquoted
)? # last one
)
@@ -201,8 +201,8 @@
_list_members = re.compile(r'''
(
- (?:".*?")| # double quotes
- (?:'.*?')| # single quotes
+ (?s)(?:".*?")| # double quotes
+ (?s)(?:'.*?')| # single quotes
(?:[^'",\s=][^,=]*?) # unquoted
)
(?:
@@ -218,28 +218,28 @@
(?:
\s*
(?:
- (?:".*?")| # double quotes
- (?:'.*?')| # single quotes
- (?:[^'",\s\)][^,\)]*?) # unquoted
+ (?s)(?:".*?")| # double quotes
+ (?s)(?:'.*?')| # single quotes
+ (?:[^'",\s\)][^,\)]*?) # unquoted
)
\s*,\s*
)*
(?:
- (?:".*?")| # double quotes
- (?:'.*?')| # single quotes
- (?:[^'",\s\)][^,\)]*?) # unquoted
+ (?s)(?:".*?")| # double quotes
+ (?s)(?:'.*?')| # single quotes
+ (?:[^'",\s\)][^,\)]*?) # unquoted
)? # last one
\)
)|
(?:
- (?:".*?")| # double quotes
- (?:'.*?')| # single quotes
+ (?s)(?:".*?")| # double quotes
+ (?s)(?:'.*?')| # single quotes
(?:[^'",\s=][^,=]*?)| # unquoted
(?: # keyword argument
[a-zA-Z_][a-zA-Z0-9_]*\s*=\s*
(?:
- (?:".*?")| # double quotes
- (?:'.*?')| # single quotes
+ (?s)(?:".*?")| # double quotes
+ (?s)(?:'.*?')| # single quotes
(?:[^'",\s=][^,=]*?) # unquoted
)
)
@@ -278,7 +278,8 @@
>>> int(dottedQuadToNum('1.2.3.4'))
16909060
>>> dottedQuadToNum('1.2.3. 4')
- 16909060
+ Traceback (most recent call last):
+ ValueError: Not a good dotted-quad IP: 1.2.3. 4
>>> dottedQuadToNum('255.255.255.255')
4294967295L
>>> dottedQuadToNum('255.255.255.256')
@@ -525,10 +526,10 @@
"""
# this regex does the initial parsing of the checks
- _func_re = re.compile(r'(.+?)\((.*)\)')
+ _func_re = re.compile(r'(.+?)\((?s)(.*)\)')
# this regex takes apart keyword arguments
- _key_arg = re.compile(r'^([a-zA-Z_][a-zA-Z0-9_]*)\s*=\s*(.*)$')
+ _key_arg = re.compile(r'^([a-zA-Z_][a-zA-Z0-9_]*)\s*=\s*(?s)(.*)$')
# this regex finds keyword=list(....) type values
@@ -573,7 +574,7 @@
def check(self, check, value, missing=False):
- """
+ r"""
Usage: check(check, value)
Arguments:
@@ -592,6 +593,27 @@
>>> vtor.check('string(default="")', '', missing=True)
''
+ >>> vtor.check('string(default="\n")', '', missing=True)
+ '\n'
+ >>> print vtor.check('string(default="\n")', '', missing=True),
+ <BLANKLINE>
+ >>> vtor.check('string()', '\n')
+ '\n'
+ >>> vtor.check('string(default="\n\n\n")', '', missing=True)
+ '\n\n\n'
+ >>> vtor.check('string()', 'random \n text goes here\n\n')
+ 'random \n text goes here\n\n'
+ >>> vtor.check('string(default=" \nrandom text\ngoes \n here\n\n ")',
+ ... '', missing=True)
+ ' \nrandom text\ngoes \n here\n\n '
+ >>> vtor.check("string(default='\n\n\n')", '', missing=True)
+ '\n\n\n'
+ >>> vtor.check("option('\n','a','b',default='\n')", '', missing=True)
+ '\n'
+ >>> vtor.check("string_list()", ['foo', '\n', 'bar'])
+ ['foo', '\n', 'bar']
+ >>> vtor.check("string_list(default=list('\n'))", '', missing=True)
+ ['\n']
"""
fun_name, fun_args, fun_kwargs, default = self._parse_with_caching(check)
|