[twill] [andychambers2002 at yahoo.co.uk: fv_match suggestion (with patch included)]
Andy Chambers
andychambers2002 at yahoo.co.uk
Mon Oct 9 04:28:58 PDT 2006
Apologies. Please ignore the earlier patch. It had some tab funkiness
that caused syntax errors. (I should really symlink my ~/.vimrc to
~root/.vimrc).
----- Forwarded message from Andy Chambers <andychambers2002 at yahoo.co.uk> -----
Date: Mon, 9 Oct 2006 11:21:04 +0100
From: Andy Chambers <andychambers2002 at yahoo.co.uk>
To: twill at lists.idyll.org
Subject: fv_match suggestion (with patch included)
User-Agent: Mutt/1.5.9i
Hi all,
Would anyone else find it useful if fv_match worked a little more like
fv_multi so that you could fill in control fields with the same name
with different values by adding extra args on the end of the command?
[snip..]
-------------- next part --------------
--- formfill.py.orig 2006-10-09 10:30:54.000000000 +0100
+++ formfill.py 2006-10-09 12:16:36.000000000 +0100
@@ -23,12 +23,15 @@
__all__ = [ 'fv_match', 'fv_multi', 'fv_multi_sub' ]
-def fv_match(formname, regexp, value):
+def fv_match(formname, regexp, *values):
"""
>> fv_match <formname> <field regexp> <value>
- Set value of *all* form fields with a name that matches the given
- regular expression.
+ Set value of form fields with a name that matches the given
+ regular expression in the order that they appear with the
+ corresponding value from values. If there are more matches than
+ values, the last value is used for all remaining matches
+
(Unlike 'formvalue' or 'fv', this will not complain about multiple
matches!)
@@ -45,7 +48,7 @@
matches = [ ctl for ctl in form.controls if regexp.search(str(ctl.name)) ]
if matches:
- print '-- matches %d' % (len(matches),)
+ print '-- matches %d, args %d' % (len(matches), len(values))
n = 0
for control in matches:
@@ -53,8 +56,11 @@
if control.readonly:
continue
+ try:
+ twill.utils.set_form_control_value(control, values[n])
+ except IndexError, e:
+ twill.utils.set_form_control_value(control, values[-1])
n += 1
- twill.utils.set_form_control_value(control, value)
print 'set %d values total' % (n,)
More information about the twill
mailing list