changeset 9:562230cc2e86

now the package class should at least extracts things. it doesnt actually do anything useful
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 23 Feb 2012 17:49:05 -0800
parents c1181e9c9ca2
children d63ae03cc300
files paint/package.py
diffstat 1 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/paint/package.py	Thu Feb 23 17:45:47 2012 -0800
+++ b/paint/package.py	Thu Feb 23 17:49:05 2012 -0800
@@ -3,6 +3,7 @@
 """
 
 import os
+import shutil
 import tarfile
 import tempfile
 import urllib2
@@ -52,10 +53,19 @@
         # TODO: should handle zipfile additionally at least
         # Ideally, this would be pluggable, etc
         assert tarfile.is_tarfile(archive), "%s is not an archive" % self.src
-        tarfile.TarFile.open(archive)
+        tf = tarfile.TarFile.open(archive)
+        self._tmppath = tempfile.mkdtemp()
+        tf.extractall(path=self._tmppath)
 
     def is_archive(self, path):
         """returns if the filesystem path is an archive"""
         # TODO: should handle zipfile additionally at least
         # Ideally, this would be pluggable, etc
         return tarfile.is_tarfile(path)
+
+    def cleanup(self):
+        if self._tmppath:
+            shutil.rmtree(self._tmppath)
+        self._tmppath = None
+
+    __del__ = cleanup