def __init__(self, request): if not request: raise ValueError('The request is none') url = request.get('url') if not url: raise ValueError("The request doesn't contain a url or it's empty") self.url = _Token(url) self.nextpage_url = _Token(request.get('nextpage_url', url)) self.headers = DictToken(request.get('headers', {})) # Request body could be string or dict body = request.get('body') if isinstance(body, dict): self.body = DictToken(body) elif isinstance(body, six.string_types): self.body = _Token(body) else: if body: logger.warning('Invalid request body: %s', body) self.body = None method = request.get('method', 'GET') if not method or method.upper() not in ('GET', 'POST'): raise ValueError( 'Unsupported value for request method: {}'.format(method)) self.method = _Token(method) self.count = 0
def __init__(self, namespaces, content, meta_config, task_config): super(CheckpointManagerAdapter, self).__init__(meta_config, task_config) if isinstance(namespaces, (list, tuple)): self.namespaces = (_Token(t) for t in namespaces) else: self.namespaces = [_Token(namespaces)] self.content = DictToken(content)
def __init__(self, method, arguments): self.method = method self.arguments = [_Token(arg) for arg in arguments or ()]
def __init__(self, method, arguments, output): self.method = method self.arguments = [_Token(arg) for arg in arguments or ()] self.output = output