commit: 74a5d6e23ea52f4bb2d19d1deb0b9abc36b20f23
Author: Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 1 04:36:07 2014 +0000
Commit: Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Fri Aug 15 21:42:42 2014 +0000
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=74a5d6e2
api.py: Makes supported_types() check for modules
Prior to executing require_supported() and notifying a user that the
overlay type isn't supported due to not finding the proper command
bin, a check has been made to see if the overlay module has been
brought in by the user. This will prevent unnecessary complaining from
layman.
---
layman/api.py | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/layman/api.py b/layman/api.py
index 0f43f28..b3f33f6 100755
--- a/layman/api.py
+++ b/layman/api.py
@@ -624,12 +624,25 @@ class LaymanAPI(object):
def supported_types(self):
"""returns a dictionary of all repository types,
with boolean values"""
+ here = os.path.dirname(os.path.realpath(__file__))
+ modpath = os.path.join('overlays', 'modules')
+ modules = os.path.listdir(os.path.join(here, modpath))
+
cmds = [x for x in self.config.keys() if '_command' in x]
supported = {}
for cmd in cmds:
type_key = cmd.split('_')[0]
- supported[type_key] = require_supported(
- [(self.config[cmd],type_key, '')], self.output.warn)
+ # The module dir might be named differently from the type_key.
+ # ex.) g-common and g-sorcery are named g_common and g_sorcery.
+ module = type_key.replace('-', '_')
+
+ # Don't bother executing require_supported() if the user didn't
+ # bring in support for the overlay type in the first place.
+ if module in modules:
+ supported[type_key] = require_supported(
+ [(self.config[cmd],type_key, '')], self.output.warn)
+ else:
+ supported[type_key] = False
return supported