Open a sequence of filenames one at a time producing a file object. The file is closed immediately when proceeding to the next iteration.
(filenames)
| 13 | yield os.path.join(path, name) |
| 14 | |
| 15 | def gen_opener(filenames): |
| 16 | ''' |
| 17 | Open a sequence of filenames one at a time producing a file object. |
| 18 | The file is closed immediately when proceeding to the next iteration. |
| 19 | ''' |
| 20 | for filename in filenames: |
| 21 | if filename.endswith('.gz'): |
| 22 | f = gzip.open(filename, 'rt') |
| 23 | elif filename.endswith('.bz2'): |
| 24 | f = bz2.open(filename, 'rt') |
| 25 | else: |
| 26 | f = open(filename, 'rt') |
| 27 | yield f |
| 28 | f.close() |
| 29 | |
| 30 | def gen_concatenate(iterators): |
| 31 | ''' |
no test coverage detected