Commits

Michał Górny  committed adbd857

Use recoding for action output as well.

  • Participants
  • Parent commits a003598

Comments (0)

Files changed (2)

File lib/flaggie/action.py

 			def __hash__(self):
 				return hash(self.pattern)
 
-		def __init__(self, arg, key):
+		def __init__(self, arg, key, output = None):
 			self.args = set((arg,))
 			self.ns = None
+			self.output = output
 
 		def clarify(self, pkgs, cache):
 			if len(self.args) > 1:

File lib/flaggie/cli.py

 from flaggie.packagefile import PackageFiles
 
 def parse_actions(args, dbapi, settings, quiet = False, strict = False, \
-		cleanupact = [], output = sys.stderr):
+		cleanupact = [], dataout = sys.stdout, output = sys.stderr):
 	out = []
 	cache = Caches(dbapi)
 	actset = ActionSet(cache = cache)
 			continue
 		try:
 			try:
-				act = Action(a)
+				act = Action(a, output = dataout)
 			except Action.NotAnAction:
 				if actset:
 					# Avoid transforming actset with all atoms being
 	locale.setlocale(locale.LC_ALL, '')
 	# Python3 does std{in,out,err} and argv recoding implicitly
 	if not hasattr(argv[0], 'decode'):
+		dataout = sys.stdout
 		output = sys.stderr
 	else:
 		indec = codecs.getdecoder(locale.getpreferredencoding())
 		argv = [indec(x)[0] for x in argv]
+		dataout = codecs.getwriter(locale.getpreferredencoding())(sys.stderr, 'backslashescape')
 		output = codecs.getwriter(locale.getpreferredencoding())(sys.stderr, 'backslashescape')
 
 	for a in list(argv[1:]):
 
 	act = parse_actions(argv[1:], porttree.dbapi, porttree.settings, \
 			quiet = quiet, strict = strict, cleanupact = cleanup_actions, \
-			output = output)
+			output = output, dataout = dataout)
 	if act is None:
 		return 1
 	if not act: