ifnot os.path.isfile(untar_path): print("{} is not file!".format(untar_path)) sys.exit() if os.path.exists(out_dir): if os.path.isfile(out_dir): print("{} is file!".format(out_dir)) sys.exit() else: print("mkdir {}".format(out_dir)) os.mkdir(out_dir) ifnot os.path.exists(out_dir): print("{} is not exists!".format(out_dir)) sys.exit() print("tar({}) \nout dir({})".format(untar_path, out_dir)) return
defuntar(tarpath, outdir): tar = tarfile.open(tarpath) tar.extractall(path = outdir) tar.close() return
if __name__ == "__main__": '''main''' parse_usage() untar(untar_path, out_dir)