Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def wrapper(*args, **kwargs):
old_config = {}
for key, value in six.iteritems(new_config):
old_config[key] = getattr(config, key)
setattr(config, key, value)
result = f(*args, **kwargs)
for key, value in six.iteritems(old_config):
setattr(config, key, value)
return result
return wrapper
def wrapper(*args, **kwargs):
old_config = {}
for key, value in six.iteritems(new_config):
old_config[key] = getattr(config, key)
setattr(config, key, value)
result = f(*args, **kwargs)
for key, value in six.iteritems(old_config):
setattr(config, key, value)
return result
return wrapper
from predicthq.config import config
from predicthq.endpoints.schemas import Model, StringType, StringListType, IntType
class GetTokenParams(Model):
class Options:
serialize_when_none = False
client_id = StringType(default=lambda: config.OAUTH2_CLIENT_ID, required=True)
client_secret = StringType(default=lambda: config.OAUTH2_CLIENT_SECRET, required=True)
scope = StringListType(StringType, default=lambda: config.OAUTH2_SCOPE, separator=" ")
grant_type = StringType(choices=('client_credentials',), default='client_credentials', required=True)
class RevokeTokenParams(Model):
class Options:
serialize_when_none = False
client_id = StringType(default=lambda: config.OAUTH2_CLIENT_ID, required=True)
client_secret = StringType(default=lambda: config.OAUTH2_CLIENT_SECRET, required=True)
token = StringType(required=True)
token_type_hint = StringType(choices=('access_token', 'refresh_token'), default='access_token', required=True)
def __init__(self, access_token=None):
self.logger = logging.getLogger('predicthq')
self.logger.setLevel(config.LOGGING_LOG_LEVEL)
self.access_token = access_token or config.OAUTH2_ACCESS_TOKEN
self.initialize_endpoints()
client_secret = StringType(default=lambda: config.OAUTH2_CLIENT_SECRET, required=True)
scope = StringListType(StringType, default=lambda: config.OAUTH2_SCOPE, separator=" ")
client_secret = StringType(default=lambda: config.OAUTH2_CLIENT_SECRET, required=True)
token = StringType(required=True)
def build_url(cls, path):
result = list(six.moves.urllib.parse.urlparse(path))
result[2] = "/{}/".format(result[2].strip('/'))
return six.moves.urllib.parse.urljoin(config.ENDPOINT_URL, six.moves.urllib.parse.urlunparse(result))
def __init__(self, access_token=None):
self.logger = logging.getLogger('predicthq')
self.logger.setLevel(config.LOGGING_LOG_LEVEL)
self.access_token = access_token or config.OAUTH2_ACCESS_TOKEN
self.initialize_endpoints()
client_id = StringType(default=lambda: config.OAUTH2_CLIENT_ID, required=True)
client_secret = StringType(default=lambda: config.OAUTH2_CLIENT_SECRET, required=True)