1
2 import DataFromKVPairs
3 import re
4
5
6 _args_re_pattern = r'''(?P<pname>[^,]+)
7 ,\s*(?P<kname>[^,]+)
8 '''
9
10 def execute(macro, text ):
11 value = ''
12
13 p = re.compile( _args_re_pattern, re.VERBOSE | re.DOTALL )
14 m = p.search( text )
15
16 if not m:
17 return '<h2 class="error">Macro error: args</h2>'+ \
18 '''<p>Should be Shorter("PageName",
19 "KeyName")</p>
20 <p>See Shorter.py on dev or ask Shandy</p>
21 '''
22
23 pageName = m.group('pname')
24 key = m.group('kname')
25
26 fakeText = '"'+ pageName +'", "a", "'+ key +'", "link"'
27 return DataFromKVPairs.execute( macro, fakeText)
MoinMoin: macro/Shorter.py (last edited 2007-10-29 19:09:05 by localhost)