Created
February 2, 2011 17:35
-
-
Save serian/808041 to your computer and use it in GitHub Desktop.
python tar.gz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tarfile | |
tgzfile = tarfile.open(tgz_name,'w:gz') | |
cp_dir = os.path.join(tgt_dir, cp_dir_name) | |
if not os.exists(cp_dir): | |
os.mkdir(cp_dir) | |
for k, v in sorted(tgt_xml_dct.items(), key=lambda x:x[1]): | |
tgzfile.add(k, os.path.join(cp_dir_name, os.path.basename(k))) | |
shutil.copy(k, cp_dir) | |
tgzfile.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
addメソッドで格納する時のディレクトリ構造を指定