From cfdc17d6c936f2570b98c9978f493fca18d8276f Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Fri, 13 Jun 2008 10:37:45 +0000 Subject: Patch by Jameson Chema Quinn. Readability cleanups and little fixes by me. use MANIFEST. Deprecate bundle_name. fix_manifest(). bundlebuilder.config() cleanup. --- (limited to 'src/sugar/bundle/bundle.py') 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.""" -- cgit v0.9.1