From a1d1a7425077843862ce4954d9b75f8ad4a98cfc Mon Sep 17 00:00:00 2001
From: Zac Medico <zmedico@gentoo.org>
Date: Tue, 2 Mar 2010 20:32:53 +0000
Subject: [PATCH] Use a property to trigger deprecation warnings if
 binarytree.remotepkgs is accessed. (trunk r15379)

svn path=/main/branches/2.1.7/; revision=15606
---
 pym/portage/dbapi/bintree.py | 36 +++++++++++++++++++++++++++---------
 1 file changed, 27 insertions(+), 9 deletions(-)

diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py
index ce636dd9c..3fd098db1 100644
--- a/pym/portage/dbapi/bintree.py
+++ b/pym/portage/dbapi/bintree.py
@@ -163,7 +163,7 @@ class binarytree(object):
 			self._remote_has_index = False
 			self._remote_base_uri = None
 			self._remotepkgs = None # remote metadata indexed by cpv
-			self.remotepkgs = {}  # indexed by tbz2 name (deprecated)
+			self.__remotepkgs = {}  # indexed by tbz2 name (deprecated)
 			self.invalids = []
 			self.settings = settings
 			self._pkg_paths = {}
@@ -223,6 +223,24 @@ class binarytree(object):
 				chain(*self._pkgindex_translated_keys)
 			))
 
+	def _get_remotepkgs(self):
+		warnings.warn("Use binarytree._remotepkgs insead of binarytree.remotepkgs",
+			DeprecationWarning)
+		return self.__remotepkgs
+
+	def _set_remotepkgs(self, remotepkgs):
+		warnings.warn("Use binarytree._remotepkgs insead of binarytree.remotepkgs",
+			DeprecationWarning)
+		self.__remotepkgs = remotepkgs
+
+	def _del_remotepkgs(self):
+		warnings.warn("Use binarytree._remotepkgs insead of binarytree.remotepkgs",
+			DeprecationWarning)
+		del self.__remotepkgs
+
+	remotepkgs = property(_get_remotepkgs, _set_remotepkgs, _del_remotepkgs,
+		"Deprecated self.remotepkgs, only for backward compatibility")
+
 	def move_ent(self, mylist):
 		if not self.populated:
 			self.populate()
@@ -753,7 +771,7 @@ class binarytree(object):
 					self._remotepkgs[d["CPV"]] = d
 				self._remote_has_index = True
 				self._remote_base_uri = pkgindex.header.get("URI", base_url)
-				self.remotepkgs = {}
+				self.__remotepkgs = {}
 				for cpv in self._remotepkgs:
 					self.dbapi.cpv_inject(cpv)
 				self.populated = 1
@@ -798,18 +816,18 @@ class binarytree(object):
 			writemsg_stdout(
 				colorize("GOOD", _("Fetching bininfo from ")) + \
 				re.sub(r'//(.+):.+@(.+)/', r'//\1:*password*@\2/', base_url) + "\n")
-			self.remotepkgs = portage.getbinpkg.dir_get_metadata(
+			self.__remotepkgs = portage.getbinpkg.dir_get_metadata(
 				self.settings["PORTAGE_BINHOST"], chunk_size=chunk_size)
 			#writemsg(green("  -- DONE!\n\n"))
 
-			for mypkg in list(self.remotepkgs):
-				if "CATEGORY" not in self.remotepkgs[mypkg]:
+			for mypkg in list(self.__remotepkgs):
+				if "CATEGORY" not in self.__remotepkgs[mypkg]:
 					#old-style or corrupt package
 					writemsg(_("!!! Invalid remote binary package: %s\n") % mypkg,
 						noiselevel=-1)
-					del self.remotepkgs[mypkg]
+					del self.__remotepkgs[mypkg]
 					continue
-				mycat = self.remotepkgs[mypkg]["CATEGORY"].strip()
+				mycat = self.__remotepkgs[mypkg]["CATEGORY"].strip()
 				fullpkg = mycat+"/"+mypkg[:-5]
 
 				if fullpkg in metadata:
@@ -832,7 +850,7 @@ class binarytree(object):
 					# invalid tbz2's can hurt things.
 					#print "cpv_inject("+str(fullpkg)+")"
 					self.dbapi.cpv_inject(fullpkg)
-					remote_metadata = self.remotepkgs[mypkg]
+					remote_metadata = self.__remotepkgs[mypkg]
 					for k, v in remote_metadata.items():
 						remote_metadata[k] = v.strip()
 
@@ -853,7 +871,7 @@ class binarytree(object):
 				except:
 					writemsg(_("!!! Failed to inject remote binary package: %s\n") % fullpkg,
 						noiselevel=-1)
-					del self.remotepkgs[mypkg]
+					del self.__remotepkgs[mypkg]
 					continue
 		self.populated=1
 
-- 
2.26.2