[Debtags-commits] [svn] r1860 - python

Enrico Zini enrico at costa.debian.org
Sun Aug 27 21:00:06 UTC 2006


Author: enrico
Date: Sun Aug 27 21:00:04 2006
New Revision: 1860

Added:
   python/smartsearch   (contents, props changed)
Modified:
   python/   (props changed)
   python/Debtags.py
Log:
 r3197 at viaza:  enrico | 2006-08-27 10:42:13 +0100
 Reimplemented commandline interactive smartsearch


Modified: python/Debtags.py
==============================================================================
--- python/Debtags.py	(original)
+++ python/Debtags.py	Sun Aug 27 21:00:04 2006
@@ -182,12 +182,31 @@
 		"""Check if the collection contains packages tagged with tag"""
 		return self.rdb.has_key(tag)
 
+	def tagsOfPackage(self, pkg):
+		"""Return the tag set of a package"""
+		return self.db.has_key(pkg) and self.db[pkg] or set()
+
+	def packagesOfTag(self, tag):
+		"""Return the package set of a tag"""
+		return self.rdb.has_key(tag) and self.rdb[tag] or set()
+
 	def card(self, tag):
 		"""
 		Return the cardinality of a tag
 		"""
 		return self.rdb.has_key(tag) and len(self.rdb[tag]) or 0
 
+	def discriminance(self, tag):
+		"""
+		Return the discriminance index if the tag, that is, the minimum
+		number of packages that would be eliminated by selecting only
+		those tagged with this tag or only those not tagged with this
+		tag.
+		"""
+		n = self.card(tag)
+		tot = self.tagCount()
+		return min(n, tot - n)
+
 	def iterPackages(self):
 		"""Iterate over the packages"""
 		return self.db.iterkeys()
@@ -196,6 +215,14 @@
 		"""Iterate over the tags"""
 		return self.rdb.iterkeys()
 
+	def iterPackagesTags(self):
+		"""Iterate over 2-tuples of (pkg, tags)"""
+		return self.db.iteritems()
+
+	def iterTagsPackages(self):
+		"""Iterate over 2-tuples of (tag, pkgs)"""
+		return self.rdb.iteritems()
+
 	def packageCount(self):
 		"""Return the number of packages"""
 		return len(self.db)



More information about the Debtags-commits mailing list