text stringlengths 81 112k |
|---|
Return `singular.format(n)` if n is 1, or `plural.format(n)` otherwise. If
plural is not specified, then it is assumed to be same as singular but
suffixed with an 's'.
:param n:
Integer which determines pluralness.
:param singular:
String with a format() placeholder for n. (Default: `u... |
Given a string or integer representing dollars, return an integer of
equivalent cents, in an input-resilient way.
This works by stripping any non-numeric characters before attempting to
cast the value.
Examples::
>>> dollars_to_cents('$1')
100
>>> dollars_to_cents('1')
... |
Normalize `s` into ASCII and replace non-word characters with `delimiter`.
def slugify(s, delimiter='-'):
"""
Normalize `s` into ASCII and replace non-word characters with `delimiter`.
"""
s = unicodedata.normalize('NFKD', to_unicode(s)).encode('ascii', 'ignore').decode('ascii')
return RE_SLUG.sub(... |
Return a string that can be used as a parameter for cache-busting URLs
for this asset.
:param src_path:
Filesystem path to the file we're generating a cache-busting value for.
:param method:
Method for cache-busting. Supported values: importtime, mtime, md5
The default is 'importti... |
Yield compiled DOM attribute key-value strings.
If the value is `True`, then it is treated as no-value. If `None`, then it
is skipped.
def _generate_dom_attrs(attrs, allow_no_value=True):
""" Yield compiled DOM attribute key-value strings.
If the value is `True`, then it is treated as no-value. If `N... |
Helper for programmatically building HTML tags.
Note that this barely does any escaping, and will happily spit out
dangerous user input if used as such.
:param tagname:
Tag name of the DOM element we want to return.
:param content:
Optional content of the DOM element. If `None`, then ... |
Helper for programmatically building HTML JavaScript source include
links, with optional cache busting.
:param src_url:
Goes into the `src` attribute of the `<script src="...">` tag.
:param src_path:
Optional filesystem path to the source file, used when `cache_bust` is
enabled.
... |
Read __init__.py for global package metadata.
Do this without importing the package.
def package_meta():
"""Read __init__.py for global package metadata.
Do this without importing the package.
"""
_version_re = re.compile(r'__version__\s+=\s+(.*)')
_url_re = re.compile(r'__url__\s+=\s+(.*)')
... |
Adds supported subscriptions
def create_subscriptions(config, profile_name):
''' Adds supported subscriptions '''
if 'kinesis' in config.subscription.keys():
data = config.subscription['kinesis']
function_name = config.name
stream_name = data['stream']
batch_size = data['batch_s... |
Subscribes the lambda to the Kinesis stream
def subscribe(self):
''' Subscribes the lambda to the Kinesis stream '''
try:
LOG.debug('Creating Kinesis subscription')
if self.starting_position_ts:
self._lambda_client \
.create_event_source_mappi... |
Returns {} if the VPC config is set to None by Config,
returns the formatted config otherwise
def _format_vpc_config(self):
'''
Returns {} if the VPC config is set to None by Config,
returns the formatted config otherwise
'''
if self._config.raw['vpc']:
retur... |
Uploads the lambda package to s3
def _upload_s3(self, zip_file):
'''
Uploads the lambda package to s3
'''
s3_client = self._aws_session.client('s3')
transfer = boto3.s3.transfer.S3Transfer(s3_client)
transfer.upload_file(zip_file, self._config.s3_bucket,
... |
lambda-uploader command line interface.
def main(arv=None):
"""lambda-uploader command line interface."""
# Check for Python 2.7 or later
if sys.version_info[0] < 3 and not sys.version_info[1] == 7:
raise RuntimeError('lambda-uploader requires Python 2.7 or later')
import argparse
parser ... |
Builds the zip file and creates the package with it
def build_package(path, requires, virtualenv=None, ignore=None,
extra_files=None, zipfile_name=ZIPFILE_NAME,
pyexec=None):
'''Builds the zip file and creates the package with it'''
pkg = Package(path, zipfile_name, pyexec)
... |
Calls all necessary methods to build the Lambda Package
def build(self, ignore=None):
'''Calls all necessary methods to build the Lambda Package'''
self._prepare_workspace()
self.install_dependencies()
self.package(ignore) |
Clean up the temporary workspace if one exists
def clean_workspace(self):
'''Clean up the temporary workspace if one exists'''
if os.path.isdir(self._temp_workspace):
shutil.rmtree(self._temp_workspace) |
remove existing zipfile
def clean_zipfile(self):
'''remove existing zipfile'''
if os.path.isfile(self.zip_file):
os.remove(self.zip_file) |
Sets the requirements for the package.
It will take either a valid path to a requirements file or
a list of requirements.
def requirements(self, requires):
'''
Sets the requirements for the package.
It will take either a valid path to a requirements file or
a list of r... |
Sets the virtual environment for the lambda package
If this is not set then package_dependencies will create a new one.
Takes a path to a virtualenv or a boolean if the virtualenv creation
should be skipped.
def virtualenv(self, virtualenv):
'''
Sets the virtual environment fo... |
Creates a virtualenv and installs requirements
def install_dependencies(self):
''' Creates a virtualenv and installs requirements '''
# If virtualenv is set to skip then do nothing
if self._skip_virtualenv:
LOG.info('Skip Virtualenv set ... nothing to do')
return
... |
Build a new virtualenvironment if self._virtualenv is set to None
def _build_new_virtualenv(self):
'''Build a new virtualenvironment if self._virtualenv is set to None'''
if self._virtualenv is None:
# virtualenv was "None" which means "do default"
self._pkg_venv = os.path.join(... |
Create a new virtualenvironment and install requirements
if there are any.
def _install_requirements(self):
'''
Create a new virtualenvironment and install requirements
if there are any.
'''
if not hasattr(self, '_pkg_venv'):
err = 'Must call build_new_virtua... |
Create a zip file of the lambda script and its dependencies.
:param list ignore: a list of regular expression strings to match paths
of files in the source of the lambda script against and ignore
those files when creating the zip file. The paths to be matched are
local to th... |
Performs encoding of url parameters from dictionary to a string. It does
not escape backslash because it is not needed.
See: http://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-SetItemProperties
def encode_properties(parameters):
"""
Performs encoding of url parameters ... |
Splits path string into drive, root and relative path
Uses '/artifactory/' as a splitting point in URI. Everything
before it, including '/artifactory/' itself is treated as drive.
The next folder is treated as root, and everything else is taken
for relative path.
def splitroot(self, pa... |
Perform a GET request to url with optional authentication
def rest_get(self, url, params=None, headers=None, auth=None, verify=True, cert=None):
"""
Perform a GET request to url with optional authentication
"""
res = requests.get(url, params=params, headers=headers, auth=auth, verify=ve... |
Perform a PUT request to url with optional authentication
def rest_put(self, url, params=None, headers=None, auth=None, verify=True, cert=None):
"""
Perform a PUT request to url with optional authentication
"""
res = requests.put(url, params=params, headers=headers, auth=auth, verify=ve... |
Perform a PUT request to url with optional authentication
def rest_post(self, url, params=None, headers=None, auth=None, verify=True, cert=None):
"""
Perform a PUT request to url with optional authentication
"""
res = requests.post(url, params=params, headers=headers, auth=auth, verify=... |
Perform a DELETE request to url with optional authentication
def rest_del(self, url, params=None, auth=None, verify=True, cert=None):
"""
Perform a DELETE request to url with optional authentication
"""
res = requests.delete(url, params=params, auth=auth, verify=verify, cert=cert)
... |
Perform a chunked GET request to url with optional authentication
This is specifically to download files.
def rest_get_stream(self, url, auth=None, verify=True, cert=None):
"""
Perform a chunked GET request to url with optional authentication
This is specifically to download files.
... |
Request remote file/directory status info
Returns a json object as specified by Artifactory REST API
def get_stat_json(self, pathobj):
"""
Request remote file/directory status info
Returns a json object as specified by Artifactory REST API
"""
url = '/'.join([pathobj.dri... |
Opens the remote file and returns a file-like object HTTPResponse
Given the nature of HTTP streaming, this object doesn't support
seek()
def open(self, pathobj):
"""
Opens the remote file and returns a file-like object HTTPResponse
Given the nature of HTTP streaming, this object... |
Uploads a given file-like object
HTTP chunked encoding will be attempted
def deploy(self, pathobj, fobj, md5=None, sha1=None, parameters=None):
"""
Uploads a given file-like object
HTTP chunked encoding will be attempted
"""
if isinstance(fobj, urllib3.response.HTTPRespo... |
Move artifact from src to dst
def move(self, src, dst):
"""
Move artifact from src to dst
"""
url = '/'.join([src.drive,
'api/move',
str(src.relative_to(src.drive)).rstrip('/')])
params = {'to': str(dst.relative_to(dst.drive)).rst... |
Set artifact properties
def set_properties(self, pathobj, props, recursive):
"""
Set artifact properties
"""
url = '/'.join([pathobj.drive,
'api/storage',
str(pathobj.relative_to(pathobj.drive)).strip('/')])
params = {'properties'... |
Delete artifact properties
def del_properties(self, pathobj, props, recursive):
"""
Delete artifact properties
"""
if isinstance(props, str):
props = (props,)
url = '/'.join([pathobj.drive,
'api/storage',
str(pathobj.r... |
Return the relative path to another path identified by the passed
arguments. If the operation is not possible (because this is not
a subpath of the other path), raise ValueError.
def relative_to(self, *other):
"""
Return the relative path to another path identified by the passed
... |
Adds new or modifies existing properties listed in properties
properties - is a dict which contains the property names and values to set.
Property values can be a list or tuple to set multiple values
for a key.
recursive - on folders property attachment is rec... |
returns a tuple that contains (screen_width,screen_height)
def getScreenDims(self):
"""returns a tuple that contains (screen_width,screen_height)
"""
width = ale_lib.getScreenWidth(self.obj)
height = ale_lib.getScreenHeight(self.obj)
return (width,height) |
This function fills screen_data with the RAW Pixel data
screen_data MUST be a numpy array of uint8/int8. This could be initialized like so:
screen_data = np.array(w*h,dtype=np.uint8)
Notice, it must be width*height in size also
If it is None, then this function will initialize it
... |
This function fills screen_data with the data
screen_data MUST be a numpy array of uint32/int32. This can be initialized like so:
screen_data = np.array(w*h,dtype=np.uint32)
Notice, it must be width*height in size also
If it is None, then this function will initialize it
def getScreenRG... |
This function grabs the atari RAM.
ram MUST be a numpy array of uint8/int8. This can be initialized like so:
ram = np.array(ram_size,dtype=uint8)
Notice: It must be ram_size where ram_size can be retrieved via the getRAMSize function.
If it is None, then this function will initialize it.... |
Convert to lowercase and strip spaces
def lowstrip(term):
"""Convert to lowercase and strip spaces"""
term = re.sub('\s+', ' ', term)
term = term.lower()
return term |
Perform the similarity join
def main(left_path, left_column, right_path, right_column,
outfile, titles, join, minscore, count, warp):
"""Perform the similarity join"""
right_file = csv.reader(open(right_path, 'r'))
if titles:
right_header = next(right_file)
index = NGram((tuple(r) for ... |
Process command-line arguments.
def console_main():
"""Process command-line arguments."""
from argparse import ArgumentParser
parser = ArgumentParser(description=__doc__)
parser.add_argument('-t', '--titles', action='store_true',
help='input files have column titles')
parser... |
Return a new NGram object with the same settings, and
referencing the same items. Copy is shallow in that
each item is not recursively copied. Optionally specify
alternate items to populate the copy.
>>> from ngram import NGram
>>> from copy import deepcopy
>>> n = NG... |
Iterates over the ngrams of a string (no padding).
>>> from ngram import NGram
>>> n = NGram()
>>> list(n._split("hamegg"))
['ham', 'ame', 'meg', 'egg']
def _split(self, string):
"""Iterates over the ngrams of a string (no padding).
>>> from ngram import NGram
... |
Add an item to the N-gram index (if it has not already been added).
>>> from ngram import NGram
>>> n = NGram()
>>> n.add("ham")
>>> list(n)
['ham']
>>> n.add("spam")
>>> sorted(list(n))
['ham', 'spam']
def add(self, item):
"""Add an item to the ... |
Retrieve the subset of items that share n-grams the query string.
:param query: look up items that share N-grams with this string.
:return: mapping from matched string to the number of shared N-grams.
>>> from ngram import NGram
>>> n = NGram(["ham","spam","eggs"])
>>> sorted(n... |
Search the index for items whose key exceeds the threshold
similarity to the key of the given item.
:return: list of pairs of (item, similarity) by decreasing similarity.
>>> from ngram import NGram
>>> n = NGram([(0, "SPAM"), (1, "SPAN"), (2, "EG"),
... (3, "SPANN")], key=lamb... |
Search the index for items whose key exceeds threshold
similarity to the query string.
:param query: returned items will have at least `threshold` \
similarity to the query string.
:return: list of pairs of (item, similarity) by decreasing similarity.
>>> from ngram import NGr... |
Return most similar item to the provided one, or None if
nothing exceeds the threshold.
>>> from ngram import NGram
>>> n = NGram([(0, "Spam"), (1, "Ham"), (2, "Eggsy"), (3, "Egggsy")],
... key=lambda x:x[1].lower())
>>> n.finditem((3, 'Hom'))
(1, 'Ham')
>>> ... |
Simply return the best match to the query, None on no match.
>>> from ngram import NGram
>>> n = NGram(["Spam","Eggs","Ham"], key=lambda x:x.lower(), N=1)
>>> n.find('Hom')
'Ham'
>>> n.find("Spom")
'Spam'
>>> n.find("Spom", 0.8)
def find(self, query, threshold=N... |
Similarity for two sets of n-grams.
:note: ``similarity = (a**e - d**e)/a**e`` where `a` is \
"all n-grams", `d` is "different n-grams" and `e` is the warp.
:param samegrams: number of n-grams shared by the two strings.
:param allgrams: total of the distinct n-grams across the two str... |
Compares two strings and returns their similarity.
:param s1: first string
:param s2: second string
:param kwargs: additional keyword arguments passed to __init__.
:return: similarity between 0.0 and 1.0.
>>> from ngram import NGram
>>> NGram.compare('spa', 'spam')
... |
Remove all elements from this set.
>>> from ngram import NGram
>>> n = NGram(['spam', 'eggs'])
>>> sorted(list(n))
['eggs', 'spam']
>>> n.clear()
>>> list(n)
[]
def clear(self):
"""Remove all elements from this set.
>>> from ngram import NGram
... |
Return the union of two or more sets as a new set.
>>> from ngram import NGram
>>> a = NGram(['spam', 'eggs'])
>>> b = NGram(['spam', 'ham'])
>>> sorted(list(a.union(b)))
['eggs', 'ham', 'spam']
def union(self, *others):
"""Return the union of two or more sets as a new ... |
Return the difference of two or more sets as a new set.
>>> from ngram import NGram
>>> a = NGram(['spam', 'eggs'])
>>> b = NGram(['spam', 'ham'])
>>> list(a.difference(b))
['eggs']
def difference(self, *others):
"""Return the difference of two or more sets as a new set... |
Return the intersection of two or more sets as a new set.
>>> from ngram import NGram
>>> a = NGram(['spam', 'eggs'])
>>> b = NGram(['spam', 'ham'])
>>> list(a.intersection(b))
['spam']
def intersection(self, *others):
"""Return the intersection of two or more sets as a... |
Update the set with the intersection of itself and other sets.
>>> from ngram import NGram
>>> n = NGram(['spam', 'eggs'])
>>> other = set(['spam', 'ham'])
>>> n.intersection_update(other)
>>> list(n)
['spam']
def intersection_update(self, *others):
"""Update th... |
Return the symmetric difference of two sets as a new set.
>>> from ngram import NGram
>>> a = NGram(['spam', 'eggs'])
>>> b = NGram(['spam', 'ham'])
>>> sorted(list(a.symmetric_difference(b)))
['eggs', 'ham']
def symmetric_difference(self, other):
"""Return the symmetri... |
Update the set with the symmetric difference of itself and `other`.
>>> from ngram import NGram
>>> n = NGram(['spam', 'eggs'])
>>> other = set(['spam', 'ham'])
>>> n.symmetric_difference_update(other)
>>> sorted(list(n))
['eggs', 'ham']
def symmetric_difference_update(... |
Subtract the arg from the value.
def sub(value, arg):
"""Subtract the arg from the value."""
try:
nvalue, narg = handle_float_decimal_combinations(
valid_numeric(value), valid_numeric(arg), '-')
return nvalue - narg
except (ValueError, TypeError):
try:
return... |
Return the absolute value.
def absolute(value):
"""Return the absolute value."""
try:
return abs(valid_numeric(value))
except (ValueError, TypeError):
try:
return abs(value)
except Exception:
return '' |
Create the cli command line.
def cli(config, server, api_key, all, credentials, project):
"""Create the cli command line."""
# Check first for the pybossa.rc file to configure server and api-key
home = expanduser("~")
if os.path.isfile(os.path.join(home, '.pybossa.cfg')):
config.parser.read(os.... |
Show pbs version.
def version():
"""Show pbs version."""
try:
import pkg_resources
click.echo(pkg_resources.get_distribution('pybossa-pbs').version)
except ImportError:
click.echo("pybossa-pbs package not found!") |
Update project templates and information.
def update_project(config, task_presenter, results,
long_description, tutorial, watch): # pragma: no cover
"""Update project templates and information."""
if watch:
res = _update_project_watch(config, task_presenter, results,
... |
Add tasks to a project.
def add_tasks(config, tasks_file, tasks_type, priority, redundancy):
"""Add tasks to a project."""
res = _add_tasks(config, tasks_file, tasks_type, priority, redundancy)
click.echo(res) |
Add helping materials to a project.
def add_helpingmaterials(config, helping_materials_file, helping_type):
"""Add helping materials to a project."""
res = _add_helpingmaterials(config, helping_materials_file, helping_type)
click.echo(res) |
Delete tasks from a project.
def delete_tasks(config, task_id):
"""Delete tasks from a project."""
if task_id is None:
msg = ("Are you sure you want to delete all the tasks and associated task runs?")
if click.confirm(msg):
res = _delete_tasks(config, task_id)
click.echo... |
Update task redudancy for a project.
def update_task_redundancy(config, task_id, redundancy):
"""Update task redudancy for a project."""
if task_id is None:
msg = ("Are you sure you want to update all the tasks redundancy?")
if click.confirm(msg):
res = _update_tasks_redundancy(conf... |
Create a project in a PyBossa server.
def _create_project(config):
"""Create a project in a PyBossa server."""
try:
response = config.pbclient.create_project(config.project['name'],
config.project['short_name'],
... |
Update a project in a loop.
def _update_project_watch(config, task_presenter, results,
long_description, tutorial): # pragma: no cover
"""Update a project in a loop."""
logging.basicConfig(level=logging.INFO,
format='%(asctime)s - %(message)s',
... |
Append to template a distribution bundle js.
def _update_task_presenter_bundle_js(project):
"""Append to template a distribution bundle js."""
if os.path.isfile ('bundle.min.js'):
with open('bundle.min.js') as f:
js = f.read()
project.info['task_presenter'] += "<script>\n%s\n</scrip... |
Update a project.
def _update_project(config, task_presenter, results,
long_description, tutorial):
"""Update a project."""
try:
# Get project
project = find_project_by_short_name(config.project['short_name'],
config.pbclient,
... |
Load data from CSV, JSON, Excel, ..., formats.
def _load_data(data_file, data_type):
"""Load data from CSV, JSON, Excel, ..., formats."""
raw_data = data_file.read()
if data_type is None:
data_type = data_file.name.split('.')[-1]
# Data list to process
data = []
# JSON type
if data_... |
Add tasks to a project.
def _add_tasks(config, tasks_file, tasks_type, priority, redundancy):
"""Add tasks to a project."""
try:
project = find_project_by_short_name(config.project['short_name'],
config.pbclient,
... |
Add helping materials to a project.
def _add_helpingmaterials(config, helping_file, helping_type):
"""Add helping materials to a project."""
try:
project = find_project_by_short_name(config.project['short_name'],
config.pbclient,
... |
Delete tasks from a project.
def _delete_tasks(config, task_id, limit=100, offset=0):
"""Delete tasks from a project."""
try:
project = find_project_by_short_name(config.project['short_name'],
config.pbclient,
con... |
Update tasks redundancy from a project.
def _update_tasks_redundancy(config, task_id, redundancy, limit=300, offset=0):
"""Update tasks redundancy from a project."""
try:
project = find_project_by_short_name(config.project['short_name'],
config.pbclient,
... |
Return project by short_name.
def find_project_by_short_name(short_name, pbclient, all=None):
"""Return project by short_name."""
try:
response = pbclient.find_project(short_name=short_name, all=all)
check_api_error(response)
if (len(response) == 0):
msg = '%s not found! You... |
Check if returned API response contains an error.
def check_api_error(api_response):
print(api_response)
"""Check if returned API response contains an error."""
if type(api_response) == dict and 'code' in api_response and api_response['code'] <> 200:
print("Server response code: %s" % api_respo... |
Format the error for the given module.
def format_error(module, error):
"""Format the error for the given module."""
logging.error(module)
# Beautify JSON error
print error.message
print json.dumps(error.error, sort_keys=True, indent=4, separators=(',', ': '))
exit(1) |
Create task_info field.
def create_task_info(task):
"""Create task_info field."""
task_info = None
if task.get('info'):
task_info = task['info']
else:
task_info = task
return task_info |
Create helping_material_info field.
def create_helping_material_info(helping):
"""Create helping_material_info field."""
helping_info = None
file_path = None
if helping.get('info'):
helping_info = helping['info']
else:
helping_info = helping
if helping_info.get('file_path'):
... |
Returns data belonging to an authorization code from redis or
``None`` if no data was found.
See :class:`oauth2.store.AuthCodeStore`.
def fetch_by_code(self, code):
"""
Returns data belonging to an authorization code from redis or
``None`` if no data was found.
See :cl... |
Stores the data belonging to an authorization code token in redis.
See :class:`oauth2.store.AuthCodeStore`.
def save_code(self, authorization_code):
"""
Stores the data belonging to an authorization code token in redis.
See :class:`oauth2.store.AuthCodeStore`.
"""
sel... |
Stores the access token and additional data in redis.
See :class:`oauth2.store.AccessTokenStore`.
def save_token(self, access_token):
"""
Stores the access token and additional data in redis.
See :class:`oauth2.store.AccessTokenStore`.
"""
self.write(access_token.toke... |
Deletes a refresh token after use
:param refresh_token: The refresh token to delete.
def delete_refresh_token(self, refresh_token):
"""
Deletes a refresh token after use
:param refresh_token: The refresh token to delete.
"""
access_token = self.fetch_by_refresh_token(ref... |
Add a client app.
:param client_id: Identifier of the client app.
:param client_secret: Secret the client app uses for authentication
against the OAuth 2.0 provider.
:param redirect_uris: A ``list`` of URIs to redirect to.
def add_client(self, client_id, client_se... |
Create data needed by an access token.
:param grant_type:
:type grant_type: str
:return: A ``dict`` containing he ``access_token`` and the
``token_type``. If the value of ``TokenGenerator.expires_in``
is larger than 0, a ``refresh_token`` will be generated too... |
:return: A new token
:rtype: str
def generate(self):
"""
:return: A new token
:rtype: str
"""
random_data = os.urandom(100)
hash_gen = hashlib.new("sha512")
hash_gen.update(random_data)
return hash_gen.hexdigest()[:self.token_length] |
Display token information or redirect to login prompt if none is
available.
def _display_token(self):
"""
Display token information or redirect to login prompt if none is
available.
"""
if self.token is None:
return "301 Moved", "", {"Location": "/login"}
... |
Login prompt
def _login(self, failed=False):
"""
Login prompt
"""
if failed:
content = self.LOGIN_TEMPLATE.format(failed_message="Login failed")
else:
content = self.LOGIN_TEMPLATE.format(failed_message="")
return "200 OK", content, {"Content-Type... |
Retrieves a new access token from the OAuth2 server.
def _request_token(self, env):
"""
Retrieves a new access token from the OAuth2 server.
"""
params = {}
content = env['wsgi.input'].read(int(env['CONTENT_LENGTH']))
post_params = parse_qs(content)
# Convert to... |
Add a client app.
:param client_id: Identifier of the client app.
:param client_secret: Secret the client app uses for authentication
against the OAuth 2.0 provider.
:param redirect_uris: A ``list`` of URIs to redirect to.
def add_client(self, client_id, client_se... |
Retrieve a client by its identifier.
:param client_id: Identifier of a client app.
:return: An instance of :class:`oauth2.Client`.
:raises: ClientNotFoundError
def fetch_by_client_id(self, client_id):
"""
Retrieve a client by its identifier.
:param client_id: Identifie... |
Returns an AuthorizationCode.
:param code: The authorization code.
:return: An instance of :class:`oauth2.datatype.AuthorizationCode`.
:raises: :class:`AuthCodeNotFound` if no data could be retrieved for
given code.
def fetch_by_code(self, code):
"""
Returns an... |
Stores an access token and additional data in memory.
:param access_token: An instance of :class:`oauth2.datatype.AccessToken`.
def save_token(self, access_token):
"""
Stores an access token and additional data in memory.
:param access_token: An instance of :class:`oauth2.datatype.Acc... |
Find an access token by its refresh token.
:param refresh_token: The refresh token that was assigned to an
``AccessToken``.
:return: The :class:`oauth2.datatype.AccessToken`.
:raises: :class:`oauth2.error.AccessTokenNotFound`
def fetch_by_refresh_token(self, refre... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.