Mercurial > repos > shellac > guppy_basecaller
comparison env/lib/python3.7/site-packages/boto/beanstalk/wrapper.py @ 2:6af9afd405e9 draft
"planemo upload commit 0a63dd5f4d38a1f6944587f52a8cd79874177fc1"
| author | shellac | 
|---|---|
| date | Thu, 14 May 2020 14:56:58 -0400 | 
| parents | 26e78fe6e8c4 | 
| children | 
   comparison
  equal
  deleted
  inserted
  replaced
| 1:75ca89e9b81c | 2:6af9afd405e9 | 
|---|---|
| 1 """Wraps layer1 api methods and converts layer1 dict responses to objects.""" | |
| 2 from boto.beanstalk.layer1 import Layer1 | |
| 3 import boto.beanstalk.response | |
| 4 from boto.exception import BotoServerError | |
| 5 import boto.beanstalk.exception as exception | |
| 6 | |
| 7 | |
| 8 def beanstalk_wrapper(func, name): | |
| 9 def _wrapped_low_level_api(*args, **kwargs): | |
| 10 try: | |
| 11 response = func(*args, **kwargs) | |
| 12 except BotoServerError as e: | |
| 13 raise exception.simple(e) | |
| 14 # Turn 'this_is_a_function_name' into 'ThisIsAFunctionNameResponse'. | |
| 15 cls_name = ''.join([part.capitalize() for part in name.split('_')]) + 'Response' | |
| 16 cls = getattr(boto.beanstalk.response, cls_name) | |
| 17 return cls(response) | |
| 18 return _wrapped_low_level_api | |
| 19 | |
| 20 | |
| 21 class Layer1Wrapper(object): | |
| 22 def __init__(self, *args, **kwargs): | |
| 23 self.api = Layer1(*args, **kwargs) | |
| 24 | |
| 25 def __getattr__(self, name): | |
| 26 try: | |
| 27 return beanstalk_wrapper(getattr(self.api, name), name) | |
| 28 except AttributeError: | |
| 29 raise AttributeError("%s has no attribute %r" % (self, name)) | 
