_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 31 13.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q245100 | filter_components_by_name | train | def filter_components_by_name(name, components_list, type_=T_RPM):
"""Generator filters components from components_list by name"""
| python | {
"resource": ""
} |
q245101 | CompareComponentsPlugin.get_component_list_from_workers | train | def get_component_list_from_workers(self, worker_metadatas):
"""
Find the component lists from each worker build.
The components that are interesting are under the 'output' key. The
buildhost's components are ignored.
Inside the 'output' key are various 'instances'. The only ... | python | {
"resource": ""
} |
q245102 | KojiPromotePlugin.get_rpms | train | def get_rpms(self):
"""
Build a list of installed RPMs in the format required for the
metadata.
"""
tags = [
'NAME',
'VERSION',
'RELEASE',
'ARCH',
'EPOCH',
'SIGMD5',
'SIGPGP:pgpsig',
... | python | {
"resource": ""
} |
q245103 | KojiPromotePlugin.get_output_metadata | train | def get_output_metadata(self, path, filename):
"""
Describe a file by its metadata.
:return: dict
"""
checksums = get_checksums(path, ['md5'])
metadata = {'filename': filename,
'filesize': os.path.getsize(path),
| python | {
"resource": ""
} |
q245104 | KojiPromotePlugin.get_builder_image_id | train | def get_builder_image_id(self):
"""
Find out the docker ID of the buildroot image we are in.
"""
try:
buildroot_tag = os.environ["OPENSHIFT_CUSTOM_BUILD_BASE_IMAGE"]
except KeyError:
return ''
try:
pod = self.osbs.get_pod_for_build(se... | python | {
"resource": ""
} |
q245105 | KojiPromotePlugin.get_image_components | train | def get_image_components(self):
"""
Re-package the output of the rpmqa plugin into the format required
for the metadata.
"""
output = self.workflow.image_components
if output is None:
| python | {
"resource": ""
} |
q245106 | KojiPromotePlugin.get_digests | train | def get_digests(self):
"""
Returns a map of images to their digests
"""
try:
pulp = get_manifests_in_pulp_repository(self.workflow)
except KeyError:
pulp = None
digests = {} # repository -> digests
for registry in self.workflow.push_conf... | python | {
"resource": ""
} |
q245107 | KojiPromotePlugin.get_repositories | train | def get_repositories(self, digests):
"""
Build the repositories metadata
:param digests: dict, image -> digests
"""
if self.workflow.push_conf.pulp_registries:
# If pulp was used, only report pulp images
registries = self.workflow.push_conf.pulp_registrie... | python | {
"resource": ""
} |
q245108 | KojiPromotePlugin.upload_file | train | def upload_file(self, session, output, serverdir):
"""
Upload a file to koji
:return: str, pathname on server
"""
name = output.metadata['filename']
self.log.debug("uploading %r to %r as %r",
output.file.name, serverdir, name)
kwargs = {}
... | python | {
"resource": ""
} |
q245109 | VerifyMediaTypesPlugin.get_manifest_list_only_expectation | train | def get_manifest_list_only_expectation(self):
"""
Get expectation for manifest list only
:return: bool, expect manifest list only?
"""
if not self.workflow.postbuild_results.get(PLUGIN_GROUP_MANIFESTS_KEY):
self.log.debug('Cannot check if only manifest list digest sh... | python | {
"resource": ""
} |
q245110 | PullBaseImagePlugin.run | train | def run(self):
"""
Pull parent images and retag them uniquely for this build.
"""
build_json = get_build_json()
current_platform = platform.processor() or 'x86_64'
self.manifest_list_cache = {}
organization = get_registries_organization(self.workflow)
for... | python | {
"resource": ""
} |
q245111 | PullBaseImagePlugin._get_image_for_different_arch | train | def _get_image_for_different_arch(self, image, platform):
"""Get image from random arch
This is a workaround for aarch64 platform, because orchestrator cannot
get this arch from manifests lists so we have to provide digest of a
random platform to get image metadata for orchestrator.
... | python | {
"resource": ""
} |
q245112 | PullBaseImagePlugin._resolve_base_image | train | def _resolve_base_image(self, build_json):
"""If this is an auto-rebuild, adjust the base image to use the triggering build"""
spec = build_json.get("spec")
try:
image_id = spec['triggeredBy'][0]['imageChangeBuild']['imageID']
except (TypeError, KeyError, IndexError):
... | python | {
"resource": ""
} |
q245113 | PullBaseImagePlugin._ensure_image_registry | train | def _ensure_image_registry(self, image):
"""If plugin configured with a parent registry, ensure the image uses it"""
image_with_registry = image.copy()
if self.parent_registry:
# if registry specified in Dockerfile image, ensure it's the one allowed by config
if image.reg... | python | {
"resource": ""
} |
q245114 | PullBaseImagePlugin._pull_and_tag_image | train | def _pull_and_tag_image(self, image, build_json, nonce):
"""Docker pull the image and tag it uniquely for use by this build"""
image = image.copy()
first_library_exc = None
for _ in range(20):
# retry until pull and tag is successful or definitively fails.
# shoul... | python | {
"resource": ""
} |
q245115 | PullBaseImagePlugin._get_manifest_list | train | def _get_manifest_list(self, image):
"""try to figure out manifest list"""
if image in self.manifest_list_cache:
return self.manifest_list_cache[image]
manifest_list = get_manifest_list(image, image.registry,
insecure=self.parent_registry_in... | python | {
"resource": ""
} |
q245116 | PullBaseImagePlugin._validate_platforms_in_image | train | def _validate_platforms_in_image(self, image):
"""Ensure that the image provides all platforms expected for the build."""
expected_platforms = get_platforms(self.workflow)
if not expected_platforms:
self.log.info('Skipping validation of available platforms '
... | python | {
"resource": ""
} |
q245117 | PulpSyncPlugin.get_dockercfg_credentials | train | def get_dockercfg_credentials(self, docker_registry):
"""
Read the .dockercfg file and return an empty dict, or else a dict
with keys 'basic_auth_username' and 'basic_auth_password'.
"""
if not self.registry_secret_path:
return {}
dockercfg = Dockercfg(self.r... | python | {
"resource": ""
} |
q245118 | ODCSClient.start_compose | train | def start_compose(self, source_type, source, packages=None, sigkeys=None, arches=None,
flags=None, multilib_arches=None, multilib_method=None,
modular_koji_tags=None):
"""Start a new ODCS compose
:param source_type: str, the type of compose to request (tag, m... | python | {
"resource": ""
} |
q245119 | ODCSClient.renew_compose | train | def renew_compose(self, compose_id):
"""Renew, or extend, existing compose
If the compose has already been removed, ODCS creates a new compose.
Otherwise, it extends the time_to_expire of existing compose. In most
cases, caller should assume the compose ID will change.
:param c... | python | {
"resource": ""
} |
q245120 | ODCSClient.wait_for_compose | train | def wait_for_compose(self, compose_id,
burst_retry=1,
burst_length=30,
slow_retry=10,
timeout=1800):
"""Wait for compose request to finalize
:param compose_id: int, compose ID to wait for
:param ... | python | {
"resource": ""
} |
q245121 | HideFilesPlugin._find_stages | train | def _find_stages(self):
"""Find limits of each Dockerfile stage"""
stages = []
end = last_user_found = None
for part in reversed(self.dfp.structure):
if end is None:
end = part
if part['instruction'] == 'USER' and not last_user_found:
... | python | {
"resource": ""
} |
q245122 | StoreMetadataInOSv3Plugin.get_digests | train | def get_digests(self):
"""
Returns a map of repositories to digests
"""
digests = {} # repository -> digest
for registry in self.workflow.push_conf.docker_registries:
for image in self.workflow.tag_conf.images:
image_str = image.to_str()
| python | {
"resource": ""
} |
q245123 | StoreMetadataInOSv3Plugin._get_registries | train | def _get_registries(self):
"""
Return a list of registries that this build updated
For orchestrator it should attempt to filter out non-pulp registries, on worker - return
all registries
"""
if self.workflow.buildstep_result.get(PLUGIN_BUILD_ORCHESTRATE_KEY):
... | python | {
"resource": ""
} |
q245124 | KojiUploadPlugin.get_repositories_and_digests | train | def get_repositories_and_digests(self):
"""
Returns a map of images to their repositories and a map of media types to each digest
it creates a map of images to digests, which is need to create the image->repository
map and uses the same loop structure as media_types->digest, but the ima... | python | {
"resource": ""
} |
q245125 | KojiUploadPlugin.update_buildroot_koji | train | def update_buildroot_koji(self, buildroot, output):
"""
put the final koji information in the buildroot under extra.osbs
"""
docker = output[1]['extra']['docker']
name = ''
for tag in docker['tags']:
for repo in docker['repositories']:
if tag ... | python | {
"resource": ""
} |
q245126 | KojiUploadPlugin.get_metadata | train | def get_metadata(self):
"""
Build the metadata needed for importing the build
:return: tuple, the metadata and the list of Output instances
"""
try:
metadata = get_build_json()["metadata"]
self.build_id = metadata["name"]
except KeyError:
... | python | {
"resource": ""
} |
q245127 | DeleteFromRegistryPlugin.get_worker_digests | train | def get_worker_digests(self):
"""
If we are being called from an orchestrator build, collect the worker
node data and recreate the data locally.
"""
try:
builds = self.workflow.build_result.annotations['worker-builds']
except(TypeError, KeyError):
... | python | {
"resource": ""
} |
q245128 | BuildResult.make_remote_image_result | train | def make_remote_image_result(annotations=None, labels=None):
"""Instantiate BuildResult for image not built locally."""
| python | {
"resource": ""
} |
q245129 | InsideBuilder.base_image_inspect | train | def base_image_inspect(self):
"""
inspect base image
:return: dict
"""
if self._base_image_inspect is None:
if self.base_from_scratch:
self._base_image_inspect = {}
elif self.parents_pulled or self.custom_base_image:
try:
... | python | {
"resource": ""
} |
q245130 | InsideBuilder.parent_image_inspect | train | def parent_image_inspect(self, image):
"""
inspect parent image
:return: dict
"""
image_name = ImageName.parse(image)
if image_name not in self._parent_images_inspect:
if self.parents_pulled:
self._parent_images_inspect[image_name] = self.task... | python | {
"resource": ""
} |
q245131 | InsideBuilder.inspect_built_image | train | def inspect_built_image(self):
"""
inspect built image
:return: dict
"""
logger.info("inspecting built image '%s'", self.image_id)
self.ensure_is_built()
| python | {
"resource": ""
} |
q245132 | InsideBuilder.get_base_image_info | train | def get_base_image_info(self):
"""
query docker about base image
:return dict
"""
if self.base_from_scratch:
return
logger.info("getting information about base image '%s'", self.base_image)
image_info = self.tasker.get_image_info_by_image_name(self.ba... | python | {
"resource": ""
} |
q245133 | InsideBuilder.get_built_image_info | train | def get_built_image_info(self):
"""
query docker about built image
:return dict
"""
logger.info("getting information about built image '%s'", self.image)
image_info = self.tasker.get_image_info_by_image_name(self.image)
items_count = len(image_info)
if it... | python | {
"resource": ""
} |
q245134 | build_inside | train | def build_inside(input_method, input_args=None, substitutions=None):
"""
use requested input plugin to load configuration and then initiate build
"""
def process_keyvals(keyvals):
""" ["key=val", "x=y"] -> {"key": "val", "x": "y"} """
keyvals = keyvals or []
processed_keyvals = {... | python | {
"resource": ""
} |
q245135 | FSWatcher.run | train | def run(self):
""" Overrides parent method to implement thread's functionality. """
while True: # make sure to run at least once before exiting
with self._lock:
| python | {
"resource": ""
} |
q245136 | get_config | train | def get_config(workflow):
"""
Obtain configuration object
Does not fail
:return: ReactorConfig instance
"""
try:
workspace = workflow.plugin_workspace[ReactorConfigPlugin.key]
return workspace[WORKSPACE_CONF_KEY]
except KeyError:
# The plugin did not run or was not s... | python | {
"resource": ""
} |
q245137 | ReactorConfigPlugin.run | train | def run(self):
"""
Run the plugin
Parse and validate config.
Store in workflow workspace for later retrieval.
"""
if self.reactor_config_map:
self.log.info("reading config from REACTOR_CONFIG env variable")
conf = read_yaml(self.reactor_config_map... | python | {
"resource": ""
} |
q245138 | BuildContainerFactory._check_build_input | train | def _check_build_input(self, image, args_path):
"""
Internal method, validate provided args.
:param image: str
:param args_path: str, path dir which is mounter inside container
:return: None
:raises RuntimeError
"""
try:
with open(os.path.join... | python | {
"resource": ""
} |
q245139 | DockerTasker.build_image_from_path | train | def build_image_from_path(self, path, image, use_cache=False, remove_im=True):
"""
build image from provided path and tag it
this operation is asynchronous and you should consume returned generator in order to wait
for build to finish
:param path: str
:param image: Imag... | python | {
"resource": ""
} |
q245140 | DockerTasker.build_image_from_git | train | def build_image_from_git(self, url, image, git_path=None, git_commit=None,
copy_dockerfile_to=None,
stream=False, use_cache=False):
"""
build image from provided url and tag it
this operation is asynchronous and you should consume return... | python | {
"resource": ""
} |
q245141 | DockerTasker.run | train | def run(self, image, command=None, create_kwargs=None, start_kwargs=None,
volume_bindings=None, privileged=None):
"""
create container from provided image and start it
for more info, see documentation of REST API calls:
* containers/{}/start
* container/create
... | python | {
"resource": ""
} |
q245142 | DockerTasker.commit_container | train | def commit_container(self, container_id, image=None, message=None):
"""
create image from provided container
:param container_id: str
:param image: ImageName
:param message: str
:return: image_id
"""
logger.info("committing container '%s'", container_id)
... | python | {
"resource": ""
} |
q245143 | DockerTasker.pull_image | train | def pull_image(self, image, insecure=False, dockercfg_path=None):
"""
pull provided image from registry
:param image_name: ImageName, image to pull
:param insecure: bool, allow connecting to registry over plain http
:param dockercfg_path: str, path to dockercfg
:return: ... | python | {
"resource": ""
} |
q245144 | DockerTasker.tag_image | train | def tag_image(self, image, target_image, force=False):
"""
tag provided image with specified image_name, registry and tag
:param image: str or ImageName, image to tag
:param target_image: ImageName, new name for the image
:param force: bool, force tag the image?
:return:... | python | {
"resource": ""
} |
q245145 | DockerTasker.login | train | def login(self, registry, docker_secret_path):
"""
login to docker registry
:param registry: registry name
:param docker_secret_path: path to docker config directory
"""
logger.info("logging in: registry '%s', secret path '%s'", registry, docker_secret_path)
# Do... | python | {
"resource": ""
} |
q245146 | DockerTasker.push_image | train | def push_image(self, image, insecure=False):
"""
push provided image to registry
:param image: ImageName
:param insecure: bool, allow connecting to registry over plain http
:return: str, logs from push
"""
logger.info("pushing image '%s'", image)
logger.d... | python | {
"resource": ""
} |
q245147 | DockerTasker.tag_and_push_image | train | def tag_and_push_image(self, image, target_image, insecure=False, force=False,
dockercfg=None):
"""
tag provided image and push it to registry
:param image: str or ImageName, image id or name
:param target_image: ImageName, img
:param insecure: bool, a... | python | {
"resource": ""
} |
q245148 | DockerTasker.remove_image | train | def remove_image(self, image_id, force=False, noprune=False):
"""
remove provided image from filesystem
:param image_id: str or ImageName
:param noprune: bool, keep untagged parents?
:param force: bool, force remove -- just trash it no matter what
:return: None
"... | python | {
"resource": ""
} |
q245149 | DockerTasker.remove_container | train | def remove_container(self, container_id, force=False):
"""
remove provided container from filesystem
:param container_id: str
:param force: bool, remove | python | {
"resource": ""
} |
q245150 | DockerTasker.image_exists | train | def image_exists(self, image_id):
"""
does provided image exists?
:param image_id: str or ImageName
:return: True if exists, False if not
"""
logger.info("checking whether image '%s' exists", image_id)
logger.debug("image_id = '%s'", image_id)
try:
... | python | {
"resource": ""
} |
q245151 | DockerTasker.get_volumes_for_container | train | def get_volumes_for_container(self, container_id, skip_empty_source=True):
"""
get a list of volumes mounter in a container
:param container_id: str
:param skip_empty_source: bool, don't list volumes which are not created on FS
:return: list, a list of volume names
"""
... | python | {
"resource": ""
} |
q245152 | DockerTasker.remove_volume | train | def remove_volume(self, volume_name):
"""
remove a volume by its name
:param volume_name: str
:return None
"""
logger.info("removing volume '%s'", volume_name)
try:
self.d.remove_volume(volume_name)
except APIError as ex:
| python | {
"resource": ""
} |
q245153 | EnvInputPlugin.run | train | def run(self):
"""
get json with build config from environment variable
"""
env_name = self.env_name or BUILD_JSON_ENV
try:
build_cfg_json = os.environ[env_name]
except KeyError:
self.log.error("build config not found in env variable '%s'", env_nam... | python | {
"resource": ""
} |
q245154 | AddFilesystemPlugin.get_default_image_build_conf | train | def get_default_image_build_conf(self):
"""Create a default image build config
:rtype: ConfigParser
:return: Initialized config with defaults
"""
target = self.koji_target
vcs_info = self.workflow.source.get_vcs_info()
ksurl = '{}#{}'.format(vcs_info.vcs_url, vc... | python | {
"resource": ""
} |
q245155 | AddFilesystemPlugin.update_config_from_dockerfile | train | def update_config_from_dockerfile(self, config):
"""Updates build config with values from the Dockerfile
Updates:
* set "name" from LABEL com.redhat.component (if exists)
* set "version" from LABEL version (if exists)
:param config: ConfigParser object
"""
l... | python | {
"resource": ""
} |
q245156 | PluginsRunner.load_plugins | train | def load_plugins(self, plugin_class_name):
"""
load all available plugins
:param plugin_class_name: str, name of plugin class (e.g. 'PreBuildPlugin')
:return: dict, bindings for plugins of the plugin_class_name class
"""
# imp.findmodule('atomic_reactor') doesn't work
... | python | {
"resource": ""
} |
q245157 | PluginsRunner.get_available_plugins | train | def get_available_plugins(self):
"""
check requested plugins availability
and handle missing plugins
:return: list of namedtuples, runnable plugins data
"""
available_plugins = []
PluginData = namedtuple('PluginData', 'name, plugin_class, conf, is_allowed_to_fail... | python | {
"resource": ""
} |
q245158 | PluginsRunner.run | train | def run(self, keep_going=False, buildstep_phase=False):
"""
run all requested plugins
:param keep_going: bool, whether to keep going after unexpected
failure (only used for exit plugins)
:param buildstep_phase: bool, when True remaining plugins will
... | python | {
"resource": ""
} |
q245159 | SendMailPlugin._should_send | train | def _should_send(self, rebuild, success, auto_canceled, manual_canceled):
"""Return True if any state in `self.send_on` meets given conditions, thus meaning
that a notification mail should be sent.
"""
should_send = False
should_send_mapping = {
self.MANUAL_SUCCESS: ... | python | {
"resource": ""
} |
q245160 | SendMailPlugin._render_mail | train | def _render_mail(self, rebuild, success, auto_canceled, manual_canceled):
"""Render and return subject and body of the mail to send."""
subject_template = '%(endstate)s building image %(image_name)s'
body_template = '\n'.join([
'Image Name: %(image_name)s',
'Repositories:... | python | {
"resource": ""
} |
q245161 | SendMailPlugin._send_mail | train | def _send_mail(self, receivers_list, subject, body, log_files=None):
if not receivers_list:
self.log.info('no valid addresses in requested addresses. Doing nothing')
return
self.log.info('sending notification to %s ...', receivers_list)
"""Actually sends the mail with `... | python | {
"resource": ""
} |
q245162 | FetchWorkerMetadataPlugin.get_platform_metadata | train | def get_platform_metadata(self, platform, build_annotations):
"""
Return the metadata for the given platform.
"""
# retrieve all the workspace data
build_info = get_worker_build_info(self.workflow, platform)
osbs = build_info.osbs
kind = "configmap/"
cml... | python | {
"resource": ""
} |
q245163 | KojiImportPlugin.get_output | train | def get_output(self, worker_metadatas):
"""
Build the output entry of the metadata.
:return: list, containing dicts of partial metadata
"""
outputs = []
has_pulp_pull = PLUGIN_PULP_PULL_KEY in self.workflow.exit_results
try:
pulp_sync_results = self.w... | python | {
"resource": ""
} |
q245164 | HTTPBearerAuth.handle_401 | train | def handle_401(self, response, repo, **kwargs):
"""Fetch Bearer token and retry."""
if response.status_code != requests.codes.unauthorized:
return response
auth_info = response.headers.get('www-authenticate', '')
if 'bearer' not in auth_info.lower():
return resp... | python | {
"resource": ""
} |
q245165 | OSv3InputPlugin.remove_plugins_without_parameters | train | def remove_plugins_without_parameters(self):
"""
This used to be handled in BuildRequest, but with REACTOR_CONFIG, osbs-client doesn't have
enough information.
"""
# Compatibility code for dockerfile_content plugin
self.remove_plugin('prebuild_plugins', PLUGIN_DOCKERFILE... | python | {
"resource": ""
} |
q245166 | ResolveComposesPlugin.adjust_for_autorebuild | train | def adjust_for_autorebuild(self):
"""Ignore pre-filled signing_intent and compose_ids for autorebuids
Auto rebuilds are expected to use a known configuration. The parameters
signing_intent and compose_ids are meant for one-off build calls. This
method ensure that these parameters are ig... | python | {
"resource": ""
} |
q245167 | ResolveComposesPlugin.resolve_signing_intent | train | def resolve_signing_intent(self):
"""Determine the correct signing intent
Regardless of what was requested, or provided as signing_intent plugin parameter,
consult sigkeys of the actual composes used to guarantee information accuracy.
"""
all_signing_intents = [
sel... | python | {
"resource": ""
} |
q245168 | ComposeConfig.validate_for_request | train | def validate_for_request(self):
"""Verify enough information is available for requesting compose."""
if not self.use_packages and not self.modules and not self.pulp:
raise ValueError("Nothing to | python | {
"resource": ""
} |
q245169 | PathInputPlugin.run | train | def run(self):
"""
get json with build config from path
"""
path = self.path or CONTAINER_BUILD_JSON_PATH
try:
with open(path, 'r') as build_cfg_fd:
build_cfg_json = json.load(build_cfg_fd)
except ValueError:
self.log.error("couldn'... | python | {
"resource": ""
} |
q245170 | ExportOperatorManifestsPlugin.has_operator_manifest | train | def has_operator_manifest(self):
"""
Check if Dockerfile sets the operator manifest label
:return: bool
"""
dockerfile = df_parser(self.workflow.builder.df_path, workflow=self.workflow)
labels = Labels(dockerfile.labels)
try:
_, operator_label = | python | {
"resource": ""
} |
q245171 | ExportOperatorManifestsPlugin.should_run | train | def should_run(self):
"""
Check if the plugin should run or skip execution.
:return: bool, False if plugin should skip execution
"""
if self.is_orchestrator():
self.log.warning("%s plugin set to run on orchestrator. Skipping", self.key)
return False
... | python | {
"resource": ""
} |
q245172 | SSEClient._read | train | def _read(self):
"""Read the incoming event source stream and yield event chunks.
Unfortunately it is possible for some servers to decide to break an
event into multiple HTTP chunks in the response. It is thus necessary
to correctly stitch together consecutive response chunks and find t... | python | {
"resource": ""
} |
q245173 | check | train | def check(wants, has):
"""
Check if a desired scope ``wants`` is part of an available scope ``has``.
Returns ``False`` if not, return ``True`` if yes.
:example:
If a list of scopes such as
::
READ = 1 << 1
WRITE = 1 << 2
READ_WRITE = READ | WRITE
SCOPES = (
... | python | {
"resource": ""
} |
q245174 | to_int | train | def to_int(*names, **kwargs):
"""
Turns a list of scope names into an integer value.
::
>>> scope.to_int('read')
2
>>> scope.to_int('write')
6
>>> scope.to_int('read', 'write')
6
>>> scope.to_int('invalid')
| python | {
"resource": ""
} |
q245175 | Mixin.get_data | train | def get_data(self, request, key='params'):
"""
Return stored data from the session store.
:param key: `str` The key under which the data | python | {
"resource": ""
} |
q245176 | Mixin.cache_data | train | def cache_data(self, request, data, key='params'):
"""
Cache data in the session store.
:param request: :attr:`django.http.HttpRequest`
:param data: Arbitrary data to store.
| python | {
"resource": ""
} |
q245177 | Mixin.clear_data | train | def clear_data(self, request):
"""
Clear all OAuth related data from the session store.
| python | {
"resource": ""
} |
q245178 | Authorize.error_response | train | def error_response(self, request, error, **kwargs):
"""
Return an error to be displayed to the resource owner if anything goes
awry. Errors can include invalid clients, authorization denials and
other edge cases such as a wrong ``redirect_uri`` in the authorization
request.
... | python | {
"resource": ""
} |
q245179 | AccessToken.get_handler | train | def get_handler(self, grant_type):
"""
Return a function or method that is capable handling the ``grant_type``
requested by the client or return ``None`` to indicate that this type
of grant type is not supported, resulting in an error response.
"""
if grant_type == 'autho... | python | {
"resource": ""
} |
q245180 | AccessToken.get_expire_delta | train | def get_expire_delta(self, reference=None):
"""
Return the number of seconds until this token expires.
"""
if reference is None:
reference = now()
expiration = self.expires
if timezone:
if timezone.is_aware(reference) and timezone.is_naive(expirat... | python | {
"resource": ""
} |
q245181 | OAuthForm._clean_fields | train | def _clean_fields(self):
"""
Overriding the default cleaning behaviour to exit early on errors
instead of validating | python | {
"resource": ""
} |
q245182 | rfclink | train | def rfclink(name, rawtext, text, lineno, inliner, options={}, content=[]):
"""Link to the OAuth2 draft.
Returns 2 part tuple containing list of nodes to insert into the
document and a list of system messages. Both are allowed to be
empty.
:param name: The role name used in the document.
:para... | python | {
"resource": ""
} |
q245183 | ScopeChoiceField.validate | train | def validate(self, value):
"""
Validates that the input is a list or tuple.
"""
if self.required and not value:
raise OAuthValidationError({'error': 'invalid_request'})
# Validate that each value in the value list is in self.choices.
for val in value:
... | python | {
"resource": ""
} |
q245184 | ScopeMixin.clean_scope | train | def clean_scope(self):
"""
The scope is assembled by combining all the set flags into a single
integer value which we can later check again for set bits.
If *no* | python | {
"resource": ""
} |
q245185 | RefreshTokenGrantForm.clean | train | def clean(self):
"""
Make sure that the scope is less or equal to the previous scope!
"""
data = self.cleaned_data
want_scope = data.get('scope') or 0
refresh_token = data.get('refresh_token')
access_token = getattr(refresh_token, 'access_token', None) if \ | python | {
"resource": ""
} |
q245186 | AuthorizationCodeGrantForm.clean | train | def clean(self):
"""
Make sure that the scope is less or equal to the scope allowed on the
grant!
"""
data = self.cleaned_data
want_scope = data.get('scope') or 0
grant = data.get('grant')
has_scope = grant.scope if grant else 0
# Only check if we... | python | {
"resource": ""
} |
q245187 | short_token | train | def short_token():
"""
Generate a hash that can be used as an application identifier
| python | {
"resource": ""
} |
q245188 | deserialize_instance | train | def deserialize_instance(model, data={}):
"Translate raw data into a model instance."
ret = model()
for k, v in data.items():
if v is not None:
try:
f = model._meta.get_field(k)
if isinstance(f, DateTimeField):
v = dateparse.parse_datet... | python | {
"resource": ""
} |
q245189 | get_media_urls | train | def get_media_urls(tweet):
"""
Gets the https links to each media entity in the tweet.
Args:
tweet (Tweet or dict): tweet
Returns:
list: list of urls. Will be an empty list if there are no urls present.
Example:
>>> from tweet_parser.getter_methods.tweet_entities import ge... | python | {
"resource": ""
} |
q245190 | get_hashtags | train | def get_hashtags(tweet):
"""
Get a list of hashtags in the Tweet
Note that in the case of a quote-tweet, this does not return the
hashtags in the quoted status.
Args:
tweet (Tweet or dict): A Tweet object or dictionary
Returns:
list (a list of strings): list of all of the hasht... | python | {
"resource": ""
} |
q245191 | get_embedded_tweet | train | def get_embedded_tweet(tweet):
"""
Get the retweeted Tweet OR the quoted Tweet and return it as a dictionary
Args:
tweet (Tweet): A Tweet object (not simply a dict)
Returns:
dict (or None, if the Tweet is neither a quote tweet or a Retweet):
a dictionary representing the quote ... | python | {
"resource": ""
} |
q245192 | get_bio | train | def get_bio(tweet):
"""
Get the bio text of the user who posted the Tweet
Args:
tweet (Tweet): A Tweet object (or a dictionary)
Returns:
str: the bio text of the user who posted the Tweet
In a payload the abscence of a bio seems to be represented by an
empty string or a... | python | {
"resource": ""
} |
q245193 | is_original_format | train | def is_original_format(tweet):
"""
Simple checker to flag the format of a tweet.
Args:
tweet (Tweet): tweet in qustion
Returns:
Bool
Example:
>>> import tweet_parser.tweet_checking as tc
>>> tweet = {"created_at": 124125125125,
... "text": "just se... | python | {
"resource": ""
} |
q245194 | get_all_keys | train | def get_all_keys(tweet, parent_key=''):
"""
Takes a tweet object and recursively returns a list of all keys contained
in this level and all nexstted levels of the tweet.
Args:
tweet (Tweet): the tweet dict
parent_key (str): key from which this process will start, e.g., you can
... | python | {
"resource": ""
} |
q245195 | key_validation_check | train | def key_validation_check(tweet_keys_list, superset_keys, minset_keys):
"""
Validates the keys present in a Tweet.
Args:
tweet_keys_list (list): the keys present in a tweet
superset_keys (set): the set of all possible keys for a tweet
minset_keys (set): the set of minimal keys expect... | python | {
"resource": ""
} |
q245196 | check_tweet | train | def check_tweet(tweet, validation_checking=False):
"""
Ensures a tweet is valid and determines the type of format for the tweet.
Args:
tweet (dict/Tweet): the tweet payload
validation_checking (bool): check for valid key structure in a tweet.
"""
if "id" not in tweet:
raise... | python | {
"resource": ""
} |
q245197 | get_lang | train | def get_lang(tweet):
"""
Get the language that the Tweet is written in.
Args:
tweet (Tweet or dict): A Tweet object or dictionary
Returns:
str: 2-letter BCP 47 language code (or None if undefined)
Example:
>>> from tweet_parser.getter_methods.tweet_text import get_lang
... | python | {
"resource": ""
} |
q245198 | get_poll_options | train | def get_poll_options(tweet):
"""
Get the text in the options of a poll as a list
- If there is no poll in the Tweet, return an empty list
- If the Tweet is in activity-streams format, raise 'NotAvailableError'
Args:
tweet (Tweet or dict): A Tweet object or dictionary
Returns:
l... | python | {
"resource": ""
} |
q245199 | remove_links | train | def remove_links(text):
"""
Helper function to remove the links from the input text
Args:
text (str): A string
Returns:
str: the same text, but with any substring that matches the regex
for a link removed and replaced with a space
Example:
>>> from tweet_parser.get... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.