From 39f92f41f954817ce300716e8e4e6c22fd59624e Mon Sep 17 00:00:00 2001 From: Aleksey Lim Date: Sun, 08 Sep 2013 08:10:20 +0000 Subject: Process zipped directories properly --- diff --git a/sugar_network/toolkit/bundle.py b/sugar_network/toolkit/bundle.py index 067bb5e..7d484ad 100644 --- a/sugar_network/toolkit/bundle.py +++ b/sugar_network/toolkit/bundle.py @@ -75,14 +75,17 @@ class Bundle(object): try: prefix = prefix.strip(os.sep) + os.sep for arcname in self.get_names(): - dst_path = arcname.strip(os.sep) + dst_path = arcname.lstrip(os.sep) if dst_path.startswith(prefix): dst_path = dst_path[len(prefix):] dst_path = join(dst_root, dst_path) - if not exists(dirname(dst_path)): - os.makedirs(dirname(dst_path)) - with file(dst_path, 'wb') as dst: - shutil.copyfileobj(self.extractfile(arcname), dst) + if dst_path.endswith(os.sep): + os.makedirs(dst_path) + else: + if not exists(dirname(dst_path)): + os.makedirs(dirname(dst_path)) + with file(dst_path, 'wb') as dst: + shutil.copyfileobj(self.extractfile(arcname), dst) except Exception: if exists(dst_root): shutil.rmtree(dst_root) -- cgit v0.9.1