commit: cf8329cb7218173bba6cc57ed8f43e54e8ec9775
Author: Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Tue Jul 14 15:15:54 2015 +0000
Commit: Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Tue Jul 14 15:15:54 2015 +0000
URL: https://gitweb.gentoo.org/proj/layman.git/commit/?id=cf8329cb
overlay.py: Adds better error handling for missing "source" entries
layman/overlays/overlay.py | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 6e289b6..c6a0cee 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -160,10 +160,13 @@ class Overlay(object):
msg = 'Overlay from_dict(), "name" entry missing from dictionary!'
raise Exception(msg)
- _sources = overlay['source']
+ if 'source' in overlay:
+ _sources = overlay['source']
+ else:
+ _sources = None
if _sources == None:
- msg = 'Overlay from_dict(), "%(name)s" is missing a "source"'\
+ msg = 'Overlay from_dict(), "%(name)s" is missing a "source" '\
'entry!' % {'name': self.name}
raise Exception(msg)
@@ -267,10 +270,13 @@ class Overlay(object):
msg = 'Overlay from_json(), "name" entry missing from json!'
raise Exception(msg)
- _sources = json['source']
+ if 'source' in json:
+ _sources = json['source']
+ else:
+ _sources = None
if _sources == None:
- msg = 'Overlay from_json(), "%(name)s" is missing a "source"'\
+ msg = 'Overlay from_json(), "%(name)s" is missing a "source" '\
'entry!' % {'name': self.name}
raise Exception(msg)