[Checkins] SVN: z3c.pt/trunk/src/z3c/pt/expressions.py Allow
methods with no argument clause.
Malthe Borch
mborch at gmail.com
Sat Aug 9 05:47:06 EDT 2008
Log message for revision 89566:
Allow methods with no argument clause.
Changed:
U z3c.pt/trunk/src/z3c/pt/expressions.py
-=-
Modified: z3c.pt/trunk/src/z3c/pt/expressions.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/expressions.py 2008-08-09 02:10:41 UTC (rev 89565)
+++ z3c.pt/trunk/src/z3c/pt/expressions.py 2008-08-09 09:46:59 UTC (rev 89566)
@@ -20,7 +20,7 @@
re_pragma = re.compile(r'^\s*(?P<pragma>[a-z]+):\s*')
re_interpolation = re.compile(r'(?P<prefix>[^\\]\$|^\$){((?P<expression>.*)})?')
re_method = re.compile(r'^(?P<name>[A-Za-z0-9_]+)'
- '\((?P<args>[A-Za-z0-9_]+\s*(,\s*[A-Za-z0-9_]+)*)\)')
+ '(\((?P<args>[A-Za-z0-9_]+\s*(,\s*[A-Za-z0-9_]+)*)\))?')
def name(self, string):
return string
@@ -435,6 +435,9 @@
>>> method = ExpressionTranslation().method
+ >>> method('name')
+ name()
+
>>> method('name(a, b, c)')
name(a, b, c)
@@ -442,10 +445,10 @@
m = self.re_method.match(string)
if m is None:
- return None
+ raise ValueError("Not a valid method definition (%s)." % string)
name = m.group('name')
- args = [arg.strip() for arg in m.group('args').split(',')]
+ args = [arg.strip() for arg in (m.group('args') or "").split(',') if arg]
return types.method(name, args)
More information about the Checkins
mailing list