aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJauhien Piatlicki (jauhien) <piatlicki@gmail.com>2013-07-17 19:04:20 +0200
committerJauhien Piatlicki (jauhien) <piatlicki@gmail.com>2013-07-17 19:04:20 +0200
commit1a08be09e50ba9bdce2e7838db2d120f22279e80 (patch)
tree7e646cad9a0da7e162a0d1ad5ac2bd4be6c7657f /g_sorcery/fileutils.py
parentg_sorcery/package_db: split generate_tree function (diff)
downloadg-sorcery-1a08be09e50ba9bdce2e7838db2d120f22279e80.tar.gz
g-sorcery-1a08be09e50ba9bdce2e7838db2d120f22279e80.tar.bz2
g-sorcery-1a08be09e50ba9bdce2e7838db2d120f22279e80.zip
g_sorcery/fileutils: xz files support
Diffstat (limited to 'g_sorcery/fileutils.py')
-rw-r--r--g_sorcery/fileutils.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/g_sorcery/fileutils.py b/g_sorcery/fileutils.py
index 115f330..cdec458 100644
--- a/g_sorcery/fileutils.py
+++ b/g_sorcery/fileutils.py
@@ -212,8 +212,7 @@ def _call_loader(f_name, loader, open_file = True, open_mode = 'r'):
return {os.path.basename(f_name): data}
-def load_remote_file(uri, loader, open_file = True, open_mode='r',
- process_unpacked_as_directory = False):
+def load_remote_file(uri, loader, open_file = True, open_mode='r'):
download_dir = TemporaryDirectory()
loaded_data = {}
if wget(uri, download_dir.name):
@@ -223,14 +222,16 @@ def load_remote_file(uri, loader, open_file = True, open_mode='r',
unpack_dir = TemporaryDirectory()
with tarfile.open(f_name) as f:
f.extractall(unpack_dir.name)
- if process_unpacked_as_directory:
- loaded_data.update(_call_loader(unpack_dir.name, loader, open_file=False))
- else:
- for uf_name in glob.glob(os.path.join(unpack_dir, "*")):
- loaded_data.update(_call_loader(uf_name, loader,
+ for uf_name in glob.glob(os.path.join(unpack_dir, "*")):
+ loaded_data.update(_call_loader(uf_name, loader,
open_file=open_file, open_mode=open_mode))
del unpack_dir
else:
+ name, extention = os.path.splitext(f_name)
+ if (extention == ".xz"):
+ if (os.system("xz -d " + f_name)):
+ raise DownloadingError("xz failed: " + f_name + " from " + uri)
+ f_name = name
loaded_data.update(_call_loader(f_name, loader,
open_file=open_file, open_mode=open_mode))
del download_dir