Commits

Aleš Erjavec committed 75b8b5b

Add support for bz2 compressed files.

  • Participants
  • Parent commits 1479961

Comments (0)

Files changed (1)

File Orange/utils/serverfiles.py

 
 import os
 import shutil
+import tarfile
+import gzip
+import bz2
 import glob
 import datetime
 import tempfile
     _save_file_info(target + '.info', info)
     
     if extract:
-        import tarfile, gzip, shutil
-        if specialtags.get("#compression") == "tar.gz" and specialtags.get("#files"):
+        if specialtags.get("#compression") in ["tar.gz", "tar.bz2"] and \
+                specialtags.get("#files"):
             f = tarfile.open(target + ".tmp")
             f.extractall(localpath(domain))
             shutil.copyfile(target + ".tmp", target)
         elif specialtags.get("#compression") == "gz":
             f = gzip.open(target + ".tmp")
             shutil.copyfileobj(f, open(target, "wb"))
+        elif specialtags.get("#compression") == "bz2":
+            f = bz2.BZ2File(target + ".tmp", "r")
+            shutil.copyfileobj(f, open(target, "wb"))
         f.close()
         os.remove(target + ".tmp")