changeset 8:c1181e9c9ca2

yet more stubbing
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 23 Feb 2012 17:45:47 -0800
parents a7bf894c96c7
children 562230cc2e86
files paint/package.py
diffstat 1 files changed, 9 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/paint/package.py	Thu Feb 23 17:41:54 2012 -0800
+++ b/paint/package.py	Thu Feb 23 17:45:47 2012 -0800
@@ -26,19 +26,21 @@
         tmpfile = None
         src = self.src
         if utils.isURL(self.src):
-            tmpfile = self.fetch()
-            return self._tmppath
+            tmpfile = src = self.fetch()
 
         # unpack if an archive
         if self.is_archive(src):
-            self.unpack(src)
+            try:
+                self.unpack(src)
+            finally:
+                if tmpfile:
+                    os.remove(tmpfile)
             return self._tmppath
 
         return self.src
 
     def fetch(self):
-        """fetch from remote source"""
-
+        """fetch from remote source to a temporary file"""
         fd, filename = tmpfile.mkstemp()
         resource = urllib.urlopen(self.src)
         os.write(fd, resource.read())
@@ -49,8 +51,8 @@
         """unpack the archive to a temporary destination"""
         # TODO: should handle zipfile additionally at least
         # Ideally, this would be pluggable, etc
-        assert tarfile.is_tarfile
-        tarfile.TarFile.open(
+        assert tarfile.is_tarfile(archive), "%s is not an archive" % self.src
+        tarfile.TarFile.open(archive)
 
     def is_archive(self, path):
         """returns if the filesystem path is an archive"""