changeset 14:6d27c2136163

a decent structure; need to reuse more
author Jeff Hammel <jhammel@mozilla.com>
date Fri, 24 Feb 2012 15:50:31 -0800
parents 0dd1f8f83be2
children 8c8b7482772f
files paint/package.py
diffstat 1 files changed, 20 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/paint/package.py	Fri Feb 24 15:39:42 2012 -0800
+++ b/paint/package.py	Fri Feb 24 15:50:31 2012 -0800
@@ -84,10 +84,6 @@
             # return cached copy
             return self._egg_info
 
-        directory = self.path
-
-    def info(self):
-        """return info dictionary for package"""
         directory = self.path()
         assert os.path.exists(os.path.join(path, 'setup.py'))
 
@@ -101,12 +97,15 @@
         egg_info = os.path.join(directory, egg_info[0])
         assert os.path.isdir(egg_info), "%s is not a directory" % egg_info
 
-        # read the dependencies
-        requires = os.path.join(egg_info, 'requires.txt')
-        if os.path.exists(requires):
-            dependencies = [i.strip() for i in file(requires).readlines() if i.strip()]
-        else:
-            dependencies = []
+        # cache it
+        self._egg_info = egg_info
+        return self._egg_info
+
+    def info(self):
+        """return info dictionary for package"""
+        # could use pkginfo
+
+        egg_info = self.egg_info()
 
         # read the package information
         pkg_info = os.path.join(egg_info, 'PKG-INFO')
@@ -122,4 +121,14 @@
         return info_dict['Name'], dependencies
 
     def dependencies(self):
-        info = self.info()
+        """return the dependencies"""
+
+        egg_info = self.egg_info()
+
+        # read the dependencies
+        requires = os.path.join(egg_info, 'requires.txt')
+        if os.path.exists(requires):
+            dependencies = [i.strip() for i in file(requires).readlines() if i.strip()]
+        else:
+            dependencies = []
+