~lifeless/meliae/stuff

« back to all changes in this revision

Viewing changes to meliae/files.py

  • Committer: John Arbash Meinel
  • Date: 2009-09-11 17:52:35 UTC
  • Revision ID: john@arbash-meinel.com-20090911175235-5k1cqyq61s18i0ix
It didn't really seem safe to open the file in raw mode
to pass it into a Gzip stream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
    
32
32
    :return: An iterator of lines, and a cleanup function.
33
33
    """
34
 
    source = open(filename, 'r')
 
34
    source = open(filename, 'rb')
35
35
    gzip_source = gzip.GzipFile(mode='rb', fileobj=source)
36
36
    try:
37
37
        line = gzip_source.readline()
42
42
        source.seek(0)
43
43
        return source, None
44
44
    else:
 
45
        # We don't need these anymore, so close them out in case the rest of
 
46
        # the code raises an exception.
45
47
        gzip_source.close()
46
48
        source.close()
47
49
        # a gzip file