1. Michał Górny
  2. flaggie

Commits

Michał Górny  committed 2132fc4

Move cleanup actions into flaggie.cleanup.

  • Participants
  • Parent commits 8aef075
  • Branches master

Comments (0)

Files changed (2)

File lib/flaggie/cleanup.py

View file
  • Ignore whitespace
+#!/usr/bin/python
+#	vim:fileencoding=utf-8
+# (C) 2010 Michał Górny <gentoo@mgorny.alt.pl>
+# Released under the terms of the 3-clause BSD license.
+
+class BaseCleanupAction(object):
+	def __init__(self, *args):
+		if args:
+			self(*args)
+
+	def __call__(self, pfiles):
+		for f in pfiles:
+			self._perform(f)
+
+class SortEntries(BaseCleanupAction):
+	def _perform(self, f):
+		f.sort()
+
+class SortFlags(BaseCleanupAction):
+	def _perform(self, f):
+		for pe in f:
+			pe.sort()

File lib/flaggie/cli.py

View file
  • Ignore whitespace
 from flaggie import PV
 from flaggie.action import Action, ActionSet, ParserError
 from flaggie.cache import Caches
+from flaggie.cleanup import SortEntries, SortFlags
 from flaggie.packagefile import PackageFiles
 
 def parse_actions(args, dbapi, settings):
 			print('Warning: %s' % e)
 
 	if sort_flags:
-		for f in pfiles:
-			for pe in f:
-				pe.sort()
+		SortFlags(pfiles)
 	if sort_entries:
-		for f in pfiles:
-			f.sort()
+		SortEntries(pfiles)
 
 	pfiles.write()