partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | MarathonClient.create_app | Create and start an app.
:param str app_id: application ID
:param :class:`marathon.models.app.MarathonApp` app: the application to create
:param bool minimal: ignore nulls and empty collections
:returns: the created app (on success)
:rtype: :class:`marathon.models.app.MarathonA... | marathon/client.py | def create_app(self, app_id, app, minimal=True):
"""Create and start an app.
:param str app_id: application ID
:param :class:`marathon.models.app.MarathonApp` app: the application to create
:param bool minimal: ignore nulls and empty collections
:returns: the created app (on su... | def create_app(self, app_id, app, minimal=True):
"""Create and start an app.
:param str app_id: application ID
:param :class:`marathon.models.app.MarathonApp` app: the application to create
:param bool minimal: ignore nulls and empty collections
:returns: the created app (on su... | [
"Create",
"and",
"start",
"an",
"app",
"."
] | thefactory/marathon-python | python | https://github.com/thefactory/marathon-python/blob/592b253aa8edf2475c97ca438ad7b6936652caf2/marathon/client.py#L160-L176 | [
"def",
"create_app",
"(",
"self",
",",
"app_id",
",",
"app",
",",
"minimal",
"=",
"True",
")",
":",
"app",
".",
"id",
"=",
"app_id",
"data",
"=",
"app",
".",
"to_json",
"(",
"minimal",
"=",
"minimal",
")",
"response",
"=",
"self",
".",
"_do_request",... | 592b253aa8edf2475c97ca438ad7b6936652caf2 |
train | MarathonClient.list_apps | List all apps.
:param str cmd: if passed, only show apps with a matching `cmd`
:param bool embed_tasks: embed tasks in result
:param bool embed_counts: embed all task counts
:param bool embed_deployments: embed all deployment identifier
:param bool embed_readiness: embed all rea... | marathon/client.py | def list_apps(self, cmd=None, embed_tasks=False, embed_counts=False,
embed_deployments=False, embed_readiness=False,
embed_last_task_failure=False, embed_failures=False,
embed_task_stats=False, app_id=None, label=None, **kwargs):
"""List all apps.
:... | def list_apps(self, cmd=None, embed_tasks=False, embed_counts=False,
embed_deployments=False, embed_readiness=False,
embed_last_task_failure=False, embed_failures=False,
embed_task_stats=False, app_id=None, label=None, **kwargs):
"""List all apps.
:... | [
"List",
"all",
"apps",
"."
] | thefactory/marathon-python | python | https://github.com/thefactory/marathon-python/blob/592b253aa8edf2475c97ca438ad7b6936652caf2/marathon/client.py#L178-L225 | [
"def",
"list_apps",
"(",
"self",
",",
"cmd",
"=",
"None",
",",
"embed_tasks",
"=",
"False",
",",
"embed_counts",
"=",
"False",
",",
"embed_deployments",
"=",
"False",
",",
"embed_readiness",
"=",
"False",
",",
"embed_last_task_failure",
"=",
"False",
",",
"e... | 592b253aa8edf2475c97ca438ad7b6936652caf2 |
train | MarathonClient.get_app | Get a single app.
:param str app_id: application ID
:param bool embed_tasks: embed tasks in result
:param bool embed_counts: embed all task counts
:param bool embed_deployments: embed all deployment identifier
:param bool embed_readiness: embed all readiness check results
... | marathon/client.py | def get_app(self, app_id, embed_tasks=False, embed_counts=False,
embed_deployments=False, embed_readiness=False,
embed_last_task_failure=False, embed_failures=False,
embed_task_stats=False):
"""Get a single app.
:param str app_id: application ID
:... | def get_app(self, app_id, embed_tasks=False, embed_counts=False,
embed_deployments=False, embed_readiness=False,
embed_last_task_failure=False, embed_failures=False,
embed_task_stats=False):
"""Get a single app.
:param str app_id: application ID
:... | [
"Get",
"a",
"single",
"app",
"."
] | thefactory/marathon-python | python | https://github.com/thefactory/marathon-python/blob/592b253aa8edf2475c97ca438ad7b6936652caf2/marathon/client.py#L227-L261 | [
"def",
"get_app",
"(",
"self",
",",
"app_id",
",",
"embed_tasks",
"=",
"False",
",",
"embed_counts",
"=",
"False",
",",
"embed_deployments",
"=",
"False",
",",
"embed_readiness",
"=",
"False",
",",
"embed_last_task_failure",
"=",
"False",
",",
"embed_failures",
... | 592b253aa8edf2475c97ca438ad7b6936652caf2 |
train | MarathonClient.update_app | Update an app.
Applies writable settings in `app` to `app_id`
Note: this method can not be used to rename apps.
:param str app_id: target application ID
:param app: application settings
:type app: :class:`marathon.models.app.MarathonApp`
:param bool force: apply even if... | marathon/client.py | def update_app(self, app_id, app, force=False, minimal=True):
"""Update an app.
Applies writable settings in `app` to `app_id`
Note: this method can not be used to rename apps.
:param str app_id: target application ID
:param app: application settings
:type app: :class:`... | def update_app(self, app_id, app, force=False, minimal=True):
"""Update an app.
Applies writable settings in `app` to `app_id`
Note: this method can not be used to rename apps.
:param str app_id: target application ID
:param app: application settings
:type app: :class:`... | [
"Update",
"an",
"app",
"."
] | thefactory/marathon-python | python | https://github.com/thefactory/marathon-python/blob/592b253aa8edf2475c97ca438ad7b6936652caf2/marathon/client.py#L276-L299 | [
"def",
"update_app",
"(",
"self",
",",
"app_id",
",",
"app",
",",
"force",
"=",
"False",
",",
"minimal",
"=",
"True",
")",
":",
"# Changes won't take if version is set - blank it for convenience",
"app",
".",
"version",
"=",
"None",
"params",
"=",
"{",
"'force'"... | 592b253aa8edf2475c97ca438ad7b6936652caf2 |
train | MarathonClient.update_apps | Update multiple apps.
Applies writable settings in elements of apps either by upgrading existing ones or creating new ones
:param apps: sequence of application settings
:param bool force: apply even if a deployment is in progress
:param bool minimal: ignore nulls and empty collections
... | marathon/client.py | def update_apps(self, apps, force=False, minimal=True):
"""Update multiple apps.
Applies writable settings in elements of apps either by upgrading existing ones or creating new ones
:param apps: sequence of application settings
:param bool force: apply even if a deployment is in progre... | def update_apps(self, apps, force=False, minimal=True):
"""Update multiple apps.
Applies writable settings in elements of apps either by upgrading existing ones or creating new ones
:param apps: sequence of application settings
:param bool force: apply even if a deployment is in progre... | [
"Update",
"multiple",
"apps",
"."
] | thefactory/marathon-python | python | https://github.com/thefactory/marathon-python/blob/592b253aa8edf2475c97ca438ad7b6936652caf2/marathon/client.py#L301-L325 | [
"def",
"update_apps",
"(",
"self",
",",
"apps",
",",
"force",
"=",
"False",
",",
"minimal",
"=",
"True",
")",
":",
"json_repr_apps",
"=",
"[",
"]",
"for",
"app",
"in",
"apps",
":",
"# Changes won't take if version is set - blank it for convenience",
"app",
".",
... | 592b253aa8edf2475c97ca438ad7b6936652caf2 |
train | MarathonClient.rollback_app | Roll an app back to a previous version.
:param str app_id: application ID
:param str version: application version
:param bool force: apply even if a deployment is in progress
:returns: a dict containing the deployment id and version
:rtype: dict | marathon/client.py | def rollback_app(self, app_id, version, force=False):
"""Roll an app back to a previous version.
:param str app_id: application ID
:param str version: application version
:param bool force: apply even if a deployment is in progress
:returns: a dict containing the deployment id ... | def rollback_app(self, app_id, version, force=False):
"""Roll an app back to a previous version.
:param str app_id: application ID
:param str version: application version
:param bool force: apply even if a deployment is in progress
:returns: a dict containing the deployment id ... | [
"Roll",
"an",
"app",
"back",
"to",
"a",
"previous",
"version",
"."
] | thefactory/marathon-python | python | https://github.com/thefactory/marathon-python/blob/592b253aa8edf2475c97ca438ad7b6936652caf2/marathon/client.py#L327-L341 | [
"def",
"rollback_app",
"(",
"self",
",",
"app_id",
",",
"version",
",",
"force",
"=",
"False",
")",
":",
"params",
"=",
"{",
"'force'",
":",
"force",
"}",
"data",
"=",
"json",
".",
"dumps",
"(",
"{",
"'version'",
":",
"version",
"}",
")",
"response",... | 592b253aa8edf2475c97ca438ad7b6936652caf2 |
train | MarathonClient.delete_app | Stop and destroy an app.
:param str app_id: application ID
:param bool force: apply even if a deployment is in progress
:returns: a dict containing the deployment id and version
:rtype: dict | marathon/client.py | def delete_app(self, app_id, force=False):
"""Stop and destroy an app.
:param str app_id: application ID
:param bool force: apply even if a deployment is in progress
:returns: a dict containing the deployment id and version
:rtype: dict
"""
params = {'force': fo... | def delete_app(self, app_id, force=False):
"""Stop and destroy an app.
:param str app_id: application ID
:param bool force: apply even if a deployment is in progress
:returns: a dict containing the deployment id and version
:rtype: dict
"""
params = {'force': fo... | [
"Stop",
"and",
"destroy",
"an",
"app",
"."
] | thefactory/marathon-python | python | https://github.com/thefactory/marathon-python/blob/592b253aa8edf2475c97ca438ad7b6936652caf2/marathon/client.py#L343-L355 | [
"def",
"delete_app",
"(",
"self",
",",
"app_id",
",",
"force",
"=",
"False",
")",
":",
"params",
"=",
"{",
"'force'",
":",
"force",
"}",
"response",
"=",
"self",
".",
"_do_request",
"(",
"'DELETE'",
",",
"'/v2/apps/{app_id}'",
".",
"format",
"(",
"app_id... | 592b253aa8edf2475c97ca438ad7b6936652caf2 |
train | MarathonClient.scale_app | Scale an app.
Scale an app to a target number of instances (with `instances`), or scale the number of
instances up or down by some delta (`delta`). If the resulting number of instances would be negative,
desired instances will be set to zero.
If both `instances` and `delta` are passed,... | marathon/client.py | def scale_app(self, app_id, instances=None, delta=None, force=False):
"""Scale an app.
Scale an app to a target number of instances (with `instances`), or scale the number of
instances up or down by some delta (`delta`). If the resulting number of instances would be negative,
desired in... | def scale_app(self, app_id, instances=None, delta=None, force=False):
"""Scale an app.
Scale an app to a target number of instances (with `instances`), or scale the number of
instances up or down by some delta (`delta`). If the resulting number of instances would be negative,
desired in... | [
"Scale",
"an",
"app",
"."
] | thefactory/marathon-python | python | https://github.com/thefactory/marathon-python/blob/592b253aa8edf2475c97ca438ad7b6936652caf2/marathon/client.py#L357-L386 | [
"def",
"scale_app",
"(",
"self",
",",
"app_id",
",",
"instances",
"=",
"None",
",",
"delta",
"=",
"None",
",",
"force",
"=",
"False",
")",
":",
"if",
"instances",
"is",
"None",
"and",
"delta",
"is",
"None",
":",
"marathon",
".",
"log",
".",
"error",
... | 592b253aa8edf2475c97ca438ad7b6936652caf2 |
train | MarathonClient.create_group | Create and start a group.
:param :class:`marathon.models.group.MarathonGroup` group: the group to create
:returns: success
:rtype: dict containing the version ID | marathon/client.py | def create_group(self, group):
"""Create and start a group.
:param :class:`marathon.models.group.MarathonGroup` group: the group to create
:returns: success
:rtype: dict containing the version ID
"""
data = group.to_json()
response = self._do_request('POST', '/v... | def create_group(self, group):
"""Create and start a group.
:param :class:`marathon.models.group.MarathonGroup` group: the group to create
:returns: success
:rtype: dict containing the version ID
"""
data = group.to_json()
response = self._do_request('POST', '/v... | [
"Create",
"and",
"start",
"a",
"group",
"."
] | thefactory/marathon-python | python | https://github.com/thefactory/marathon-python/blob/592b253aa8edf2475c97ca438ad7b6936652caf2/marathon/client.py#L388-L398 | [
"def",
"create_group",
"(",
"self",
",",
"group",
")",
":",
"data",
"=",
"group",
".",
"to_json",
"(",
")",
"response",
"=",
"self",
".",
"_do_request",
"(",
"'POST'",
",",
"'/v2/groups'",
",",
"data",
"=",
"data",
")",
"return",
"response",
".",
"json... | 592b253aa8edf2475c97ca438ad7b6936652caf2 |
train | MarathonClient.list_groups | List all groups.
:param kwargs: arbitrary search filters
:returns: list of groups
:rtype: list[:class:`marathon.models.group.MarathonGroup`] | marathon/client.py | def list_groups(self, **kwargs):
"""List all groups.
:param kwargs: arbitrary search filters
:returns: list of groups
:rtype: list[:class:`marathon.models.group.MarathonGroup`]
"""
response = self._do_request('GET', '/v2/groups')
groups = self._parse_response(
... | def list_groups(self, **kwargs):
"""List all groups.
:param kwargs: arbitrary search filters
:returns: list of groups
:rtype: list[:class:`marathon.models.group.MarathonGroup`]
"""
response = self._do_request('GET', '/v2/groups')
groups = self._parse_response(
... | [
"List",
"all",
"groups",
"."
] | thefactory/marathon-python | python | https://github.com/thefactory/marathon-python/blob/592b253aa8edf2475c97ca438ad7b6936652caf2/marathon/client.py#L400-L413 | [
"def",
"list_groups",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"response",
"=",
"self",
".",
"_do_request",
"(",
"'GET'",
",",
"'/v2/groups'",
")",
"groups",
"=",
"self",
".",
"_parse_response",
"(",
"response",
",",
"MarathonGroup",
",",
"is_list",... | 592b253aa8edf2475c97ca438ad7b6936652caf2 |
train | MarathonClient.get_group | Get a single group.
:param str group_id: group ID
:returns: group
:rtype: :class:`marathon.models.group.MarathonGroup` | marathon/client.py | def get_group(self, group_id):
"""Get a single group.
:param str group_id: group ID
:returns: group
:rtype: :class:`marathon.models.group.MarathonGroup`
"""
response = self._do_request(
'GET', '/v2/groups/{group_id}'.format(group_id=group_id))
return... | def get_group(self, group_id):
"""Get a single group.
:param str group_id: group ID
:returns: group
:rtype: :class:`marathon.models.group.MarathonGroup`
"""
response = self._do_request(
'GET', '/v2/groups/{group_id}'.format(group_id=group_id))
return... | [
"Get",
"a",
"single",
"group",
"."
] | thefactory/marathon-python | python | https://github.com/thefactory/marathon-python/blob/592b253aa8edf2475c97ca438ad7b6936652caf2/marathon/client.py#L415-L425 | [
"def",
"get_group",
"(",
"self",
",",
"group_id",
")",
":",
"response",
"=",
"self",
".",
"_do_request",
"(",
"'GET'",
",",
"'/v2/groups/{group_id}'",
".",
"format",
"(",
"group_id",
"=",
"group_id",
")",
")",
"return",
"self",
".",
"_parse_response",
"(",
... | 592b253aa8edf2475c97ca438ad7b6936652caf2 |
train | MarathonClient.update_group | Update a group.
Applies writable settings in `group` to `group_id`
Note: this method can not be used to rename groups.
:param str group_id: target group ID
:param group: group settings
:type group: :class:`marathon.models.group.MarathonGroup`
:param bool force: apply ev... | marathon/client.py | def update_group(self, group_id, group, force=False, minimal=True):
"""Update a group.
Applies writable settings in `group` to `group_id`
Note: this method can not be used to rename groups.
:param str group_id: target group ID
:param group: group settings
:type group: :... | def update_group(self, group_id, group, force=False, minimal=True):
"""Update a group.
Applies writable settings in `group` to `group_id`
Note: this method can not be used to rename groups.
:param str group_id: target group ID
:param group: group settings
:type group: :... | [
"Update",
"a",
"group",
"."
] | thefactory/marathon-python | python | https://github.com/thefactory/marathon-python/blob/592b253aa8edf2475c97ca438ad7b6936652caf2/marathon/client.py#L427-L450 | [
"def",
"update_group",
"(",
"self",
",",
"group_id",
",",
"group",
",",
"force",
"=",
"False",
",",
"minimal",
"=",
"True",
")",
":",
"# Changes won't take if version is set - blank it for convenience",
"group",
".",
"version",
"=",
"None",
"params",
"=",
"{",
"... | 592b253aa8edf2475c97ca438ad7b6936652caf2 |
train | MarathonClient.rollback_group | Roll a group back to a previous version.
:param str group_id: group ID
:param str version: group version
:param bool force: apply even if a deployment is in progress
:returns: a dict containing the deployment id and version
:rtype: dict | marathon/client.py | def rollback_group(self, group_id, version, force=False):
"""Roll a group back to a previous version.
:param str group_id: group ID
:param str version: group version
:param bool force: apply even if a deployment is in progress
:returns: a dict containing the deployment id and v... | def rollback_group(self, group_id, version, force=False):
"""Roll a group back to a previous version.
:param str group_id: group ID
:param str version: group version
:param bool force: apply even if a deployment is in progress
:returns: a dict containing the deployment id and v... | [
"Roll",
"a",
"group",
"back",
"to",
"a",
"previous",
"version",
"."
] | thefactory/marathon-python | python | https://github.com/thefactory/marathon-python/blob/592b253aa8edf2475c97ca438ad7b6936652caf2/marathon/client.py#L452-L468 | [
"def",
"rollback_group",
"(",
"self",
",",
"group_id",
",",
"version",
",",
"force",
"=",
"False",
")",
":",
"params",
"=",
"{",
"'force'",
":",
"force",
"}",
"response",
"=",
"self",
".",
"_do_request",
"(",
"'PUT'",
",",
"'/v2/groups/{group_id}/versions/{v... | 592b253aa8edf2475c97ca438ad7b6936652caf2 |
train | MarathonClient.delete_group | Stop and destroy a group.
:param str group_id: group ID
:param bool force: apply even if a deployment is in progress
:returns: a dict containing the deleted version
:rtype: dict | marathon/client.py | def delete_group(self, group_id, force=False):
"""Stop and destroy a group.
:param str group_id: group ID
:param bool force: apply even if a deployment is in progress
:returns: a dict containing the deleted version
:rtype: dict
"""
params = {'force': force}
... | def delete_group(self, group_id, force=False):
"""Stop and destroy a group.
:param str group_id: group ID
:param bool force: apply even if a deployment is in progress
:returns: a dict containing the deleted version
:rtype: dict
"""
params = {'force': force}
... | [
"Stop",
"and",
"destroy",
"a",
"group",
"."
] | thefactory/marathon-python | python | https://github.com/thefactory/marathon-python/blob/592b253aa8edf2475c97ca438ad7b6936652caf2/marathon/client.py#L470-L482 | [
"def",
"delete_group",
"(",
"self",
",",
"group_id",
",",
"force",
"=",
"False",
")",
":",
"params",
"=",
"{",
"'force'",
":",
"force",
"}",
"response",
"=",
"self",
".",
"_do_request",
"(",
"'DELETE'",
",",
"'/v2/groups/{group_id}'",
".",
"format",
"(",
... | 592b253aa8edf2475c97ca438ad7b6936652caf2 |
train | MarathonClient.scale_group | Scale a group by a factor.
:param str group_id: group ID
:param int scale_by: factor to scale by
:returns: a dict containing the deployment id and version
:rtype: dict | marathon/client.py | def scale_group(self, group_id, scale_by):
"""Scale a group by a factor.
:param str group_id: group ID
:param int scale_by: factor to scale by
:returns: a dict containing the deployment id and version
:rtype: dict
"""
data = {'scaleBy': scale_by}
respons... | def scale_group(self, group_id, scale_by):
"""Scale a group by a factor.
:param str group_id: group ID
:param int scale_by: factor to scale by
:returns: a dict containing the deployment id and version
:rtype: dict
"""
data = {'scaleBy': scale_by}
respons... | [
"Scale",
"a",
"group",
"by",
"a",
"factor",
"."
] | thefactory/marathon-python | python | https://github.com/thefactory/marathon-python/blob/592b253aa8edf2475c97ca438ad7b6936652caf2/marathon/client.py#L484-L496 | [
"def",
"scale_group",
"(",
"self",
",",
"group_id",
",",
"scale_by",
")",
":",
"data",
"=",
"{",
"'scaleBy'",
":",
"scale_by",
"}",
"response",
"=",
"self",
".",
"_do_request",
"(",
"'PUT'",
",",
"'/v2/groups/{group_id}'",
".",
"format",
"(",
"group_id",
"... | 592b253aa8edf2475c97ca438ad7b6936652caf2 |
train | MarathonClient.list_tasks | List running tasks, optionally filtered by app_id.
:param str app_id: if passed, only show tasks for this application
:param kwargs: arbitrary search filters
:returns: list of tasks
:rtype: list[:class:`marathon.models.task.MarathonTask`] | marathon/client.py | def list_tasks(self, app_id=None, **kwargs):
"""List running tasks, optionally filtered by app_id.
:param str app_id: if passed, only show tasks for this application
:param kwargs: arbitrary search filters
:returns: list of tasks
:rtype: list[:class:`marathon.models.task.Marath... | def list_tasks(self, app_id=None, **kwargs):
"""List running tasks, optionally filtered by app_id.
:param str app_id: if passed, only show tasks for this application
:param kwargs: arbitrary search filters
:returns: list of tasks
:rtype: list[:class:`marathon.models.task.Marath... | [
"List",
"running",
"tasks",
"optionally",
"filtered",
"by",
"app_id",
"."
] | thefactory/marathon-python | python | https://github.com/thefactory/marathon-python/blob/592b253aa8edf2475c97ca438ad7b6936652caf2/marathon/client.py#L498-L516 | [
"def",
"list_tasks",
"(",
"self",
",",
"app_id",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"response",
"=",
"self",
".",
"_do_request",
"(",
"'GET'",
",",
"'/v2/apps/%s/tasks'",
"%",
"app_id",
"if",
"app_id",
"else",
"'/v2/tasks'",
")",
"tasks",
"=... | 592b253aa8edf2475c97ca438ad7b6936652caf2 |
train | MarathonClient.kill_given_tasks | Kill a list of given tasks.
:param list[str] task_ids: tasks to kill
:param bool scale: if true, scale down the app by the number of tasks killed
:param bool force: if true, ignore any current running deployments
:return: True on success
:rtype: bool | marathon/client.py | def kill_given_tasks(self, task_ids, scale=False, force=None):
"""Kill a list of given tasks.
:param list[str] task_ids: tasks to kill
:param bool scale: if true, scale down the app by the number of tasks killed
:param bool force: if true, ignore any current running deployments
... | def kill_given_tasks(self, task_ids, scale=False, force=None):
"""Kill a list of given tasks.
:param list[str] task_ids: tasks to kill
:param bool scale: if true, scale down the app by the number of tasks killed
:param bool force: if true, ignore any current running deployments
... | [
"Kill",
"a",
"list",
"of",
"given",
"tasks",
"."
] | thefactory/marathon-python | python | https://github.com/thefactory/marathon-python/blob/592b253aa8edf2475c97ca438ad7b6936652caf2/marathon/client.py#L518-L534 | [
"def",
"kill_given_tasks",
"(",
"self",
",",
"task_ids",
",",
"scale",
"=",
"False",
",",
"force",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'scale'",
":",
"scale",
"}",
"if",
"force",
"is",
"not",
"None",
":",
"params",
"[",
"'force'",
"]",
"=",
... | 592b253aa8edf2475c97ca438ad7b6936652caf2 |
train | MarathonClient.kill_tasks | Kill all tasks belonging to app.
:param str app_id: application ID
:param bool scale: if true, scale down the app by the number of tasks killed
:param str host: if provided, only terminate tasks on this Mesos slave
:param int batch_size: if non-zero, terminate tasks in groups of this si... | marathon/client.py | def kill_tasks(self, app_id, scale=False, wipe=False,
host=None, batch_size=0, batch_delay=0):
"""Kill all tasks belonging to app.
:param str app_id: application ID
:param bool scale: if true, scale down the app by the number of tasks killed
:param str host: if provid... | def kill_tasks(self, app_id, scale=False, wipe=False,
host=None, batch_size=0, batch_delay=0):
"""Kill all tasks belonging to app.
:param str app_id: application ID
:param bool scale: if true, scale down the app by the number of tasks killed
:param str host: if provid... | [
"Kill",
"all",
"tasks",
"belonging",
"to",
"app",
"."
] | thefactory/marathon-python | python | https://github.com/thefactory/marathon-python/blob/592b253aa8edf2475c97ca438ad7b6936652caf2/marathon/client.py#L536-L597 | [
"def",
"kill_tasks",
"(",
"self",
",",
"app_id",
",",
"scale",
"=",
"False",
",",
"wipe",
"=",
"False",
",",
"host",
"=",
"None",
",",
"batch_size",
"=",
"0",
",",
"batch_delay",
"=",
"0",
")",
":",
"def",
"batch",
"(",
"iterable",
",",
"size",
")"... | 592b253aa8edf2475c97ca438ad7b6936652caf2 |
train | MarathonClient.kill_task | Kill a task.
:param str app_id: application ID
:param str task_id: the task to kill
:param bool scale: if true, scale down the app by one if the task exists
:returns: the killed task
:rtype: :class:`marathon.models.task.MarathonTask` | marathon/client.py | def kill_task(self, app_id, task_id, scale=False, wipe=False):
"""Kill a task.
:param str app_id: application ID
:param str task_id: the task to kill
:param bool scale: if true, scale down the app by one if the task exists
:returns: the killed task
:rtype: :class:`marat... | def kill_task(self, app_id, task_id, scale=False, wipe=False):
"""Kill a task.
:param str app_id: application ID
:param str task_id: the task to kill
:param bool scale: if true, scale down the app by one if the task exists
:returns: the killed task
:rtype: :class:`marat... | [
"Kill",
"a",
"task",
"."
] | thefactory/marathon-python | python | https://github.com/thefactory/marathon-python/blob/592b253aa8edf2475c97ca438ad7b6936652caf2/marathon/client.py#L599-L618 | [
"def",
"kill_task",
"(",
"self",
",",
"app_id",
",",
"task_id",
",",
"scale",
"=",
"False",
",",
"wipe",
"=",
"False",
")",
":",
"params",
"=",
"{",
"'scale'",
":",
"scale",
",",
"'wipe'",
":",
"wipe",
"}",
"response",
"=",
"self",
".",
"_do_request"... | 592b253aa8edf2475c97ca438ad7b6936652caf2 |
train | MarathonClient.list_versions | List the versions of an app.
:param str app_id: application ID
:returns: list of versions
:rtype: list[str] | marathon/client.py | def list_versions(self, app_id):
"""List the versions of an app.
:param str app_id: application ID
:returns: list of versions
:rtype: list[str]
"""
response = self._do_request(
'GET', '/v2/apps/{app_id}/versions'.format(app_id=app_id))
return [versio... | def list_versions(self, app_id):
"""List the versions of an app.
:param str app_id: application ID
:returns: list of versions
:rtype: list[str]
"""
response = self._do_request(
'GET', '/v2/apps/{app_id}/versions'.format(app_id=app_id))
return [versio... | [
"List",
"the",
"versions",
"of",
"an",
"app",
"."
] | thefactory/marathon-python | python | https://github.com/thefactory/marathon-python/blob/592b253aa8edf2475c97ca438ad7b6936652caf2/marathon/client.py#L620-L630 | [
"def",
"list_versions",
"(",
"self",
",",
"app_id",
")",
":",
"response",
"=",
"self",
".",
"_do_request",
"(",
"'GET'",
",",
"'/v2/apps/{app_id}/versions'",
".",
"format",
"(",
"app_id",
"=",
"app_id",
")",
")",
"return",
"[",
"version",
"for",
"version",
... | 592b253aa8edf2475c97ca438ad7b6936652caf2 |
train | MarathonClient.get_version | Get the configuration of an app at a specific version.
:param str app_id: application ID
:param str version: application version
:return: application configuration
:rtype: :class:`marathon.models.app.MarathonApp` | marathon/client.py | def get_version(self, app_id, version):
"""Get the configuration of an app at a specific version.
:param str app_id: application ID
:param str version: application version
:return: application configuration
:rtype: :class:`marathon.models.app.MarathonApp`
"""
re... | def get_version(self, app_id, version):
"""Get the configuration of an app at a specific version.
:param str app_id: application ID
:param str version: application version
:return: application configuration
:rtype: :class:`marathon.models.app.MarathonApp`
"""
re... | [
"Get",
"the",
"configuration",
"of",
"an",
"app",
"at",
"a",
"specific",
"version",
"."
] | thefactory/marathon-python | python | https://github.com/thefactory/marathon-python/blob/592b253aa8edf2475c97ca438ad7b6936652caf2/marathon/client.py#L632-L643 | [
"def",
"get_version",
"(",
"self",
",",
"app_id",
",",
"version",
")",
":",
"response",
"=",
"self",
".",
"_do_request",
"(",
"'GET'",
",",
"'/v2/apps/{app_id}/versions/{version}'",
".",
"format",
"(",
"app_id",
"=",
"app_id",
",",
"version",
"=",
"version",
... | 592b253aa8edf2475c97ca438ad7b6936652caf2 |
train | MarathonClient.create_event_subscription | Register a callback URL as an event subscriber.
:param str url: callback URL
:returns: the created event subscription
:rtype: dict | marathon/client.py | def create_event_subscription(self, url):
"""Register a callback URL as an event subscriber.
:param str url: callback URL
:returns: the created event subscription
:rtype: dict
"""
params = {'callbackUrl': url}
response = self._do_request('POST', '/v2/eventSubscr... | def create_event_subscription(self, url):
"""Register a callback URL as an event subscriber.
:param str url: callback URL
:returns: the created event subscription
:rtype: dict
"""
params = {'callbackUrl': url}
response = self._do_request('POST', '/v2/eventSubscr... | [
"Register",
"a",
"callback",
"URL",
"as",
"an",
"event",
"subscriber",
"."
] | thefactory/marathon-python | python | https://github.com/thefactory/marathon-python/blob/592b253aa8edf2475c97ca438ad7b6936652caf2/marathon/client.py#L654-L664 | [
"def",
"create_event_subscription",
"(",
"self",
",",
"url",
")",
":",
"params",
"=",
"{",
"'callbackUrl'",
":",
"url",
"}",
"response",
"=",
"self",
".",
"_do_request",
"(",
"'POST'",
",",
"'/v2/eventSubscriptions'",
",",
"params",
")",
"return",
"response",
... | 592b253aa8edf2475c97ca438ad7b6936652caf2 |
train | MarathonClient.delete_event_subscription | Deregister a callback URL as an event subscriber.
:param str url: callback URL
:returns: the deleted event subscription
:rtype: dict | marathon/client.py | def delete_event_subscription(self, url):
"""Deregister a callback URL as an event subscriber.
:param str url: callback URL
:returns: the deleted event subscription
:rtype: dict
"""
params = {'callbackUrl': url}
response = self._do_request('DELETE', '/v2/eventSu... | def delete_event_subscription(self, url):
"""Deregister a callback URL as an event subscriber.
:param str url: callback URL
:returns: the deleted event subscription
:rtype: dict
"""
params = {'callbackUrl': url}
response = self._do_request('DELETE', '/v2/eventSu... | [
"Deregister",
"a",
"callback",
"URL",
"as",
"an",
"event",
"subscriber",
"."
] | thefactory/marathon-python | python | https://github.com/thefactory/marathon-python/blob/592b253aa8edf2475c97ca438ad7b6936652caf2/marathon/client.py#L666-L676 | [
"def",
"delete_event_subscription",
"(",
"self",
",",
"url",
")",
":",
"params",
"=",
"{",
"'callbackUrl'",
":",
"url",
"}",
"response",
"=",
"self",
".",
"_do_request",
"(",
"'DELETE'",
",",
"'/v2/eventSubscriptions'",
",",
"params",
")",
"return",
"response"... | 592b253aa8edf2475c97ca438ad7b6936652caf2 |
train | MarathonClient.list_deployments | List all running deployments.
:returns: list of deployments
:rtype: list[:class:`marathon.models.deployment.MarathonDeployment`] | marathon/client.py | def list_deployments(self):
"""List all running deployments.
:returns: list of deployments
:rtype: list[:class:`marathon.models.deployment.MarathonDeployment`]
"""
response = self._do_request('GET', '/v2/deployments')
return self._parse_response(response, MarathonDeploym... | def list_deployments(self):
"""List all running deployments.
:returns: list of deployments
:rtype: list[:class:`marathon.models.deployment.MarathonDeployment`]
"""
response = self._do_request('GET', '/v2/deployments')
return self._parse_response(response, MarathonDeploym... | [
"List",
"all",
"running",
"deployments",
"."
] | thefactory/marathon-python | python | https://github.com/thefactory/marathon-python/blob/592b253aa8edf2475c97ca438ad7b6936652caf2/marathon/client.py#L678-L685 | [
"def",
"list_deployments",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"_do_request",
"(",
"'GET'",
",",
"'/v2/deployments'",
")",
"return",
"self",
".",
"_parse_response",
"(",
"response",
",",
"MarathonDeployment",
",",
"is_list",
"=",
"True",
")"
] | 592b253aa8edf2475c97ca438ad7b6936652caf2 |
train | MarathonClient.list_queue | List all the tasks queued up or waiting to be scheduled.
:returns: list of queue items
:rtype: list[:class:`marathon.models.queue.MarathonQueueItem`] | marathon/client.py | def list_queue(self, embed_last_unused_offers=False):
"""List all the tasks queued up or waiting to be scheduled.
:returns: list of queue items
:rtype: list[:class:`marathon.models.queue.MarathonQueueItem`]
"""
if embed_last_unused_offers:
params = {'embed': 'lastUnu... | def list_queue(self, embed_last_unused_offers=False):
"""List all the tasks queued up or waiting to be scheduled.
:returns: list of queue items
:rtype: list[:class:`marathon.models.queue.MarathonQueueItem`]
"""
if embed_last_unused_offers:
params = {'embed': 'lastUnu... | [
"List",
"all",
"the",
"tasks",
"queued",
"up",
"or",
"waiting",
"to",
"be",
"scheduled",
"."
] | thefactory/marathon-python | python | https://github.com/thefactory/marathon-python/blob/592b253aa8edf2475c97ca438ad7b6936652caf2/marathon/client.py#L687-L698 | [
"def",
"list_queue",
"(",
"self",
",",
"embed_last_unused_offers",
"=",
"False",
")",
":",
"if",
"embed_last_unused_offers",
":",
"params",
"=",
"{",
"'embed'",
":",
"'lastUnusedOffers'",
"}",
"else",
":",
"params",
"=",
"{",
"}",
"response",
"=",
"self",
".... | 592b253aa8edf2475c97ca438ad7b6936652caf2 |
train | MarathonClient.delete_deployment | Cancel a deployment.
:param str deployment_id: deployment id
:param bool force: if true, don't create a rollback deployment to restore the previous configuration
:returns: a dict containing the deployment id and version (empty dict if force=True)
:rtype: dict | marathon/client.py | def delete_deployment(self, deployment_id, force=False):
"""Cancel a deployment.
:param str deployment_id: deployment id
:param bool force: if true, don't create a rollback deployment to restore the previous configuration
:returns: a dict containing the deployment id and version (empty... | def delete_deployment(self, deployment_id, force=False):
"""Cancel a deployment.
:param str deployment_id: deployment id
:param bool force: if true, don't create a rollback deployment to restore the previous configuration
:returns: a dict containing the deployment id and version (empty... | [
"Cancel",
"a",
"deployment",
"."
] | thefactory/marathon-python | python | https://github.com/thefactory/marathon-python/blob/592b253aa8edf2475c97ca438ad7b6936652caf2/marathon/client.py#L700-L719 | [
"def",
"delete_deployment",
"(",
"self",
",",
"deployment_id",
",",
"force",
"=",
"False",
")",
":",
"if",
"force",
":",
"params",
"=",
"{",
"'force'",
":",
"True",
"}",
"self",
".",
"_do_request",
"(",
"'DELETE'",
",",
"'/v2/deployments/{deployment}'",
".",... | 592b253aa8edf2475c97ca438ad7b6936652caf2 |
train | MarathonClient.event_stream | Polls event bus using /v2/events
:param bool raw: if true, yield raw event text, else yield MarathonEvent object
:param event_types: a list of event types to consume
:type event_types: list[type] or list[str]
:returns: iterator with events
:rtype: iterator | marathon/client.py | def event_stream(self, raw=False, event_types=None):
"""Polls event bus using /v2/events
:param bool raw: if true, yield raw event text, else yield MarathonEvent object
:param event_types: a list of event types to consume
:type event_types: list[type] or list[str]
:returns: iter... | def event_stream(self, raw=False, event_types=None):
"""Polls event bus using /v2/events
:param bool raw: if true, yield raw event text, else yield MarathonEvent object
:param event_types: a list of event types to consume
:type event_types: list[type] or list[str]
:returns: iter... | [
"Polls",
"event",
"bus",
"using",
"/",
"v2",
"/",
"events"
] | thefactory/marathon-python | python | https://github.com/thefactory/marathon-python/blob/592b253aa8edf2475c97ca438ad7b6936652caf2/marathon/client.py#L771-L804 | [
"def",
"event_stream",
"(",
"self",
",",
"raw",
"=",
"False",
",",
"event_types",
"=",
"None",
")",
":",
"ef",
"=",
"EventFactory",
"(",
")",
"params",
"=",
"{",
"'event_type'",
":",
"[",
"EventFactory",
".",
"class_to_event",
"[",
"et",
"]",
"if",
"is... | 592b253aa8edf2475c97ca438ad7b6936652caf2 |
train | assert_valid_path | Checks if a path is a correct format that Marathon expects. Raises ValueError if not valid.
:param str path: The app id.
:rtype: str | marathon/models/base.py | def assert_valid_path(path):
"""Checks if a path is a correct format that Marathon expects. Raises ValueError if not valid.
:param str path: The app id.
:rtype: str
"""
if path is None:
return
# As seen in:
# https://github.com/mesosphere/marathon/blob/0c11661ca2f259f8a903d114ef790... | def assert_valid_path(path):
"""Checks if a path is a correct format that Marathon expects. Raises ValueError if not valid.
:param str path: The app id.
:rtype: str
"""
if path is None:
return
# As seen in:
# https://github.com/mesosphere/marathon/blob/0c11661ca2f259f8a903d114ef790... | [
"Checks",
"if",
"a",
"path",
"is",
"a",
"correct",
"format",
"that",
"Marathon",
"expects",
".",
"Raises",
"ValueError",
"if",
"not",
"valid",
"."
] | thefactory/marathon-python | python | https://github.com/thefactory/marathon-python/blob/592b253aa8edf2475c97ca438ad7b6936652caf2/marathon/models/base.py#L90-L105 | [
"def",
"assert_valid_path",
"(",
"path",
")",
":",
"if",
"path",
"is",
"None",
":",
"return",
"# As seen in:",
"# https://github.com/mesosphere/marathon/blob/0c11661ca2f259f8a903d114ef79023649a6f04b/src/main/scala/mesosphere/marathon/state/PathId.scala#L71",
"for",
"id",
"in",
"fil... | 592b253aa8edf2475c97ca438ad7b6936652caf2 |
train | assert_valid_id | Checks if an id is the correct format that Marathon expects. Raises ValueError if not valid.
:param str id: App or group id.
:rtype: str | marathon/models/base.py | def assert_valid_id(id):
"""Checks if an id is the correct format that Marathon expects. Raises ValueError if not valid.
:param str id: App or group id.
:rtype: str
"""
if id is None:
return
if not ID_PATTERN.match(id.strip('/')):
raise ValueError(
'invalid id (allo... | def assert_valid_id(id):
"""Checks if an id is the correct format that Marathon expects. Raises ValueError if not valid.
:param str id: App or group id.
:rtype: str
"""
if id is None:
return
if not ID_PATTERN.match(id.strip('/')):
raise ValueError(
'invalid id (allo... | [
"Checks",
"if",
"an",
"id",
"is",
"the",
"correct",
"format",
"that",
"Marathon",
"expects",
".",
"Raises",
"ValueError",
"if",
"not",
"valid",
"."
] | thefactory/marathon-python | python | https://github.com/thefactory/marathon-python/blob/592b253aa8edf2475c97ca438ad7b6936652caf2/marathon/models/base.py#L108-L120 | [
"def",
"assert_valid_id",
"(",
"id",
")",
":",
"if",
"id",
"is",
"None",
":",
"return",
"if",
"not",
"ID_PATTERN",
".",
"match",
"(",
"id",
".",
"strip",
"(",
"'/'",
")",
")",
":",
"raise",
"ValueError",
"(",
"'invalid id (allowed: lowercase letters, digits,... | 592b253aa8edf2475c97ca438ad7b6936652caf2 |
train | MarathonObject.json_repr | Construct a JSON-friendly representation of the object.
:param bool minimal: Construct a minimal representation of the object (ignore nulls and empty collections)
:rtype: dict | marathon/models/base.py | def json_repr(self, minimal=False):
"""Construct a JSON-friendly representation of the object.
:param bool minimal: Construct a minimal representation of the object (ignore nulls and empty collections)
:rtype: dict
"""
if minimal:
return {to_camel_case(k): v for k, ... | def json_repr(self, minimal=False):
"""Construct a JSON-friendly representation of the object.
:param bool minimal: Construct a minimal representation of the object (ignore nulls and empty collections)
:rtype: dict
"""
if minimal:
return {to_camel_case(k): v for k, ... | [
"Construct",
"a",
"JSON",
"-",
"friendly",
"representation",
"of",
"the",
"object",
"."
] | thefactory/marathon-python | python | https://github.com/thefactory/marathon-python/blob/592b253aa8edf2475c97ca438ad7b6936652caf2/marathon/models/base.py#L25-L35 | [
"def",
"json_repr",
"(",
"self",
",",
"minimal",
"=",
"False",
")",
":",
"if",
"minimal",
":",
"return",
"{",
"to_camel_case",
"(",
"k",
")",
":",
"v",
"for",
"k",
",",
"v",
"in",
"vars",
"(",
"self",
")",
".",
"items",
"(",
")",
"if",
"(",
"v"... | 592b253aa8edf2475c97ca438ad7b6936652caf2 |
train | MarathonObject.from_json | Construct an object from a parsed response.
:param dict attributes: object attributes from parsed response | marathon/models/base.py | def from_json(cls, attributes):
"""Construct an object from a parsed response.
:param dict attributes: object attributes from parsed response
"""
return cls(**{to_snake_case(k): v for k, v in attributes.items()}) | def from_json(cls, attributes):
"""Construct an object from a parsed response.
:param dict attributes: object attributes from parsed response
"""
return cls(**{to_snake_case(k): v for k, v in attributes.items()}) | [
"Construct",
"an",
"object",
"from",
"a",
"parsed",
"response",
"."
] | thefactory/marathon-python | python | https://github.com/thefactory/marathon-python/blob/592b253aa8edf2475c97ca438ad7b6936652caf2/marathon/models/base.py#L38-L43 | [
"def",
"from_json",
"(",
"cls",
",",
"attributes",
")",
":",
"return",
"cls",
"(",
"*",
"*",
"{",
"to_snake_case",
"(",
"k",
")",
":",
"v",
"for",
"k",
",",
"v",
"in",
"attributes",
".",
"items",
"(",
")",
"}",
")"
] | 592b253aa8edf2475c97ca438ad7b6936652caf2 |
train | MarathonObject.to_json | Encode an object as a JSON string.
:param bool minimal: Construct a minimal representation of the object (ignore nulls and empty collections)
:rtype: str | marathon/models/base.py | def to_json(self, minimal=True):
"""Encode an object as a JSON string.
:param bool minimal: Construct a minimal representation of the object (ignore nulls and empty collections)
:rtype: str
"""
if minimal:
return json.dumps(self.json_repr(minimal=True), cls=Marathon... | def to_json(self, minimal=True):
"""Encode an object as a JSON string.
:param bool minimal: Construct a minimal representation of the object (ignore nulls and empty collections)
:rtype: str
"""
if minimal:
return json.dumps(self.json_repr(minimal=True), cls=Marathon... | [
"Encode",
"an",
"object",
"as",
"a",
"JSON",
"string",
"."
] | thefactory/marathon-python | python | https://github.com/thefactory/marathon-python/blob/592b253aa8edf2475c97ca438ad7b6936652caf2/marathon/models/base.py#L45-L55 | [
"def",
"to_json",
"(",
"self",
",",
"minimal",
"=",
"True",
")",
":",
"if",
"minimal",
":",
"return",
"json",
".",
"dumps",
"(",
"self",
".",
"json_repr",
"(",
"minimal",
"=",
"True",
")",
",",
"cls",
"=",
"MarathonMinimalJsonEncoder",
",",
"sort_keys",
... | 592b253aa8edf2475c97ca438ad7b6936652caf2 |
train | MarathonConstraint.json_repr | Construct a JSON-friendly representation of the object.
:param bool minimal: [ignored]
:rtype: list | marathon/models/constraint.py | def json_repr(self, minimal=False):
"""Construct a JSON-friendly representation of the object.
:param bool minimal: [ignored]
:rtype: list
"""
if self.value:
return [self.field, self.operator, self.value]
else:
return [self.field, self.operator] | def json_repr(self, minimal=False):
"""Construct a JSON-friendly representation of the object.
:param bool minimal: [ignored]
:rtype: list
"""
if self.value:
return [self.field, self.operator, self.value]
else:
return [self.field, self.operator] | [
"Construct",
"a",
"JSON",
"-",
"friendly",
"representation",
"of",
"the",
"object",
"."
] | thefactory/marathon-python | python | https://github.com/thefactory/marathon-python/blob/592b253aa8edf2475c97ca438ad7b6936652caf2/marathon/models/constraint.py#L32-L42 | [
"def",
"json_repr",
"(",
"self",
",",
"minimal",
"=",
"False",
")",
":",
"if",
"self",
".",
"value",
":",
"return",
"[",
"self",
".",
"field",
",",
"self",
".",
"operator",
",",
"self",
".",
"value",
"]",
"else",
":",
"return",
"[",
"self",
".",
... | 592b253aa8edf2475c97ca438ad7b6936652caf2 |
train | MarathonConstraint.from_json | Construct a MarathonConstraint from a parsed response.
:param dict attributes: object attributes from parsed response
:rtype: :class:`MarathonConstraint` | marathon/models/constraint.py | def from_json(cls, obj):
"""Construct a MarathonConstraint from a parsed response.
:param dict attributes: object attributes from parsed response
:rtype: :class:`MarathonConstraint`
"""
if len(obj) == 2:
(field, operator) = obj
return cls(field, operator... | def from_json(cls, obj):
"""Construct a MarathonConstraint from a parsed response.
:param dict attributes: object attributes from parsed response
:rtype: :class:`MarathonConstraint`
"""
if len(obj) == 2:
(field, operator) = obj
return cls(field, operator... | [
"Construct",
"a",
"MarathonConstraint",
"from",
"a",
"parsed",
"response",
"."
] | thefactory/marathon-python | python | https://github.com/thefactory/marathon-python/blob/592b253aa8edf2475c97ca438ad7b6936652caf2/marathon/models/constraint.py#L45-L57 | [
"def",
"from_json",
"(",
"cls",
",",
"obj",
")",
":",
"if",
"len",
"(",
"obj",
")",
"==",
"2",
":",
"(",
"field",
",",
"operator",
")",
"=",
"obj",
"return",
"cls",
"(",
"field",
",",
"operator",
")",
"if",
"len",
"(",
"obj",
")",
">",
"2",
"... | 592b253aa8edf2475c97ca438ad7b6936652caf2 |
train | MarathonConstraint.from_string | :param str constraint: The string representation of a constraint
:rtype: :class:`MarathonConstraint` | marathon/models/constraint.py | def from_string(cls, constraint):
"""
:param str constraint: The string representation of a constraint
:rtype: :class:`MarathonConstraint`
"""
obj = constraint.split(':')
marathon_constraint = cls.from_json(obj)
if marathon_constraint:
return maratho... | def from_string(cls, constraint):
"""
:param str constraint: The string representation of a constraint
:rtype: :class:`MarathonConstraint`
"""
obj = constraint.split(':')
marathon_constraint = cls.from_json(obj)
if marathon_constraint:
return maratho... | [
":",
"param",
"str",
"constraint",
":",
"The",
"string",
"representation",
"of",
"a",
"constraint"
] | thefactory/marathon-python | python | https://github.com/thefactory/marathon-python/blob/592b253aa8edf2475c97ca438ad7b6936652caf2/marathon/models/constraint.py#L60-L73 | [
"def",
"from_string",
"(",
"cls",
",",
"constraint",
")",
":",
"obj",
"=",
"constraint",
".",
"split",
"(",
"':'",
")",
"marathon_constraint",
"=",
"cls",
".",
"from_json",
"(",
"obj",
")",
"if",
"marathon_constraint",
":",
"return",
"marathon_constraint",
"... | 592b253aa8edf2475c97ca438ad7b6936652caf2 |
train | MarathonEndpoint.from_tasks | Construct a list of MarathonEndpoints from a list of tasks.
:param list[:class:`marathon.models.MarathonTask`] tasks: list of tasks to parse
:rtype: list[:class:`MarathonEndpoint`] | marathon/models/endpoint.py | def from_tasks(cls, tasks):
"""Construct a list of MarathonEndpoints from a list of tasks.
:param list[:class:`marathon.models.MarathonTask`] tasks: list of tasks to parse
:rtype: list[:class:`MarathonEndpoint`]
"""
endpoints = [
[
MarathonEndpoint(... | def from_tasks(cls, tasks):
"""Construct a list of MarathonEndpoints from a list of tasks.
:param list[:class:`marathon.models.MarathonTask`] tasks: list of tasks to parse
:rtype: list[:class:`MarathonEndpoint`]
"""
endpoints = [
[
MarathonEndpoint(... | [
"Construct",
"a",
"list",
"of",
"MarathonEndpoints",
"from",
"a",
"list",
"of",
"tasks",
"."
] | thefactory/marathon-python | python | https://github.com/thefactory/marathon-python/blob/592b253aa8edf2475c97ca438ad7b6936652caf2/marathon/models/endpoint.py#L33-L50 | [
"def",
"from_tasks",
"(",
"cls",
",",
"tasks",
")",
":",
"endpoints",
"=",
"[",
"[",
"MarathonEndpoint",
"(",
"task",
".",
"app_id",
",",
"task",
".",
"service_ports",
"[",
"port_index",
"]",
",",
"task",
".",
"host",
",",
"task",
".",
"id",
",",
"po... | 592b253aa8edf2475c97ca438ad7b6936652caf2 |
train | _format_newlines | Convert newlines into U+23EC characters, followed by an actual newline and
then a tree prefix so as to position the remaining text under the previous
line. | tree_format/_text.py | def _format_newlines(prefix, formatted_node, options):
"""
Convert newlines into U+23EC characters, followed by an actual newline and
then a tree prefix so as to position the remaining text under the previous
line.
"""
replacement = u''.join([
options.NEWLINE,
u'\n',
pref... | def _format_newlines(prefix, formatted_node, options):
"""
Convert newlines into U+23EC characters, followed by an actual newline and
then a tree prefix so as to position the remaining text under the previous
line.
"""
replacement = u''.join([
options.NEWLINE,
u'\n',
pref... | [
"Convert",
"newlines",
"into",
"U",
"+",
"23EC",
"characters",
"followed",
"by",
"an",
"actual",
"newline",
"and",
"then",
"a",
"tree",
"prefix",
"so",
"as",
"to",
"position",
"the",
"remaining",
"text",
"under",
"the",
"previous",
"line",
"."
] | jml/tree-format | python | https://github.com/jml/tree-format/blob/cb17aba273ff043505ab9fd2afc08ce18a44cf44/tree_format/_text.py#L45-L55 | [
"def",
"_format_newlines",
"(",
"prefix",
",",
"formatted_node",
",",
"options",
")",
":",
"replacement",
"=",
"u''",
".",
"join",
"(",
"[",
"options",
".",
"NEWLINE",
",",
"u'\\n'",
",",
"prefix",
"]",
")",
"return",
"formatted_node",
".",
"replace",
"(",... | cb17aba273ff043505ab9fd2afc08ce18a44cf44 |
train | Client.get_band | Gets a band.
Gets a band with specified tag. If no tag is specified, the request will fail.
If the tag is invalid, a brawlstars.InvalidTag will be raised.
If the data is missing, a ValueError will be raised.
If the connection times out, a brawlstars.Timeout will be raised.
If th... | brawlstars/client.py | def get_band(self, tag):
"""Gets a band.
Gets a band with specified tag. If no tag is specified, the request will fail.
If the tag is invalid, a brawlstars.InvalidTag will be raised.
If the data is missing, a ValueError will be raised.
If the connection times out, a brawlstars.T... | def get_band(self, tag):
"""Gets a band.
Gets a band with specified tag. If no tag is specified, the request will fail.
If the tag is invalid, a brawlstars.InvalidTag will be raised.
If the data is missing, a ValueError will be raised.
If the connection times out, a brawlstars.T... | [
"Gets",
"a",
"band",
"."
] | umbresp/brawlstars | python | https://github.com/umbresp/brawlstars/blob/dc8c91b68dc01983c6af3ab68df266a657ec3f7c/brawlstars/client.py#L78-L108 | [
"def",
"get_band",
"(",
"self",
",",
"tag",
")",
":",
"tag",
"=",
"tag",
".",
"strip",
"(",
"\"#\"",
")",
"tag",
"=",
"tag",
".",
"upper",
"(",
")",
"try",
":",
"resp",
"=",
"requests",
".",
"get",
"(",
"self",
".",
"_base_url",
"+",
"'bands/'",
... | dc8c91b68dc01983c6af3ab68df266a657ec3f7c |
train | AsyncClient.get_player | Gets a player.
Gets a player with specified tag. If no tag is specified, the request will fail.
If the tag is invalid, a brawlstars.InvalidTag will be raised.
If the data is missing, a ValueError will be raised.
If the connection times out, a brawlstars.Timeout will be raised.
I... | brawlstars/asyncclient.py | async def get_player(self, tag):
"""Gets a player.
Gets a player with specified tag. If no tag is specified, the request will fail.
If the tag is invalid, a brawlstars.InvalidTag will be raised.
If the data is missing, a ValueError will be raised.
If the connection times out, a ... | async def get_player(self, tag):
"""Gets a player.
Gets a player with specified tag. If no tag is specified, the request will fail.
If the tag is invalid, a brawlstars.InvalidTag will be raised.
If the data is missing, a ValueError will be raised.
If the connection times out, a ... | [
"Gets",
"a",
"player",
"."
] | umbresp/brawlstars | python | https://github.com/umbresp/brawlstars/blob/dc8c91b68dc01983c6af3ab68df266a657ec3f7c/brawlstars/asyncclient.py#L48-L81 | [
"async",
"def",
"get_player",
"(",
"self",
",",
"tag",
")",
":",
"tag",
"=",
"tag",
".",
"strip",
"(",
"\"#\"",
")",
"tag",
"=",
"tag",
".",
"upper",
"(",
")",
"try",
":",
"async",
"with",
"self",
".",
"session",
".",
"get",
"(",
"self",
".",
"... | dc8c91b68dc01983c6af3ab68df266a657ec3f7c |
train | AsyncClient.get_band | Gets a band.
Gets a band with specified tag. If no tag is specified, the request will fail.
If the tag is invalid, a brawlstars.InvalidTag will be raised.
If the data is missing, a ValueError will be raised.
If the connection times out, a brawlstars.Timeout will be raised.
If th... | brawlstars/asyncclient.py | async def get_band(self, tag):
"""Gets a band.
Gets a band with specified tag. If no tag is specified, the request will fail.
If the tag is invalid, a brawlstars.InvalidTag will be raised.
If the data is missing, a ValueError will be raised.
If the connection times out, a brawls... | async def get_band(self, tag):
"""Gets a band.
Gets a band with specified tag. If no tag is specified, the request will fail.
If the tag is invalid, a brawlstars.InvalidTag will be raised.
If the data is missing, a ValueError will be raised.
If the connection times out, a brawls... | [
"Gets",
"a",
"band",
"."
] | umbresp/brawlstars | python | https://github.com/umbresp/brawlstars/blob/dc8c91b68dc01983c6af3ab68df266a657ec3f7c/brawlstars/asyncclient.py#L83-L116 | [
"async",
"def",
"get_band",
"(",
"self",
",",
"tag",
")",
":",
"tag",
"=",
"tag",
".",
"strip",
"(",
"\"#\"",
")",
"tag",
"=",
"tag",
".",
"upper",
"(",
")",
"try",
":",
"async",
"with",
"self",
".",
"session",
".",
"get",
"(",
"self",
".",
"_b... | dc8c91b68dc01983c6af3ab68df266a657ec3f7c |
train | lazy_module | Function allowing lazy importing of a module into the namespace.
A lazy module object is created, registered in `sys.modules`, and
returned. This is a hollow module; actual loading, and `ImportErrors` if
not found, are delayed until an attempt is made to access attributes of the
lazy module.
A han... | lazy_import/__init__.py | def lazy_module(modname, error_strings=None, lazy_mod_class=LazyModule,
level='leaf'):
"""Function allowing lazy importing of a module into the namespace.
A lazy module object is created, registered in `sys.modules`, and
returned. This is a hollow module; actual loading, and `ImportErrors... | def lazy_module(modname, error_strings=None, lazy_mod_class=LazyModule,
level='leaf'):
"""Function allowing lazy importing of a module into the namespace.
A lazy module object is created, registered in `sys.modules`, and
returned. This is a hollow module; actual loading, and `ImportErrors... | [
"Function",
"allowing",
"lazy",
"importing",
"of",
"a",
"module",
"into",
"the",
"namespace",
"."
] | mnmelo/lazy_import | python | https://github.com/mnmelo/lazy_import/blob/29c74c83e90adff62d363220fee8cf7d6f0dd3c9/lazy_import/__init__.py#L233-L334 | [
"def",
"lazy_module",
"(",
"modname",
",",
"error_strings",
"=",
"None",
",",
"lazy_mod_class",
"=",
"LazyModule",
",",
"level",
"=",
"'leaf'",
")",
":",
"if",
"error_strings",
"is",
"None",
":",
"error_strings",
"=",
"{",
"}",
"_set_default_errornames",
"(",
... | 29c74c83e90adff62d363220fee8cf7d6f0dd3c9 |
train | lazy_callable | Performs lazy importing of one or more callables.
:func:`lazy_callable` creates functions that are thin wrappers that pass
any and all arguments straight to the target module's callables. These can
be functions or classes. The full loading of that module is only actually
triggered when the returned laz... | lazy_import/__init__.py | def lazy_callable(modname, *names, **kwargs):
"""Performs lazy importing of one or more callables.
:func:`lazy_callable` creates functions that are thin wrappers that pass
any and all arguments straight to the target module's callables. These can
be functions or classes. The full loading of that module... | def lazy_callable(modname, *names, **kwargs):
"""Performs lazy importing of one or more callables.
:func:`lazy_callable` creates functions that are thin wrappers that pass
any and all arguments straight to the target module's callables. These can
be functions or classes. The full loading of that module... | [
"Performs",
"lazy",
"importing",
"of",
"one",
"or",
"more",
"callables",
"."
] | mnmelo/lazy_import | python | https://github.com/mnmelo/lazy_import/blob/29c74c83e90adff62d363220fee8cf7d6f0dd3c9/lazy_import/__init__.py#L384-L483 | [
"def",
"lazy_callable",
"(",
"modname",
",",
"*",
"names",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"names",
":",
"modname",
",",
"_",
",",
"name",
"=",
"modname",
".",
"rpartition",
"(",
"\".\"",
")",
"lazy_mod_class",
"=",
"_setdef",
"(",
"k... | 29c74c83e90adff62d363220fee8cf7d6f0dd3c9 |
train | _load_module | Ensures that a module, and its parents, are properly loaded | lazy_import/__init__.py | def _load_module(module):
"""Ensures that a module, and its parents, are properly loaded
"""
modclass = type(module)
# We only take care of our own LazyModule instances
if not issubclass(modclass, LazyModule):
raise TypeError("Passed module is not a LazyModule instance.")
with _ImportLo... | def _load_module(module):
"""Ensures that a module, and its parents, are properly loaded
"""
modclass = type(module)
# We only take care of our own LazyModule instances
if not issubclass(modclass, LazyModule):
raise TypeError("Passed module is not a LazyModule instance.")
with _ImportLo... | [
"Ensures",
"that",
"a",
"module",
"and",
"its",
"parents",
"are",
"properly",
"loaded"
] | mnmelo/lazy_import | python | https://github.com/mnmelo/lazy_import/blob/29c74c83e90adff62d363220fee8cf7d6f0dd3c9/lazy_import/__init__.py#L504-L563 | [
"def",
"_load_module",
"(",
"module",
")",
":",
"modclass",
"=",
"type",
"(",
"module",
")",
"# We only take care of our own LazyModule instances",
"if",
"not",
"issubclass",
"(",
"modclass",
",",
"LazyModule",
")",
":",
"raise",
"TypeError",
"(",
"\"Passed module i... | 29c74c83e90adff62d363220fee8cf7d6f0dd3c9 |
train | _setdef | Like dict.setdefault but sets the default value also if None is present. | lazy_import/__init__.py | def _setdef(argdict, name, defaultvalue):
"""Like dict.setdefault but sets the default value also if None is present.
"""
if not name in argdict or argdict[name] is None:
argdict[name] = defaultvalue
return argdict[name] | def _setdef(argdict, name, defaultvalue):
"""Like dict.setdefault but sets the default value also if None is present.
"""
if not name in argdict or argdict[name] is None:
argdict[name] = defaultvalue
return argdict[name] | [
"Like",
"dict",
".",
"setdefault",
"but",
"sets",
"the",
"default",
"value",
"also",
"if",
"None",
"is",
"present",
"."
] | mnmelo/lazy_import | python | https://github.com/mnmelo/lazy_import/blob/29c74c83e90adff62d363220fee8cf7d6f0dd3c9/lazy_import/__init__.py#L584-L590 | [
"def",
"_setdef",
"(",
"argdict",
",",
"name",
",",
"defaultvalue",
")",
":",
"if",
"not",
"name",
"in",
"argdict",
"or",
"argdict",
"[",
"name",
"]",
"is",
"None",
":",
"argdict",
"[",
"name",
"]",
"=",
"defaultvalue",
"return",
"argdict",
"[",
"name"... | 29c74c83e90adff62d363220fee8cf7d6f0dd3c9 |
train | _clean_lazymodule | Removes all lazy behavior from a module's class, for loading.
Also removes all module attributes listed under the module's class deletion
dictionaries. Deletion dictionaries are class attributes with names
specified in `_DELETION_DICT`.
Parameters
----------
module: LazyModule
Returns
... | lazy_import/__init__.py | def _clean_lazymodule(module):
"""Removes all lazy behavior from a module's class, for loading.
Also removes all module attributes listed under the module's class deletion
dictionaries. Deletion dictionaries are class attributes with names
specified in `_DELETION_DICT`.
Parameters
----------
... | def _clean_lazymodule(module):
"""Removes all lazy behavior from a module's class, for loading.
Also removes all module attributes listed under the module's class deletion
dictionaries. Deletion dictionaries are class attributes with names
specified in `_DELETION_DICT`.
Parameters
----------
... | [
"Removes",
"all",
"lazy",
"behavior",
"from",
"a",
"module",
"s",
"class",
"for",
"loading",
"."
] | mnmelo/lazy_import | python | https://github.com/mnmelo/lazy_import/blob/29c74c83e90adff62d363220fee8cf7d6f0dd3c9/lazy_import/__init__.py#L619-L648 | [
"def",
"_clean_lazymodule",
"(",
"module",
")",
":",
"modclass",
"=",
"type",
"(",
"module",
")",
"_clean_lazy_submod_refs",
"(",
"module",
")",
"modclass",
".",
"__getattribute__",
"=",
"ModuleType",
".",
"__getattribute__",
"modclass",
".",
"__setattr__",
"=",
... | 29c74c83e90adff62d363220fee8cf7d6f0dd3c9 |
train | _reset_lazymodule | Resets a module's lazy state from cached data. | lazy_import/__init__.py | def _reset_lazymodule(module, cls_attrs):
"""Resets a module's lazy state from cached data.
"""
modclass = type(module)
del modclass.__getattribute__
del modclass.__setattr__
try:
del modclass._LOADING
except AttributeError:
pass
for cls_attr in _CLS_ATTRS:
try:
... | def _reset_lazymodule(module, cls_attrs):
"""Resets a module's lazy state from cached data.
"""
modclass = type(module)
del modclass.__getattribute__
del modclass.__setattr__
try:
del modclass._LOADING
except AttributeError:
pass
for cls_attr in _CLS_ATTRS:
try:
... | [
"Resets",
"a",
"module",
"s",
"lazy",
"state",
"from",
"cached",
"data",
"."
] | mnmelo/lazy_import | python | https://github.com/mnmelo/lazy_import/blob/29c74c83e90adff62d363220fee8cf7d6f0dd3c9/lazy_import/__init__.py#L666-L682 | [
"def",
"_reset_lazymodule",
"(",
"module",
",",
"cls_attrs",
")",
":",
"modclass",
"=",
"type",
"(",
"module",
")",
"del",
"modclass",
".",
"__getattribute__",
"del",
"modclass",
".",
"__setattr__",
"try",
":",
"del",
"modclass",
".",
"_LOADING",
"except",
"... | 29c74c83e90adff62d363220fee8cf7d6f0dd3c9 |
train | python_2_unicode_compatible | A decorator that defines __unicode__ and __str__ methods under Python 2.
Under Python 3 it does nothing.
To support Python 2 and 3 with a single code base, define a __str__ method
returning text and apply this decorator to the class. | mangopay/compat.py | def python_2_unicode_compatible(klass):
"""
A decorator that defines __unicode__ and __str__ methods under Python 2.
Under Python 3 it does nothing.
To support Python 2 and 3 with a single code base, define a __str__ method
returning text and apply this decorator to the class.
"""
if six.PY... | def python_2_unicode_compatible(klass):
"""
A decorator that defines __unicode__ and __str__ methods under Python 2.
Under Python 3 it does nothing.
To support Python 2 and 3 with a single code base, define a __str__ method
returning text and apply this decorator to the class.
"""
if six.PY... | [
"A",
"decorator",
"that",
"defines",
"__unicode__",
"and",
"__str__",
"methods",
"under",
"Python",
"2",
".",
"Under",
"Python",
"3",
"it",
"does",
"nothing",
"."
] | Mangopay/mangopay2-python-sdk | python | https://github.com/Mangopay/mangopay2-python-sdk/blob/9bbbc0f797581c9fdf7da5a70879bee6643024b7/mangopay/compat.py#L5-L16 | [
"def",
"python_2_unicode_compatible",
"(",
"klass",
")",
":",
"if",
"six",
".",
"PY2",
":",
"klass",
".",
"__unicode__",
"=",
"klass",
".",
"__str__",
"klass",
".",
"__str__",
"=",
"lambda",
"self",
":",
"self",
".",
"__unicode__",
"(",
")",
".",
"encode... | 9bbbc0f797581c9fdf7da5a70879bee6643024b7 |
train | timestamp_from_datetime | Compute timestamp from a datetime object that could be timezone aware
or unaware. | mangopay/utils.py | def timestamp_from_datetime(dt):
"""
Compute timestamp from a datetime object that could be timezone aware
or unaware.
"""
try:
utc_dt = dt.astimezone(pytz.utc)
except ValueError:
utc_dt = dt.replace(tzinfo=pytz.utc)
return timegm(utc_dt.timetuple()) | def timestamp_from_datetime(dt):
"""
Compute timestamp from a datetime object that could be timezone aware
or unaware.
"""
try:
utc_dt = dt.astimezone(pytz.utc)
except ValueError:
utc_dt = dt.replace(tzinfo=pytz.utc)
return timegm(utc_dt.timetuple()) | [
"Compute",
"timestamp",
"from",
"a",
"datetime",
"object",
"that",
"could",
"be",
"timezone",
"aware",
"or",
"unaware",
"."
] | Mangopay/mangopay2-python-sdk | python | https://github.com/Mangopay/mangopay2-python-sdk/blob/9bbbc0f797581c9fdf7da5a70879bee6643024b7/mangopay/utils.py#L549-L558 | [
"def",
"timestamp_from_datetime",
"(",
"dt",
")",
":",
"try",
":",
"utc_dt",
"=",
"dt",
".",
"astimezone",
"(",
"pytz",
".",
"utc",
")",
"except",
"ValueError",
":",
"utc_dt",
"=",
"dt",
".",
"replace",
"(",
"tzinfo",
"=",
"pytz",
".",
"utc",
")",
"r... | 9bbbc0f797581c9fdf7da5a70879bee6643024b7 |
train | force_bytes | Similar to smart_bytes, except that lazy instances are resolved to
strings, rather than kept as lazy objects.
If strings_only is True, don't convert (some) non-string-like objects. | mangopay/utils.py | def force_bytes(s, encoding='utf-8', strings_only=False, errors='strict'):
"""
Similar to smart_bytes, except that lazy instances are resolved to
strings, rather than kept as lazy objects.
If strings_only is True, don't convert (some) non-string-like objects.
"""
if isinstance(s, memoryview):
... | def force_bytes(s, encoding='utf-8', strings_only=False, errors='strict'):
"""
Similar to smart_bytes, except that lazy instances are resolved to
strings, rather than kept as lazy objects.
If strings_only is True, don't convert (some) non-string-like objects.
"""
if isinstance(s, memoryview):
... | [
"Similar",
"to",
"smart_bytes",
"except",
"that",
"lazy",
"instances",
"are",
"resolved",
"to",
"strings",
"rather",
"than",
"kept",
"as",
"lazy",
"objects",
"."
] | Mangopay/mangopay2-python-sdk | python | https://github.com/Mangopay/mangopay2-python-sdk/blob/9bbbc0f797581c9fdf7da5a70879bee6643024b7/mangopay/utils.py#L624-L655 | [
"def",
"force_bytes",
"(",
"s",
",",
"encoding",
"=",
"'utf-8'",
",",
"strings_only",
"=",
"False",
",",
"errors",
"=",
"'strict'",
")",
":",
"if",
"isinstance",
"(",
"s",
",",
"memoryview",
")",
":",
"s",
"=",
"bytes",
"(",
"s",
")",
"if",
"isinstan... | 9bbbc0f797581c9fdf7da5a70879bee6643024b7 |
train | memoize | Wrap a function so that results for any argument tuple are stored in
'cache'. Note that the args to the function must be usable as dictionary
keys.
Only the first num_args are considered when creating the key. | mangopay/utils.py | def memoize(func, cache, num_args):
"""
Wrap a function so that results for any argument tuple are stored in
'cache'. Note that the args to the function must be usable as dictionary
keys.
Only the first num_args are considered when creating the key.
"""
@wraps(func)
def wrapper(*args):
... | def memoize(func, cache, num_args):
"""
Wrap a function so that results for any argument tuple are stored in
'cache'. Note that the args to the function must be usable as dictionary
keys.
Only the first num_args are considered when creating the key.
"""
@wraps(func)
def wrapper(*args):
... | [
"Wrap",
"a",
"function",
"so",
"that",
"results",
"for",
"any",
"argument",
"tuple",
"are",
"stored",
"in",
"cache",
".",
"Note",
"that",
"the",
"args",
"to",
"the",
"function",
"must",
"be",
"usable",
"as",
"dictionary",
"keys",
".",
"Only",
"the",
"fir... | Mangopay/mangopay2-python-sdk | python | https://github.com/Mangopay/mangopay2-python-sdk/blob/9bbbc0f797581c9fdf7da5a70879bee6643024b7/mangopay/utils.py#L664-L681 | [
"def",
"memoize",
"(",
"func",
",",
"cache",
",",
"num_args",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"*",
"args",
")",
":",
"mem_args",
"=",
"args",
"[",
":",
"num_args",
"]",
"if",
"mem_args",
"in",
"cache",
":",
"return"... | 9bbbc0f797581c9fdf7da5a70879bee6643024b7 |
train | reraise_as | Obtained from https://github.com/dcramer/reraise/blob/master/src/reraise.py
>>> try:
>>> do_something_crazy()
>>> except Exception:
>>> reraise_as(UnhandledException) | mangopay/utils.py | def reraise_as(new_exception_or_type):
"""
Obtained from https://github.com/dcramer/reraise/blob/master/src/reraise.py
>>> try:
>>> do_something_crazy()
>>> except Exception:
>>> reraise_as(UnhandledException)
"""
__traceback_hide__ = True # NOQA
e_type, e_value, e_tracebac... | def reraise_as(new_exception_or_type):
"""
Obtained from https://github.com/dcramer/reraise/blob/master/src/reraise.py
>>> try:
>>> do_something_crazy()
>>> except Exception:
>>> reraise_as(UnhandledException)
"""
__traceback_hide__ = True # NOQA
e_type, e_value, e_tracebac... | [
"Obtained",
"from",
"https",
":",
"//",
"github",
".",
"com",
"/",
"dcramer",
"/",
"reraise",
"/",
"blob",
"/",
"master",
"/",
"src",
"/",
"reraise",
".",
"py",
">>>",
"try",
":",
">>>",
"do_something_crazy",
"()",
">>>",
"except",
"Exception",
":",
">... | Mangopay/mangopay2-python-sdk | python | https://github.com/Mangopay/mangopay2-python-sdk/blob/9bbbc0f797581c9fdf7da5a70879bee6643024b7/mangopay/utils.py#L684-L708 | [
"def",
"reraise_as",
"(",
"new_exception_or_type",
")",
":",
"__traceback_hide__",
"=",
"True",
"# NOQA",
"e_type",
",",
"e_value",
",",
"e_traceback",
"=",
"sys",
".",
"exc_info",
"(",
")",
"if",
"inspect",
".",
"isclass",
"(",
"new_exception_or_type",
")",
"... | 9bbbc0f797581c9fdf7da5a70879bee6643024b7 |
train | hide_auth | Remove sensitive information from msg. | zabbix_api.py | def hide_auth(msg):
"""Remove sensitive information from msg."""
for pattern, repl in RE_HIDE_AUTH:
msg = pattern.sub(repl, msg)
return msg | def hide_auth(msg):
"""Remove sensitive information from msg."""
for pattern, repl in RE_HIDE_AUTH:
msg = pattern.sub(repl, msg)
return msg | [
"Remove",
"sensitive",
"information",
"from",
"msg",
"."
] | erigones/zabbix-api | python | https://github.com/erigones/zabbix-api/blob/2474ab1d1ddb46c26eea70671b3a599b836d42da/zabbix_api.py#L71-L76 | [
"def",
"hide_auth",
"(",
"msg",
")",
":",
"for",
"pattern",
",",
"repl",
"in",
"RE_HIDE_AUTH",
":",
"msg",
"=",
"pattern",
".",
"sub",
"(",
"repl",
",",
"msg",
")",
"return",
"msg"
] | 2474ab1d1ddb46c26eea70671b3a599b836d42da |
train | ZabbixAPI.init | Prepare the HTTP handler, URL, and HTTP headers for all subsequent requests | zabbix_api.py | def init(self):
"""Prepare the HTTP handler, URL, and HTTP headers for all subsequent requests"""
self.debug('Initializing %r', self)
proto = self.server.split('://')[0]
if proto == 'https':
if hasattr(ssl, 'create_default_context'):
context = ssl.create_defa... | def init(self):
"""Prepare the HTTP handler, URL, and HTTP headers for all subsequent requests"""
self.debug('Initializing %r', self)
proto = self.server.split('://')[0]
if proto == 'https':
if hasattr(ssl, 'create_default_context'):
context = ssl.create_defa... | [
"Prepare",
"the",
"HTTP",
"handler",
"URL",
"and",
"HTTP",
"headers",
"for",
"all",
"subsequent",
"requests"
] | erigones/zabbix-api | python | https://github.com/erigones/zabbix-api/blob/2474ab1d1ddb46c26eea70671b3a599b836d42da/zabbix_api.py#L168-L201 | [
"def",
"init",
"(",
"self",
")",
":",
"self",
".",
"debug",
"(",
"'Initializing %r'",
",",
"self",
")",
"proto",
"=",
"self",
".",
"server",
".",
"split",
"(",
"'://'",
")",
"[",
"0",
"]",
"if",
"proto",
"==",
"'https'",
":",
"if",
"hasattr",
"(",
... | 2474ab1d1ddb46c26eea70671b3a599b836d42da |
train | ZabbixAPI.timestamp_to_datetime | Convert unix timestamp to human readable date/time string | zabbix_api.py | def timestamp_to_datetime(cls, dt, dt_format=DATETIME_FORMAT):
"""Convert unix timestamp to human readable date/time string"""
return cls.convert_datetime(cls.get_datetime(dt), dt_format=dt_format) | def timestamp_to_datetime(cls, dt, dt_format=DATETIME_FORMAT):
"""Convert unix timestamp to human readable date/time string"""
return cls.convert_datetime(cls.get_datetime(dt), dt_format=dt_format) | [
"Convert",
"unix",
"timestamp",
"to",
"human",
"readable",
"date",
"/",
"time",
"string"
] | erigones/zabbix-api | python | https://github.com/erigones/zabbix-api/blob/2474ab1d1ddb46c26eea70671b3a599b836d42da/zabbix_api.py#L222-L224 | [
"def",
"timestamp_to_datetime",
"(",
"cls",
",",
"dt",
",",
"dt_format",
"=",
"DATETIME_FORMAT",
")",
":",
"return",
"cls",
".",
"convert_datetime",
"(",
"cls",
".",
"get_datetime",
"(",
"dt",
")",
",",
"dt_format",
"=",
"dt_format",
")"
] | 2474ab1d1ddb46c26eea70671b3a599b836d42da |
train | ZabbixAPI.get_age | Calculate delta between current time and datetime and return a human readable form of the delta object | zabbix_api.py | def get_age(dt):
"""Calculate delta between current time and datetime and return a human readable form of the delta object"""
delta = datetime.now() - dt
days = delta.days
hours, rem = divmod(delta.seconds, 3600)
minutes, seconds = divmod(rem, 60)
if days:
re... | def get_age(dt):
"""Calculate delta between current time and datetime and return a human readable form of the delta object"""
delta = datetime.now() - dt
days = delta.days
hours, rem = divmod(delta.seconds, 3600)
minutes, seconds = divmod(rem, 60)
if days:
re... | [
"Calculate",
"delta",
"between",
"current",
"time",
"and",
"datetime",
"and",
"return",
"a",
"human",
"readable",
"form",
"of",
"the",
"delta",
"object"
] | erigones/zabbix-api | python | https://github.com/erigones/zabbix-api/blob/2474ab1d1ddb46c26eea70671b3a599b836d42da/zabbix_api.py#L227-L237 | [
"def",
"get_age",
"(",
"dt",
")",
":",
"delta",
"=",
"datetime",
".",
"now",
"(",
")",
"-",
"dt",
"days",
"=",
"delta",
".",
"days",
"hours",
",",
"rem",
"=",
"divmod",
"(",
"delta",
".",
"seconds",
",",
"3600",
")",
"minutes",
",",
"seconds",
"=... | 2474ab1d1ddb46c26eea70671b3a599b836d42da |
train | ZabbixAPI.json_obj | Return JSON object expected by the Zabbix API | zabbix_api.py | def json_obj(self, method, params=None, auth=True):
"""Return JSON object expected by the Zabbix API"""
if params is None:
params = {}
obj = {
'jsonrpc': '2.0',
'method': method,
'params': params,
'auth': self.__auth if auth else None,... | def json_obj(self, method, params=None, auth=True):
"""Return JSON object expected by the Zabbix API"""
if params is None:
params = {}
obj = {
'jsonrpc': '2.0',
'method': method,
'params': params,
'auth': self.__auth if auth else None,... | [
"Return",
"JSON",
"object",
"expected",
"by",
"the",
"Zabbix",
"API"
] | erigones/zabbix-api | python | https://github.com/erigones/zabbix-api/blob/2474ab1d1ddb46c26eea70671b3a599b836d42da/zabbix_api.py#L253-L266 | [
"def",
"json_obj",
"(",
"self",
",",
"method",
",",
"params",
"=",
"None",
",",
"auth",
"=",
"True",
")",
":",
"if",
"params",
"is",
"None",
":",
"params",
"=",
"{",
"}",
"obj",
"=",
"{",
"'jsonrpc'",
":",
"'2.0'",
",",
"'method'",
":",
"method",
... | 2474ab1d1ddb46c26eea70671b3a599b836d42da |
train | ZabbixAPI.do_request | Perform one HTTP request to Zabbix API | zabbix_api.py | def do_request(self, json_obj):
"""Perform one HTTP request to Zabbix API"""
self.debug('Request: url="%s" headers=%s', self._api_url, self._http_headers)
self.debug('Request: body=%s', json_obj)
self.r_query.append(json_obj)
request = urllib2.Request(url=self._api_url, data=jso... | def do_request(self, json_obj):
"""Perform one HTTP request to Zabbix API"""
self.debug('Request: url="%s" headers=%s', self._api_url, self._http_headers)
self.debug('Request: body=%s', json_obj)
self.r_query.append(json_obj)
request = urllib2.Request(url=self._api_url, data=jso... | [
"Perform",
"one",
"HTTP",
"request",
"to",
"Zabbix",
"API"
] | erigones/zabbix-api | python | https://github.com/erigones/zabbix-api/blob/2474ab1d1ddb46c26eea70671b3a599b836d42da/zabbix_api.py#L268-L312 | [
"def",
"do_request",
"(",
"self",
",",
"json_obj",
")",
":",
"self",
".",
"debug",
"(",
"'Request: url=\"%s\" headers=%s'",
",",
"self",
".",
"_api_url",
",",
"self",
".",
"_http_headers",
")",
"self",
".",
"debug",
"(",
"'Request: body=%s'",
",",
"json_obj",
... | 2474ab1d1ddb46c26eea70671b3a599b836d42da |
train | ZabbixAPI.login | Perform a user.login API request | zabbix_api.py | def login(self, user=None, password=None, save=True):
"""Perform a user.login API request"""
if user and password:
if save:
self.__username = user
self.__password = password
elif self.__username and self.__password:
user = self.__username
... | def login(self, user=None, password=None, save=True):
"""Perform a user.login API request"""
if user and password:
if save:
self.__username = user
self.__password = password
elif self.__username and self.__password:
user = self.__username
... | [
"Perform",
"a",
"user",
".",
"login",
"API",
"request"
] | erigones/zabbix-api | python | https://github.com/erigones/zabbix-api/blob/2474ab1d1ddb46c26eea70671b3a599b836d42da/zabbix_api.py#L314-L331 | [
"def",
"login",
"(",
"self",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"save",
"=",
"True",
")",
":",
"if",
"user",
"and",
"password",
":",
"if",
"save",
":",
"self",
".",
"__username",
"=",
"user",
"self",
".",
"__password",
"="... | 2474ab1d1ddb46c26eea70671b3a599b836d42da |
train | ZabbixAPI.relogin | Perform a re-login | zabbix_api.py | def relogin(self):
"""Perform a re-login"""
try:
self.__auth = None # reset auth before relogin
self.login()
except ZabbixAPIException as e:
self.log(ERROR, 'Zabbix API relogin error (%s)', e)
self.__auth = None # logged_in() will always return F... | def relogin(self):
"""Perform a re-login"""
try:
self.__auth = None # reset auth before relogin
self.login()
except ZabbixAPIException as e:
self.log(ERROR, 'Zabbix API relogin error (%s)', e)
self.__auth = None # logged_in() will always return F... | [
"Perform",
"a",
"re",
"-",
"login"
] | erigones/zabbix-api | python | https://github.com/erigones/zabbix-api/blob/2474ab1d1ddb46c26eea70671b3a599b836d42da/zabbix_api.py#L333-L341 | [
"def",
"relogin",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"__auth",
"=",
"None",
"# reset auth before relogin",
"self",
".",
"login",
"(",
")",
"except",
"ZabbixAPIException",
"as",
"e",
":",
"self",
".",
"log",
"(",
"ERROR",
",",
"'Zabbix API relo... | 2474ab1d1ddb46c26eea70671b3a599b836d42da |
train | ZabbixAPI.check_auth | Perform a re-login if not signed in or raise an exception | zabbix_api.py | def check_auth(self):
"""Perform a re-login if not signed in or raise an exception"""
if not self.logged_in:
if self.relogin_interval and self.last_login and (time() - self.last_login) > self.relogin_interval:
self.log(WARNING, 'Zabbix API not logged in. Performing Zabbix API... | def check_auth(self):
"""Perform a re-login if not signed in or raise an exception"""
if not self.logged_in:
if self.relogin_interval and self.last_login and (time() - self.last_login) > self.relogin_interval:
self.log(WARNING, 'Zabbix API not logged in. Performing Zabbix API... | [
"Perform",
"a",
"re",
"-",
"login",
"if",
"not",
"signed",
"in",
"or",
"raise",
"an",
"exception"
] | erigones/zabbix-api | python | https://github.com/erigones/zabbix-api/blob/2474ab1d1ddb46c26eea70671b3a599b836d42da/zabbix_api.py#L347-L355 | [
"def",
"check_auth",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"logged_in",
":",
"if",
"self",
".",
"relogin_interval",
"and",
"self",
".",
"last_login",
"and",
"(",
"time",
"(",
")",
"-",
"self",
".",
"last_login",
")",
">",
"self",
".",
"rel... | 2474ab1d1ddb46c26eea70671b3a599b836d42da |
train | ZabbixAPI.call | Check authentication and perform actual API request and relogin if needed | zabbix_api.py | def call(self, method, params=None):
"""Check authentication and perform actual API request and relogin if needed"""
start_time = time()
self.check_auth()
self.log(INFO, '[%s-%05d] Calling Zabbix API method "%s"', start_time, self.id, method)
self.log(DEBUG, '\twith parameters: %... | def call(self, method, params=None):
"""Check authentication and perform actual API request and relogin if needed"""
start_time = time()
self.check_auth()
self.log(INFO, '[%s-%05d] Calling Zabbix API method "%s"', start_time, self.id, method)
self.log(DEBUG, '\twith parameters: %... | [
"Check",
"authentication",
"and",
"perform",
"actual",
"API",
"request",
"and",
"relogin",
"if",
"needed"
] | erigones/zabbix-api | python | https://github.com/erigones/zabbix-api/blob/2474ab1d1ddb46c26eea70671b3a599b836d42da/zabbix_api.py#L361-L378 | [
"def",
"call",
"(",
"self",
",",
"method",
",",
"params",
"=",
"None",
")",
":",
"start_time",
"=",
"time",
"(",
")",
"self",
".",
"check_auth",
"(",
")",
"self",
".",
"log",
"(",
"INFO",
",",
"'[%s-%05d] Calling Zabbix API method \"%s\"'",
",",
"start_tim... | 2474ab1d1ddb46c26eea70671b3a599b836d42da |
train | download_parallel | download function to download parallely | ctdl/gui_downloader.py | def download_parallel(url, directory, idx, min_file_size = 0, max_file_size = -1,
no_redirects = False, pos = 0, mode = 's'):
"""
download function to download parallely
"""
global main_it
global exit_flag
global total_chunks
global file_name
global i_max
file_name[idx]= url.split('/')[-1]
file_addres... | def download_parallel(url, directory, idx, min_file_size = 0, max_file_size = -1,
no_redirects = False, pos = 0, mode = 's'):
"""
download function to download parallely
"""
global main_it
global exit_flag
global total_chunks
global file_name
global i_max
file_name[idx]= url.split('/')[-1]
file_addres... | [
"download",
"function",
"to",
"download",
"parallely"
] | nikhilkumarsingh/content-downloader | python | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui_downloader.py#L75-L116 | [
"def",
"download_parallel",
"(",
"url",
",",
"directory",
",",
"idx",
",",
"min_file_size",
"=",
"0",
",",
"max_file_size",
"=",
"-",
"1",
",",
"no_redirects",
"=",
"False",
",",
"pos",
"=",
"0",
",",
"mode",
"=",
"'s'",
")",
":",
"global",
"main_it",
... | 8b14af3a6eadcc43581e0425dc1d218208de12df |
train | download_parallel_gui | called when paralled downloading is true | ctdl/gui_downloader.py | def download_parallel_gui(root, urls, directory, min_file_size, max_file_size, no_redirects):
"""
called when paralled downloading is true
"""
global parallel
# create directory to save files
if not os.path.exists(directory):
os.makedirs(directory)
parallel = True
app = progress_class(root, urls, directory, ... | def download_parallel_gui(root, urls, directory, min_file_size, max_file_size, no_redirects):
"""
called when paralled downloading is true
"""
global parallel
# create directory to save files
if not os.path.exists(directory):
os.makedirs(directory)
parallel = True
app = progress_class(root, urls, directory, ... | [
"called",
"when",
"paralled",
"downloading",
"is",
"true"
] | nikhilkumarsingh/content-downloader | python | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui_downloader.py#L239-L249 | [
"def",
"download_parallel_gui",
"(",
"root",
",",
"urls",
",",
"directory",
",",
"min_file_size",
",",
"max_file_size",
",",
"no_redirects",
")",
":",
"global",
"parallel",
"# create directory to save files",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"... | 8b14af3a6eadcc43581e0425dc1d218208de12df |
train | download_series_gui | called when user wants serial downloading | ctdl/gui_downloader.py | def download_series_gui(frame, urls, directory, min_file_size, max_file_size, no_redirects):
"""
called when user wants serial downloading
"""
# create directory to save files
if not os.path.exists(directory):
os.makedirs(directory)
app = progress_class(frame, urls, directory, min_file_size, max_file_size, no_... | def download_series_gui(frame, urls, directory, min_file_size, max_file_size, no_redirects):
"""
called when user wants serial downloading
"""
# create directory to save files
if not os.path.exists(directory):
os.makedirs(directory)
app = progress_class(frame, urls, directory, min_file_size, max_file_size, no_... | [
"called",
"when",
"user",
"wants",
"serial",
"downloading"
] | nikhilkumarsingh/content-downloader | python | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui_downloader.py#L254-L262 | [
"def",
"download_series_gui",
"(",
"frame",
",",
"urls",
",",
"directory",
",",
"min_file_size",
",",
"max_file_size",
",",
"no_redirects",
")",
":",
"# create directory to save files",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"directory",
")",
":",
... | 8b14af3a6eadcc43581e0425dc1d218208de12df |
train | myThread.run | function called when thread is started | ctdl/gui_downloader.py | def run(self):
"""
function called when thread is started
"""
global parallel
if parallel:
download_parallel(self.url, self.directory, self.idx,
self.min_file_size, self.max_file_size, self.no_redirects)
else:
download(self.url, self.directory, self.idx,
self.min_file_size, self.max... | def run(self):
"""
function called when thread is started
"""
global parallel
if parallel:
download_parallel(self.url, self.directory, self.idx,
self.min_file_size, self.max_file_size, self.no_redirects)
else:
download(self.url, self.directory, self.idx,
self.min_file_size, self.max... | [
"function",
"called",
"when",
"thread",
"is",
"started"
] | nikhilkumarsingh/content-downloader | python | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui_downloader.py#L134-L145 | [
"def",
"run",
"(",
"self",
")",
":",
"global",
"parallel",
"if",
"parallel",
":",
"download_parallel",
"(",
"self",
".",
"url",
",",
"self",
".",
"directory",
",",
"self",
".",
"idx",
",",
"self",
".",
"min_file_size",
",",
"self",
".",
"max_file_size",
... | 8b14af3a6eadcc43581e0425dc1d218208de12df |
train | progress_class.start | function to initialize thread for downloading | ctdl/gui_downloader.py | def start(self):
"""
function to initialize thread for downloading
"""
global parallel
for self.i in range(0, self.length):
if parallel:
self.thread.append(myThread(self.url[ self.i ], self.directory, self.i,
self.min_file_size, self.max_file_size, self.no_redirects))
else:
# if not ... | def start(self):
"""
function to initialize thread for downloading
"""
global parallel
for self.i in range(0, self.length):
if parallel:
self.thread.append(myThread(self.url[ self.i ], self.directory, self.i,
self.min_file_size, self.max_file_size, self.no_redirects))
else:
# if not ... | [
"function",
"to",
"initialize",
"thread",
"for",
"downloading"
] | nikhilkumarsingh/content-downloader | python | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui_downloader.py#L198-L215 | [
"def",
"start",
"(",
"self",
")",
":",
"global",
"parallel",
"for",
"self",
".",
"i",
"in",
"range",
"(",
"0",
",",
"self",
".",
"length",
")",
":",
"if",
"parallel",
":",
"self",
".",
"thread",
".",
"append",
"(",
"myThread",
"(",
"self",
".",
"... | 8b14af3a6eadcc43581e0425dc1d218208de12df |
train | progress_class.read_bytes | reading bytes; update progress bar after 1 ms | ctdl/gui_downloader.py | def read_bytes(self):
"""
reading bytes; update progress bar after 1 ms
"""
global exit_flag
for self.i in range(0, self.length) :
self.bytes[self.i] = i_max[self.i]
self.maxbytes[self.i] = total_chunks[self.i]
self.progress[self.i]["maximum"] = total_chunks[self.i]
self.progress[self.i]["value"]... | def read_bytes(self):
"""
reading bytes; update progress bar after 1 ms
"""
global exit_flag
for self.i in range(0, self.length) :
self.bytes[self.i] = i_max[self.i]
self.maxbytes[self.i] = total_chunks[self.i]
self.progress[self.i]["maximum"] = total_chunks[self.i]
self.progress[self.i]["value"]... | [
"reading",
"bytes",
";",
"update",
"progress",
"bar",
"after",
"1",
"ms"
] | nikhilkumarsingh/content-downloader | python | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui_downloader.py#L218-L236 | [
"def",
"read_bytes",
"(",
"self",
")",
":",
"global",
"exit_flag",
"for",
"self",
".",
"i",
"in",
"range",
"(",
"0",
",",
"self",
".",
"length",
")",
":",
"self",
".",
"bytes",
"[",
"self",
".",
"i",
"]",
"=",
"i_max",
"[",
"self",
".",
"i",
"]... | 8b14af3a6eadcc43581e0425dc1d218208de12df |
train | CodeGenBase.declare_type | Add this type to our collection, if needed. | schema_salad/codegen_base.py | def declare_type(self, declared_type): # type: (TypeDef) -> TypeDef
"""Add this type to our collection, if needed."""
if declared_type not in self.collected_types:
self.collected_types[declared_type.name] = declared_type
return declared_type | def declare_type(self, declared_type): # type: (TypeDef) -> TypeDef
"""Add this type to our collection, if needed."""
if declared_type not in self.collected_types:
self.collected_types[declared_type.name] = declared_type
return declared_type | [
"Add",
"this",
"type",
"to",
"our",
"collection",
"if",
"needed",
"."
] | common-workflow-language/schema_salad | python | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/codegen_base.py#L33-L37 | [
"def",
"declare_type",
"(",
"self",
",",
"declared_type",
")",
":",
"# type: (TypeDef) -> TypeDef",
"if",
"declared_type",
"not",
"in",
"self",
".",
"collected_types",
":",
"self",
".",
"collected_types",
"[",
"declared_type",
".",
"name",
"]",
"=",
"declared_type... | 608ba207b9058fe0a9c3db161058ab3782eef015 |
train | get_metaschema | Instantiate the metaschema. | schema_salad/schema.py | def get_metaschema(): # type: () -> Tuple[Names, List[Dict[Text, Any]], Loader]
"""Instantiate the metaschema."""
loader = ref_resolver.Loader({
"Any": "https://w3id.org/cwl/salad#Any",
"ArraySchema": "https://w3id.org/cwl/salad#ArraySchema",
"Array_symbol": "https://w3id.org/cwl/salad#... | def get_metaschema(): # type: () -> Tuple[Names, List[Dict[Text, Any]], Loader]
"""Instantiate the metaschema."""
loader = ref_resolver.Loader({
"Any": "https://w3id.org/cwl/salad#Any",
"ArraySchema": "https://w3id.org/cwl/salad#ArraySchema",
"Array_symbol": "https://w3id.org/cwl/salad#... | [
"Instantiate",
"the",
"metaschema",
"."
] | common-workflow-language/schema_salad | python | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L56-L194 | [
"def",
"get_metaschema",
"(",
")",
":",
"# type: () -> Tuple[Names, List[Dict[Text, Any]], Loader]",
"loader",
"=",
"ref_resolver",
".",
"Loader",
"(",
"{",
"\"Any\"",
":",
"\"https://w3id.org/cwl/salad#Any\"",
",",
"\"ArraySchema\"",
":",
"\"https://w3id.org/cwl/salad#ArraySch... | 608ba207b9058fe0a9c3db161058ab3782eef015 |
train | add_namespaces | Collect the provided namespaces, checking for conflicts. | schema_salad/schema.py | def add_namespaces(metadata, namespaces):
# type: (Mapping[Text, Any], MutableMapping[Text, Text]) -> None
"""Collect the provided namespaces, checking for conflicts."""
for key, value in metadata.items():
if key not in namespaces:
namespaces[key] = value
elif namespaces[key] != ... | def add_namespaces(metadata, namespaces):
# type: (Mapping[Text, Any], MutableMapping[Text, Text]) -> None
"""Collect the provided namespaces, checking for conflicts."""
for key, value in metadata.items():
if key not in namespaces:
namespaces[key] = value
elif namespaces[key] != ... | [
"Collect",
"the",
"provided",
"namespaces",
"checking",
"for",
"conflicts",
"."
] | common-workflow-language/schema_salad | python | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L196-L205 | [
"def",
"add_namespaces",
"(",
"metadata",
",",
"namespaces",
")",
":",
"# type: (Mapping[Text, Any], MutableMapping[Text, Text]) -> None",
"for",
"key",
",",
"value",
"in",
"metadata",
".",
"items",
"(",
")",
":",
"if",
"key",
"not",
"in",
"namespaces",
":",
"name... | 608ba207b9058fe0a9c3db161058ab3782eef015 |
train | collect_namespaces | Walk through the metadata object, collecting namespace declarations. | schema_salad/schema.py | def collect_namespaces(metadata):
# type: (Mapping[Text, Any]) -> Dict[Text, Text]
"""Walk through the metadata object, collecting namespace declarations."""
namespaces = {} # type: Dict[Text, Text]
if "$import_metadata" in metadata:
for value in metadata["$import_metadata"].values():
... | def collect_namespaces(metadata):
# type: (Mapping[Text, Any]) -> Dict[Text, Text]
"""Walk through the metadata object, collecting namespace declarations."""
namespaces = {} # type: Dict[Text, Text]
if "$import_metadata" in metadata:
for value in metadata["$import_metadata"].values():
... | [
"Walk",
"through",
"the",
"metadata",
"object",
"collecting",
"namespace",
"declarations",
"."
] | common-workflow-language/schema_salad | python | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L208-L217 | [
"def",
"collect_namespaces",
"(",
"metadata",
")",
":",
"# type: (Mapping[Text, Any]) -> Dict[Text, Text]",
"namespaces",
"=",
"{",
"}",
"# type: Dict[Text, Text]",
"if",
"\"$import_metadata\"",
"in",
"metadata",
":",
"for",
"value",
"in",
"metadata",
"[",
"\"$import_meta... | 608ba207b9058fe0a9c3db161058ab3782eef015 |
train | load_schema | Load a schema that can be used to validate documents using load_and_validate.
return: document_loader, avsc_names, schema_metadata, metaschema_loader | schema_salad/schema.py | def load_schema(schema_ref, # type: Union[CommentedMap, CommentedSeq, Text]
cache=None # type: Dict
):
# type: (...) -> Tuple[Loader, Union[Names, SchemaParseException], Dict[Text, Any], Loader]
"""
Load a schema that can be used to validate documents using load_and_valida... | def load_schema(schema_ref, # type: Union[CommentedMap, CommentedSeq, Text]
cache=None # type: Dict
):
# type: (...) -> Tuple[Loader, Union[Names, SchemaParseException], Dict[Text, Any], Loader]
"""
Load a schema that can be used to validate documents using load_and_valida... | [
"Load",
"a",
"schema",
"that",
"can",
"be",
"used",
"to",
"validate",
"documents",
"using",
"load_and_validate",
"."
] | common-workflow-language/schema_salad | python | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L219-L249 | [
"def",
"load_schema",
"(",
"schema_ref",
",",
"# type: Union[CommentedMap, CommentedSeq, Text]",
"cache",
"=",
"None",
"# type: Dict",
")",
":",
"# type: (...) -> Tuple[Loader, Union[Names, SchemaParseException], Dict[Text, Any], Loader]",
"metaschema_names",
",",
"_metaschema_doc",
... | 608ba207b9058fe0a9c3db161058ab3782eef015 |
train | load_and_validate | Load a document and validate it with the provided schema.
return data, metadata | schema_salad/schema.py | def load_and_validate(document_loader, # type: Loader
avsc_names, # type: Names
document, # type: Union[CommentedMap, Text]
strict, # type: bool
st... | def load_and_validate(document_loader, # type: Loader
avsc_names, # type: Names
document, # type: Union[CommentedMap, Text]
strict, # type: bool
st... | [
"Load",
"a",
"document",
"and",
"validate",
"it",
"with",
"the",
"provided",
"schema",
"."
] | common-workflow-language/schema_salad | python | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L252-L278 | [
"def",
"load_and_validate",
"(",
"document_loader",
",",
"# type: Loader",
"avsc_names",
",",
"# type: Names",
"document",
",",
"# type: Union[CommentedMap, Text]",
"strict",
",",
"# type: bool",
"strict_foreign_properties",
"=",
"False",
"# type: bool",
")",
":",
"# type: ... | 608ba207b9058fe0a9c3db161058ab3782eef015 |
train | validate_doc | Validate a document using the provided schema. | schema_salad/schema.py | def validate_doc(schema_names, # type: Names
doc, # type: Union[Dict[Text, Any], List[Dict[Text, Any]], Text, None]
loader, # type: Loader
strict, # type: bool
strict_foreign_properties=False # type: bool
):
... | def validate_doc(schema_names, # type: Names
doc, # type: Union[Dict[Text, Any], List[Dict[Text, Any]], Text, None]
loader, # type: Loader
strict, # type: bool
strict_foreign_properties=False # type: bool
):
... | [
"Validate",
"a",
"document",
"using",
"the",
"provided",
"schema",
"."
] | common-workflow-language/schema_salad | python | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L281-L361 | [
"def",
"validate_doc",
"(",
"schema_names",
",",
"# type: Names",
"doc",
",",
"# type: Union[Dict[Text, Any], List[Dict[Text, Any]], Text, None]",
"loader",
",",
"# type: Loader",
"strict",
",",
"# type: bool",
"strict_foreign_properties",
"=",
"False",
"# type: bool",
")",
"... | 608ba207b9058fe0a9c3db161058ab3782eef015 |
train | get_anon_name | Calculate a reproducible name for anonymous types. | schema_salad/schema.py | def get_anon_name(rec):
# type: (MutableMapping[Text, Any]) -> Text
"""Calculate a reproducible name for anonymous types."""
if "name" in rec:
return rec["name"]
anon_name = ""
if rec['type'] in ('enum', 'https://w3id.org/cwl/salad#enum'):
for sym in rec["symbols"]:
anon_... | def get_anon_name(rec):
# type: (MutableMapping[Text, Any]) -> Text
"""Calculate a reproducible name for anonymous types."""
if "name" in rec:
return rec["name"]
anon_name = ""
if rec['type'] in ('enum', 'https://w3id.org/cwl/salad#enum'):
for sym in rec["symbols"]:
anon_... | [
"Calculate",
"a",
"reproducible",
"name",
"for",
"anonymous",
"types",
"."
] | common-workflow-language/schema_salad | python | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L363-L379 | [
"def",
"get_anon_name",
"(",
"rec",
")",
":",
"# type: (MutableMapping[Text, Any]) -> Text",
"if",
"\"name\"",
"in",
"rec",
":",
"return",
"rec",
"[",
"\"name\"",
"]",
"anon_name",
"=",
"\"\"",
"if",
"rec",
"[",
"'type'",
"]",
"in",
"(",
"'enum'",
",",
"'htt... | 608ba207b9058fe0a9c3db161058ab3782eef015 |
train | replace_type | Go through and replace types in the 'spec' mapping | schema_salad/schema.py | def replace_type(items, spec, loader, found, find_embeds=True, deepen=True):
# type: (Any, Dict[Text, Any], Loader, Set[Text], bool, bool) -> Any
""" Go through and replace types in the 'spec' mapping"""
if isinstance(items, MutableMapping):
# recursively check these fields for types to replace
... | def replace_type(items, spec, loader, found, find_embeds=True, deepen=True):
# type: (Any, Dict[Text, Any], Loader, Set[Text], bool, bool) -> Any
""" Go through and replace types in the 'spec' mapping"""
if isinstance(items, MutableMapping):
# recursively check these fields for types to replace
... | [
"Go",
"through",
"and",
"replace",
"types",
"in",
"the",
"spec",
"mapping"
] | common-workflow-language/schema_salad | python | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L381-L426 | [
"def",
"replace_type",
"(",
"items",
",",
"spec",
",",
"loader",
",",
"found",
",",
"find_embeds",
"=",
"True",
",",
"deepen",
"=",
"True",
")",
":",
"# type: (Any, Dict[Text, Any], Loader, Set[Text], bool, bool) -> Any",
"if",
"isinstance",
"(",
"items",
",",
"Mu... | 608ba207b9058fe0a9c3db161058ab3782eef015 |
train | avro_name | Turn a URL into an Avro-safe name.
If the URL has no fragment, return this plain URL.
Extract either the last part of the URL fragment past the slash, otherwise
the whole fragment. | schema_salad/schema.py | def avro_name(url): # type: (AnyStr) -> AnyStr
"""
Turn a URL into an Avro-safe name.
If the URL has no fragment, return this plain URL.
Extract either the last part of the URL fragment past the slash, otherwise
the whole fragment.
"""
frg = urllib.parse.urldefrag(url)[1]
if frg != ''... | def avro_name(url): # type: (AnyStr) -> AnyStr
"""
Turn a URL into an Avro-safe name.
If the URL has no fragment, return this plain URL.
Extract either the last part of the URL fragment past the slash, otherwise
the whole fragment.
"""
frg = urllib.parse.urldefrag(url)[1]
if frg != ''... | [
"Turn",
"a",
"URL",
"into",
"an",
"Avro",
"-",
"safe",
"name",
"."
] | common-workflow-language/schema_salad | python | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L429-L443 | [
"def",
"avro_name",
"(",
"url",
")",
":",
"# type: (AnyStr) -> AnyStr",
"frg",
"=",
"urllib",
".",
"parse",
".",
"urldefrag",
"(",
"url",
")",
"[",
"1",
"]",
"if",
"frg",
"!=",
"''",
":",
"if",
"'/'",
"in",
"frg",
":",
"return",
"frg",
"[",
"frg",
... | 608ba207b9058fe0a9c3db161058ab3782eef015 |
train | make_valid_avro | Convert our schema to be more avro like. | schema_salad/schema.py | def make_valid_avro(items, # type: Avro
alltypes, # type: Dict[Text, Dict[Text, Any]]
found, # type: Set[Text]
union=False # type: bool
):
# type: (...) -> Union[Avro, Dict, Text]
"""Convert our schema to... | def make_valid_avro(items, # type: Avro
alltypes, # type: Dict[Text, Dict[Text, Any]]
found, # type: Set[Text]
union=False # type: bool
):
# type: (...) -> Union[Avro, Dict, Text]
"""Convert our schema to... | [
"Convert",
"our",
"schema",
"to",
"be",
"more",
"avro",
"like",
"."
] | common-workflow-language/schema_salad | python | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L449-L488 | [
"def",
"make_valid_avro",
"(",
"items",
",",
"# type: Avro",
"alltypes",
",",
"# type: Dict[Text, Dict[Text, Any]]",
"found",
",",
"# type: Set[Text]",
"union",
"=",
"False",
"# type: bool",
")",
":",
"# type: (...) -> Union[Avro, Dict, Text]",
"# Possibly could be integrated i... | 608ba207b9058fe0a9c3db161058ab3782eef015 |
train | deepcopy_strip | Make a deep copy of list and dict objects.
Intentionally do not copy attributes. This is to discard CommentedMap and
CommentedSeq metadata which is very expensive with regular copy.deepcopy. | schema_salad/schema.py | def deepcopy_strip(item): # type: (Any) -> Any
"""
Make a deep copy of list and dict objects.
Intentionally do not copy attributes. This is to discard CommentedMap and
CommentedSeq metadata which is very expensive with regular copy.deepcopy.
"""
if isinstance(item, MutableMapping):
r... | def deepcopy_strip(item): # type: (Any) -> Any
"""
Make a deep copy of list and dict objects.
Intentionally do not copy attributes. This is to discard CommentedMap and
CommentedSeq metadata which is very expensive with regular copy.deepcopy.
"""
if isinstance(item, MutableMapping):
r... | [
"Make",
"a",
"deep",
"copy",
"of",
"list",
"and",
"dict",
"objects",
"."
] | common-workflow-language/schema_salad | python | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L491-L503 | [
"def",
"deepcopy_strip",
"(",
"item",
")",
":",
"# type: (Any) -> Any",
"if",
"isinstance",
"(",
"item",
",",
"MutableMapping",
")",
":",
"return",
"{",
"k",
":",
"deepcopy_strip",
"(",
"v",
")",
"for",
"k",
",",
"v",
"in",
"iteritems",
"(",
"item",
")",... | 608ba207b9058fe0a9c3db161058ab3782eef015 |
train | extend_and_specialize | Apply 'extend' and 'specialize' to fully materialize derived record types. | schema_salad/schema.py | def extend_and_specialize(items, loader):
# type: (List[Dict[Text, Any]], Loader) -> List[Dict[Text, Any]]
"""
Apply 'extend' and 'specialize' to fully materialize derived record types.
"""
items = deepcopy_strip(items)
types = {i["name"]: i for i in items} # type: Dict[Text, Any]
results ... | def extend_and_specialize(items, loader):
# type: (List[Dict[Text, Any]], Loader) -> List[Dict[Text, Any]]
"""
Apply 'extend' and 'specialize' to fully materialize derived record types.
"""
items = deepcopy_strip(items)
types = {i["name"]: i for i in items} # type: Dict[Text, Any]
results ... | [
"Apply",
"extend",
"and",
"specialize",
"to",
"fully",
"materialize",
"derived",
"record",
"types",
"."
] | common-workflow-language/schema_salad | python | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L506-L591 | [
"def",
"extend_and_specialize",
"(",
"items",
",",
"loader",
")",
":",
"# type: (List[Dict[Text, Any]], Loader) -> List[Dict[Text, Any]]",
"items",
"=",
"deepcopy_strip",
"(",
"items",
")",
"types",
"=",
"{",
"i",
"[",
"\"name\"",
"]",
":",
"i",
"for",
"i",
"in",
... | 608ba207b9058fe0a9c3db161058ab3782eef015 |
train | make_avro_schema | All in one convenience function.
Call make_avro() and make_avro_schema_from_avro() separately if you need
the intermediate result for diagnostic output. | schema_salad/schema.py | def make_avro_schema(i, # type: List[Any]
loader # type: Loader
): # type: (...) -> Names
"""
All in one convenience function.
Call make_avro() and make_avro_schema_from_avro() separately if you need
the intermediate result for diagnostic output.
... | def make_avro_schema(i, # type: List[Any]
loader # type: Loader
): # type: (...) -> Names
"""
All in one convenience function.
Call make_avro() and make_avro_schema_from_avro() separately if you need
the intermediate result for diagnostic output.
... | [
"All",
"in",
"one",
"convenience",
"function",
"."
] | common-workflow-language/schema_salad | python | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L609-L621 | [
"def",
"make_avro_schema",
"(",
"i",
",",
"# type: List[Any]",
"loader",
"# type: Loader",
")",
":",
"# type: (...) -> Names",
"names",
"=",
"Names",
"(",
")",
"avro",
"=",
"make_avro",
"(",
"i",
",",
"loader",
")",
"make_avsc_object",
"(",
"convert_to_dict",
"(... | 608ba207b9058fe0a9c3db161058ab3782eef015 |
train | shortname | Returns the last segment of the provided fragment or path. | schema_salad/schema.py | def shortname(inputid): # type: (Text) -> Text
"""Returns the last segment of the provided fragment or path."""
parsed_id = urllib.parse.urlparse(inputid)
if parsed_id.fragment:
return parsed_id.fragment.split(u"/")[-1]
return parsed_id.path.split(u"/")[-1] | def shortname(inputid): # type: (Text) -> Text
"""Returns the last segment of the provided fragment or path."""
parsed_id = urllib.parse.urlparse(inputid)
if parsed_id.fragment:
return parsed_id.fragment.split(u"/")[-1]
return parsed_id.path.split(u"/")[-1] | [
"Returns",
"the",
"last",
"segment",
"of",
"the",
"provided",
"fragment",
"or",
"path",
"."
] | common-workflow-language/schema_salad | python | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L631-L636 | [
"def",
"shortname",
"(",
"inputid",
")",
":",
"# type: (Text) -> Text",
"parsed_id",
"=",
"urllib",
".",
"parse",
".",
"urlparse",
"(",
"inputid",
")",
"if",
"parsed_id",
".",
"fragment",
":",
"return",
"parsed_id",
".",
"fragment",
".",
"split",
"(",
"u\"/\... | 608ba207b9058fe0a9c3db161058ab3782eef015 |
train | print_inheritance | Write a Grapviz inheritance graph for the supplied document. | schema_salad/schema.py | def print_inheritance(doc, stream):
# type: (List[Dict[Text, Any]], IO) -> None
"""Write a Grapviz inheritance graph for the supplied document."""
stream.write("digraph {\n")
for entry in doc:
if entry["type"] == "record":
label = name = shortname(entry["name"])
fields = ... | def print_inheritance(doc, stream):
# type: (List[Dict[Text, Any]], IO) -> None
"""Write a Grapviz inheritance graph for the supplied document."""
stream.write("digraph {\n")
for entry in doc:
if entry["type"] == "record":
label = name = shortname(entry["name"])
fields = ... | [
"Write",
"a",
"Grapviz",
"inheritance",
"graph",
"for",
"the",
"supplied",
"document",
"."
] | common-workflow-language/schema_salad | python | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L639-L658 | [
"def",
"print_inheritance",
"(",
"doc",
",",
"stream",
")",
":",
"# type: (List[Dict[Text, Any]], IO) -> None",
"stream",
".",
"write",
"(",
"\"digraph {\\n\"",
")",
"for",
"entry",
"in",
"doc",
":",
"if",
"entry",
"[",
"\"type\"",
"]",
"==",
"\"record\"",
":",
... | 608ba207b9058fe0a9c3db161058ab3782eef015 |
train | print_fieldrefs | Write a GraphViz graph of the relationships between the fields. | schema_salad/schema.py | def print_fieldrefs(doc, loader, stream):
# type: (List[Dict[Text, Any]], Loader, IO) -> None
"""Write a GraphViz graph of the relationships between the fields."""
obj = extend_and_specialize(doc, loader)
primitives = set(("http://www.w3.org/2001/XMLSchema#string",
"http://www.w3.... | def print_fieldrefs(doc, loader, stream):
# type: (List[Dict[Text, Any]], Loader, IO) -> None
"""Write a GraphViz graph of the relationships between the fields."""
obj = extend_and_specialize(doc, loader)
primitives = set(("http://www.w3.org/2001/XMLSchema#string",
"http://www.w3.... | [
"Write",
"a",
"GraphViz",
"graph",
"of",
"the",
"relationships",
"between",
"the",
"fields",
"."
] | common-workflow-language/schema_salad | python | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L661-L691 | [
"def",
"print_fieldrefs",
"(",
"doc",
",",
"loader",
",",
"stream",
")",
":",
"# type: (List[Dict[Text, Any]], Loader, IO) -> None",
"obj",
"=",
"extend_and_specialize",
"(",
"doc",
",",
"loader",
")",
"primitives",
"=",
"set",
"(",
"(",
"\"http://www.w3.org/2001/XMLS... | 608ba207b9058fe0a9c3db161058ab3782eef015 |
train | get_other_props | Retrieve the non-reserved properties from a dictionary of properties
@args reserved_props: The set of reserved properties to exclude | schema_salad/avro/schema.py | def get_other_props(all_props, reserved_props):
# type: (Dict, Tuple) -> Optional[Dict]
"""
Retrieve the non-reserved properties from a dictionary of properties
@args reserved_props: The set of reserved properties to exclude
"""
if hasattr(all_props, 'items') and callable(all_props.items):
... | def get_other_props(all_props, reserved_props):
# type: (Dict, Tuple) -> Optional[Dict]
"""
Retrieve the non-reserved properties from a dictionary of properties
@args reserved_props: The set of reserved properties to exclude
"""
if hasattr(all_props, 'items') and callable(all_props.items):
... | [
"Retrieve",
"the",
"non",
"-",
"reserved",
"properties",
"from",
"a",
"dictionary",
"of",
"properties"
] | common-workflow-language/schema_salad | python | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/avro/schema.py#L515-L524 | [
"def",
"get_other_props",
"(",
"all_props",
",",
"reserved_props",
")",
":",
"# type: (Dict, Tuple) -> Optional[Dict]",
"if",
"hasattr",
"(",
"all_props",
",",
"'items'",
")",
"and",
"callable",
"(",
"all_props",
".",
"items",
")",
":",
"return",
"dict",
"(",
"[... | 608ba207b9058fe0a9c3db161058ab3782eef015 |
train | make_avsc_object | Build Avro Schema from data parsed out of JSON string.
@arg names: A Name object (tracks seen names and default space) | schema_salad/avro/schema.py | def make_avsc_object(json_data, names=None):
# type: (Union[Dict[Text, Text], List[Any], Text], Optional[Names]) -> Schema
"""
Build Avro Schema from data parsed out of JSON string.
@arg names: A Name object (tracks seen names and default space)
"""
if names is None:
names = Names()
... | def make_avsc_object(json_data, names=None):
# type: (Union[Dict[Text, Text], List[Any], Text], Optional[Names]) -> Schema
"""
Build Avro Schema from data parsed out of JSON string.
@arg names: A Name object (tracks seen names and default space)
"""
if names is None:
names = Names()
... | [
"Build",
"Avro",
"Schema",
"from",
"data",
"parsed",
"out",
"of",
"JSON",
"string",
"."
] | common-workflow-language/schema_salad | python | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/avro/schema.py#L527-L573 | [
"def",
"make_avsc_object",
"(",
"json_data",
",",
"names",
"=",
"None",
")",
":",
"# type: (Union[Dict[Text, Text], List[Any], Text], Optional[Names]) -> Schema",
"if",
"names",
"is",
"None",
":",
"names",
"=",
"Names",
"(",
")",
"assert",
"isinstance",
"(",
"names",
... | 608ba207b9058fe0a9c3db161058ab3782eef015 |
train | Name.get_space | Back out a namespace from full name. | schema_salad/avro/schema.py | def get_space(self):
# type: () -> Optional[Text]
"""Back out a namespace from full name."""
if self._full is None:
return None
if self._full.find('.') > 0:
return self._full.rsplit(".", 1)[0]
else:
return "" | def get_space(self):
# type: () -> Optional[Text]
"""Back out a namespace from full name."""
if self._full is None:
return None
if self._full.find('.') > 0:
return self._full.rsplit(".", 1)[0]
else:
return "" | [
"Back",
"out",
"a",
"namespace",
"from",
"full",
"name",
"."
] | common-workflow-language/schema_salad | python | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/avro/schema.py#L184-L193 | [
"def",
"get_space",
"(",
"self",
")",
":",
"# type: () -> Optional[Text]",
"if",
"self",
".",
"_full",
"is",
"None",
":",
"return",
"None",
"if",
"self",
".",
"_full",
".",
"find",
"(",
"'.'",
")",
">",
"0",
":",
"return",
"self",
".",
"_full",
".",
... | 608ba207b9058fe0a9c3db161058ab3782eef015 |
train | Names.add_name | Add a new schema object to the name set.
@arg name_attr: name value read in schema
@arg space_attr: namespace value read in schema.
@return: the Name that was just added. | schema_salad/avro/schema.py | def add_name(self, name_attr, space_attr, new_schema):
# type: (Text, Optional[Text], NamedSchema) -> Name
"""
Add a new schema object to the name set.
@arg name_attr: name value read in schema
@arg space_attr: namespace value read in schema.
@return: the Name tha... | def add_name(self, name_attr, space_attr, new_schema):
# type: (Text, Optional[Text], NamedSchema) -> Name
"""
Add a new schema object to the name set.
@arg name_attr: name value read in schema
@arg space_attr: namespace value read in schema.
@return: the Name tha... | [
"Add",
"a",
"new",
"schema",
"object",
"to",
"the",
"name",
"set",
"."
] | common-workflow-language/schema_salad | python | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/avro/schema.py#L215-L235 | [
"def",
"add_name",
"(",
"self",
",",
"name_attr",
",",
"space_attr",
",",
"new_schema",
")",
":",
"# type: (Text, Optional[Text], NamedSchema) -> Name",
"to_add",
"=",
"Name",
"(",
"name_attr",
",",
"space_attr",
",",
"self",
".",
"default_namespace",
")",
"if",
"... | 608ba207b9058fe0a9c3db161058ab3782eef015 |
train | RecordSchema.make_field_objects | We're going to need to make message parameters too. | schema_salad/avro/schema.py | def make_field_objects(field_data, names):
# type: (List[Dict[Text, Text]], Names) -> List[Field]
"""We're going to need to make message parameters too."""
field_objects = []
field_names = [] # type: List[Text]
for field in field_data:
if hasattr(field, 'get') and ca... | def make_field_objects(field_data, names):
# type: (List[Dict[Text, Text]], Names) -> List[Field]
"""We're going to need to make message parameters too."""
field_objects = []
field_names = [] # type: List[Text]
for field in field_data:
if hasattr(field, 'get') and ca... | [
"We",
"re",
"going",
"to",
"need",
"to",
"make",
"message",
"parameters",
"too",
"."
] | common-workflow-language/schema_salad | python | https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/avro/schema.py#L446-L476 | [
"def",
"make_field_objects",
"(",
"field_data",
",",
"names",
")",
":",
"# type: (List[Dict[Text, Text]], Names) -> List[Field]",
"field_objects",
"=",
"[",
"]",
"field_names",
"=",
"[",
"]",
"# type: List[Text]",
"for",
"field",
"in",
"field_data",
":",
"if",
"hasatt... | 608ba207b9058fe0a9c3db161058ab3782eef015 |
train | search_function | function to get links | ctdl/gui.py | def search_function(root1, q, s, f, l, o='g'):
"""
function to get links
"""
global links
links = search(q, o, s, f, l)
root1.destroy()
root1.quit() | def search_function(root1, q, s, f, l, o='g'):
"""
function to get links
"""
global links
links = search(q, o, s, f, l)
root1.destroy()
root1.quit() | [
"function",
"to",
"get",
"links"
] | nikhilkumarsingh/content-downloader | python | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui.py#L53-L60 | [
"def",
"search_function",
"(",
"root1",
",",
"q",
",",
"s",
",",
"f",
",",
"l",
",",
"o",
"=",
"'g'",
")",
":",
"global",
"links",
"links",
"=",
"search",
"(",
"q",
",",
"o",
",",
"s",
",",
"f",
",",
"l",
")",
"root1",
".",
"destroy",
"(",
... | 8b14af3a6eadcc43581e0425dc1d218208de12df |
train | task | to create loading progress bar | ctdl/gui.py | def task(ft):
"""
to create loading progress bar
"""
ft.pack(expand = True, fill = BOTH, side = TOP)
pb_hD = ttk.Progressbar(ft, orient = 'horizontal', mode = 'indeterminate')
pb_hD.pack(expand = True, fill = BOTH, side = TOP)
pb_hD.start(50)
ft.mainloop() | def task(ft):
"""
to create loading progress bar
"""
ft.pack(expand = True, fill = BOTH, side = TOP)
pb_hD = ttk.Progressbar(ft, orient = 'horizontal', mode = 'indeterminate')
pb_hD.pack(expand = True, fill = BOTH, side = TOP)
pb_hD.start(50)
ft.mainloop() | [
"to",
"create",
"loading",
"progress",
"bar"
] | nikhilkumarsingh/content-downloader | python | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui.py#L63-L71 | [
"def",
"task",
"(",
"ft",
")",
":",
"ft",
".",
"pack",
"(",
"expand",
"=",
"True",
",",
"fill",
"=",
"BOTH",
",",
"side",
"=",
"TOP",
")",
"pb_hD",
"=",
"ttk",
".",
"Progressbar",
"(",
"ft",
",",
"orient",
"=",
"'horizontal'",
",",
"mode",
"=",
... | 8b14af3a6eadcc43581e0425dc1d218208de12df |
train | download_content_gui | function to fetch links and download them | ctdl/gui.py | def download_content_gui(**args):
"""
function to fetch links and download them
"""
global row
if not args ['directory']:
args ['directory'] = args ['query'].replace(' ', '-')
root1 = Frame(root)
t1 = threading.Thread(target = search_function, args = (root1,
args['query'], args['website'], args['fil... | def download_content_gui(**args):
"""
function to fetch links and download them
"""
global row
if not args ['directory']:
args ['directory'] = args ['query'].replace(' ', '-')
root1 = Frame(root)
t1 = threading.Thread(target = search_function, args = (root1,
args['query'], args['website'], args['fil... | [
"function",
"to",
"fetch",
"links",
"and",
"download",
"them"
] | nikhilkumarsingh/content-downloader | python | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui.py#L74-L98 | [
"def",
"download_content_gui",
"(",
"*",
"*",
"args",
")",
":",
"global",
"row",
"if",
"not",
"args",
"[",
"'directory'",
"]",
":",
"args",
"[",
"'directory'",
"]",
"=",
"args",
"[",
"'query'",
"]",
".",
"replace",
"(",
"' '",
",",
"'-'",
")",
"root1... | 8b14af3a6eadcc43581e0425dc1d218208de12df |
train | main | main function | ctdl/gui.py | def main():
"""
main function
"""
s = ttk.Style()
s.theme_use('clam')
ents = makeform(root)
root.mainloop() | def main():
"""
main function
"""
s = ttk.Style()
s.theme_use('clam')
ents = makeform(root)
root.mainloop() | [
"main",
"function"
] | nikhilkumarsingh/content-downloader | python | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui.py#L330-L337 | [
"def",
"main",
"(",
")",
":",
"s",
"=",
"ttk",
".",
"Style",
"(",
")",
"s",
".",
"theme_use",
"(",
"'clam'",
")",
"ents",
"=",
"makeform",
"(",
"root",
")",
"root",
".",
"mainloop",
"(",
")"
] | 8b14af3a6eadcc43581e0425dc1d218208de12df |
train | makeform.click_download | event for download button | ctdl/gui.py | def click_download(self, event):
"""
event for download button
"""
args ['parallel'] = self.p.get()
args ['file_type'] = self.optionmenu.get()
args ['no_redirects'] = self.t.get()
args ['query'] = self.entry_query.get()
args ['min_file_size'] = int( self.entry_min.get())
args ['max_file_size'] = int( ... | def click_download(self, event):
"""
event for download button
"""
args ['parallel'] = self.p.get()
args ['file_type'] = self.optionmenu.get()
args ['no_redirects'] = self.t.get()
args ['query'] = self.entry_query.get()
args ['min_file_size'] = int( self.entry_min.get())
args ['max_file_size'] = int( ... | [
"event",
"for",
"download",
"button"
] | nikhilkumarsingh/content-downloader | python | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui.py#L258-L273 | [
"def",
"click_download",
"(",
"self",
",",
"event",
")",
":",
"args",
"[",
"'parallel'",
"]",
"=",
"self",
".",
"p",
".",
"get",
"(",
")",
"args",
"[",
"'file_type'",
"]",
"=",
"self",
".",
"optionmenu",
".",
"get",
"(",
")",
"args",
"[",
"'no_redi... | 8b14af3a6eadcc43581e0425dc1d218208de12df |
train | makeform.on_entry_click | function that gets called whenever entry is clicked | ctdl/gui.py | def on_entry_click(self, event):
"""
function that gets called whenever entry is clicked
"""
if event.widget.config('fg') [4] == 'grey':
event.widget.delete(0, "end" ) # delete all the text in the entry
event.widget.insert(0, '') #Insert blank for user input
event.widget.config(fg = 'black') | def on_entry_click(self, event):
"""
function that gets called whenever entry is clicked
"""
if event.widget.config('fg') [4] == 'grey':
event.widget.delete(0, "end" ) # delete all the text in the entry
event.widget.insert(0, '') #Insert blank for user input
event.widget.config(fg = 'black') | [
"function",
"that",
"gets",
"called",
"whenever",
"entry",
"is",
"clicked"
] | nikhilkumarsingh/content-downloader | python | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui.py#L276-L283 | [
"def",
"on_entry_click",
"(",
"self",
",",
"event",
")",
":",
"if",
"event",
".",
"widget",
".",
"config",
"(",
"'fg'",
")",
"[",
"4",
"]",
"==",
"'grey'",
":",
"event",
".",
"widget",
".",
"delete",
"(",
"0",
",",
"\"end\"",
")",
"# delete all the t... | 8b14af3a6eadcc43581e0425dc1d218208de12df |
train | makeform.on_focusout | function that gets called whenever anywhere except entry is clicked | ctdl/gui.py | def on_focusout(self, event, a):
"""
function that gets called whenever anywhere except entry is clicked
"""
if event.widget.get() == '':
event.widget.insert(0, default_text[a])
event.widget.config(fg = 'grey') | def on_focusout(self, event, a):
"""
function that gets called whenever anywhere except entry is clicked
"""
if event.widget.get() == '':
event.widget.insert(0, default_text[a])
event.widget.config(fg = 'grey') | [
"function",
"that",
"gets",
"called",
"whenever",
"anywhere",
"except",
"entry",
"is",
"clicked"
] | nikhilkumarsingh/content-downloader | python | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui.py#L286-L292 | [
"def",
"on_focusout",
"(",
"self",
",",
"event",
",",
"a",
")",
":",
"if",
"event",
".",
"widget",
".",
"get",
"(",
")",
"==",
"''",
":",
"event",
".",
"widget",
".",
"insert",
"(",
"0",
",",
"default_text",
"[",
"a",
"]",
")",
"event",
".",
"w... | 8b14af3a6eadcc43581e0425dc1d218208de12df |
train | makeform.check_threat | function to check input filetype against threat extensions list | ctdl/gui.py | def check_threat(self):
"""
function to check input filetype against threat extensions list
"""
is_high_threat = False
for val in THREAT_EXTENSIONS.values():
if type(val) == list:
for el in val:
if self.optionmenu.get() == el:
is_high_threat = True
break
else:
if self.optionmen... | def check_threat(self):
"""
function to check input filetype against threat extensions list
"""
is_high_threat = False
for val in THREAT_EXTENSIONS.values():
if type(val) == list:
for el in val:
if self.optionmenu.get() == el:
is_high_threat = True
break
else:
if self.optionmen... | [
"function",
"to",
"check",
"input",
"filetype",
"against",
"threat",
"extensions",
"list"
] | nikhilkumarsingh/content-downloader | python | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui.py#L295-L315 | [
"def",
"check_threat",
"(",
"self",
")",
":",
"is_high_threat",
"=",
"False",
"for",
"val",
"in",
"THREAT_EXTENSIONS",
".",
"values",
"(",
")",
":",
"if",
"type",
"(",
"val",
")",
"==",
"list",
":",
"for",
"el",
"in",
"val",
":",
"if",
"self",
".",
... | 8b14af3a6eadcc43581e0425dc1d218208de12df |
train | makeform.ask_dir | dialogue box for choosing directory | ctdl/gui.py | def ask_dir(self):
"""
dialogue box for choosing directory
"""
args ['directory'] = askdirectory(**self.dir_opt)
self.dir_text.set(args ['directory']) | def ask_dir(self):
"""
dialogue box for choosing directory
"""
args ['directory'] = askdirectory(**self.dir_opt)
self.dir_text.set(args ['directory']) | [
"dialogue",
"box",
"for",
"choosing",
"directory"
] | nikhilkumarsingh/content-downloader | python | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/gui.py#L317-L322 | [
"def",
"ask_dir",
"(",
"self",
")",
":",
"args",
"[",
"'directory'",
"]",
"=",
"askdirectory",
"(",
"*",
"*",
"self",
".",
"dir_opt",
")",
"self",
".",
"dir_text",
".",
"set",
"(",
"args",
"[",
"'directory'",
"]",
")"
] | 8b14af3a6eadcc43581e0425dc1d218208de12df |
train | get_google_links | function to fetch links equal to limit
every Google search result page has a start index.
every page contains 10 search results. | ctdl/ctdl.py | def get_google_links(limit, params, headers):
"""
function to fetch links equal to limit
every Google search result page has a start index.
every page contains 10 search results.
"""
links = []
for start_index in range(0, limit, 10):
params['start'] = start_index
resp = s.get("https://www.google.com/search"... | def get_google_links(limit, params, headers):
"""
function to fetch links equal to limit
every Google search result page has a start index.
every page contains 10 search results.
"""
links = []
for start_index in range(0, limit, 10):
params['start'] = start_index
resp = s.get("https://www.google.com/search"... | [
"function",
"to",
"fetch",
"links",
"equal",
"to",
"limit"
] | nikhilkumarsingh/content-downloader | python | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/ctdl.py#L26-L39 | [
"def",
"get_google_links",
"(",
"limit",
",",
"params",
",",
"headers",
")",
":",
"links",
"=",
"[",
"]",
"for",
"start_index",
"in",
"range",
"(",
"0",
",",
"limit",
",",
"10",
")",
":",
"params",
"[",
"'start'",
"]",
"=",
"start_index",
"resp",
"="... | 8b14af3a6eadcc43581e0425dc1d218208de12df |
train | get_duckduckgo_links | function to fetch links equal to limit
duckduckgo pagination is not static, so there is a limit on
maximum number of links that can be scraped | ctdl/ctdl.py | def get_duckduckgo_links(limit, params, headers):
"""
function to fetch links equal to limit
duckduckgo pagination is not static, so there is a limit on
maximum number of links that can be scraped
"""
resp = s.get('https://duckduckgo.com/html', params = params, headers = headers)
links = scrape_links(resp.conte... | def get_duckduckgo_links(limit, params, headers):
"""
function to fetch links equal to limit
duckduckgo pagination is not static, so there is a limit on
maximum number of links that can be scraped
"""
resp = s.get('https://duckduckgo.com/html', params = params, headers = headers)
links = scrape_links(resp.conte... | [
"function",
"to",
"fetch",
"links",
"equal",
"to",
"limit"
] | nikhilkumarsingh/content-downloader | python | https://github.com/nikhilkumarsingh/content-downloader/blob/8b14af3a6eadcc43581e0425dc1d218208de12df/ctdl/ctdl.py#L43-L52 | [
"def",
"get_duckduckgo_links",
"(",
"limit",
",",
"params",
",",
"headers",
")",
":",
"resp",
"=",
"s",
".",
"get",
"(",
"'https://duckduckgo.com/html'",
",",
"params",
"=",
"params",
",",
"headers",
"=",
"headers",
")",
"links",
"=",
"scrape_links",
"(",
... | 8b14af3a6eadcc43581e0425dc1d218208de12df |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.