_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q254800 | cmd_logs | validation | def cmd_logs(opts):
"""Fetch the logs of a container
"""
config = load_config(opts.config)
b = get_blockade(config, opts)
puts(b.logs(opts.container).decode(encoding='UTF-8')) | python | {
"resource": ""
} |
q254801 | cmd_daemon | validation | def cmd_daemon(opts):
"""Start the Blockade REST API
"""
if opts.data_dir is None:
raise BlockadeError("You must supply a data directory for the daemon")
rest.start(data_dir=opts.data_dir, port=opts.port, debug=opts.debug,
host_exec=get_host_exec()) | python | {
"resource": ""
} |
q254802 | cmd_add | validation | def cmd_add(opts):
"""Add one or more existing Docker containers to a Blockade group
"""
config = load_config(opts.config)
b = get_blockade(config, opts)
b.add_container(opts.containers) | python | {
"resource": ""
} |
q254803 | cmd_events | validation | def cmd_events(opts):
"""Get the event log for a given blockade
"""
config = load_config(opts.config)
b = get_blockade(config, opts)
if opts.json:
outf = None
_write = puts
if opts.output is not None:
outf = open(opts.output, "w")
_write = outf.write
... | python | {
"resource": ""
} |
q254804 | set_cors_headers | validation | def set_cors_headers(resp, options):
"""
Performs the actual evaluation of Flas-CORS options and actually
modifies the response object.
This function is used both in the decorator and the after_request
callback
"""
# If CORS has already been evaluated via the decorator, skip
if hasattr... | python | {
"resource": ""
} |
q254805 | try_match | validation | def try_match(request_origin, maybe_regex):
"""Safely attempts to match a pattern or string to a request origin."""
if isinstance(maybe_regex, RegexObject):
return re.match(maybe_regex, request_origin)
elif probably_regex(maybe_regex):
return re.match(maybe_regex, request_origin, flags=re.IG... | python | {
"resource": ""
} |
q254806 | get_cors_options | validation | def get_cors_options(appInstance, *dicts):
"""
Compute CORS options for an application by combining the DEFAULT_OPTIONS,
the app's configuration-specified options and any dictionaries passed. The
last specified option wins.
"""
options = DEFAULT_OPTIONS.copy()
options.update(get_app_kwarg_di... | python | {
"resource": ""
} |
q254807 | get_app_kwarg_dict | validation | def get_app_kwarg_dict(appInstance=None):
"""Returns the dictionary of CORS specific app configurations."""
app = (appInstance or current_app)
# In order to support blueprints which do not have a config attribute
app_config = getattr(app, 'config', {})
return {
k.lower().replace('cors_', '... | python | {
"resource": ""
} |
q254808 | ensure_iterable | validation | def ensure_iterable(inst):
"""
Wraps scalars or string types as a list, or returns the iterable instance.
"""
if isinstance(inst, string_types):
return [inst]
elif not isinstance(inst, collections.Iterable):
return [inst]
else:
return inst | python | {
"resource": ""
} |
q254809 | serialize_options | validation | def serialize_options(opts):
"""
A helper method to serialize and processes the options dictionary.
"""
options = (opts or {}).copy()
for key in opts.keys():
if key not in DEFAULT_OPTIONS:
LOG.warning("Unknown option passed to Flask-CORS: %s", key)
# Ensure origins is a li... | python | {
"resource": ""
} |
q254810 | cross_origin | validation | def cross_origin(*args, **kwargs):
"""
This function is the decorator which is used to wrap a Flask route with.
In the simplest case, simply use the default parameters to allow all
origins in what is the most permissive configuration. If this method
modifies state or performs authentication which ma... | python | {
"resource": ""
} |
q254811 | symbolsDF | validation | def symbolsDF(token='', version=''):
'''This call returns an array of symbols that IEX Cloud supports for API calls.
https://iexcloud.io/docs/api/#symbols
8am, 9am, 12pm, 1pm UTC daily
Args:
token (string); Access token
version (string); API version
Returns:
dataframe: res... | python | {
"resource": ""
} |
q254812 | mutualFundSymbolsDF | validation | def mutualFundSymbolsDF(token='', version=''):
'''This call returns an array of mutual fund symbols that IEX Cloud supports for API calls.
https://iexcloud.io/docs/api/#mutual-fund-symbols
8am, 9am, 12pm, 1pm UTC daily
Args:
token (string); Access token
version (string); API version
... | python | {
"resource": ""
} |
q254813 | otcSymbolsDF | validation | def otcSymbolsDF(token='', version=''):
'''This call returns an array of OTC symbols that IEX Cloud supports for API calls.
https://iexcloud.io/docs/api/#otc-symbols
8am, 9am, 12pm, 1pm UTC daily
Args:
token (string); Access token
version (string); API version
Returns:
Dat... | python | {
"resource": ""
} |
q254814 | _getJson | validation | def _getJson(url, token='', version=''):
'''for backwards compat, accepting token and version but ignoring'''
if token:
return _getJsonIEXCloud(url, token, version)
return _getJsonOrig(url) | python | {
"resource": ""
} |
q254815 | _getJsonIEXCloud | validation | def _getJsonIEXCloud(url, token='', version='beta'):
'''for iex cloud'''
url = _URL_PREFIX2.format(version=version) + url
resp = requests.get(urlparse(url).geturl(), proxies=_PYEX_PROXIES, params={'token': token})
if resp.status_code == 200:
return resp.json()
raise PyEXception('Response %d ... | python | {
"resource": ""
} |
q254816 | marketNewsDF | validation | def marketNewsDF(count=10, token='', version=''):
'''News about market
https://iexcloud.io/docs/api/#news
Continuous
Args:
count (int): limit number of results
token (string); Access token
version (string); API version
Returns:
DataFrame: result
'''
df = pd... | python | {
"resource": ""
} |
q254817 | marketOhlcDF | validation | def marketOhlcDF(token='', version=''):
'''Returns the official open and close for whole market.
https://iexcloud.io/docs/api/#news
9:30am-5pm ET Mon-Fri
Args:
token (string); Access token
version (string); API version
Returns:
DataFrame: result
'''
x = marketOhlc(... | python | {
"resource": ""
} |
q254818 | marketYesterdayDF | validation | def marketYesterdayDF(token='', version=''):
'''This returns previous day adjusted price data for whole market
https://iexcloud.io/docs/api/#previous-day-prices
Available after 4am ET Tue-Sat
Args:
symbol (string); Ticker to request
token (string); Access token
version (string)... | python | {
"resource": ""
} |
q254819 | sectorPerformanceDF | validation | def sectorPerformanceDF(token='', version=''):
'''This returns an array of each sector and performance for the current trading day. Performance is based on each sector ETF.
https://iexcloud.io/docs/api/#sector-performance
8am-5pm ET Mon-Fri
Args:
token (string); Access token
version (s... | python | {
"resource": ""
} |
q254820 | splitsDF | validation | def splitsDF(symbol, timeframe='ytd', token='', version=''):
'''Stock split history
https://iexcloud.io/docs/api/#splits
Updated at 9am UTC every day
Args:
symbol (string); Ticker to request
token (string); Access token
version (string); API version
Returns:
DataFr... | python | {
"resource": ""
} |
q254821 | cryptoDF | validation | def cryptoDF(token='', version=''):
'''This will return an array of quotes for all Cryptocurrencies supported by the IEX API. Each element is a standard quote object with four additional keys.
https://iexcloud.io/docs/api/#crypto
Args:
token (string); Access token
version (string); API ver... | python | {
"resource": ""
} |
q254822 | ToggleJupyterTensorboardApp.start | validation | def start(self):
"""Perform the App's actions as configured."""
if self.extra_args:
sys.exit('{} takes no extra arguments'.format(self.name))
else:
if self._toggle_value:
nbextensions.install_nbextension_python(
_pkg_name, over... | python | {
"resource": ""
} |
q254823 | JupyterTensorboardApp.start | validation | def start(self):
"""Perform the App's actions as configured"""
super(JupyterTensorboardApp, self).start()
# The above should have called a subcommand and raised NoStart; if we
# get here, it didn't, so we should self.log.info a message.
subcmds = ", ".join(sorted(self.subc... | python | {
"resource": ""
} |
q254824 | _get_oauth2_client_id_and_secret | validation | def _get_oauth2_client_id_and_secret(settings_instance):
"""Initializes client id and client secret based on the settings.
Args:
settings_instance: An instance of ``django.conf.settings``.
Returns:
A 2-tuple, the first item is the client id and the second
item is the client secret... | python | {
"resource": ""
} |
q254825 | _get_storage_model | validation | def _get_storage_model():
"""This configures whether the credentials will be stored in the session
or the Django ORM based on the settings. By default, the credentials
will be stored in the session, unless `GOOGLE_OAUTH2_STORAGE_MODEL`
is found in the settings. Usually, the ORM storage is used to integr... | python | {
"resource": ""
} |
q254826 | get_storage | validation | def get_storage(request):
""" Gets a Credentials storage object provided by the Django OAuth2 Helper
object.
Args:
request: Reference to the current request object.
Returns:
An :class:`oauth2.client.Storage` object.
"""
storage_model = oauth2_settings.storage_model
user_prop... | python | {
"resource": ""
} |
q254827 | _redirect_with_params | validation | def _redirect_with_params(url_name, *args, **kwargs):
"""Helper method to create a redirect response with URL params.
This builds a redirect string that converts kwargs into a
query string.
Args:
url_name: The name of the url to redirect to.
kwargs: the query string param and their val... | python | {
"resource": ""
} |
q254828 | _credentials_from_request | validation | def _credentials_from_request(request):
"""Gets the authorized credentials for this flow, if they exist."""
# ORM storage requires a logged in user
if (oauth2_settings.storage_model is None or
request.user.is_authenticated()):
return get_storage(request).get()
else:
return No... | python | {
"resource": ""
} |
q254829 | UserOAuth2.has_credentials | validation | def has_credentials(self):
"""Returns True if there are valid credentials for the current user
and required scopes."""
credentials = _credentials_from_request(self.request)
return (credentials and not credentials.invalid and
credentials.has_scopes(self._get_scopes())) | python | {
"resource": ""
} |
q254830 | UserOAuth2._get_scopes | validation | def _get_scopes(self):
"""Returns the scopes associated with this object, kept up to
date for incremental auth."""
if _credentials_from_request(self.request):
return (self._scopes |
_credentials_from_request(self.request).scopes)
else:
return ... | python | {
"resource": ""
} |
q254831 | Storage.locked_get | validation | def locked_get(self):
"""Retrieve stored credential.
Returns:
A :class:`oauth2client.Credentials` instance or `None`.
"""
filters = {self.key_name: self.key_value}
query = self.session.query(self.model_class).filter_by(**filters)
entity = query.first()
... | python | {
"resource": ""
} |
q254832 | Storage.locked_put | validation | def locked_put(self, credentials):
"""Write a credentials to the SQLAlchemy datastore.
Args:
credentials: :class:`oauth2client.Credentials`
"""
filters = {self.key_name: self.key_value}
query = self.session.query(self.model_class).filter_by(**filters)
entity ... | python | {
"resource": ""
} |
q254833 | Storage.locked_delete | validation | def locked_delete(self):
"""Delete credentials from the SQLAlchemy datastore."""
filters = {self.key_name: self.key_value}
self.session.query(self.model_class).filter_by(**filters).delete() | python | {
"resource": ""
} |
q254834 | ServiceAccountCredentials._to_json | validation | def _to_json(self, strip, to_serialize=None):
"""Utility function that creates JSON repr. of a credentials object.
Over-ride is needed since PKCS#12 keys will not in general be JSON
serializable.
Args:
strip: array, An array of names of members to exclude from the
... | python | {
"resource": ""
} |
q254835 | ServiceAccountCredentials._from_parsed_json_keyfile | validation | def _from_parsed_json_keyfile(cls, keyfile_dict, scopes,
token_uri=None, revoke_uri=None):
"""Helper for factory constructors from JSON keyfile.
Args:
keyfile_dict: dict-like object, The parsed dictionary-like object
containing the... | python | {
"resource": ""
} |
q254836 | ServiceAccountCredentials.from_json_keyfile_name | validation | def from_json_keyfile_name(cls, filename, scopes='',
token_uri=None, revoke_uri=None):
"""Factory constructor from JSON keyfile by name.
Args:
filename: string, The location of the keyfile.
scopes: List or string, (Optional) Scopes to use when acq... | python | {
"resource": ""
} |
q254837 | ServiceAccountCredentials.from_json_keyfile_dict | validation | def from_json_keyfile_dict(cls, keyfile_dict, scopes='',
token_uri=None, revoke_uri=None):
"""Factory constructor from parsed JSON keyfile.
Args:
keyfile_dict: dict-like object, The parsed dictionary-like object
containing the content... | python | {
"resource": ""
} |
q254838 | ServiceAccountCredentials._generate_assertion | validation | def _generate_assertion(self):
"""Generate the assertion that will be used in the request."""
now = int(time.time())
payload = {
'aud': self.token_uri,
'scope': self._scopes,
'iat': now,
'exp': now + self.MAX_TOKEN_LIFETIME_SECS,
'iss':... | python | {
"resource": ""
} |
q254839 | ServiceAccountCredentials.from_json | validation | def from_json(cls, json_data):
"""Deserialize a JSON-serialized instance.
Inverse to :meth:`to_json`.
Args:
json_data: dict or string, Serialized JSON (as a string or an
already parsed dictionary) representing a credential.
Returns:
Servi... | python | {
"resource": ""
} |
q254840 | ServiceAccountCredentials.create_with_claims | validation | def create_with_claims(self, claims):
"""Create credentials that specify additional claims.
Args:
claims: dict, key-value pairs for claims.
Returns:
ServiceAccountCredentials, a copy of the current service account
credentials with updated claims to use when ... | python | {
"resource": ""
} |
q254841 | _JWTAccessCredentials.get_access_token | validation | def get_access_token(self, http=None, additional_claims=None):
"""Create a signed jwt.
Args:
http: unused
additional_claims: dict, additional claims to add to
the payload of the JWT.
Returns:
An AccessTokenInfo with the signed jwt
"""
... | python | {
"resource": ""
} |
q254842 | _detect_gce_environment | validation | def _detect_gce_environment():
"""Determine if the current environment is Compute Engine.
Returns:
Boolean indicating whether or not the current environment is Google
Compute Engine.
"""
# NOTE: The explicit ``timeout`` is a workaround. The underlying
# issue is that resolving... | python | {
"resource": ""
} |
q254843 | _in_gae_environment | validation | def _in_gae_environment():
"""Detects if the code is running in the App Engine environment.
Returns:
True if running in the GAE environment, False otherwise.
"""
if SETTINGS.env_name is not None:
return SETTINGS.env_name in ('GAE_PRODUCTION', 'GAE_LOCAL')
try:
import google... | python | {
"resource": ""
} |
q254844 | _in_gce_environment | validation | def _in_gce_environment():
"""Detect if the code is running in the Compute Engine environment.
Returns:
True if running in the GCE environment, False otherwise.
"""
if SETTINGS.env_name is not None:
return SETTINGS.env_name == 'GCE_PRODUCTION'
if NO_GCE_CHECK != 'True' and _detect_... | python | {
"resource": ""
} |
q254845 | _save_private_file | validation | def _save_private_file(filename, json_contents):
"""Saves a file with read-write permissions on for the owner.
Args:
filename: String. Absolute path to file.
json_contents: JSON serializable object to be saved.
"""
temp_filename = tempfile.mktemp()
file_desc = os.open(temp_filename,... | python | {
"resource": ""
} |
q254846 | save_to_well_known_file | validation | def save_to_well_known_file(credentials, well_known_file=None):
"""Save the provided GoogleCredentials to the well known file.
Args:
credentials: the credentials to be saved to the well known file;
it should be an instance of GoogleCredentials
well_known_file: the name of t... | python | {
"resource": ""
} |
q254847 | _get_well_known_file | validation | def _get_well_known_file():
"""Get the well known file produced by command 'gcloud auth login'."""
# TODO(orestica): Revisit this method once gcloud provides a better way
# of pinpointing the exact location of the file.
default_config_dir = os.getenv(_CLOUDSDK_CONFIG_ENV_VAR)
if default_config_dir i... | python | {
"resource": ""
} |
q254848 | _get_application_default_credential_from_file | validation | def _get_application_default_credential_from_file(filename):
"""Build the Application Default Credentials from file."""
# read the credentials from the file
with open(filename) as file_obj:
client_credentials = json.load(file_obj)
credentials_type = client_credentials.get('type')
if credent... | python | {
"resource": ""
} |
q254849 | verify_id_token | validation | def verify_id_token(id_token, audience, http=None,
cert_uri=ID_TOKEN_VERIFICATION_CERTS):
"""Verifies a signed JWT id_token.
This function requires PyOpenSSL and because of that it does not work on
App Engine.
Args:
id_token: string, A Signed JWT.
audience: string, ... | python | {
"resource": ""
} |
q254850 | _extract_id_token | validation | def _extract_id_token(id_token):
"""Extract the JSON payload from a JWT.
Does the extraction w/o checking the signature.
Args:
id_token: string or bytestring, OAuth 2.0 id_token.
Returns:
object, The deserialized JSON payload.
"""
if type(id_token) == bytes:
segments =... | python | {
"resource": ""
} |
q254851 | _parse_exchange_token_response | validation | def _parse_exchange_token_response(content):
"""Parses response of an exchange token request.
Most providers return JSON but some (e.g. Facebook) return a
url-encoded string.
Args:
content: The body of a response
Returns:
Content as a dictionary object. Note that the dict could be... | python | {
"resource": ""
} |
q254852 | credentials_from_code | validation | def credentials_from_code(client_id, client_secret, scope, code,
redirect_uri='postmessage', http=None,
user_agent=None,
token_uri=oauth2client.GOOGLE_TOKEN_URI,
auth_uri=oauth2client.GOOGLE_AUTH_URI,
... | python | {
"resource": ""
} |
q254853 | credentials_from_clientsecrets_and_code | validation | def credentials_from_clientsecrets_and_code(filename, scope, code,
message=None,
redirect_uri='postmessage',
http=None,
cache=None,
... | python | {
"resource": ""
} |
q254854 | _oauth2_web_server_flow_params | validation | def _oauth2_web_server_flow_params(kwargs):
"""Configures redirect URI parameters for OAuth2WebServerFlow."""
params = {
'access_type': 'offline',
'response_type': 'code',
}
params.update(kwargs)
# Check for the presence of the deprecated approval_prompt param and
# warn approp... | python | {
"resource": ""
} |
q254855 | flow_from_clientsecrets | validation | def flow_from_clientsecrets(filename, scope, redirect_uri=None,
message=None, cache=None, login_hint=None,
device_uri=None, pkce=None, code_verifier=None,
prompt=None):
"""Create a Flow from a clientsecrets file.
Will create th... | python | {
"resource": ""
} |
q254856 | Credentials._to_json | validation | def _to_json(self, strip, to_serialize=None):
"""Utility function that creates JSON repr. of a Credentials object.
Args:
strip: array, An array of names of members to exclude from the
JSON.
to_serialize: dict, (Optional) The properties for this object
... | python | {
"resource": ""
} |
q254857 | Credentials.new_from_json | validation | def new_from_json(cls, json_data):
"""Utility class method to instantiate a Credentials subclass from JSON.
Expects the JSON string to have been produced by to_json().
Args:
json_data: string or bytes, JSON from to_json().
Returns:
An instance of the subclass o... | python | {
"resource": ""
} |
q254858 | Storage.put | validation | def put(self, credentials):
"""Write a credential.
The Storage lock must be held when this is called.
Args:
credentials: Credentials, the credentials to store.
"""
self.acquire_lock()
try:
self.locked_put(credentials)
finally:
... | python | {
"resource": ""
} |
q254859 | OAuth2Credentials.has_scopes | validation | def has_scopes(self, scopes):
"""Verify that the credentials are authorized for the given scopes.
Returns True if the credentials authorized scopes contain all of the
scopes given.
Args:
scopes: list or string, the scopes to check.
Notes:
There are case... | python | {
"resource": ""
} |
q254860 | OAuth2Credentials.from_json | validation | def from_json(cls, json_data):
"""Instantiate a Credentials object from a JSON description of it.
The JSON should have been produced by calling .to_json() on the object.
Args:
json_data: string or bytes, JSON to deserialize.
Returns:
An instance of a Credential... | python | {
"resource": ""
} |
q254861 | OAuth2Credentials.access_token_expired | validation | def access_token_expired(self):
"""True if the credential is expired or invalid.
If the token_expiry isn't set, we assume the token doesn't expire.
"""
if self.invalid:
return True
if not self.token_expiry:
return False
now = _UTCNOW()
i... | python | {
"resource": ""
} |
q254862 | OAuth2Credentials.get_access_token | validation | def get_access_token(self, http=None):
"""Return the access token and its expiration information.
If the token does not exist, get one.
If the token expired, refresh it.
"""
if not self.access_token or self.access_token_expired:
if not http:
http = tr... | python | {
"resource": ""
} |
q254863 | OAuth2Credentials._expires_in | validation | def _expires_in(self):
"""Return the number of seconds until this token expires.
If token_expiry is in the past, this method will return 0, meaning the
token has already expired.
If token_expiry is None, this method will return None. Note that
returning 0 in such a case would n... | python | {
"resource": ""
} |
q254864 | OAuth2Credentials._generate_refresh_request_body | validation | def _generate_refresh_request_body(self):
"""Generate the body that will be used in the refresh request."""
body = urllib.parse.urlencode({
'grant_type': 'refresh_token',
'client_id': self.client_id,
'client_secret': self.client_secret,
'refresh_token': se... | python | {
"resource": ""
} |
q254865 | OAuth2Credentials._refresh | validation | def _refresh(self, http):
"""Refreshes the access_token.
This method first checks by reading the Storage object if available.
If a refresh is still needed, it holds the Storage lock until the
refresh is completed.
Args:
http: an object to be used to make HTTP reques... | python | {
"resource": ""
} |
q254866 | OAuth2Credentials._do_refresh_request | validation | def _do_refresh_request(self, http):
"""Refresh the access_token using the refresh_token.
Args:
http: an object to be used to make HTTP requests.
Raises:
HttpAccessTokenRefreshError: When the refresh fails.
"""
body = self._generate_refresh_request_body(... | python | {
"resource": ""
} |
q254867 | OAuth2Credentials._do_retrieve_scopes | validation | def _do_retrieve_scopes(self, http, token):
"""Retrieves the list of authorized scopes from the OAuth2 provider.
Args:
http: an object to be used to make HTTP requests.
token: A string used as the token to identify the credentials to
the provider.
Rai... | python | {
"resource": ""
} |
q254868 | GoogleCredentials._implicit_credentials_from_files | validation | def _implicit_credentials_from_files():
"""Attempts to get implicit credentials from local credential files.
First checks if the environment variable GOOGLE_APPLICATION_CREDENTIALS
is set with a filename and then falls back to a configuration file (the
"well known" file) associated with... | python | {
"resource": ""
} |
q254869 | GoogleCredentials._get_implicit_credentials | validation | def _get_implicit_credentials(cls):
"""Gets credentials implicitly from the environment.
Checks environment in order of precedence:
- Environment variable GOOGLE_APPLICATION_CREDENTIALS pointing to
a file with stored credentials information.
- Stored "well known" file associat... | python | {
"resource": ""
} |
q254870 | GoogleCredentials.from_stream | validation | def from_stream(credential_filename):
"""Create a Credentials object by reading information from a file.
It returns an object of type GoogleCredentials.
Args:
credential_filename: the path to the file from where the
credentials are to be read
... | python | {
"resource": ""
} |
q254871 | DeviceFlowInfo.FromResponse | validation | def FromResponse(cls, response):
"""Create a DeviceFlowInfo from a server response.
The response should be a dict containing entries as described here:
http://tools.ietf.org/html/draft-ietf-oauth-v2-05#section-3.7.1
"""
# device_code, user_code, and verification_url are require... | python | {
"resource": ""
} |
q254872 | OAuth2WebServerFlow.step1_get_authorize_url | validation | def step1_get_authorize_url(self, redirect_uri=None, state=None):
"""Returns a URI to redirect to the provider.
Args:
redirect_uri: string, Either the string 'urn:ietf:wg:oauth:2.0:oob'
for a non-web-based application, or a URI that
handle... | python | {
"resource": ""
} |
q254873 | OAuth2WebServerFlow.step1_get_device_and_user_codes | validation | def step1_get_device_and_user_codes(self, http=None):
"""Returns a user code and the verification URL where to enter it
Returns:
A user code as a string for the user to authorize the application
An URL as a string where the user has to enter the code
"""
if self.... | python | {
"resource": ""
} |
q254874 | RsaVerifier.from_string | validation | def from_string(cls, key_pem, is_x509_cert):
"""Construct an RsaVerifier instance from a string.
Args:
key_pem: string, public key in PEM format.
is_x509_cert: bool, True if key_pem is an X509 cert, otherwise it
is expected to be an RSA key in PEM forma... | python | {
"resource": ""
} |
q254875 | RsaSigner.from_string | validation | def from_string(cls, key, password='notasecret'):
"""Construct an RsaSigner instance from a string.
Args:
key: string, private key in PEM format.
password: string, password for private key file. Unused for PEM
files.
Returns:
RsaSigner ... | python | {
"resource": ""
} |
q254876 | _create_file_if_needed | validation | def _create_file_if_needed(filename):
"""Creates the an empty file if it does not already exist.
Returns:
True if the file was created, False otherwise.
"""
if os.path.exists(filename):
return False
else:
# Equivalent to "touch".
open(filename, 'a+b').close()
... | python | {
"resource": ""
} |
q254877 | _load_credentials_file | validation | def _load_credentials_file(credentials_file):
"""Load credentials from the given file handle.
The file is expected to be in this format:
{
"file_version": 2,
"credentials": {
"key": "base64 encoded json representation of credentials."
}
}
... | python | {
"resource": ""
} |
q254878 | _write_credentials_file | validation | def _write_credentials_file(credentials_file, credentials):
"""Writes credentials to a file.
Refer to :func:`_load_credentials_file` for the format.
Args:
credentials_file: An open file handle, must be read/write.
credentials: A dictionary mapping user-defined keys to an instance of
... | python | {
"resource": ""
} |
q254879 | _get_backend | validation | def _get_backend(filename):
"""A helper method to get or create a backend with thread locking.
This ensures that only one backend is used per-file per-process, so that
thread and process locks are appropriately shared.
Args:
filename: The full path to the credential storage file.
Returns:... | python | {
"resource": ""
} |
q254880 | MultiprocessFileStorage.locked_get | validation | def locked_get(self):
"""Retrieves the current credentials from the store.
Returns:
An instance of :class:`oauth2client.client.Credentials` or `None`.
"""
credential = self._backend.locked_get(self._key)
if credential is not None:
credential.set_store(se... | python | {
"resource": ""
} |
q254881 | positional | validation | def positional(max_positional_args):
"""A decorator to declare that only the first N arguments my be positional.
This decorator makes it easy to support Python 3 style keyword-only
parameters. For example, in Python 3 it is possible to write::
def fn(pos1, *, kwonly1=None, kwonly1=None):
... | python | {
"resource": ""
} |
q254882 | string_to_scopes | validation | def string_to_scopes(scopes):
"""Converts stringifed scope value to a list.
If scopes is a list then it is simply passed through. If scopes is an
string then a list of each individual scope is returned.
Args:
scopes: a string or iterable of strings, the scopes.
Returns:
The scopes... | python | {
"resource": ""
} |
q254883 | parse_unique_urlencoded | validation | def parse_unique_urlencoded(content):
"""Parses unique key-value parameters from urlencoded content.
Args:
content: string, URL-encoded key-value pairs.
Returns:
dict, The key-value pairs from ``content``.
Raises:
ValueError: if one of the keys is repeated.
"""
urlenco... | python | {
"resource": ""
} |
q254884 | update_query_params | validation | def update_query_params(uri, params):
"""Updates a URI with new query parameters.
If a given key from ``params`` is repeated in the ``uri``, then
the URI will be considered invalid and an error will occur.
If the URI is valid, then each value from ``params`` will
replace the corresponding value in... | python | {
"resource": ""
} |
q254885 | _add_query_parameter | validation | def _add_query_parameter(url, name, value):
"""Adds a query parameter to a url.
Replaces the current value if it already exists in the URL.
Args:
url: string, url to add the query parameter to.
name: string, query parameter name.
value: string, query parameter value.
Returns:
... | python | {
"resource": ""
} |
q254886 | _apply_user_agent | validation | def _apply_user_agent(headers, user_agent):
"""Adds a user-agent to the headers.
Args:
headers: dict, request headers to add / modify user
agent within.
user_agent: str, the user agent to add.
Returns:
dict, the original headers passed in, but modified if the
... | python | {
"resource": ""
} |
q254887 | clean_headers | validation | def clean_headers(headers):
"""Forces header keys and values to be strings, i.e not unicode.
The httplib module just concats the header keys and values in a way that
may make the message header a unicode string, which, if it then tries to
contatenate to a binary request body may result in a unicode dec... | python | {
"resource": ""
} |
q254888 | wrap_http_for_auth | validation | def wrap_http_for_auth(credentials, http):
"""Prepares an HTTP object's request method for auth.
Wraps HTTP requests with logic to catch auth failures (typically
identified via a 401 status code). In the event of failure, tries
to refresh the token used and then retry the original request.
Args:
... | python | {
"resource": ""
} |
q254889 | wrap_http_for_jwt_access | validation | def wrap_http_for_jwt_access(credentials, http):
"""Prepares an HTTP object's request method for JWT access.
Wraps HTTP requests with logic to catch auth failures (typically
identified via a 401 status code). In the event of failure, tries
to refresh the token used and then retry the original request.
... | python | {
"resource": ""
} |
q254890 | request | validation | def request(http, uri, method='GET', body=None, headers=None,
redirections=httplib2.DEFAULT_MAX_REDIRECTS,
connection_type=None):
"""Make an HTTP request with an HTTP object and arguments.
Args:
http: httplib2.Http, an http object to be used to make requests.
uri: string... | python | {
"resource": ""
} |
q254891 | _get_flow_for_token | validation | def _get_flow_for_token(csrf_token):
"""Retrieves the flow instance associated with a given CSRF token from
the Flask session."""
flow_pickle = session.pop(
_FLOW_KEY.format(csrf_token), None)
if flow_pickle is None:
return None
else:
return pickle.loads(flow_pickle) | python | {
"resource": ""
} |
q254892 | UserOAuth2.init_app | validation | def init_app(self, app, scopes=None, client_secrets_file=None,
client_id=None, client_secret=None, authorize_callback=None,
storage=None, **kwargs):
"""Initialize this extension for the given app.
Arguments:
app: A Flask application.
scopes: Opt... | python | {
"resource": ""
} |
q254893 | UserOAuth2._load_config | validation | def _load_config(self, client_secrets_file, client_id, client_secret):
"""Loads oauth2 configuration in order of priority.
Priority:
1. Config passed to the constructor or init_app.
2. Config passed via the GOOGLE_OAUTH2_CLIENT_SECRETS_FILE app
config.
... | python | {
"resource": ""
} |
q254894 | UserOAuth2.authorize_view | validation | def authorize_view(self):
"""Flask view that starts the authorization flow.
Starts flow by redirecting the user to the OAuth2 provider.
"""
args = request.args.to_dict()
# Scopes will be passed as mutliple args, and to_dict() will only
# return one. So, we use getlist()... | python | {
"resource": ""
} |
q254895 | UserOAuth2.callback_view | validation | def callback_view(self):
"""Flask view that handles the user's return from OAuth2 provider.
On return, exchanges the authorization code for credentials and stores
the credentials.
"""
if 'error' in request.args:
reason = request.args.get(
'error_descr... | python | {
"resource": ""
} |
q254896 | UserOAuth2.credentials | validation | def credentials(self):
"""The credentials for the current user or None if unavailable."""
ctx = _app_ctx_stack.top
if not hasattr(ctx, _CREDENTIALS_KEY):
ctx.google_oauth2_credentials = self.storage.get()
return ctx.google_oauth2_credentials | python | {
"resource": ""
} |
q254897 | UserOAuth2.has_credentials | validation | def has_credentials(self):
"""Returns True if there are valid credentials for the current user."""
if not self.credentials:
return False
# Is the access token expired? If so, do we have an refresh token?
elif (self.credentials.access_token_expired and
not self... | python | {
"resource": ""
} |
q254898 | UserOAuth2.email | validation | def email(self):
"""Returns the user's email address or None if there are no credentials.
The email address is provided by the current credentials' id_token.
This should not be used as unique identifier as the user can change
their email. If you need a unique identifier, use user_id.
... | python | {
"resource": ""
} |
q254899 | get | validation | def get(http, path, root=METADATA_ROOT, recursive=None):
"""Fetch a resource from the metadata server.
Args:
http: an object to be used to make HTTP requests.
path: A string indicating the resource to retrieve. For example,
'instance/service-accounts/default'
root: A string ... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.