(self, name, type, kind, id, label, predicate, nr)
| 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) |
no test coverage detected