Fix deleting repos when sec scan or signing is disabled

Make sure we don't invoke the APIs to non-existent endpoints
This commit is contained in:
Joseph Schorr 2017-04-19 13:51:13 -04:00
parent 624d8e1851
commit c5bb9abf11
4 changed files with 181 additions and 40 deletions

20
util/abchelpers.py Normal file
View file

@ -0,0 +1,20 @@
class NoopIsANoopException(TypeError):
""" Raised if the nooper decorator is unnecessary on a class. """
pass
def nooper(cls):
""" Decorates a class that derives from an ABCMeta, filling in any unimplemented methods with
no-ops.
"""
def empty_func(self_or_cls, *args, **kwargs):
pass
empty_methods = {}
for method in cls.__abstractmethods__:
empty_methods[method] = empty_func
if not empty_methods:
raise NoopIsANoopException('nooper implemented no abstract methods on %s' % cls)
return type(cls.__name__, (cls,), empty_methods)