Commits

Michał Górny committed c113836

Support matching license groups in package.license.

  • Participants
  • Parent commits cb2ec29

Comments (0)

Files changed (1)

File lib/flaggie/cache.py

 
 	class LicenseCache(DBAPICache):
 		aux_key = 'LICENSE'
+		_groupcache = None
+
+		@property
+		def groups(self):
+			if self._groupcache is None:
+				self._groupcache = {}
+				for r in self.dbapi.porttrees:
+					for k, v in grabdict(os.path.join(r, 'profiles', 'license_groups')).items():
+						k = '@%s' % k
+						if k not in self._groupcache:
+							self._groupcache[k] = set()
+						self._groupcache[k].update(v)
+
+			return self._groupcache
 
 		@property
 		def glob(self):
 						lic.update(os.listdir(os.path.join(r, 'licenses')))
 					except OSError:
 						pass
-
-					lgroups = grabdict(os.path.join(r, 'profiles', 'license_groups'))
-					lic.update(['@%s' % x for x in lgroups])
+					lic.update(self.groups)
 
 				lic.discard('CVS')
 				self.cache[None] = frozenset(lic)
 
 			lic = set(lic)
 			lic.discard('||')
+			lic.update([k for k, v in self.groups.items() if lic & v])
 			return lic
 
 	class EnvCache(object):