[TIC-CORE] Set the default installation packages
[archive/20170607/tools/tic-core.git] / tic / utils / file.py
index 9e51ffb..b1cf3ac 100644 (file)
@@ -22,7 +22,7 @@
 import errno
 import gzip
 import os
-
+import shutil
 
 def make_dirs(dirname):
     try:
@@ -43,11 +43,13 @@ def decompress_gzip(intput_path, output_path):
         f.write(fobj.read())
         f.close()
     return output_path
-     
-# def decompress_bunzip(intput_path, output_path):
-#     with open(output_path, 'wb') as new_file, bz2.BZ2File(intput_path, 'rb') as file:
-#         for data in iter(lambda : file.read(100 * 1024), b''):
-#             new_file.write(data)
-
 
\ No newline at end of file
+def copyfile(src, dst, filename=None):
+    abs_dst=os.path.abspath(os.path.expanduser(dst))
+    make_dirs(abs_dst)
+    if filename:
+        abs_dst = os.path.join(abs_dst, filename)
+    shutil.copy(src, abs_dst)
+    if filename:
+        return abs_dst
+    return os.path.join(abs_dst, os.path.basename(src))
\ No newline at end of file