From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (unknown [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id F246B1381FA for ; Wed, 14 May 2014 22:16:12 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 8729CE09D7; Wed, 14 May 2014 22:16: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 0D316E09D7 for ; Wed, 14 May 2014 22:16: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 F3F2433FF58 for ; Wed, 14 May 2014 22:16:10 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by spoonbill.gentoo.org (Postfix) with ESMTP id 99E8F1818D for ; Wed, 14 May 2014 22:16:09 +0000 (UTC) From: "Devan Franchini" 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" Message-ID: <1400105325.4d712142d792cf5803428f9ec5f2a618c89b4135.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: 4d712142d792cf5803428f9ec5f2a618c89b4135 X-VCS-Branch: gsoc2014 Date: Wed, 14 May 2014 22:16:09 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 368b11ac-7de3-45e6-b546-0a62fc3626ac X-Archives-Hash: 230202f4114f9b465ec236be7bb07f0f commit: 4d712142d792cf5803428f9ec5f2a618c89b4135 Author: Devan Franchini gentoo org> AuthorDate: Wed May 14 22:08:45 2014 +0000 Commit: Devan Franchini gentoo org> CommitDate: Wed May 14 22:08:45 2014 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=4d712142 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 assigned 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)