(filename, match_kind, get_file_preprocessor, maxsizes)
| 31 | |
| 32 | |
| 33 | def _parse_file(filename, match_kind, get_file_preprocessor, maxsizes): |
| 34 | srckwargs = {} |
| 35 | maxsize = _resolve_max_size(filename, maxsizes) |
| 36 | if maxsize: |
| 37 | srckwargs['maxtext'], srckwargs['maxlines'] = maxsize |
| 38 | |
| 39 | # Preprocess the file. |
| 40 | preprocess = get_file_preprocessor(filename) |
| 41 | preprocessed = preprocess() |
| 42 | if preprocessed is None: |
| 43 | return |
| 44 | |
| 45 | # Parse the lines. |
| 46 | srclines = ((l.file, l.data) for l in preprocessed if l.kind == 'source') |
| 47 | for item in _parse(srclines, **srckwargs): |
| 48 | if match_kind is not None and not match_kind(item.kind): |
| 49 | continue |
| 50 | if not item.filename: |
| 51 | raise NotImplementedError(repr(item)) |
| 52 | yield item |
| 53 | |
| 54 | |
| 55 | def _resolve_max_size(filename, maxsizes): |
no test coverage detected
searching dependent graphs…