[egenix-users] mx.TextTools - any way to return a value from
CallTag (or add a new command/flag)?
M.-A. Lemburg
mal at egenix.com
Wed Jul 25 01:51:17 CEST 2007
On 2007-07-25 00:39, Frank McIngvale wrote:
> Hi, I'm trying to find a way to call a conversion function with the text
> matched through a TagTable entry. For example, lets say I'm matching on
> [0-9]+ and want to convert the result to an integer. I'd like to be able to
> do something like:
>
> TagTable:
> ...
> (int, AllIn+CallWithMatch, number)
>
> Where 'CallWithMatch' would be a flag that says to call the tagobj and add
> the result to the to the taglist. I've looked all through the manual but
> none of the commands+flags seem to do that. Am I overlooking it somewhere?
You can use the flag CallTag and then use a helper function as
tagobj:
"""
CallTag
Instead of appending (tagobj,l,r,subtags) to the taglist upon successful
matching, call tagobj(taglist,text,l,r,subtags) or
tagobj(taglist,text,l,r,subtags,context) if a context object was passed to the
tag() function.
"""
Note that the function has access to the current taglist, so it's
possible to append the converted value to the taglist if that's
what you want to do.
Alternatively, you can use a context object and maintain a list
of integers in there.
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Source (#1, Jul 25 2007)
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
More information about the egenix-users
mailing list