From: "Devan Franchini" <twitch153@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/layman:master commit in: layman/overlays/
Date: Thu, 26 Mar 2015 23:08:53 +0000 (UTC) [thread overview]
Message-ID: <1427411187.a263463472cee1763e9e6abb915b015ee1de0cb7.twitch153@gentoo> (raw)
commit: a263463472cee1763e9e6abb915b015ee1de0cb7
Author: Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Thu Mar 26 23:06:25 2015 +0000
Commit: Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Thu Mar 26 23:06:27 2015 +0000
URL: https://gitweb.gentoo.org/proj/layman.git/commit/?id=a2634634
overlay.py: Modifies the implementation of filter_protocols
This modification allows for layman to only filter protocols
when running Overlay.add() and Overlay.update(), preventing
redundant code and checks along the way.
X-Gentoo-Bug: 542342
X-Gentoo-Bug-URL: https://bugs.gentoo.org/542342
layman/overlays/overlay.py | 29 +++++++++++++++++++----------
1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 59aa74b..2257373 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -69,17 +69,16 @@ class Overlay(object):
self.from_dict(ovl_dict, ignore)
- def filter_protocols(self, sources, create_source_func):
+ def filter_protocols(self, sources):
'''
Filters any protocols not specified in self.config['protocol_order']
from the overlay's sources.
'''
_sources = []
- if not 'protocol_order' in self.config.keys():
- return [create_source_func(e) for e in sources]
+ if not self.config['protocol_order']:
+ return sources
- for e in sources:
- source = create_source_func(e)
+ for source in sources:
for protocol in self.config['protocol_order']:
protocol = protocol.lower()
#re.search considers "\+" as the literal "+".
@@ -144,7 +143,7 @@ class Overlay(object):
raise Exception('Overlay from_xml(), "' + self.name + \
'" is missing a "source" entry!')
- self.sources = self.filter_protocols(_sources, create_overlay_source)
+ self.sources = [create_overlay_source(e) for e in _sources]
_owner = xml.find('owner')
if _owner == None:
@@ -254,7 +253,7 @@ class Overlay(object):
return _class(parent=self, config=self.config,
_location=_location, ignore=ignore)
- self.sources = self.filter_protocols(_sources, create_dict_overlay_source)
+ self.sources = [create_dict_overlay_source(e) for e in _sources]
if 'owner_name' in overlay:
_owner = overlay['owner_name']
@@ -403,9 +402,10 @@ class Overlay(object):
res = 1
first_s = True
- if 'protocol_order' in self.config.keys() and not self.sources:
- msg = 'Overlay.add() error: overlay "%s" does not support any of'\
- ' the given\nprotocols %s and cannot be installed.'\
+ self.sources = filter_protocols(self.sources)
+ if not self.sources:
+ msg = 'Overlay.add() error: overlay "%s" does not support the'\
+ ' given\nprotocol(s) %s and cannot be installed.'\
% (self.name, str(self.config['protocol_order']))
self.output.error(msg)
return 1
@@ -430,6 +430,15 @@ class Overlay(object):
first_src = True
result = False
+ self.sources = filter_protocols(self.sources)
+ available_srcs = filter_protocols(available_srcs)
+ if not self.sources or not available_srcs:
+ msg = 'Overlay.update() error: overlay "%s" does not support the'\
+ 'given protocol(s) %s and cannot be updated.'\
+ % (self.name, str(self.config['protocol_order'])
+ self.output.error(msg)
+ return 1
+
if isinstance(available_srcs, str):
available_srcs = [available_srcs]
next reply other threads:[~2015-03-26 23:09 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-26 23:08 Devan Franchini [this message]
-- strict thread matches above, loose matches on Subject: below --
2015-08-28 3:50 [gentoo-commits] proj/layman:master commit in: layman/overlays/ Devan Franchini
2015-08-28 3:43 Devan Franchini
2015-08-28 0:41 Devan Franchini
2015-08-04 0:23 Devan Franchini
2015-07-21 16:39 Devan Franchini
2015-07-14 15:15 Devan Franchini
2015-07-13 23:05 Devan Franchini
2015-07-13 19:04 Devan Franchini
2015-07-13 18:59 Devan Franchini
2015-07-13 18:52 Devan Franchini
2015-07-13 18:48 Devan Franchini
2015-07-10 16:13 Devan Franchini
2015-03-26 23:47 Devan Franchini
2015-03-26 18:13 Devan Franchini
2014-12-08 4:15 Devan Franchini
2014-06-16 3:40 Brian Dolbec
2014-06-16 3:40 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: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: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-03-10 3:18 Brian Dolbec
2013-08-18 16:46 Brian Dolbec
2012-11-01 7:06 Brian Dolbec
2012-10-08 6:16 Brian Dolbec
2012-10-08 4:36 Brian Dolbec
2012-10-07 23:40 Brian Dolbec
2012-01-06 8:16 Brian Dolbec
2011-09-26 1:18 Brian Dolbec
2011-09-24 6:07 Brian Dolbec
2011-09-13 14:16 Brian Dolbec
2011-09-05 16:09 Brian Dolbec
2011-08-07 8:47 Brian Dolbec
2011-08-07 8:39 Brian Dolbec
2011-07-28 21:33 Brian Dolbec
2011-07-23 6:45 Brian Dolbec
2011-05-05 9:44 Brian Dolbec
2011-04-30 22:37 Brian Dolbec
2011-04-30 6:37 Brian Dolbec
2011-04-27 10:58 Brian Dolbec
2011-04-27 10:58 Brian Dolbec
2011-04-27 10:58 Brian Dolbec
2011-04-27 10:58 Brian Dolbec
2011-04-27 10:58 Brian Dolbec
2011-02-17 21:53 Brian Dolbec
2011-02-14 6:00 Brian Dolbec
2011-02-14 6:00 Brian Dolbec
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=1427411187.a263463472cee1763e9e6abb915b015ee1de0cb7.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