# HG changeset patch # User Jeff Hammel # Date 1333148293 25200 # Node ID 06f21791eba1da01a3fa67ba5fb8fb4d1e5cb0a1 # Parent cc25499e9485685dc43ad48633ab985b8b94dbc3 add yet another indirection layer diff -r cc25499e9485 -r 06f21791eba1 paint/package.py --- a/paint/package.py Fri Mar 30 15:46:37 2012 -0700 +++ b/paint/package.py Fri Mar 30 15:58:13 2012 -0700 @@ -36,6 +36,7 @@ self._tmppath = None self._egg_info_path = None self._build_path = None + self._pkg_info_path = None # TODO: list of temporary files/directories to be deleted @@ -151,19 +152,34 @@ self._egg_info_path = egg_info return self._egg_info_path - def info(self): - """return info dictionary for package""" - # could use pkginfo + def _pkg_info(self): + """returns path to PKG-INFO file""" if self._pkg_info_path: - pkg_info = self._pkg_info_path - else: - try: - egg_info = self._egg_info() - pkg_info = os.path.join(egg_info, 'PKG-INFO') - except BaseException, exception: - # try to get the package info from a file - raise NotImplementedError("TODO: try to get the package info from a file") + # return cached value + return self._pkg_info_path + + try: + egg_info = self._egg_info() + except BaseException, exception: + # try to get the package info from a file + path = self._path() + pkg_info = os.path.join(path, 'PKG-INFO') + if os.path.exists(pkg_info): + self._pkg_info_path = pkg_info + return self._pkg_info_path + raise Exception("Cannot find or generate PKG-INFO") + + pkg_info = os.path.join(egg_info, 'PKG-INFO') + assert os.path.exists(pkg_info) + self._pkg_info_path = pkg_info + return self._pkg_info_path + + def info(self): + """return info dictionary for package""" + # could use pkginfo module + + pkg_info = self._pkg_info() # read the package information info_dict = {}