MCPcopy Index your code
hub / github.com/sqlmapproject/sqlmap / _find_control

Method _find_control

thirdparty/clientform/clientform.py:3251–3320  ·  view source on GitHub ↗
(self, name, type, kind, id, label, predicate, nr)

Source from the content-addressed store, hash-verified

3249 is_listcontrol, nr)
3250
3251 def _find_control(self, name, type, kind, id, label, predicate, nr):
3252 if ((name is not None) and (name is not Missing) and
3253 not isstringlike(name)):
3254 raise TypeError("control name must be string-like")
3255 if (type is not None) and not isstringlike(type):
3256 raise TypeError("control type must be string-like")
3257 if (kind is not None) and not isstringlike(kind):
3258 raise TypeError("control kind must be string-like")
3259 if (id is not None) and not isstringlike(id):
3260 raise TypeError("control id must be string-like")
3261 if (label is not None) and not isstringlike(label):
3262 raise TypeError("control label must be string-like")
3263 if (predicate is not None) and not callable(predicate):
3264 raise TypeError("control predicate must be callable")
3265 if (nr is not None) and nr < 0:
3266 raise ValueError("control number must be a positive integer")
3267
3268 orig_nr = nr
3269 found = None
3270 ambiguous = False
3271 if nr is None and self.backwards_compat:
3272 nr = 0
3273
3274 for control in self.controls:
3275 if ((name is not None and name != control.name) and
3276 (name is not Missing or control.name is not None)):
3277 continue
3278 if type is not None and type != control.type:
3279 continue
3280 if kind is not None and not control.is_of_kind(kind):
3281 continue
3282 if id is not None and id != control.id:
3283 continue
3284 if predicate and not predicate(control):
3285 continue
3286 if label:
3287 for l in control.get_labels():
3288 if l.text.find(label) > -1:
3289 break
3290 else:
3291 continue
3292 if nr is not None:
3293 if nr == 0:
3294 return control # early exit: unambiguous due to nr
3295 nr -= 1
3296 continue
3297 if found:
3298 ambiguous = True
3299 break
3300 found = control
3301
3302 if found and not ambiguous:
3303 return found
3304
3305 description = []
3306 if name is not None: description.append("name %s" % repr(name))
3307 if type is not None: description.append("type '%s'" % type)
3308 if kind is not None: description.append("kind '%s'" % kind)

Callers 3

find_controlMethod · 0.95
_find_list_controlMethod · 0.95
_clickMethod · 0.95

Calls 8

isstringlikeFunction · 0.85
callableFunction · 0.85
AmbiguityErrorClass · 0.85
findMethod · 0.80
is_of_kindMethod · 0.45
get_labelsMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected