Commits

David McClosky committed ed13fc7

waterworks/Files: support for arguments to openers in possibly_compressed_file

  • Participants
  • Parent commits fb81f3f

Comments (0)

Files changed (1)

File waterworks/Files.py

 
     return tf
 
-def possibly_compressed_file(filename, mode='r'):
+def possibly_compressed_file(filename, mode='r', opener_args=None):
     from bz2 import BZ2File
     if filename.lower().endswith('.gz'):
         opener = GzipFile
     else:
         opener = file
 
-    return opener(filename, mode)
+    opener_args = opener_args or {}
+    opener_args = opener_args.get(opener, {})
+    return opener(filename, mode, **opener_args)
 
 
 def read_file_with_timeout(fileobject, timeout=1):