Cosmetics for --forms

This commit is contained in:
Bernardo Damele 2010-11-14 21:59:35 +00:00
parent 0bfc1b411a
commit 5f46a549ba

View File

@ -133,24 +133,28 @@ def findPageForms():
count = 1 count = 1
for form in forms: for form in forms:
request = form.click() request = form.click()
url = request.get_full_url() url = request.get_full_url()
method = request.get_method() method = request.get_method()
data = request.get_data() if request.has_data() else None data = request.get_data() if request.has_data() else None
message = "(#%d) Do you want to test form '%s' (%s, %s%s) [Y/n] " % (count, form.name, method, url, ", %s" % repr(data) if data else "") if form.name is None:
name = ""
else:
name = " '%s'" % form.name
message = "[#%d] Do you want to test form%s (%s, %s%s) [Y/n] " % (count, name, method, url, ", %s" % repr(data) if data else "")
test = readInput(message, default="Y") test = readInput(message, default="Y")
if not test or test[0] in ("y", "Y"): if not test or test[0] in ("y", "Y"):
if method == HTTPMETHOD.POST: if method == HTTPMETHOD.POST:
message = " Edit POST data [default: %s]: " % (data if data else "") message = "Edit POST data [default: %s]: " % (data if data else "")
test = readInput(message, default=data) test = readInput(message, default=data)
elif method == HTTPMETHOD.GET: elif method == HTTPMETHOD.GET:
if url.find("?") > -1: if url.find("?") > -1:
firstPart = url[:url.find("?")] firstPart = url[:url.find("?")]
secondPart = url[url.find("?")+1:] secondPart = url[url.find("?")+1:]
message = " Edit GET data [default: %s]: " % secondPart message = "Edit GET data [default: %s]: " % secondPart
test = readInput(message, default=secondPart) test = readInput(message, default=secondPart)
url = "%s?%s" % (firstPart, test) url = "%s?%s" % (firstPart, test)