def decorator(func, quota=int(quota), restore=float(restore)): version, accesskey, path = api_version_path[section] action = ''.join( api or list(map(str.capitalize, func.__name__.split('_')))) if hasattr(boto.mws.response, action + 'Response'): response = getattr(boto.mws.response, action + 'Response') else: response = ResponseFactory(action) response._action = action def wrapper(self, *args, **kw): kw.setdefault(accesskey, getattr(self, accesskey, None)) if kw[accesskey] is None: message = "{0} requires {1} argument. Set the " \ "MWSConnection.{2} attribute?" \ "".format(action, accesskey, accesskey) raise KeyError(message) kw['Action'] = action kw['Version'] = version return func(self, path, response, *args, **kw) for attr in decorated_attrs: setattr(wrapper, attr, locals().get(attr)) wrapper.__doc__ = "MWS {0}/{1} API call; quota={2} restore={3:.2f}\n" \ "{4}".format(action, version, quota, restore, func.__doc__) return wrapper
def decorator(func, quota=int(quota), restore=float(restore)): version, accesskey, path = api_version_path[section] action = ''.join(api or map(str.capitalize, func.func_name.split('_'))) if hasattr(boto.mws.response, action + 'Response'): response = getattr(boto.mws.response, action + 'Response') else: response = ResponseFactory(action) response._action = action def wrapper(self, *args, **kw): kw.setdefault(accesskey, getattr(self, accesskey, None)) if kw[accesskey] is None: message = "{0} requires {1} argument. Set the " \ "MWSConnection.{2} attribute?" \ "".format(action, accesskey, accesskey) raise KeyError(message) kw['Action'] = action kw['Version'] = version return func(self, path, response, *args, **kw) for attr in decorated_attrs: setattr(wrapper, attr, locals().get(attr)) wrapper.__doc__ = "MWS {0}/{1} API call; quota={2} restore={3:.2f}\n" \ "{4}".format(action, version, quota, restore, func.__doc__) return wrapper
def check_issue(self, klass, text): action = klass.__name__[:-len('Result')] factory = ResponseFactory(scopes=[{klass.__name__: klass}]) parser = factory(action, connection=self.service_connection) return self.service_connection._parse_response(parser, 'text/xml', text)
def issue_test(self, action, klass, text): cls = ResponseFactory(action, force=klass) return self.service_connection._parse_response(cls, text)