From: "Devan Franchini" <twitch153@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
Date: Fri, 16 May 2014 01:07:07 +0000 (UTC) [thread overview]
Message-ID: <1400202406.77fa5d8cd3ead77a9fb03ced890a874d98f9e604.twitch153@gentoo> (raw)
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)
next reply other threads:[~2014-05-16 1:07 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-16 1:07 Devan Franchini [this message]
-- strict thread matches above, loose matches on Subject: below --
2014-08-15 23:59 [gentoo-commits] proj/layman:master commit in: layman/ Devan Franchini
2014-08-16 0:00 ` [gentoo-commits] proj/layman:gsoc2014 " Devan Franchini
2014-08-15 22:32 Devan Franchini
2014-08-15 22:32 Devan Franchini
2014-08-15 22:32 Devan Franchini
2014-08-15 22:32 Devan Franchini
2014-06-27 4:07 Devan Franchini
2014-06-27 4:07 Devan Franchini
2014-06-27 4:07 Devan Franchini
2014-06-16 3:40 [gentoo-commits] proj/layman:master " Brian Dolbec
2014-06-16 3:37 ` [gentoo-commits] proj/layman:gsoc2014 " Brian Dolbec
2014-06-16 3:40 [gentoo-commits] proj/layman:master " Brian Dolbec
2014-06-16 3:37 ` [gentoo-commits] proj/layman:gsoc2014 " Brian Dolbec
2014-06-16 3:40 [gentoo-commits] proj/layman:master " Brian Dolbec
2014-06-16 3:37 ` [gentoo-commits] proj/layman:gsoc2014 " Brian Dolbec
2014-06-16 3:37 Brian Dolbec
2014-06-16 3:37 Brian Dolbec
2014-06-16 3:37 Brian Dolbec
2014-06-16 3:37 Brian Dolbec
2014-05-16 2:30 Devan Franchini
2014-05-16 1:07 Devan Franchini
2014-05-16 1:07 Devan Franchini
2014-05-16 1:07 Devan Franchini
2014-05-16 1:07 Devan Franchini
2014-05-16 1:07 Devan Franchini
2014-05-16 1:07 Devan Franchini
2014-05-16 1:07 Devan Franchini
2014-05-16 1:07 Devan Franchini
2014-05-16 1:07 Devan Franchini
2014-05-16 1:07 Devan Franchini
2014-05-16 0:58 Devan Franchini
2014-05-16 0:58 Devan Franchini
2014-05-16 0:57 Devan Franchini
2014-05-15 20:46 Devan Franchini
2014-05-15 20:46 Devan Franchini
2014-05-15 20:37 Devan Franchini
2014-05-15 20:30 Devan Franchini
2014-05-15 20:02 Devan Franchini
2014-05-15 0:04 Devan Franchini
2014-05-14 23:54 Devan Franchini
2014-05-14 23:49 Devan Franchini
2014-05-14 23:49 Devan Franchini
2014-05-14 23:49 Devan Franchini
2014-05-14 23:49 Devan Franchini
2014-05-14 23:49 Devan Franchini
2014-05-14 23:49 Devan Franchini
2014-05-14 23:49 Devan Franchini
2014-05-14 23:49 Devan Franchini
2014-05-14 23:49 Devan Franchini
2014-05-14 23:49 Devan Franchini
2014-05-14 23:49 Devan Franchini
2014-05-14 22:16 Devan Franchini
2014-05-14 22:08 Devan Franchini
2014-05-14 21:42 Devan Franchini
2014-05-14 21:30 Devan Franchini
2014-05-14 21:15 Devan Franchini
2014-05-14 21:15 Devan Franchini
2014-05-14 19:29 Devan Franchini
2014-05-14 18:55 Devan Franchini
2014-05-14 18:44 Devan Franchini
2014-05-14 17:32 Devan Franchini
2014-05-14 3:21 Devan Franchini
2014-05-14 0:37 Devan Franchini
2014-05-07 22:21 Devan Franchini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1400202406.77fa5d8cd3ead77a9fb03ced890a874d98f9e604.twitch153@gentoo \
--to=twitch153@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox