(entries, *, ignoresep=None)
| 9 | |
| 10 | |
| 11 | def parse_entries(entries, *, ignoresep=None): |
| 12 | for entry in entries: |
| 13 | if ignoresep and ignoresep in entry: |
| 14 | subentries = [entry] |
| 15 | else: |
| 16 | subentries = entry.strip().replace(',', ' ').split() |
| 17 | for item in subentries: |
| 18 | if item.startswith('+'): |
| 19 | filename = item[1:] |
| 20 | try: |
| 21 | infile = open(filename) |
| 22 | except FileNotFoundError: |
| 23 | logger.debug(f'ignored in parse_entries(): +{filename}') |
| 24 | return |
| 25 | with infile: |
| 26 | # We read the entire file here to ensure the file |
| 27 | # gets closed sooner rather than later. Note that |
| 28 | # the file would stay open if this iterator is never |
| 29 | # exhausted. |
| 30 | lines = infile.read().splitlines() |
| 31 | for line in _iter_significant_lines(lines): |
| 32 | yield line, filename |
| 33 | else: |
| 34 | yield item, None |
| 35 | |
| 36 | |
| 37 | def _iter_significant_lines(lines): |
nothing calls this directly
no test coverage detected
searching dependent graphs…