Commits

Michał Górny  committed c19281a

Support package.keywords file defaults.

  • Participants
  • Parent commits 7bbc873

Comments (0)

Files changed (2)

File lib/flaggie/cli.py

 		return 0
 
 	pfiles = PackageFiles(os.path.join( \
-		porttree.settings['PORTAGE_CONFIGROOT'], USER_CONFIG_PATH))
+		porttree.settings['PORTAGE_CONFIGROOT'], USER_CONFIG_PATH), porttree)
 
 	for actset in act:
 		try:

File lib/flaggie/packagefile.py

 				f.remove(e)
 			f.modified = True
 
+class PackageKeywordsFileSet(PackageFileSet):
+	def __init__(self, path, dbapi):
+		PackageFileSet.__init__(self, path)
+
+		self._defkw = ['~' + x for x \
+				in dbapi.settings['ACCEPT_KEYWORDS'].split() \
+				if x[0] not in ('~', '-')]
+
+	def read(self, *args):
+		if self._files:
+			return
+
+		PackageFileSet.read(*((self,) + args))
+
+		# set defaults
+		for e in self:
+			if not e:
+				for f in self._defkw:
+					e.append(f)
+				e.modified = False
+
 class PackageFiles(object):
-	def __init__(self, basedir):
+	def __init__(self, basedir, dbapi):
 		p = lambda x: os.path.join(basedir, x)
 		self.files = {
 			'use': PackageFileSet(p('package.use')),
-			'kw': PackageFileSet(p('package.keywords')),
+			'kw': PackageKeywordsFileSet(p('package.keywords'), dbapi),
 			'lic': PackageFileSet(p('package.license'))
 		}