Merge release-0.28.17 from 'tools/mic'
[platform/upstream/mic.git] / mic / archive.py
index 72f506f..c6fde02 100644 (file)
@@ -20,7 +20,7 @@
 #  * Used builtin function (W0141)
 #  * Invalid name for type (C0103)
 #  * Popen has no '%s' member (E1101)
-# pylint: disable=W0142, W0612, W0141, C0103, E1101
+# pylint: disable= W0612, C0103, E1101
 
 """ Compression and Archiving
 
@@ -203,12 +203,12 @@ def compress(file_path, compress_format):
     @retval: the path of the compressed file
     """
     if not os.path.isfile(file_path):
-        raise OSError, "can't compress a file not existed: '%s'" % file_path
+        raise OSError  ("can't compress a file not existed: '%s'" % file_path)
 
     try:
         func = _COMPRESS_FORMATS[compress_format]
     except KeyError:
-        raise ValueError, "unknown compress format '%s'" % compress_format
+        raise ValueError ("unknown compress format '%s'" % compress_format)
     return func(file_path, True)
 
 def decompress(file_path, decompress_format=None):
@@ -219,7 +219,7 @@ def decompress(file_path, decompress_format=None):
     @retval: the path of the decompressed file
     """
     if not os.path.isfile(file_path):
-        raise OSError, "can't decompress a file not existed: '%s'" % file_path
+        raise OSError ("can't decompress a file not existed: '%s'" % file_path)
 
     (file_name, file_ext) = os.path.splitext(file_path)
     for key, suffixes in _COMPRESS_SUFFIXES.iteritems():
@@ -237,7 +237,7 @@ def decompress(file_path, decompress_format=None):
     try:
         func = _COMPRESS_FORMATS[decompress_format]
     except KeyError:
-        raise ValueError, "unknown decompress format '%s'" % decompress_format
+        raise ValueError ("unknown decompress format '%s'" % decompress_format)
     return func(file_path, False)
 
 
@@ -276,7 +276,7 @@ def _do_untar(archive_name, target_dir=None):
     cmdln = ["tar", "-C", target_dir, "-xf", archive_name]
     (returncode, stdout, stderr) = _call_external(cmdln)
     if returncode != 0:
-        raise OSError, os.linesep.join([stdout, stderr])
+        raise OSError (os.linesep.join([stdout, stderr]))
 
 def _imp_tarfile(archive_name, target_name):
     """ Archive the directory or the file with tarfile module
@@ -400,19 +400,19 @@ def make_archive(archive_name, target_name):
     @retval: the archiving result
     """
     if not os.path.exists(target_name):
-        raise OSError, "archive object does not exist: '%s'" % target_name
+        raise OSError ("archive object does not exist: '%s'" % target_name)
 
     for aformat, suffixes in _ARCHIVE_SUFFIXES.iteritems():
         if filter(archive_name.endswith, suffixes):
             archive_format = aformat
             break
     else:
-        raise ValueError, "unknown archive suffix '%s'" % archive_name
+        raise ValueError ("unknown archive suffix '%s'" % archive_name)
 
     try:
         func, kwargs = _ARCHIVE_FORMATS[archive_format]
     except KeyError:
-        raise ValueError, "unknown archive format '%s'" % archive_format
+        raise ValueError ("unknown archive format '%s'" % archive_format)
 
     archive_name = os.path.abspath(archive_name)
     target_name = os.path.abspath(target_name)
@@ -431,14 +431,14 @@ def extract_archive(archive_name, target_name):
     raise exception if fail to extract archive
     """
     if not os.path.exists(archive_name):
-        raise OSError, "archived object does not exist: '%s'" % archive_name
+        raise OSError ("archived object does not exist: '%s'" % archive_name)
 
     archive_name = os.path.abspath(archive_name)
     target_name = os.path.abspath(target_name)
 
     if os.path.exists(target_name) and not os.path.isdir(target_name):
-        raise OSError"%s should be directory where extracted files locate"\
-                        % target_name
+        raise OSError ("%s should be directory where extracted files locate"\
+                        % target_name)
 
     if not os.path.exists(target_name):
         os.makedirs(target_name)