[copr] bkabrda-workspace: Make the enum fail fast instead of returning None (bdea269)

bkabrda at fedoraproject.org bkabrda at fedoraproject.org
Mon Nov 26 12:06:29 UTC 2012


Repository : http://git.fedorahosted.org/cgit/copr.git

On branch  : bkabrda-workspace

>---------------------------------------------------------------

commit bdea269979e248f0cd3b7a1bb9128740e7a2688b
Author: Bohuslav Kabrda <bkabrda at redhat.com>
Date:   Mon Nov 26 13:05:50 2012 +0100

    Make the enum fail fast instead of returning None


>---------------------------------------------------------------

 wsgi/coprs/helpers.py |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/wsgi/coprs/helpers.py b/wsgi/coprs/helpers.py
index 6eae1e2..c2bf632 100644
--- a/wsgi/coprs/helpers.py
+++ b/wsgi/coprs/helpers.py
@@ -13,14 +13,14 @@ class PermissionEnum(object):
 
     @classmethod
     def num(cls, key):
-        return cls.vals.get(key, None)
+        return cls.vals[key]
 
     @classmethod
     def key(cls, num):
         for k, n in cls.vals.items():
             if n == num:
                 return k
-        return None
+        raise KeyError('num {0} is not mapped'.format(num))
 
     @classmethod
     def choices_list(cls, without = 2):



More information about the copr-devel mailing list