fps: files check_fn: lambda(file) -> boolean msg: string-format of pre-defined constant string.
(fps, check_fn, msg)
| 212 | err = [] |
| 213 | |
| 214 | def validate(fps, check_fn, msg): |
| 215 | ''' fps: files |
| 216 | check_fn: lambda(file) -> boolean |
| 217 | msg: string-format of pre-defined constant string. |
| 218 | ''' |
| 219 | ret = True |
| 220 | if not fps: |
| 221 | return ret |
| 222 | for fp in fps: |
| 223 | try: |
| 224 | f = curr_b.status_file(fp) |
| 225 | except KeyError: |
| 226 | err.append('File {0} doesn\'t exist'.format(fp)) |
| 227 | ret = False # set error flag, but keep assessing other files |
| 228 | else: # executed after "try", exception will be ignored here |
| 229 | if not check_fn(f): |
| 230 | err.append(msg(fp)) # dynamic string formatting |
| 231 | ret = False |
| 232 | return ret |
| 233 | |
| 234 | only_valid = validate( |
| 235 | only, lambda f: f.type == core.GL_STATUS_UNTRACKED or ( |
no test coverage detected