From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-697042-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (unknown [208.92.234.80])
	by finch.gentoo.org (Postfix) with ESMTP id 041E21381FA
	for <garchives@archives.gentoo.org>; Fri, 16 May 2014 01:07:16 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id BBE67E0AD0;
	Fri, 16 May 2014 01:07:12 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id E200BE0AD0
	for <gentoo-commits@lists.gentoo.org>; Fri, 16 May 2014 01:07:11 +0000 (UTC)
Received: from spoonbill.gentoo.org (unknown [81.93.255.5])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 0AB4D34006F
	for <gentoo-commits@lists.gentoo.org>; Fri, 16 May 2014 01:07:10 +0000 (UTC)
Received: from localhost.localdomain (localhost [127.0.0.1])
	by spoonbill.gentoo.org (Postfix) with ESMTP id 41B69182D8
	for <gentoo-commits@lists.gentoo.org>; Fri, 16 May 2014 01:07:07 +0000 (UTC)
From: "Devan Franchini" <twitch153@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Devan Franchini" <twitch153@gentoo.org>
Message-ID: <1400202406.77fa5d8cd3ead77a9fb03ced890a874d98f9e604.twitch153@gentoo>
Subject: [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
X-VCS-Repository: proj/layman
X-VCS-Files: layman/cli.py
X-VCS-Directories: layman/
X-VCS-Committer: twitch153
X-VCS-Committer-Name: Devan Franchini
X-VCS-Revision: 77fa5d8cd3ead77a9fb03ced890a874d98f9e604
X-VCS-Branch: gsoc2014
Date: Fri, 16 May 2014 01:07:07 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Archives-Salt: 8de648a3-a829-478c-868d-76d50e8bcf78
X-Archives-Hash: 3588f6b0237df47f3bd3a2a818504268

commit:     77fa5d8cd3ead77a9fb03ced890a874d98f9e604
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed May 14 22:08:45 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Fri May 16 01:06:46 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=77fa5d8c

layman/cli.py: Adds byte array support

When checking the selection of which servers to sync/add there is
a check to see if 'ALL' is specified. In py2 with argparser this
works, but with py3 and argparser, this doesn't work because the
'ALL' string will come in as a bytearray. This commit fixes that
by checking the python version and assigning a varaible to be checked
instead of a simple string like 'ALL'. It will now come in as either
'ALL' or b'ALL', py version dependent. A small fix is also made to
docstring to make the print function py3 compatibile.

---
 layman/cli.py | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/layman/cli.py b/layman/cli.py
index cccddc6..460114a 100644
--- a/layman/cli.py
+++ b/layman/cli.py
@@ -30,7 +30,10 @@ from layman.utils import (decode_selection, encoder, get_encoding,
 from layman.constants import (NOT_OFFICIAL_MSG, NOT_SUPPORTED_MSG,
     FAILURE, SUCCEED)
 
-
+if sys.hexversion >= 0x30200f0:
+    ALL_KEYWORD = b'ALL'
+else:
+    ALL_KEYWORD = 'ALL'
 
 class ListPrinter(object):
     def __init__(self, config):
@@ -103,7 +106,7 @@ class ListPrinter(object):
 
     def short_list(self, overlay):
         '''
-        >>> print short_list(overlay)
+        >>> print(short_list(overlay))
         wrobel                    [Subversion] (https://o.g.o/svn/dev/wrobel         )
         '''
         name   = pad(overlay['name'], 25)
@@ -184,7 +187,6 @@ class Main(object):
         a=act.intersection(k)
         self.output.debug('Actions = %s' % str(a), 4)
         for action in self.actions:
-
             self.output.debug('Checking for action %s' % action[0], 4)
 
             if action[0] in list(self.config.keys()):
@@ -234,13 +236,14 @@ class Main(object):
         '''
         self.output.info("Adding overlay,...", 2)
         selection = decode_selection(self.config['add'])
-        if 'ALL' in selection:
+        if ALL_KEYWORD in selection:
+            selection = str(selection)
             selection = self.api.get_available()
         self.output.debug('Adding selected overlays', 6)
         result = self.api.add_repos(selection, update_news=True)
         if result:
-            self.output.info('Successfully added overlay(s) '+\
-                ', '.join(selection) +'.', 2)
+            selection = b', '.join(selection)
+            self.output.info('Successfully added overlay(s) '+ selection.decode('UTF-8') +'.', 2)
         # blank newline  -- no " *"
         self.output.notice('')
         return result
@@ -253,7 +256,7 @@ class Main(object):
         self.output.info("Syncing selected overlays,...", 2)
         # Note api.sync() defaults to printing results
         selection = decode_selection(self.config['sync'])
-        if self.config['sync_all'] or 'ALL' in selection:
+        if self.config['sync_all'] or ALL_KEYWORD in selection:
             selection = self.api.get_installed()
         self.output.debug('Updating selected overlays', 6)
         result = self.api.sync(selection, update_news=True)
@@ -267,7 +270,7 @@ class Main(object):
         '''
         self.output.info('Deleting selected overlays,...', 2)
         selection = decode_selection(self.config['delete'])
-        if 'ALL' in selection:
+        if ALL_KEYWORD in selection:
             selection = self.api.get_installed()
         result = self.api.delete_repos(selection)
         if result:
@@ -282,7 +285,7 @@ class Main(object):
         ''' Print information about the specified overlays.
         '''
         selection = decode_selection(self.config['info'])
-        if 'ALL' in selection:
+        if ALL_KEYWORD in selection:
             selection = self.api.get_available()
 
         list_printer = ListPrinter(self.config)