diff options
author | Marco Pesenti Gritti <marco@localhost.localdomain> | 2008-06-13 10:37:45 (GMT) |
---|---|---|
committer | Marco Pesenti Gritti <marco@localhost.localdomain> | 2008-06-13 10:37:45 (GMT) |
commit | cfdc17d6c936f2570b98c9978f493fca18d8276f (patch) | |
tree | 79bd196f40b20986176e575582301e28270d7ca4 /src/sugar/bundle/bundle.py | |
parent | de04b1500f1c12030f5057c34ba1a15cae709159 (diff) |
Patch by Jameson Chema Quinn.
Readability cleanups and little fixes by me.
use MANIFEST. Deprecate bundle_name. fix_manifest().
bundlebuilder.config() cleanup.
Diffstat (limited to 'src/sugar/bundle/bundle.py')
-rw-r--r-- | src/sugar/bundle/bundle.py | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/sugar/bundle/bundle.py b/src/sugar/bundle/bundle.py index 47d08b2..9e876c2 100644 --- a/src/sugar/bundle/bundle.py +++ b/src/sugar/bundle/bundle.py @@ -96,13 +96,15 @@ class Bundle: 'All files in the bundle must be inside a single ' + 'top-level directory') - def _get_file(self, filename): + def get_file(self, filename): f = None if self._unpacked: path = os.path.join(self._path, filename) - if os.path.isfile(path): - f = open(path) + try: + f = open(path,"rb") + except IOError: + return None else: zip_file = zipfile.ZipFile(self._path) path = os.path.join(self._zip_root_dir, filename) @@ -114,6 +116,23 @@ class Bundle: zip_file.close() return f + + def is_file(self, filename): + if self._unpacked: + path = os.path.join(self._path, filename) + return os.path.isfile(path) + else: + zip_file = zipfile.ZipFile(self._path) + path = os.path.join(self._zip_root_dir, filename) + try: + zip_file.getinfo(path) + except KeyError: + return False + finally: + zip_file.close() + + return True + def get_path(self): """Get the bundle path.""" |