repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
unfoldingWord-dev/python-gogs-client | gogs_client/interface.py | GogsApi.get_repo_hooks | def get_repo_hooks(self, auth, username, repo_name):
"""
Returns all hooks of repository with name ``repo_name`` owned by
the user with username ``username``.
:param auth.Authentication auth: authentication object
:param str username: username of owner of repository
:par... | python | def get_repo_hooks(self, auth, username, repo_name):
"""
Returns all hooks of repository with name ``repo_name`` owned by
the user with username ``username``.
:param auth.Authentication auth: authentication object
:param str username: username of owner of repository
:par... | [
"def",
"get_repo_hooks",
"(",
"self",
",",
"auth",
",",
"username",
",",
"repo_name",
")",
":",
"path",
"=",
"\"/repos/{u}/{r}/hooks\"",
".",
"format",
"(",
"u",
"=",
"username",
",",
"r",
"=",
"repo_name",
")",
"response",
"=",
"self",
".",
"get",
"(",
... | Returns all hooks of repository with name ``repo_name`` owned by
the user with username ``username``.
:param auth.Authentication auth: authentication object
:param str username: username of owner of repository
:param str repo_name: name of repository
:return: a list of hooks for... | [
"Returns",
"all",
"hooks",
"of",
"repository",
"with",
"name",
"repo_name",
"owned",
"by",
"the",
"user",
"with",
"username",
"username",
"."
] | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/interface.py#L377-L392 |
unfoldingWord-dev/python-gogs-client | gogs_client/interface.py | GogsApi.create_hook | def create_hook(self, auth, repo_name, hook_type, config, events=None, organization=None, active=False):
"""
Creates a new hook, and returns the created hook.
:param auth.Authentication auth: authentication object, must be admin-level
:param str repo_name: the name of the repo for which... | python | def create_hook(self, auth, repo_name, hook_type, config, events=None, organization=None, active=False):
"""
Creates a new hook, and returns the created hook.
:param auth.Authentication auth: authentication object, must be admin-level
:param str repo_name: the name of the repo for which... | [
"def",
"create_hook",
"(",
"self",
",",
"auth",
",",
"repo_name",
",",
"hook_type",
",",
"config",
",",
"events",
"=",
"None",
",",
"organization",
"=",
"None",
",",
"active",
"=",
"False",
")",
":",
"if",
"events",
"is",
"None",
":",
"events",
"=",
... | Creates a new hook, and returns the created hook.
:param auth.Authentication auth: authentication object, must be admin-level
:param str repo_name: the name of the repo for which we create the hook
:param str hook_type: The type of webhook, either "gogs" or "slack"
:param dict config: S... | [
"Creates",
"a",
"new",
"hook",
"and",
"returns",
"the",
"created",
"hook",
"."
] | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/interface.py#L394-L424 |
unfoldingWord-dev/python-gogs-client | gogs_client/interface.py | GogsApi.update_hook | def update_hook(self, auth, repo_name, hook_id, update, organization=None):
"""
Updates hook with id ``hook_id`` according to ``update``.
:param auth.Authentication auth: authentication object
:param str repo_name: repo of the hook to update
:param int hook_id: id of the hook to... | python | def update_hook(self, auth, repo_name, hook_id, update, organization=None):
"""
Updates hook with id ``hook_id`` according to ``update``.
:param auth.Authentication auth: authentication object
:param str repo_name: repo of the hook to update
:param int hook_id: id of the hook to... | [
"def",
"update_hook",
"(",
"self",
",",
"auth",
",",
"repo_name",
",",
"hook_id",
",",
"update",
",",
"organization",
"=",
"None",
")",
":",
"if",
"organization",
"is",
"not",
"None",
":",
"path",
"=",
"\"/repos/{o}/{r}/hooks/{i}\"",
".",
"format",
"(",
"o... | Updates hook with id ``hook_id`` according to ``update``.
:param auth.Authentication auth: authentication object
:param str repo_name: repo of the hook to update
:param int hook_id: id of the hook to update
:param GogsHookUpdate update: a ``GogsHookUpdate`` object describing the request... | [
"Updates",
"hook",
"with",
"id",
"hook_id",
"according",
"to",
"update",
"."
] | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/interface.py#L426-L445 |
unfoldingWord-dev/python-gogs-client | gogs_client/interface.py | GogsApi.delete_hook | def delete_hook(self, auth, username, repo_name, hook_id):
"""
Deletes the hook with id ``hook_id`` for repo with name ``repo_name``
owned by the user with username ``username``.
:param auth.Authentication auth: authentication object
:param str username: username of owner of rep... | python | def delete_hook(self, auth, username, repo_name, hook_id):
"""
Deletes the hook with id ``hook_id`` for repo with name ``repo_name``
owned by the user with username ``username``.
:param auth.Authentication auth: authentication object
:param str username: username of owner of rep... | [
"def",
"delete_hook",
"(",
"self",
",",
"auth",
",",
"username",
",",
"repo_name",
",",
"hook_id",
")",
":",
"path",
"=",
"\"/repos/{u}/{r}/hooks/{i}\"",
".",
"format",
"(",
"u",
"=",
"username",
",",
"r",
"=",
"repo_name",
",",
"i",
"=",
"hook_id",
")",... | Deletes the hook with id ``hook_id`` for repo with name ``repo_name``
owned by the user with username ``username``.
:param auth.Authentication auth: authentication object
:param str username: username of owner of repository
:param str repo_name: name of repository of hook to delete
... | [
"Deletes",
"the",
"hook",
"with",
"id",
"hook_id",
"for",
"repo",
"with",
"name",
"repo_name",
"owned",
"by",
"the",
"user",
"with",
"username",
"username",
"."
] | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/interface.py#L447-L460 |
unfoldingWord-dev/python-gogs-client | gogs_client/interface.py | GogsApi.create_organization | def create_organization(self, auth, owner_name, org_name, full_name=None, description=None,
website=None, location=None):
"""
Creates a new organization, and returns the created organization.
:param auth.Authentication auth: authentication object, must be admin-level... | python | def create_organization(self, auth, owner_name, org_name, full_name=None, description=None,
website=None, location=None):
"""
Creates a new organization, and returns the created organization.
:param auth.Authentication auth: authentication object, must be admin-level... | [
"def",
"create_organization",
"(",
"self",
",",
"auth",
",",
"owner_name",
",",
"org_name",
",",
"full_name",
"=",
"None",
",",
"description",
"=",
"None",
",",
"website",
"=",
"None",
",",
"location",
"=",
"None",
")",
":",
"data",
"=",
"{",
"\"username... | Creates a new organization, and returns the created organization.
:param auth.Authentication auth: authentication object, must be admin-level
:param str owner_name: Username of organization owner
:param str org_name: Organization name
:param str full_name: Full name of organization
... | [
"Creates",
"a",
"new",
"organization",
"and",
"returns",
"the",
"created",
"organization",
"."
] | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/interface.py#L462-L489 |
unfoldingWord-dev/python-gogs-client | gogs_client/interface.py | GogsApi.create_organization_team | def create_organization_team(self, auth, org_name, name, description=None, permission="read"):
"""
Creates a new team of the organization.
:param auth.Authentication auth: authentication object, must be admin-level
:param str org_name: Organization user name
:param str name: Ful... | python | def create_organization_team(self, auth, org_name, name, description=None, permission="read"):
"""
Creates a new team of the organization.
:param auth.Authentication auth: authentication object, must be admin-level
:param str org_name: Organization user name
:param str name: Ful... | [
"def",
"create_organization_team",
"(",
"self",
",",
"auth",
",",
"org_name",
",",
"name",
",",
"description",
"=",
"None",
",",
"permission",
"=",
"\"read\"",
")",
":",
"data",
"=",
"{",
"\"name\"",
":",
"name",
",",
"\"description\"",
":",
"description",
... | Creates a new team of the organization.
:param auth.Authentication auth: authentication object, must be admin-level
:param str org_name: Organization user name
:param str name: Full name of the team
:param str description: Description of the team
:param str permission: Team perm... | [
"Creates",
"a",
"new",
"team",
"of",
"the",
"organization",
"."
] | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/interface.py#L491-L513 |
unfoldingWord-dev/python-gogs-client | gogs_client/interface.py | GogsApi.add_team_membership | def add_team_membership(self, auth, team_id, username):
"""
Add user to team.
:param auth.Authentication auth: authentication object, must be admin-level
:param str team_id: Team's id
:param str username: Username of the user to be added to team
:raises NetworkFailure: i... | python | def add_team_membership(self, auth, team_id, username):
"""
Add user to team.
:param auth.Authentication auth: authentication object, must be admin-level
:param str team_id: Team's id
:param str username: Username of the user to be added to team
:raises NetworkFailure: i... | [
"def",
"add_team_membership",
"(",
"self",
",",
"auth",
",",
"team_id",
",",
"username",
")",
":",
"url",
"=",
"\"/admin/teams/{t}/members/{u}\"",
".",
"format",
"(",
"t",
"=",
"team_id",
",",
"u",
"=",
"username",
")",
"self",
".",
"put",
"(",
"url",
",... | Add user to team.
:param auth.Authentication auth: authentication object, must be admin-level
:param str team_id: Team's id
:param str username: Username of the user to be added to team
:raises NetworkFailure: if there is an error communicating with the server
:raises ApiFailure... | [
"Add",
"user",
"to",
"team",
"."
] | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/interface.py#L515-L526 |
unfoldingWord-dev/python-gogs-client | gogs_client/interface.py | GogsApi.remove_team_membership | def remove_team_membership(self, auth, team_id, username):
"""
Remove user from team.
:param auth.Authentication auth: authentication object, must be admin-level
:param str team_id: Team's id
:param str username: Username of the user to be removed from the team
:raises N... | python | def remove_team_membership(self, auth, team_id, username):
"""
Remove user from team.
:param auth.Authentication auth: authentication object, must be admin-level
:param str team_id: Team's id
:param str username: Username of the user to be removed from the team
:raises N... | [
"def",
"remove_team_membership",
"(",
"self",
",",
"auth",
",",
"team_id",
",",
"username",
")",
":",
"url",
"=",
"\"/admin/teams/{t}/members/{u}\"",
".",
"format",
"(",
"t",
"=",
"team_id",
",",
"u",
"=",
"username",
")",
"self",
".",
"delete",
"(",
"url"... | Remove user from team.
:param auth.Authentication auth: authentication object, must be admin-level
:param str team_id: Team's id
:param str username: Username of the user to be removed from the team
:raises NetworkFailure: if there is an error communicating with the server
:rais... | [
"Remove",
"user",
"from",
"team",
"."
] | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/interface.py#L528-L539 |
unfoldingWord-dev/python-gogs-client | gogs_client/interface.py | GogsApi.add_repo_to_team | def add_repo_to_team(self, auth, team_id, repo_name):
"""
Add or update repo from team.
:param auth.Authentication auth: authentication object, must be admin-level
:param str team_id: Team's id
:param str repo_name: Name of the repo to be added to the team
:raises Networ... | python | def add_repo_to_team(self, auth, team_id, repo_name):
"""
Add or update repo from team.
:param auth.Authentication auth: authentication object, must be admin-level
:param str team_id: Team's id
:param str repo_name: Name of the repo to be added to the team
:raises Networ... | [
"def",
"add_repo_to_team",
"(",
"self",
",",
"auth",
",",
"team_id",
",",
"repo_name",
")",
":",
"url",
"=",
"\"/admin/teams/{t}/repos/{r}\"",
".",
"format",
"(",
"t",
"=",
"team_id",
",",
"r",
"=",
"repo_name",
")",
"self",
".",
"put",
"(",
"url",
",",
... | Add or update repo from team.
:param auth.Authentication auth: authentication object, must be admin-level
:param str team_id: Team's id
:param str repo_name: Name of the repo to be added to the team
:raises NetworkFailure: if there is an error communicating with the server
:rais... | [
"Add",
"or",
"update",
"repo",
"from",
"team",
"."
] | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/interface.py#L541-L552 |
unfoldingWord-dev/python-gogs-client | gogs_client/interface.py | GogsApi.remove_repo_from_team | def remove_repo_from_team(self, auth, team_id, repo_name):
"""
Remove repo from team.
:param auth.Authentication auth: authentication object, must be admin-level
:param str team_id: Team's id
:param str repo_name: Name of the repo to be removed from the team
:raises Netw... | python | def remove_repo_from_team(self, auth, team_id, repo_name):
"""
Remove repo from team.
:param auth.Authentication auth: authentication object, must be admin-level
:param str team_id: Team's id
:param str repo_name: Name of the repo to be removed from the team
:raises Netw... | [
"def",
"remove_repo_from_team",
"(",
"self",
",",
"auth",
",",
"team_id",
",",
"repo_name",
")",
":",
"url",
"=",
"\"/admin/teams/{t}/repos/{r}\"",
".",
"format",
"(",
"t",
"=",
"team_id",
",",
"r",
"=",
"repo_name",
")",
"self",
".",
"delete",
"(",
"url",... | Remove repo from team.
:param auth.Authentication auth: authentication object, must be admin-level
:param str team_id: Team's id
:param str repo_name: Name of the repo to be removed from the team
:raises NetworkFailure: if there is an error communicating with the server
:raises ... | [
"Remove",
"repo",
"from",
"team",
"."
] | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/interface.py#L554-L565 |
unfoldingWord-dev/python-gogs-client | gogs_client/interface.py | GogsApi.list_deploy_keys | def list_deploy_keys(self, auth, username, repo_name):
"""
List deploy keys for the specified repo.
:param auth.Authentication auth: authentication object
:param str username: username of owner of repository
:param str repo_name: the name of the repo
:return: a list of d... | python | def list_deploy_keys(self, auth, username, repo_name):
"""
List deploy keys for the specified repo.
:param auth.Authentication auth: authentication object
:param str username: username of owner of repository
:param str repo_name: the name of the repo
:return: a list of d... | [
"def",
"list_deploy_keys",
"(",
"self",
",",
"auth",
",",
"username",
",",
"repo_name",
")",
":",
"response",
"=",
"self",
".",
"get",
"(",
"\"/repos/{u}/{r}/keys\"",
".",
"format",
"(",
"u",
"=",
"username",
",",
"r",
"=",
"repo_name",
")",
",",
"auth",... | List deploy keys for the specified repo.
:param auth.Authentication auth: authentication object
:param str username: username of owner of repository
:param str repo_name: the name of the repo
:return: a list of deploy keys for the repo
:rtype: List[GogsRepo.DeployKey]
:r... | [
"List",
"deploy",
"keys",
"for",
"the",
"specified",
"repo",
"."
] | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/interface.py#L567-L580 |
unfoldingWord-dev/python-gogs-client | gogs_client/interface.py | GogsApi.get_deploy_key | def get_deploy_key(self, auth, username, repo_name, key_id):
"""
Get a deploy key for the specified repo.
:param auth.Authentication auth: authentication object
:param str username: username of owner of repository
:param str repo_name: the name of the repo
:param int key... | python | def get_deploy_key(self, auth, username, repo_name, key_id):
"""
Get a deploy key for the specified repo.
:param auth.Authentication auth: authentication object
:param str username: username of owner of repository
:param str repo_name: the name of the repo
:param int key... | [
"def",
"get_deploy_key",
"(",
"self",
",",
"auth",
",",
"username",
",",
"repo_name",
",",
"key_id",
")",
":",
"response",
"=",
"self",
".",
"get",
"(",
"\"/repos/{u}/{r}/keys/{k}\"",
".",
"format",
"(",
"u",
"=",
"username",
",",
"r",
"=",
"repo_name",
... | Get a deploy key for the specified repo.
:param auth.Authentication auth: authentication object
:param str username: username of owner of repository
:param str repo_name: the name of the repo
:param int key_id: the id of the key
:return: the deploy key
:rtype: GogsRepo.D... | [
"Get",
"a",
"deploy",
"key",
"for",
"the",
"specified",
"repo",
"."
] | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/interface.py#L582-L596 |
unfoldingWord-dev/python-gogs-client | gogs_client/interface.py | GogsApi.add_deploy_key | def add_deploy_key(self, auth, username, repo_name, title, key_content):
"""
Add a deploy key to the specified repo.
:param auth.Authentication auth: authentication object
:param str username: username of owner of repository
:param str repo_name: the name of the repo
:pa... | python | def add_deploy_key(self, auth, username, repo_name, title, key_content):
"""
Add a deploy key to the specified repo.
:param auth.Authentication auth: authentication object
:param str username: username of owner of repository
:param str repo_name: the name of the repo
:pa... | [
"def",
"add_deploy_key",
"(",
"self",
",",
"auth",
",",
"username",
",",
"repo_name",
",",
"title",
",",
"key_content",
")",
":",
"data",
"=",
"{",
"\"title\"",
":",
"title",
",",
"\"key\"",
":",
"key_content",
"}",
"response",
"=",
"self",
".",
"post",
... | Add a deploy key to the specified repo.
:param auth.Authentication auth: authentication object
:param str username: username of owner of repository
:param str repo_name: the name of the repo
:param str title: title of the key to add
:param str key_content: content of the key to ... | [
"Add",
"a",
"deploy",
"key",
"to",
"the",
"specified",
"repo",
"."
] | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/interface.py#L598-L617 |
unfoldingWord-dev/python-gogs-client | gogs_client/interface.py | GogsApi.delete_deploy_key | def delete_deploy_key(self, auth, username, repo_name, key_id):
"""
Remove deploy key for the specified repo.
:param auth.Authentication auth: authentication object
:param str username: username of owner of repository
:param str repo_name: the name of the repo
:param int... | python | def delete_deploy_key(self, auth, username, repo_name, key_id):
"""
Remove deploy key for the specified repo.
:param auth.Authentication auth: authentication object
:param str username: username of owner of repository
:param str repo_name: the name of the repo
:param int... | [
"def",
"delete_deploy_key",
"(",
"self",
",",
"auth",
",",
"username",
",",
"repo_name",
",",
"key_id",
")",
":",
"self",
".",
"delete",
"(",
"\"/repos/{u}/{r}/keys/{k}\"",
".",
"format",
"(",
"u",
"=",
"username",
",",
"r",
"=",
"repo_name",
",",
"k",
"... | Remove deploy key for the specified repo.
:param auth.Authentication auth: authentication object
:param str username: username of owner of repository
:param str repo_name: the name of the repo
:param int key_id: the id of the key
:raises NetworkFailure: if there is an error comm... | [
"Remove",
"deploy",
"key",
"for",
"the",
"specified",
"repo",
"."
] | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/interface.py#L619-L630 |
unfoldingWord-dev/python-gogs-client | gogs_client/interface.py | GogsApi.delete | def delete(self, path, auth=None, **kwargs):
"""
Manually make a DELETE request.
:param str path: relative url of the request (e.g. `/users/username`)
:param auth.Authentication auth: authentication object
:param kwargs dict: Extra arguments for the request, as supported by the
... | python | def delete(self, path, auth=None, **kwargs):
"""
Manually make a DELETE request.
:param str path: relative url of the request (e.g. `/users/username`)
:param auth.Authentication auth: authentication object
:param kwargs dict: Extra arguments for the request, as supported by the
... | [
"def",
"delete",
"(",
"self",
",",
"path",
",",
"auth",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_check_ok",
"(",
"self",
".",
"_delete",
"(",
"path",
",",
"auth",
"=",
"auth",
",",
"*",
"*",
"kwargs",
")",
")"
] | Manually make a DELETE request.
:param str path: relative url of the request (e.g. `/users/username`)
:param auth.Authentication auth: authentication object
:param kwargs dict: Extra arguments for the request, as supported by the
`requests <http://docs.python-request... | [
"Manually",
"make",
"a",
"DELETE",
"request",
"."
] | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/interface.py#L642-L653 |
unfoldingWord-dev/python-gogs-client | gogs_client/interface.py | GogsApi.get | def get(self, path, auth=None, **kwargs):
"""
Manually make a GET request.
:param str path: relative url of the request (e.g. `/users/username`)
:param auth.Authentication auth: authentication object
:param kwargs dict: Extra arguments for the request, as supported by the
... | python | def get(self, path, auth=None, **kwargs):
"""
Manually make a GET request.
:param str path: relative url of the request (e.g. `/users/username`)
:param auth.Authentication auth: authentication object
:param kwargs dict: Extra arguments for the request, as supported by the
... | [
"def",
"get",
"(",
"self",
",",
"path",
",",
"auth",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_check_ok",
"(",
"self",
".",
"_get",
"(",
"path",
",",
"auth",
"=",
"auth",
",",
"*",
"*",
"kwargs",
")",
")"
] | Manually make a GET request.
:param str path: relative url of the request (e.g. `/users/username`)
:param auth.Authentication auth: authentication object
:param kwargs dict: Extra arguments for the request, as supported by the
`requests <http://docs.python-requests.o... | [
"Manually",
"make",
"a",
"GET",
"request",
"."
] | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/interface.py#L663-L674 |
unfoldingWord-dev/python-gogs-client | gogs_client/interface.py | GogsApi.patch | def patch(self, path, auth=None, **kwargs):
"""
Manually make a PATCH request.
:param str path: relative url of the request (e.g. `/users/username`)
:param auth.Authentication auth: authentication object
:param kwargs dict: Extra arguments for the request, as supported by the
... | python | def patch(self, path, auth=None, **kwargs):
"""
Manually make a PATCH request.
:param str path: relative url of the request (e.g. `/users/username`)
:param auth.Authentication auth: authentication object
:param kwargs dict: Extra arguments for the request, as supported by the
... | [
"def",
"patch",
"(",
"self",
",",
"path",
",",
"auth",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_check_ok",
"(",
"self",
".",
"_patch",
"(",
"path",
",",
"auth",
"=",
"auth",
",",
"*",
"*",
"kwargs",
")",
")"
] | Manually make a PATCH request.
:param str path: relative url of the request (e.g. `/users/username`)
:param auth.Authentication auth: authentication object
:param kwargs dict: Extra arguments for the request, as supported by the
`requests <http://docs.python-requests... | [
"Manually",
"make",
"a",
"PATCH",
"request",
"."
] | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/interface.py#L684-L695 |
unfoldingWord-dev/python-gogs-client | gogs_client/interface.py | GogsApi.post | def post(self, path, auth=None, **kwargs):
"""
Manually make a POST request.
:param str path: relative url of the request (e.g. `/users/username`)
:param auth.Authentication auth: authentication object
:param kwargs dict: Extra arguments for the request, as supported by the
... | python | def post(self, path, auth=None, **kwargs):
"""
Manually make a POST request.
:param str path: relative url of the request (e.g. `/users/username`)
:param auth.Authentication auth: authentication object
:param kwargs dict: Extra arguments for the request, as supported by the
... | [
"def",
"post",
"(",
"self",
",",
"path",
",",
"auth",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_check_ok",
"(",
"self",
".",
"_post",
"(",
"path",
",",
"auth",
"=",
"auth",
",",
"*",
"*",
"kwargs",
")",
")"
] | Manually make a POST request.
:param str path: relative url of the request (e.g. `/users/username`)
:param auth.Authentication auth: authentication object
:param kwargs dict: Extra arguments for the request, as supported by the
`requests <http://docs.python-requests.... | [
"Manually",
"make",
"a",
"POST",
"request",
"."
] | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/interface.py#L705-L716 |
unfoldingWord-dev/python-gogs-client | gogs_client/interface.py | GogsApi.put | def put(self, path, auth=None, **kwargs):
"""
Manually make a PUT request.
:param str path: relative url of the request (e.g. `/users/username`)
:param auth.Authentication auth: authentication object
:param kwargs dict: Extra arguments for the request, as supported by the
... | python | def put(self, path, auth=None, **kwargs):
"""
Manually make a PUT request.
:param str path: relative url of the request (e.g. `/users/username`)
:param auth.Authentication auth: authentication object
:param kwargs dict: Extra arguments for the request, as supported by the
... | [
"def",
"put",
"(",
"self",
",",
"path",
",",
"auth",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_check_ok",
"(",
"self",
".",
"_put",
"(",
"path",
",",
"auth",
"=",
"auth",
",",
"*",
"*",
"kwargs",
")",
")"
] | Manually make a PUT request.
:param str path: relative url of the request (e.g. `/users/username`)
:param auth.Authentication auth: authentication object
:param kwargs dict: Extra arguments for the request, as supported by the
`requests <http://docs.python-requests.o... | [
"Manually",
"make",
"a",
"PUT",
"request",
"."
] | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/interface.py#L726-L737 |
unfoldingWord-dev/python-gogs-client | gogs_client/interface.py | GogsApi._fail | def _fail(response):
"""
Raise an ApiFailure pertaining to the given response
"""
message = "Status code: {}-{}, url: {}".format(response.status_code, response.reason, response.url)
try:
message += ", message:{}".format(response.json()["message"])
except (Valu... | python | def _fail(response):
"""
Raise an ApiFailure pertaining to the given response
"""
message = "Status code: {}-{}, url: {}".format(response.status_code, response.reason, response.url)
try:
message += ", message:{}".format(response.json()["message"])
except (Valu... | [
"def",
"_fail",
"(",
"response",
")",
":",
"message",
"=",
"\"Status code: {}-{}, url: {}\"",
".",
"format",
"(",
"response",
".",
"status_code",
",",
"response",
".",
"reason",
",",
"response",
".",
"url",
")",
"try",
":",
"message",
"+=",
"\", message:{}\"",... | Raise an ApiFailure pertaining to the given response | [
"Raise",
"an",
"ApiFailure",
"pertaining",
"to",
"the",
"given",
"response"
] | train | https://github.com/unfoldingWord-dev/python-gogs-client/blob/b7f27f4995abf914c0db8a424760f5b27331939d/gogs_client/interface.py#L749-L758 |
LordGaav/python-chaos | chaos/threading/scheduler.py | Scheduler.setStartAction | def setStartAction(self, action, *args, **kwargs):
"""
Set a function to call when run() is called, before the main action is called.
Parameters
----------
action: function pointer
The function to call.
*args
Positional arguments to pass to action.
**kwargs:
Keyword arguments to pass to action.
... | python | def setStartAction(self, action, *args, **kwargs):
"""
Set a function to call when run() is called, before the main action is called.
Parameters
----------
action: function pointer
The function to call.
*args
Positional arguments to pass to action.
**kwargs:
Keyword arguments to pass to action.
... | [
"def",
"setStartAction",
"(",
"self",
",",
"action",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"init_action",
"=",
"action",
"self",
".",
"init_args",
"=",
"args",
"self",
".",
"init_kwargs",
"=",
"kwargs"
] | Set a function to call when run() is called, before the main action is called.
Parameters
----------
action: function pointer
The function to call.
*args
Positional arguments to pass to action.
**kwargs:
Keyword arguments to pass to action. | [
"Set",
"a",
"function",
"to",
"call",
"when",
"run",
"()",
"is",
"called",
"before",
"the",
"main",
"action",
"is",
"called",
"."
] | train | https://github.com/LordGaav/python-chaos/blob/52cd29a6fd15693ee1e53786b93bcb23fbf84ddd/chaos/threading/scheduler.py#L72-L88 |
LordGaav/python-chaos | chaos/threading/scheduler.py | Scheduler.setStopAction | def setStopAction(self, action, *args, **kwargs):
"""
Set a function to call when run() is stopping, after the main action is called.
Parameters
----------
action: function pointer
The function to call.
*args
Positional arguments to pass to action.
**kwargs:
Keyword arguments to pass to action.
... | python | def setStopAction(self, action, *args, **kwargs):
"""
Set a function to call when run() is stopping, after the main action is called.
Parameters
----------
action: function pointer
The function to call.
*args
Positional arguments to pass to action.
**kwargs:
Keyword arguments to pass to action.
... | [
"def",
"setStopAction",
"(",
"self",
",",
"action",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"stop_action",
"=",
"action",
"self",
".",
"stop_args",
"=",
"args",
"self",
".",
"stop_kwargs",
"=",
"kwargs"
] | Set a function to call when run() is stopping, after the main action is called.
Parameters
----------
action: function pointer
The function to call.
*args
Positional arguments to pass to action.
**kwargs:
Keyword arguments to pass to action. | [
"Set",
"a",
"function",
"to",
"call",
"when",
"run",
"()",
"is",
"stopping",
"after",
"the",
"main",
"action",
"is",
"called",
"."
] | train | https://github.com/LordGaav/python-chaos/blob/52cd29a6fd15693ee1e53786b93bcb23fbf84ddd/chaos/threading/scheduler.py#L90-L105 |
LordGaav/python-chaos | chaos/threading/scheduler.py | Scheduler.run | def run(self):
"""
Calls the defined action every $interval seconds. Optionally calls an action before
the main loop, and an action when stopping, if these are defined.
Exceptions in the main loop will NOT cause the thread to die.
"""
self.logger.debug("Thread {0} is entering main loop".format(self.name))
... | python | def run(self):
"""
Calls the defined action every $interval seconds. Optionally calls an action before
the main loop, and an action when stopping, if these are defined.
Exceptions in the main loop will NOT cause the thread to die.
"""
self.logger.debug("Thread {0} is entering main loop".format(self.name))
... | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"Thread {0} is entering main loop\"",
".",
"format",
"(",
"self",
".",
"name",
")",
")",
"if",
"hasattr",
"(",
"self",
",",
"\"init_action\"",
")",
":",
"self",
".",
"logger... | Calls the defined action every $interval seconds. Optionally calls an action before
the main loop, and an action when stopping, if these are defined.
Exceptions in the main loop will NOT cause the thread to die. | [
"Calls",
"the",
"defined",
"action",
"every",
"$interval",
"seconds",
".",
"Optionally",
"calls",
"an",
"action",
"before",
"the",
"main",
"loop",
"and",
"an",
"action",
"when",
"stopping",
"if",
"these",
"are",
"defined",
"."
] | train | https://github.com/LordGaav/python-chaos/blob/52cd29a6fd15693ee1e53786b93bcb23fbf84ddd/chaos/threading/scheduler.py#L107-L137 |
peterldowns/lggr | lggr/__init__.py | Printer | def Printer(open_file=sys.stdout, closing=False):
""" Prints items with a timestamp. """
try:
while True:
logstr = (yield)
open_file.write(logstr)
open_file.write('\n') # new line
except GeneratorExit:
if closing:
try: open_file.close()
... | python | def Printer(open_file=sys.stdout, closing=False):
""" Prints items with a timestamp. """
try:
while True:
logstr = (yield)
open_file.write(logstr)
open_file.write('\n') # new line
except GeneratorExit:
if closing:
try: open_file.close()
... | [
"def",
"Printer",
"(",
"open_file",
"=",
"sys",
".",
"stdout",
",",
"closing",
"=",
"False",
")",
":",
"try",
":",
"while",
"True",
":",
"logstr",
"=",
"(",
"yield",
")",
"open_file",
".",
"write",
"(",
"logstr",
")",
"open_file",
".",
"write",
"(",
... | Prints items with a timestamp. | [
"Prints",
"items",
"with",
"a",
"timestamp",
"."
] | train | https://github.com/peterldowns/lggr/blob/622968f17133e02d9a46a4900dd20fb3b19fe961/lggr/__init__.py#L322-L332 |
peterldowns/lggr | lggr/__init__.py | FilePrinter | def FilePrinter(filename, mode='a', closing=True):
path = os.path.abspath(os.path.expanduser(filename))
""" Opens the given file and returns a printer to it. """
f = open(path, mode)
return Printer(f, closing) | python | def FilePrinter(filename, mode='a', closing=True):
path = os.path.abspath(os.path.expanduser(filename))
""" Opens the given file and returns a printer to it. """
f = open(path, mode)
return Printer(f, closing) | [
"def",
"FilePrinter",
"(",
"filename",
",",
"mode",
"=",
"'a'",
",",
"closing",
"=",
"True",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"expanduser",
"(",
"filename",
")",
")",
"f",
"=",
"open",
"(",
"p... | Opens the given file and returns a printer to it. | [
"Opens",
"the",
"given",
"file",
"and",
"returns",
"a",
"printer",
"to",
"it",
"."
] | train | https://github.com/peterldowns/lggr/blob/622968f17133e02d9a46a4900dd20fb3b19fe961/lggr/__init__.py#L338-L342 |
peterldowns/lggr | lggr/__init__.py | SocketWriter | def SocketWriter(host, port, af=None, st=None):
""" Writes messages to a socket/host. """
import socket
if af is None:
af = socket.AF_INET
if st is None:
st = socket.SOCK_STREAM
message = '({0}): {1}'
s = socket.socket(af, st)
s.connect(host, port)
try:
while True... | python | def SocketWriter(host, port, af=None, st=None):
""" Writes messages to a socket/host. """
import socket
if af is None:
af = socket.AF_INET
if st is None:
st = socket.SOCK_STREAM
message = '({0}): {1}'
s = socket.socket(af, st)
s.connect(host, port)
try:
while True... | [
"def",
"SocketWriter",
"(",
"host",
",",
"port",
",",
"af",
"=",
"None",
",",
"st",
"=",
"None",
")",
":",
"import",
"socket",
"if",
"af",
"is",
"None",
":",
"af",
"=",
"socket",
".",
"AF_INET",
"if",
"st",
"is",
"None",
":",
"st",
"=",
"socket",... | Writes messages to a socket/host. | [
"Writes",
"messages",
"to",
"a",
"socket",
"/",
"host",
"."
] | train | https://github.com/peterldowns/lggr/blob/622968f17133e02d9a46a4900dd20fb3b19fe961/lggr/__init__.py#L345-L360 |
peterldowns/lggr | lggr/__init__.py | Emailer | def Emailer(recipients, sender=None):
""" Sends messages as emails to the given list
of recipients. """
import smtplib
hostname = socket.gethostname()
if not sender:
sender = 'lggr@{0}'.format(hostname)
smtp = smtplib.SMTP('localhost')
try:
while True:
logstr ... | python | def Emailer(recipients, sender=None):
""" Sends messages as emails to the given list
of recipients. """
import smtplib
hostname = socket.gethostname()
if not sender:
sender = 'lggr@{0}'.format(hostname)
smtp = smtplib.SMTP('localhost')
try:
while True:
logstr ... | [
"def",
"Emailer",
"(",
"recipients",
",",
"sender",
"=",
"None",
")",
":",
"import",
"smtplib",
"hostname",
"=",
"socket",
".",
"gethostname",
"(",
")",
"if",
"not",
"sender",
":",
"sender",
"=",
"'lggr@{0}'",
".",
"format",
"(",
"hostname",
")",
"smtp",... | Sends messages as emails to the given list
of recipients. | [
"Sends",
"messages",
"as",
"emails",
"to",
"the",
"given",
"list",
"of",
"recipients",
"."
] | train | https://github.com/peterldowns/lggr/blob/622968f17133e02d9a46a4900dd20fb3b19fe961/lggr/__init__.py#L363-L379 |
peterldowns/lggr | lggr/__init__.py | GMailer | def GMailer(recipients, username, password, subject='Log message from lggr.py'):
""" Sends messages as emails to the given list
of recipients, from a GMail account. """
import smtplib
srvr = smtplib.SMTP('smtp.gmail.com', 587)
srvr.ehlo()
srvr.starttls()
srvr.ehlo()
srvr.login(userna... | python | def GMailer(recipients, username, password, subject='Log message from lggr.py'):
""" Sends messages as emails to the given list
of recipients, from a GMail account. """
import smtplib
srvr = smtplib.SMTP('smtp.gmail.com', 587)
srvr.ehlo()
srvr.starttls()
srvr.ehlo()
srvr.login(userna... | [
"def",
"GMailer",
"(",
"recipients",
",",
"username",
",",
"password",
",",
"subject",
"=",
"'Log message from lggr.py'",
")",
":",
"import",
"smtplib",
"srvr",
"=",
"smtplib",
".",
"SMTP",
"(",
"'smtp.gmail.com'",
",",
"587",
")",
"srvr",
".",
"ehlo",
"(",
... | Sends messages as emails to the given list
of recipients, from a GMail account. | [
"Sends",
"messages",
"as",
"emails",
"to",
"the",
"given",
"list",
"of",
"recipients",
"from",
"a",
"GMail",
"account",
"."
] | train | https://github.com/peterldowns/lggr/blob/622968f17133e02d9a46a4900dd20fb3b19fe961/lggr/__init__.py#L382-L407 |
peterldowns/lggr | lggr/__init__.py | Lggr.add | def add(self, levels, logger):
""" Given a list or tuple of logging levels,
add a logger instance to each. """
if isinstance(levels, (list, tuple)):
for lvl in levels:
self.config[lvl].add(logger)
else:
self.config[levels].add(logger) | python | def add(self, levels, logger):
""" Given a list or tuple of logging levels,
add a logger instance to each. """
if isinstance(levels, (list, tuple)):
for lvl in levels:
self.config[lvl].add(logger)
else:
self.config[levels].add(logger) | [
"def",
"add",
"(",
"self",
",",
"levels",
",",
"logger",
")",
":",
"if",
"isinstance",
"(",
"levels",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"for",
"lvl",
"in",
"levels",
":",
"self",
".",
"config",
"[",
"lvl",
"]",
".",
"add",
"(",
"lo... | Given a list or tuple of logging levels,
add a logger instance to each. | [
"Given",
"a",
"list",
"or",
"tuple",
"of",
"logging",
"levels",
"add",
"a",
"logger",
"instance",
"to",
"each",
"."
] | train | https://github.com/peterldowns/lggr/blob/622968f17133e02d9a46a4900dd20fb3b19fe961/lggr/__init__.py#L84-L91 |
peterldowns/lggr | lggr/__init__.py | Lggr.remove | def remove(self, level, logger):
""" Given a level, remove a given logger function
if it is a member of that level, closing the logger
function either way."""
self.config[level].discard(logger)
logger.close() | python | def remove(self, level, logger):
""" Given a level, remove a given logger function
if it is a member of that level, closing the logger
function either way."""
self.config[level].discard(logger)
logger.close() | [
"def",
"remove",
"(",
"self",
",",
"level",
",",
"logger",
")",
":",
"self",
".",
"config",
"[",
"level",
"]",
".",
"discard",
"(",
"logger",
")",
"logger",
".",
"close",
"(",
")"
] | Given a level, remove a given logger function
if it is a member of that level, closing the logger
function either way. | [
"Given",
"a",
"level",
"remove",
"a",
"given",
"logger",
"function",
"if",
"it",
"is",
"a",
"member",
"of",
"that",
"level",
"closing",
"the",
"logger",
"function",
"either",
"way",
"."
] | train | https://github.com/peterldowns/lggr/blob/622968f17133e02d9a46a4900dd20fb3b19fe961/lggr/__init__.py#L93-L98 |
peterldowns/lggr | lggr/__init__.py | Lggr.clear | def clear(self, level):
""" Remove all logger functions from a given level. """
for item in self.config[level]:
item.close()
self.config[level].clear() | python | def clear(self, level):
""" Remove all logger functions from a given level. """
for item in self.config[level]:
item.close()
self.config[level].clear() | [
"def",
"clear",
"(",
"self",
",",
"level",
")",
":",
"for",
"item",
"in",
"self",
".",
"config",
"[",
"level",
"]",
":",
"item",
".",
"close",
"(",
")",
"self",
".",
"config",
"[",
"level",
"]",
".",
"clear",
"(",
")"
] | Remove all logger functions from a given level. | [
"Remove",
"all",
"logger",
"functions",
"from",
"a",
"given",
"level",
"."
] | train | https://github.com/peterldowns/lggr/blob/622968f17133e02d9a46a4900dd20fb3b19fe961/lggr/__init__.py#L100-L104 |
peterldowns/lggr | lggr/__init__.py | Lggr._make_record | def _make_record(self,
level,
fmt,
args,
extra,
exc_info,
inc_stackinfo,
inc_multiproc):
""" Create a 'record' (a dictionary) with information to be logged. """
... | python | def _make_record(self,
level,
fmt,
args,
extra,
exc_info,
inc_stackinfo,
inc_multiproc):
""" Create a 'record' (a dictionary) with information to be logged. """
... | [
"def",
"_make_record",
"(",
"self",
",",
"level",
",",
"fmt",
",",
"args",
",",
"extra",
",",
"exc_info",
",",
"inc_stackinfo",
",",
"inc_multiproc",
")",
":",
"fn",
"=",
"fname",
"=",
"'(unknown file)'",
"lno",
"=",
"0",
"func",
"=",
"'(unknown function)'... | Create a 'record' (a dictionary) with information to be logged. | [
"Create",
"a",
"record",
"(",
"a",
"dictionary",
")",
"with",
"information",
"to",
"be",
"logged",
"."
] | train | https://github.com/peterldowns/lggr/blob/622968f17133e02d9a46a4900dd20fb3b19fe961/lggr/__init__.py#L106-L199 |
peterldowns/lggr | lggr/__init__.py | Lggr._log | def _log(self,
level,
fmt,
args=None,
extra=None,
exc_info=None,
inc_stackinfo=False,
inc_multiproc=False):
""" Send a log message to all of the logging functions
for a given level as well as adding the
... | python | def _log(self,
level,
fmt,
args=None,
extra=None,
exc_info=None,
inc_stackinfo=False,
inc_multiproc=False):
""" Send a log message to all of the logging functions
for a given level as well as adding the
... | [
"def",
"_log",
"(",
"self",
",",
"level",
",",
"fmt",
",",
"args",
"=",
"None",
",",
"extra",
"=",
"None",
",",
"exc_info",
"=",
"None",
",",
"inc_stackinfo",
"=",
"False",
",",
"inc_multiproc",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"en... | Send a log message to all of the logging functions
for a given level as well as adding the
message to this logger instance's history. | [
"Send",
"a",
"log",
"message",
"to",
"all",
"of",
"the",
"logging",
"functions",
"for",
"a",
"given",
"level",
"as",
"well",
"as",
"adding",
"the",
"message",
"to",
"this",
"logger",
"instance",
"s",
"history",
"."
] | train | https://github.com/peterldowns/lggr/blob/622968f17133e02d9a46a4900dd20fb3b19fe961/lggr/__init__.py#L201-L234 |
peterldowns/lggr | lggr/__init__.py | Lggr.log | def log(self, *args, **kwargs):
""" Do logging, but handle error suppression. """
if self.suppress_errors:
try:
self._log(*args, **kwargs)
return True
except:
return False
else:
self._log(*args, **kwargs)
... | python | def log(self, *args, **kwargs):
""" Do logging, but handle error suppression. """
if self.suppress_errors:
try:
self._log(*args, **kwargs)
return True
except:
return False
else:
self._log(*args, **kwargs)
... | [
"def",
"log",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"suppress_errors",
":",
"try",
":",
"self",
".",
"_log",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"return",
"True",
"except",
":",
"return",... | Do logging, but handle error suppression. | [
"Do",
"logging",
"but",
"handle",
"error",
"suppression",
"."
] | train | https://github.com/peterldowns/lggr/blob/622968f17133e02d9a46a4900dd20fb3b19fe961/lggr/__init__.py#L236-L246 |
peterldowns/lggr | lggr/__init__.py | Lggr.debug | def debug(self, msg, *args, **kwargs):
""" Log a message with DEBUG level. Automatically includes stack info
unless it is specifically not included. """
kwargs.setdefault('inc_stackinfo', True)
self.log(DEBUG, msg, args, **kwargs) | python | def debug(self, msg, *args, **kwargs):
""" Log a message with DEBUG level. Automatically includes stack info
unless it is specifically not included. """
kwargs.setdefault('inc_stackinfo', True)
self.log(DEBUG, msg, args, **kwargs) | [
"def",
"debug",
"(",
"self",
",",
"msg",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'inc_stackinfo'",
",",
"True",
")",
"self",
".",
"log",
"(",
"DEBUG",
",",
"msg",
",",
"args",
",",
"*",
"*",
"kwargs... | Log a message with DEBUG level. Automatically includes stack info
unless it is specifically not included. | [
"Log",
"a",
"message",
"with",
"DEBUG",
"level",
".",
"Automatically",
"includes",
"stack",
"info",
"unless",
"it",
"is",
"specifically",
"not",
"included",
"."
] | train | https://github.com/peterldowns/lggr/blob/622968f17133e02d9a46a4900dd20fb3b19fe961/lggr/__init__.py#L257-L261 |
peterldowns/lggr | lggr/__init__.py | Lggr.error | def error(self, msg, *args, **kwargs):
""" Log a message with ERROR level. Automatically includes stack and
process info unless they are specifically not included. """
kwargs.setdefault('inc_stackinfo', True)
kwargs.setdefault('inc_multiproc', True)
self.log(ERROR, msg, args, **k... | python | def error(self, msg, *args, **kwargs):
""" Log a message with ERROR level. Automatically includes stack and
process info unless they are specifically not included. """
kwargs.setdefault('inc_stackinfo', True)
kwargs.setdefault('inc_multiproc', True)
self.log(ERROR, msg, args, **k... | [
"def",
"error",
"(",
"self",
",",
"msg",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'inc_stackinfo'",
",",
"True",
")",
"kwargs",
".",
"setdefault",
"(",
"'inc_multiproc'",
",",
"True",
")",
"self",
".",
"... | Log a message with ERROR level. Automatically includes stack and
process info unless they are specifically not included. | [
"Log",
"a",
"message",
"with",
"ERROR",
"level",
".",
"Automatically",
"includes",
"stack",
"and",
"process",
"info",
"unless",
"they",
"are",
"specifically",
"not",
"included",
"."
] | train | https://github.com/peterldowns/lggr/blob/622968f17133e02d9a46a4900dd20fb3b19fe961/lggr/__init__.py#L263-L268 |
peterldowns/lggr | lggr/__init__.py | Lggr.critical | def critical(self, msg, *args, **kwargs):
""" Log a message with CRITICAL level. Automatically includes stack and
process info unless they are specifically not included. """
kwargs.setdefault('inc_stackinfo', True)
kwargs.setdefault('inc_multiproc', True)
self.log(CRITICAL, msg, ... | python | def critical(self, msg, *args, **kwargs):
""" Log a message with CRITICAL level. Automatically includes stack and
process info unless they are specifically not included. """
kwargs.setdefault('inc_stackinfo', True)
kwargs.setdefault('inc_multiproc', True)
self.log(CRITICAL, msg, ... | [
"def",
"critical",
"(",
"self",
",",
"msg",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'inc_stackinfo'",
",",
"True",
")",
"kwargs",
".",
"setdefault",
"(",
"'inc_multiproc'",
",",
"True",
")",
"self",
".",
... | Log a message with CRITICAL level. Automatically includes stack and
process info unless they are specifically not included. | [
"Log",
"a",
"message",
"with",
"CRITICAL",
"level",
".",
"Automatically",
"includes",
"stack",
"and",
"process",
"info",
"unless",
"they",
"are",
"specifically",
"not",
"included",
"."
] | train | https://github.com/peterldowns/lggr/blob/622968f17133e02d9a46a4900dd20fb3b19fe961/lggr/__init__.py#L270-L275 |
peterldowns/lggr | lggr/__init__.py | Lggr.multi | def multi(self, lvl_list, msg, *args, **kwargs):
""" Log a message at multiple levels"""
for level in lvl_list:
self.log(level, msg, args, **kwargs) | python | def multi(self, lvl_list, msg, *args, **kwargs):
""" Log a message at multiple levels"""
for level in lvl_list:
self.log(level, msg, args, **kwargs) | [
"def",
"multi",
"(",
"self",
",",
"lvl_list",
",",
"msg",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"level",
"in",
"lvl_list",
":",
"self",
".",
"log",
"(",
"level",
",",
"msg",
",",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Log a message at multiple levels | [
"Log",
"a",
"message",
"at",
"multiple",
"levels"
] | train | https://github.com/peterldowns/lggr/blob/622968f17133e02d9a46a4900dd20fb3b19fe961/lggr/__init__.py#L277-L280 |
peterldowns/lggr | lggr/__init__.py | Lggr.all | def all(self, msg, *args, **kwargs):
""" Log a message at every known log level """
self.multi(ALL, msg, args, **kwargs) | python | def all(self, msg, *args, **kwargs):
""" Log a message at every known log level """
self.multi(ALL, msg, args, **kwargs) | [
"def",
"all",
"(",
"self",
",",
"msg",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"multi",
"(",
"ALL",
",",
"msg",
",",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Log a message at every known log level | [
"Log",
"a",
"message",
"at",
"every",
"known",
"log",
"level"
] | train | https://github.com/peterldowns/lggr/blob/622968f17133e02d9a46a4900dd20fb3b19fe961/lggr/__init__.py#L282-L284 |
peterldowns/lggr | lggr/__init__.py | Lggr._find_caller | def _find_caller(self):
"""
Find the stack frame of the caller so that we can note the source file
name, line number, and function name.
"""
rv = ('(unknown file)',
0,
'(unknown function)',
'(code not available)',
[],
... | python | def _find_caller(self):
"""
Find the stack frame of the caller so that we can note the source file
name, line number, and function name.
"""
rv = ('(unknown file)',
0,
'(unknown function)',
'(code not available)',
[],
... | [
"def",
"_find_caller",
"(",
"self",
")",
":",
"rv",
"=",
"(",
"'(unknown file)'",
",",
"0",
",",
"'(unknown function)'",
",",
"'(code not available)'",
",",
"[",
"]",
",",
"None",
")",
"f",
"=",
"inspect",
".",
"currentframe",
"(",
")",
"while",
"hasattr",... | Find the stack frame of the caller so that we can note the source file
name, line number, and function name. | [
"Find",
"the",
"stack",
"frame",
"of",
"the",
"caller",
"so",
"that",
"we",
"can",
"note",
"the",
"source",
"file",
"name",
"line",
"number",
"and",
"function",
"name",
"."
] | train | https://github.com/peterldowns/lggr/blob/622968f17133e02d9a46a4900dd20fb3b19fe961/lggr/__init__.py#L286-L319 |
jakewins/neo4jdb-python | neo4j/cursor.py | Cursor._map_value | def _map_value(self, value):
''' Maps a raw deserialized row to proper types '''
# TODO: Once we've gotten here, we've done the following:
# -> Recieve the full response, copy it from network buffer it into a ByteBuffer (copy 1)
# -> Copy all the data into a String (copy 2)
# -> ... | python | def _map_value(self, value):
''' Maps a raw deserialized row to proper types '''
# TODO: Once we've gotten here, we've done the following:
# -> Recieve the full response, copy it from network buffer it into a ByteBuffer (copy 1)
# -> Copy all the data into a String (copy 2)
# -> ... | [
"def",
"_map_value",
"(",
"self",
",",
"value",
")",
":",
"# TODO: Once we've gotten here, we've done the following:",
"# -> Recieve the full response, copy it from network buffer it into a ByteBuffer (copy 1)",
"# -> Copy all the data into a String (copy 2)",
"# -> Deserialize that string (co... | Maps a raw deserialized row to proper types | [
"Maps",
"a",
"raw",
"deserialized",
"row",
"to",
"proper",
"types"
] | train | https://github.com/jakewins/neo4jdb-python/blob/cd78cb8397885f219500fb1080d301f0c900f7be/neo4j/cursor.py#L123-L149 |
jeremymcrae/denovonear | denovonear/load_gene.py | get_deprecated_gene_ids | def get_deprecated_gene_ids(filename):
""" gets a dict of the gene IDs used during in DDD datasets that have been
deprecated in favour of other gene IDs
"""
deprecated = {}
with open(filename) as handle:
for line in handle:
line = line.strip().split()
old = line[... | python | def get_deprecated_gene_ids(filename):
""" gets a dict of the gene IDs used during in DDD datasets that have been
deprecated in favour of other gene IDs
"""
deprecated = {}
with open(filename) as handle:
for line in handle:
line = line.strip().split()
old = line[... | [
"def",
"get_deprecated_gene_ids",
"(",
"filename",
")",
":",
"deprecated",
"=",
"{",
"}",
"with",
"open",
"(",
"filename",
")",
"as",
"handle",
":",
"for",
"line",
"in",
"handle",
":",
"line",
"=",
"line",
".",
"strip",
"(",
")",
".",
"split",
"(",
"... | gets a dict of the gene IDs used during in DDD datasets that have been
deprecated in favour of other gene IDs | [
"gets",
"a",
"dict",
"of",
"the",
"gene",
"IDs",
"used",
"during",
"in",
"DDD",
"datasets",
"that",
"have",
"been",
"deprecated",
"in",
"favour",
"of",
"other",
"gene",
"IDs"
] | train | https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/denovonear/load_gene.py#L7-L20 |
jeremymcrae/denovonear | denovonear/load_gene.py | get_transcript_lengths | def get_transcript_lengths(ensembl, transcript_ids):
""" finds the protein length for ensembl transcript IDs for a gene
Args:
ensembl: EnsemblRequest object to request sequences and data
from the ensembl REST API
transcript_ids: list of transcript IDs for a single gene
... | python | def get_transcript_lengths(ensembl, transcript_ids):
""" finds the protein length for ensembl transcript IDs for a gene
Args:
ensembl: EnsemblRequest object to request sequences and data
from the ensembl REST API
transcript_ids: list of transcript IDs for a single gene
... | [
"def",
"get_transcript_lengths",
"(",
"ensembl",
",",
"transcript_ids",
")",
":",
"transcripts",
"=",
"{",
"}",
"for",
"transcript_id",
"in",
"transcript_ids",
":",
"# get the transcript's protein sequence via the ensembl REST API",
"try",
":",
"seq",
"=",
"ensembl",
".... | finds the protein length for ensembl transcript IDs for a gene
Args:
ensembl: EnsemblRequest object to request sequences and data
from the ensembl REST API
transcript_ids: list of transcript IDs for a single gene
Returns:
dictionary of lengths (in amino acids), inde... | [
"finds",
"the",
"protein",
"length",
"for",
"ensembl",
"transcript",
"IDs",
"for",
"a",
"gene",
"Args",
":",
"ensembl",
":",
"EnsemblRequest",
"object",
"to",
"request",
"sequences",
"and",
"data",
"from",
"the",
"ensembl",
"REST",
"API",
"transcript_ids",
":"... | train | https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/denovonear/load_gene.py#L22-L44 |
jeremymcrae/denovonear | denovonear/load_gene.py | construct_gene_object | def construct_gene_object(ensembl, transcript_id):
""" creates an Transcript object for a gene from ensembl databases
Args:
ensembl: EnsemblRequest object to request data from ensembl
transcript_id: string for an Ensembl transcript ID
Returns:
a Transcript object, containin... | python | def construct_gene_object(ensembl, transcript_id):
""" creates an Transcript object for a gene from ensembl databases
Args:
ensembl: EnsemblRequest object to request data from ensembl
transcript_id: string for an Ensembl transcript ID
Returns:
a Transcript object, containin... | [
"def",
"construct_gene_object",
"(",
"ensembl",
",",
"transcript_id",
")",
":",
"# get the sequence for the identified transcript",
"(",
"chrom",
",",
"start",
",",
"end",
",",
"strand",
",",
"genomic_sequence",
")",
"=",
"ensembl",
".",
"get_genomic_seq_for_transcript"... | creates an Transcript object for a gene from ensembl databases
Args:
ensembl: EnsemblRequest object to request data from ensembl
transcript_id: string for an Ensembl transcript ID
Returns:
a Transcript object, containing transcript coordinates and gene and
transcript se... | [
"creates",
"an",
"Transcript",
"object",
"for",
"a",
"gene",
"from",
"ensembl",
"databases",
"Args",
":",
"ensembl",
":",
"EnsemblRequest",
"object",
"to",
"request",
"data",
"from",
"ensembl",
"transcript_id",
":",
"string",
"for",
"an",
"Ensembl",
"transcript"... | train | https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/denovonear/load_gene.py#L46-L78 |
jeremymcrae/denovonear | denovonear/load_gene.py | get_de_novos_in_transcript | def get_de_novos_in_transcript(transcript, de_novos):
""" get the de novos within the coding sequence of a transcript
Args:
transcript: Transcript object, which defines the transcript coordinates
de_novos: list of chromosome sequence positions for de novo events
Returns:
li... | python | def get_de_novos_in_transcript(transcript, de_novos):
""" get the de novos within the coding sequence of a transcript
Args:
transcript: Transcript object, which defines the transcript coordinates
de_novos: list of chromosome sequence positions for de novo events
Returns:
li... | [
"def",
"get_de_novos_in_transcript",
"(",
"transcript",
",",
"de_novos",
")",
":",
"in_transcript",
"=",
"[",
"]",
"for",
"de_novo",
"in",
"de_novos",
":",
"# we check if the de novo is within the transcript by converting the",
"# chromosomal position to a CDS-based position. Var... | get the de novos within the coding sequence of a transcript
Args:
transcript: Transcript object, which defines the transcript coordinates
de_novos: list of chromosome sequence positions for de novo events
Returns:
list of de novo positions found within the transcript | [
"get",
"the",
"de",
"novos",
"within",
"the",
"coding",
"sequence",
"of",
"a",
"transcript",
"Args",
":",
"transcript",
":",
"Transcript",
"object",
"which",
"defines",
"the",
"transcript",
"coordinates",
"de_novos",
":",
"list",
"of",
"chromosome",
"sequence",
... | train | https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/denovonear/load_gene.py#L80-L104 |
jeremymcrae/denovonear | denovonear/load_gene.py | get_transcript_ids | def get_transcript_ids(ensembl, gene_id):
""" gets transcript IDs for a gene.
Args:
ensembl: EnsemblRequest object to request data from ensembl
gene_id: HGNC symbol for gene
Returns:
dictionary of transcript ID: transcript lengths for all transcripts
for a given HGN... | python | def get_transcript_ids(ensembl, gene_id):
""" gets transcript IDs for a gene.
Args:
ensembl: EnsemblRequest object to request data from ensembl
gene_id: HGNC symbol for gene
Returns:
dictionary of transcript ID: transcript lengths for all transcripts
for a given HGN... | [
"def",
"get_transcript_ids",
"(",
"ensembl",
",",
"gene_id",
")",
":",
"ensembl_genes",
"=",
"ensembl",
".",
"get_genes_for_hgnc_id",
"(",
"gene_id",
")",
"transcript_ids",
"=",
"ensembl",
".",
"get_transcript_ids_for_ensembl_gene_ids",
"(",
"ensembl_genes",
",",
"[",... | gets transcript IDs for a gene.
Args:
ensembl: EnsemblRequest object to request data from ensembl
gene_id: HGNC symbol for gene
Returns:
dictionary of transcript ID: transcript lengths for all transcripts
for a given HGNC symbol. | [
"gets",
"transcript",
"IDs",
"for",
"a",
"gene",
".",
"Args",
":",
"ensembl",
":",
"EnsemblRequest",
"object",
"to",
"request",
"data",
"from",
"ensembl",
"gene_id",
":",
"HGNC",
"symbol",
"for",
"gene",
"Returns",
":",
"dictionary",
"of",
"transcript",
"ID"... | train | https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/denovonear/load_gene.py#L106-L134 |
jeremymcrae/denovonear | denovonear/load_gene.py | load_gene | def load_gene(ensembl, gene_id, de_novos=[]):
""" sort out all the necessary sequences and positions for a gene
Args:
ensembl: EnsemblRequest object to request data from ensembl
gene_id: HGNC symbol for gene
de_novos: list of de novo positions, so we can check they all fit in
... | python | def load_gene(ensembl, gene_id, de_novos=[]):
""" sort out all the necessary sequences and positions for a gene
Args:
ensembl: EnsemblRequest object to request data from ensembl
gene_id: HGNC symbol for gene
de_novos: list of de novo positions, so we can check they all fit in
... | [
"def",
"load_gene",
"(",
"ensembl",
",",
"gene_id",
",",
"de_novos",
"=",
"[",
"]",
")",
":",
"transcripts",
"=",
"minimise_transcripts",
"(",
"ensembl",
",",
"gene_id",
",",
"de_novos",
")",
"genes",
"=",
"[",
"]",
"for",
"transcript_id",
"in",
"transcrip... | sort out all the necessary sequences and positions for a gene
Args:
ensembl: EnsemblRequest object to request data from ensembl
gene_id: HGNC symbol for gene
de_novos: list of de novo positions, so we can check they all fit in
the gene transcript
Returns:
... | [
"sort",
"out",
"all",
"the",
"necessary",
"sequences",
"and",
"positions",
"for",
"a",
"gene",
"Args",
":",
"ensembl",
":",
"EnsemblRequest",
"object",
"to",
"request",
"data",
"from",
"ensembl",
"gene_id",
":",
"HGNC",
"symbol",
"for",
"gene",
"de_novos",
"... | train | https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/denovonear/load_gene.py#L136-L159 |
jeremymcrae/denovonear | denovonear/load_gene.py | count_de_novos_per_transcript | def count_de_novos_per_transcript(ensembl, gene_id, de_novos=[]):
""" count de novos in transcripts for a gene.
Args:
ensembl: EnsemblRequest object to request data from ensembl
gene_id: HGNC symbol for gene
de_novos: list of de novo positions, so we can check they all fit in
... | python | def count_de_novos_per_transcript(ensembl, gene_id, de_novos=[]):
""" count de novos in transcripts for a gene.
Args:
ensembl: EnsemblRequest object to request data from ensembl
gene_id: HGNC symbol for gene
de_novos: list of de novo positions, so we can check they all fit in
... | [
"def",
"count_de_novos_per_transcript",
"(",
"ensembl",
",",
"gene_id",
",",
"de_novos",
"=",
"[",
"]",
")",
":",
"transcripts",
"=",
"get_transcript_ids",
"(",
"ensembl",
",",
"gene_id",
")",
"# TODO: allow for genes without any coding sequence.",
"if",
"len",
"(",
... | count de novos in transcripts for a gene.
Args:
ensembl: EnsemblRequest object to request data from ensembl
gene_id: HGNC symbol for gene
de_novos: list of de novo positions, so we can check they all fit in
the gene transcript
Returns:
dictionary of leng... | [
"count",
"de",
"novos",
"in",
"transcripts",
"for",
"a",
"gene",
".",
"Args",
":",
"ensembl",
":",
"EnsemblRequest",
"object",
"to",
"request",
"data",
"from",
"ensembl",
"gene_id",
":",
"HGNC",
"symbol",
"for",
"gene",
"de_novos",
":",
"list",
"of",
"de",... | train | https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/denovonear/load_gene.py#L161-L193 |
jeremymcrae/denovonear | denovonear/load_gene.py | minimise_transcripts | def minimise_transcripts(ensembl, gene_id, de_novos):
""" get a set of minimal transcripts to contain all the de novos.
We identify the minimal number of transcripts to contain all de novos. This
allows for de novos on mutually exclusive transcripts. The transcripts are
selected on the basis of con... | python | def minimise_transcripts(ensembl, gene_id, de_novos):
""" get a set of minimal transcripts to contain all the de novos.
We identify the minimal number of transcripts to contain all de novos. This
allows for de novos on mutually exclusive transcripts. The transcripts are
selected on the basis of con... | [
"def",
"minimise_transcripts",
"(",
"ensembl",
",",
"gene_id",
",",
"de_novos",
")",
":",
"if",
"len",
"(",
"de_novos",
")",
"==",
"0",
":",
"return",
"{",
"}",
"counts",
"=",
"count_de_novos_per_transcript",
"(",
"ensembl",
",",
"gene_id",
",",
"de_novos",
... | get a set of minimal transcripts to contain all the de novos.
We identify the minimal number of transcripts to contain all de novos. This
allows for de novos on mutually exclusive transcripts. The transcripts are
selected on the basis of containing the most number of de novos, while also
being the ... | [
"get",
"a",
"set",
"of",
"minimal",
"transcripts",
"to",
"contain",
"all",
"the",
"de",
"novos",
".",
"We",
"identify",
"the",
"minimal",
"number",
"of",
"transcripts",
"to",
"contain",
"all",
"de",
"novos",
".",
"This",
"allows",
"for",
"de",
"novos",
"... | train | https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/denovonear/load_gene.py#L195-L241 |
LordGaav/python-chaos | chaos/db.py | dump_simple_db | def dump_simple_db(path):
"""
Dumps a SimpleDb as string in the following format:
<key>: <json-encoded string>
"""
output = []
simpledb = SimpleDb(path, mode="r", sync=False)
with simpledb as db:
for key in db:
output.append("{0}: {1}".format(key, db.dumpvalue(key)))
return "\n".join(output) | python | def dump_simple_db(path):
"""
Dumps a SimpleDb as string in the following format:
<key>: <json-encoded string>
"""
output = []
simpledb = SimpleDb(path, mode="r", sync=False)
with simpledb as db:
for key in db:
output.append("{0}: {1}".format(key, db.dumpvalue(key)))
return "\n".join(output) | [
"def",
"dump_simple_db",
"(",
"path",
")",
":",
"output",
"=",
"[",
"]",
"simpledb",
"=",
"SimpleDb",
"(",
"path",
",",
"mode",
"=",
"\"r\"",
",",
"sync",
"=",
"False",
")",
"with",
"simpledb",
"as",
"db",
":",
"for",
"key",
"in",
"db",
":",
"outpu... | Dumps a SimpleDb as string in the following format:
<key>: <json-encoded string> | [
"Dumps",
"a",
"SimpleDb",
"as",
"string",
"in",
"the",
"following",
"format",
":",
"<key",
">",
":",
"<json",
"-",
"encoded",
"string",
">"
] | train | https://github.com/LordGaav/python-chaos/blob/52cd29a6fd15693ee1e53786b93bcb23fbf84ddd/chaos/db.py#L21-L31 |
ReadabilityHoldings/python-readability-api | readability/core.py | required_from_env | def required_from_env(key):
"""
Retrieve a required variable from the current environment variables.
Raises a ValueError if the env variable is not found or has no value.
"""
val = os.environ.get(key)
if not val:
raise ValueError(
"Required argument '{}' not supplied and no... | python | def required_from_env(key):
"""
Retrieve a required variable from the current environment variables.
Raises a ValueError if the env variable is not found or has no value.
"""
val = os.environ.get(key)
if not val:
raise ValueError(
"Required argument '{}' not supplied and no... | [
"def",
"required_from_env",
"(",
"key",
")",
":",
"val",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"key",
")",
"if",
"not",
"val",
":",
"raise",
"ValueError",
"(",
"\"Required argument '{}' not supplied and not found in environment variables\"",
".",
"format",
"... | Retrieve a required variable from the current environment variables.
Raises a ValueError if the env variable is not found or has no value. | [
"Retrieve",
"a",
"required",
"variable",
"from",
"the",
"current",
"environment",
"variables",
"."
] | train | https://github.com/ReadabilityHoldings/python-readability-api/blob/4b746166877d5a8dc29222aedccb18c2506a5385/readability/core.py#L4-L15 |
ReadabilityHoldings/python-readability-api | readability/clients.py | ReaderClient.get | def get(self, url):
"""
Make a HTTP GET request to the Reader API.
:param url: url to which to make a GET request.
"""
logger.debug('Making GET request to %s', url)
return self.oauth_session.get(url) | python | def get(self, url):
"""
Make a HTTP GET request to the Reader API.
:param url: url to which to make a GET request.
"""
logger.debug('Making GET request to %s', url)
return self.oauth_session.get(url) | [
"def",
"get",
"(",
"self",
",",
"url",
")",
":",
"logger",
".",
"debug",
"(",
"'Making GET request to %s'",
",",
"url",
")",
"return",
"self",
".",
"oauth_session",
".",
"get",
"(",
"url",
")"
] | Make a HTTP GET request to the Reader API.
:param url: url to which to make a GET request. | [
"Make",
"a",
"HTTP",
"GET",
"request",
"to",
"the",
"Reader",
"API",
"."
] | train | https://github.com/ReadabilityHoldings/python-readability-api/blob/4b746166877d5a8dc29222aedccb18c2506a5385/readability/clients.py#L75-L82 |
ReadabilityHoldings/python-readability-api | readability/clients.py | ReaderClient.post | def post(self, url, post_params=None):
"""
Make a HTTP POST request to the Reader API.
:param url: url to which to make a POST request.
:param post_params: parameters to be sent in the request's body.
"""
params = urlencode(post_params)
logger.debug('Making POST ... | python | def post(self, url, post_params=None):
"""
Make a HTTP POST request to the Reader API.
:param url: url to which to make a POST request.
:param post_params: parameters to be sent in the request's body.
"""
params = urlencode(post_params)
logger.debug('Making POST ... | [
"def",
"post",
"(",
"self",
",",
"url",
",",
"post_params",
"=",
"None",
")",
":",
"params",
"=",
"urlencode",
"(",
"post_params",
")",
"logger",
".",
"debug",
"(",
"'Making POST request to %s with body %s'",
",",
"url",
",",
"params",
")",
"return",
"self",... | Make a HTTP POST request to the Reader API.
:param url: url to which to make a POST request.
:param post_params: parameters to be sent in the request's body. | [
"Make",
"a",
"HTTP",
"POST",
"request",
"to",
"the",
"Reader",
"API",
"."
] | train | https://github.com/ReadabilityHoldings/python-readability-api/blob/4b746166877d5a8dc29222aedccb18c2506a5385/readability/clients.py#L84-L93 |
ReadabilityHoldings/python-readability-api | readability/clients.py | ReaderClient.delete | def delete(self, url):
"""
Make a HTTP DELETE request to the Readability API.
:param url: The url to which to send a DELETE request.
"""
logger.debug('Making DELETE request to %s', url)
return self.oauth_session.delete(url) | python | def delete(self, url):
"""
Make a HTTP DELETE request to the Readability API.
:param url: The url to which to send a DELETE request.
"""
logger.debug('Making DELETE request to %s', url)
return self.oauth_session.delete(url) | [
"def",
"delete",
"(",
"self",
",",
"url",
")",
":",
"logger",
".",
"debug",
"(",
"'Making DELETE request to %s'",
",",
"url",
")",
"return",
"self",
".",
"oauth_session",
".",
"delete",
"(",
"url",
")"
] | Make a HTTP DELETE request to the Readability API.
:param url: The url to which to send a DELETE request. | [
"Make",
"a",
"HTTP",
"DELETE",
"request",
"to",
"the",
"Readability",
"API",
"."
] | train | https://github.com/ReadabilityHoldings/python-readability-api/blob/4b746166877d5a8dc29222aedccb18c2506a5385/readability/clients.py#L95-L102 |
ReadabilityHoldings/python-readability-api | readability/clients.py | ReaderClient.get_article | def get_article(self, article_id):
"""
Get a single article represented by `article_id`.
:param article_id: ID of the article to retrieve.
"""
url = self._generate_url('articles/{0}'.format(article_id))
return self.get(url) | python | def get_article(self, article_id):
"""
Get a single article represented by `article_id`.
:param article_id: ID of the article to retrieve.
"""
url = self._generate_url('articles/{0}'.format(article_id))
return self.get(url) | [
"def",
"get_article",
"(",
"self",
",",
"article_id",
")",
":",
"url",
"=",
"self",
".",
"_generate_url",
"(",
"'articles/{0}'",
".",
"format",
"(",
"article_id",
")",
")",
"return",
"self",
".",
"get",
"(",
"url",
")"
] | Get a single article represented by `article_id`.
:param article_id: ID of the article to retrieve. | [
"Get",
"a",
"single",
"article",
"represented",
"by",
"article_id",
"."
] | train | https://github.com/ReadabilityHoldings/python-readability-api/blob/4b746166877d5a8dc29222aedccb18c2506a5385/readability/clients.py#L119-L126 |
ReadabilityHoldings/python-readability-api | readability/clients.py | ReaderClient.get_bookmarks | def get_bookmarks(self, **filters):
"""
Get Bookmarks for the current user.
Filters:
:param archive: Filter Bookmarks returned by archived status.
:param favorite: Filter Bookmarks returned by favorite status.
:param domain: Filter Bookmarks returned by a domain.
... | python | def get_bookmarks(self, **filters):
"""
Get Bookmarks for the current user.
Filters:
:param archive: Filter Bookmarks returned by archived status.
:param favorite: Filter Bookmarks returned by favorite status.
:param domain: Filter Bookmarks returned by a domain.
... | [
"def",
"get_bookmarks",
"(",
"self",
",",
"*",
"*",
"filters",
")",
":",
"filter_dict",
"=",
"filter_args_to_dict",
"(",
"filters",
",",
"ACCEPTED_BOOKMARK_FILTERS",
")",
"url",
"=",
"self",
".",
"_generate_url",
"(",
"'bookmarks'",
",",
"query_params",
"=",
"... | Get Bookmarks for the current user.
Filters:
:param archive: Filter Bookmarks returned by archived status.
:param favorite: Filter Bookmarks returned by favorite status.
:param domain: Filter Bookmarks returned by a domain.
:param added_since: Filter bookmarks by date added (si... | [
"Get",
"Bookmarks",
"for",
"the",
"current",
"user",
"."
] | train | https://github.com/ReadabilityHoldings/python-readability-api/blob/4b746166877d5a8dc29222aedccb18c2506a5385/readability/clients.py#L128-L152 |
ReadabilityHoldings/python-readability-api | readability/clients.py | ReaderClient.get_bookmark | def get_bookmark(self, bookmark_id):
"""
Get a single bookmark represented by `bookmark_id`.
The requested bookmark must belong to the current user.
:param bookmark_id: ID of the bookmark to retrieve.
"""
url = self._generate_url('bookmarks/{0}'.format(bookmark_id))
... | python | def get_bookmark(self, bookmark_id):
"""
Get a single bookmark represented by `bookmark_id`.
The requested bookmark must belong to the current user.
:param bookmark_id: ID of the bookmark to retrieve.
"""
url = self._generate_url('bookmarks/{0}'.format(bookmark_id))
... | [
"def",
"get_bookmark",
"(",
"self",
",",
"bookmark_id",
")",
":",
"url",
"=",
"self",
".",
"_generate_url",
"(",
"'bookmarks/{0}'",
".",
"format",
"(",
"bookmark_id",
")",
")",
"return",
"self",
".",
"get",
"(",
"url",
")"
] | Get a single bookmark represented by `bookmark_id`.
The requested bookmark must belong to the current user.
:param bookmark_id: ID of the bookmark to retrieve. | [
"Get",
"a",
"single",
"bookmark",
"represented",
"by",
"bookmark_id",
"."
] | train | https://github.com/ReadabilityHoldings/python-readability-api/blob/4b746166877d5a8dc29222aedccb18c2506a5385/readability/clients.py#L154-L163 |
ReadabilityHoldings/python-readability-api | readability/clients.py | ReaderClient.add_bookmark | def add_bookmark(self, url, favorite=False, archive=False, allow_duplicates=True):
"""
Adds given bookmark to the authenticated user.
:param url: URL of the article to bookmark
:param favorite: whether or not the bookmark should be favorited
:param archive: whether or not the bo... | python | def add_bookmark(self, url, favorite=False, archive=False, allow_duplicates=True):
"""
Adds given bookmark to the authenticated user.
:param url: URL of the article to bookmark
:param favorite: whether or not the bookmark should be favorited
:param archive: whether or not the bo... | [
"def",
"add_bookmark",
"(",
"self",
",",
"url",
",",
"favorite",
"=",
"False",
",",
"archive",
"=",
"False",
",",
"allow_duplicates",
"=",
"True",
")",
":",
"rdb_url",
"=",
"self",
".",
"_generate_url",
"(",
"'bookmarks'",
")",
"params",
"=",
"{",
"\"url... | Adds given bookmark to the authenticated user.
:param url: URL of the article to bookmark
:param favorite: whether or not the bookmark should be favorited
:param archive: whether or not the bookmark should be archived
:param allow_duplicates: whether or not to allow duplicate bookmarks ... | [
"Adds",
"given",
"bookmark",
"to",
"the",
"authenticated",
"user",
"."
] | train | https://github.com/ReadabilityHoldings/python-readability-api/blob/4b746166877d5a8dc29222aedccb18c2506a5385/readability/clients.py#L165-L182 |
ReadabilityHoldings/python-readability-api | readability/clients.py | ReaderClient.update_bookmark | def update_bookmark(self, bookmark_id, favorite=None, archive=None, read_percent=None):
"""
Updates given bookmark. The requested bookmark must belong to the
current user.
:param bookmark_id: ID of the bookmark to update.
:param favorite (optional): Whether this article is favor... | python | def update_bookmark(self, bookmark_id, favorite=None, archive=None, read_percent=None):
"""
Updates given bookmark. The requested bookmark must belong to the
current user.
:param bookmark_id: ID of the bookmark to update.
:param favorite (optional): Whether this article is favor... | [
"def",
"update_bookmark",
"(",
"self",
",",
"bookmark_id",
",",
"favorite",
"=",
"None",
",",
"archive",
"=",
"None",
",",
"read_percent",
"=",
"None",
")",
":",
"rdb_url",
"=",
"self",
".",
"_generate_url",
"(",
"'bookmarks/{0}'",
".",
"format",
"(",
"boo... | Updates given bookmark. The requested bookmark must belong to the
current user.
:param bookmark_id: ID of the bookmark to update.
:param favorite (optional): Whether this article is favorited or not.
:param archive (optional): Whether this article is archived or not.
:param read... | [
"Updates",
"given",
"bookmark",
".",
"The",
"requested",
"bookmark",
"must",
"belong",
"to",
"the",
"current",
"user",
"."
] | train | https://github.com/ReadabilityHoldings/python-readability-api/blob/4b746166877d5a8dc29222aedccb18c2506a5385/readability/clients.py#L184-L206 |
ReadabilityHoldings/python-readability-api | readability/clients.py | ReaderClient.delete_bookmark | def delete_bookmark(self, bookmark_id):
"""
Delete a single bookmark represented by `bookmark_id`.
The requested bookmark must belong to the current user.
:param bookmark_id: ID of the bookmark to delete.
"""
url = self._generate_url('bookmarks/{0}'.format(bookmark_id))... | python | def delete_bookmark(self, bookmark_id):
"""
Delete a single bookmark represented by `bookmark_id`.
The requested bookmark must belong to the current user.
:param bookmark_id: ID of the bookmark to delete.
"""
url = self._generate_url('bookmarks/{0}'.format(bookmark_id))... | [
"def",
"delete_bookmark",
"(",
"self",
",",
"bookmark_id",
")",
":",
"url",
"=",
"self",
".",
"_generate_url",
"(",
"'bookmarks/{0}'",
".",
"format",
"(",
"bookmark_id",
")",
")",
"return",
"self",
".",
"delete",
"(",
"url",
")"
] | Delete a single bookmark represented by `bookmark_id`.
The requested bookmark must belong to the current user.
:param bookmark_id: ID of the bookmark to delete. | [
"Delete",
"a",
"single",
"bookmark",
"represented",
"by",
"bookmark_id",
"."
] | train | https://github.com/ReadabilityHoldings/python-readability-api/blob/4b746166877d5a8dc29222aedccb18c2506a5385/readability/clients.py#L237-L246 |
ReadabilityHoldings/python-readability-api | readability/clients.py | ReaderClient.get_bookmark_tags | def get_bookmark_tags(self, bookmark_id):
"""
Retrieve tags that have been applied to a bookmark.
The requested bookmark must belong to the current user.
:param bookmark_id: ID of the bookmark to delete.
"""
url = self._generate_url('bookmarks/{0}/tags'.format(bookmark_... | python | def get_bookmark_tags(self, bookmark_id):
"""
Retrieve tags that have been applied to a bookmark.
The requested bookmark must belong to the current user.
:param bookmark_id: ID of the bookmark to delete.
"""
url = self._generate_url('bookmarks/{0}/tags'.format(bookmark_... | [
"def",
"get_bookmark_tags",
"(",
"self",
",",
"bookmark_id",
")",
":",
"url",
"=",
"self",
".",
"_generate_url",
"(",
"'bookmarks/{0}/tags'",
".",
"format",
"(",
"bookmark_id",
")",
")",
"return",
"self",
".",
"get",
"(",
"url",
")"
] | Retrieve tags that have been applied to a bookmark.
The requested bookmark must belong to the current user.
:param bookmark_id: ID of the bookmark to delete. | [
"Retrieve",
"tags",
"that",
"have",
"been",
"applied",
"to",
"a",
"bookmark",
"."
] | train | https://github.com/ReadabilityHoldings/python-readability-api/blob/4b746166877d5a8dc29222aedccb18c2506a5385/readability/clients.py#L248-L257 |
ReadabilityHoldings/python-readability-api | readability/clients.py | ReaderClient.add_tags_to_bookmark | def add_tags_to_bookmark(self, bookmark_id, tags):
"""
Add tags to to a bookmark.
The identified bookmark must belong to the current user.
:param bookmark_id: ID of the bookmark to delete.
:param tags: Comma separated tags to be applied.
"""
url = self._generate... | python | def add_tags_to_bookmark(self, bookmark_id, tags):
"""
Add tags to to a bookmark.
The identified bookmark must belong to the current user.
:param bookmark_id: ID of the bookmark to delete.
:param tags: Comma separated tags to be applied.
"""
url = self._generate... | [
"def",
"add_tags_to_bookmark",
"(",
"self",
",",
"bookmark_id",
",",
"tags",
")",
":",
"url",
"=",
"self",
".",
"_generate_url",
"(",
"'bookmarks/{0}/tags'",
".",
"format",
"(",
"bookmark_id",
")",
")",
"params",
"=",
"dict",
"(",
"tags",
"=",
"tags",
")",... | Add tags to to a bookmark.
The identified bookmark must belong to the current user.
:param bookmark_id: ID of the bookmark to delete.
:param tags: Comma separated tags to be applied. | [
"Add",
"tags",
"to",
"to",
"a",
"bookmark",
"."
] | train | https://github.com/ReadabilityHoldings/python-readability-api/blob/4b746166877d5a8dc29222aedccb18c2506a5385/readability/clients.py#L259-L270 |
ReadabilityHoldings/python-readability-api | readability/clients.py | ReaderClient.delete_tag_from_bookmark | def delete_tag_from_bookmark(self, bookmark_id, tag_id):
"""
Remove a single tag from a bookmark.
The identified bookmark must belong to the current user.
:param bookmark_id: ID of the bookmark to delete.
"""
url = self._generate_url('bookmarks/{0}/tags/{1}'.format(
... | python | def delete_tag_from_bookmark(self, bookmark_id, tag_id):
"""
Remove a single tag from a bookmark.
The identified bookmark must belong to the current user.
:param bookmark_id: ID of the bookmark to delete.
"""
url = self._generate_url('bookmarks/{0}/tags/{1}'.format(
... | [
"def",
"delete_tag_from_bookmark",
"(",
"self",
",",
"bookmark_id",
",",
"tag_id",
")",
":",
"url",
"=",
"self",
".",
"_generate_url",
"(",
"'bookmarks/{0}/tags/{1}'",
".",
"format",
"(",
"bookmark_id",
",",
"tag_id",
")",
")",
"return",
"self",
".",
"delete",... | Remove a single tag from a bookmark.
The identified bookmark must belong to the current user.
:param bookmark_id: ID of the bookmark to delete. | [
"Remove",
"a",
"single",
"tag",
"from",
"a",
"bookmark",
"."
] | train | https://github.com/ReadabilityHoldings/python-readability-api/blob/4b746166877d5a8dc29222aedccb18c2506a5385/readability/clients.py#L272-L282 |
ReadabilityHoldings/python-readability-api | readability/clients.py | ReaderClient.get_tag | def get_tag(self, tag_id):
"""
Get a single tag represented by `tag_id`.
The requested tag must belong to the current user.
:param tag_id: ID fo the tag to retrieve.
"""
url = self._generate_url('tags/{0}'.format(tag_id))
return self.get(url) | python | def get_tag(self, tag_id):
"""
Get a single tag represented by `tag_id`.
The requested tag must belong to the current user.
:param tag_id: ID fo the tag to retrieve.
"""
url = self._generate_url('tags/{0}'.format(tag_id))
return self.get(url) | [
"def",
"get_tag",
"(",
"self",
",",
"tag_id",
")",
":",
"url",
"=",
"self",
".",
"_generate_url",
"(",
"'tags/{0}'",
".",
"format",
"(",
"tag_id",
")",
")",
"return",
"self",
".",
"get",
"(",
"url",
")"
] | Get a single tag represented by `tag_id`.
The requested tag must belong to the current user.
:param tag_id: ID fo the tag to retrieve. | [
"Get",
"a",
"single",
"tag",
"represented",
"by",
"tag_id",
"."
] | train | https://github.com/ReadabilityHoldings/python-readability-api/blob/4b746166877d5a8dc29222aedccb18c2506a5385/readability/clients.py#L284-L293 |
ReadabilityHoldings/python-readability-api | readability/clients.py | ParserClient.post | def post(self, url, post_params=None):
"""
Make an HTTP POST request to the Parser API.
:param url: url to which to make the request
:param post_params: POST data to send along. Expected to be a dict.
"""
post_params['token'] = self.token
params = urlencode(post_... | python | def post(self, url, post_params=None):
"""
Make an HTTP POST request to the Parser API.
:param url: url to which to make the request
:param post_params: POST data to send along. Expected to be a dict.
"""
post_params['token'] = self.token
params = urlencode(post_... | [
"def",
"post",
"(",
"self",
",",
"url",
",",
"post_params",
"=",
"None",
")",
":",
"post_params",
"[",
"'token'",
"]",
"=",
"self",
".",
"token",
"params",
"=",
"urlencode",
"(",
"post_params",
")",
"logger",
".",
"debug",
"(",
"'Making POST request to %s ... | Make an HTTP POST request to the Parser API.
:param url: url to which to make the request
:param post_params: POST data to send along. Expected to be a dict. | [
"Make",
"an",
"HTTP",
"POST",
"request",
"to",
"the",
"Parser",
"API",
"."
] | train | https://github.com/ReadabilityHoldings/python-readability-api/blob/4b746166877d5a8dc29222aedccb18c2506a5385/readability/clients.py#L350-L360 |
ReadabilityHoldings/python-readability-api | readability/clients.py | ParserClient._generate_url | def _generate_url(self, resource, query_params=None):
"""
Build the url to resource.
:param resource: Name of the resource that is being called. Options are
`''` (empty string) for root resource, `'parser'`, `'confidence'`.
:param query_params: Data to be passed as query paramet... | python | def _generate_url(self, resource, query_params=None):
"""
Build the url to resource.
:param resource: Name of the resource that is being called. Options are
`''` (empty string) for root resource, `'parser'`, `'confidence'`.
:param query_params: Data to be passed as query paramet... | [
"def",
"_generate_url",
"(",
"self",
",",
"resource",
",",
"query_params",
"=",
"None",
")",
":",
"resource",
"=",
"'{resource}?token={token}'",
".",
"format",
"(",
"resource",
"=",
"resource",
",",
"token",
"=",
"self",
".",
"token",
")",
"if",
"query_param... | Build the url to resource.
:param resource: Name of the resource that is being called. Options are
`''` (empty string) for root resource, `'parser'`, `'confidence'`.
:param query_params: Data to be passed as query parameters. | [
"Build",
"the",
"url",
"to",
"resource",
"."
] | train | https://github.com/ReadabilityHoldings/python-readability-api/blob/4b746166877d5a8dc29222aedccb18c2506a5385/readability/clients.py#L362-L373 |
ReadabilityHoldings/python-readability-api | readability/clients.py | ParserClient.get_article | def get_article(self, url=None, article_id=None, max_pages=25):
"""
Send a GET request to the `parser` endpoint of the parser API to get
back the representation of an article.
The article can be identified by either a URL or an id that exists
in Readability.
Note that e... | python | def get_article(self, url=None, article_id=None, max_pages=25):
"""
Send a GET request to the `parser` endpoint of the parser API to get
back the representation of an article.
The article can be identified by either a URL or an id that exists
in Readability.
Note that e... | [
"def",
"get_article",
"(",
"self",
",",
"url",
"=",
"None",
",",
"article_id",
"=",
"None",
",",
"max_pages",
"=",
"25",
")",
":",
"query_params",
"=",
"{",
"}",
"if",
"url",
"is",
"not",
"None",
":",
"query_params",
"[",
"'url'",
"]",
"=",
"url",
... | Send a GET request to the `parser` endpoint of the parser API to get
back the representation of an article.
The article can be identified by either a URL or an id that exists
in Readability.
Note that either the `url` or `article_id` param should be passed.
:param url (optiona... | [
"Send",
"a",
"GET",
"request",
"to",
"the",
"parser",
"endpoint",
"of",
"the",
"parser",
"API",
"to",
"get",
"back",
"the",
"representation",
"of",
"an",
"article",
"."
] | train | https://github.com/ReadabilityHoldings/python-readability-api/blob/4b746166877d5a8dc29222aedccb18c2506a5385/readability/clients.py#L382-L405 |
ReadabilityHoldings/python-readability-api | readability/clients.py | ParserClient.post_article_content | def post_article_content(self, content, url, max_pages=25):
"""
POST content to be parsed to the Parser API.
Note: Even when POSTing content, a url must still be provided.
:param content: the content to be parsed
:param url: the url that represents the content
:param ma... | python | def post_article_content(self, content, url, max_pages=25):
"""
POST content to be parsed to the Parser API.
Note: Even when POSTing content, a url must still be provided.
:param content: the content to be parsed
:param url: the url that represents the content
:param ma... | [
"def",
"post_article_content",
"(",
"self",
",",
"content",
",",
"url",
",",
"max_pages",
"=",
"25",
")",
":",
"params",
"=",
"{",
"'doc'",
":",
"content",
",",
"'max_pages'",
":",
"max_pages",
"}",
"url",
"=",
"self",
".",
"_generate_url",
"(",
"'parser... | POST content to be parsed to the Parser API.
Note: Even when POSTing content, a url must still be provided.
:param content: the content to be parsed
:param url: the url that represents the content
:param max_pages (optional): the maximum number of pages to parse
and combine... | [
"POST",
"content",
"to",
"be",
"parsed",
"to",
"the",
"Parser",
"API",
"."
] | train | https://github.com/ReadabilityHoldings/python-readability-api/blob/4b746166877d5a8dc29222aedccb18c2506a5385/readability/clients.py#L407-L423 |
ReadabilityHoldings/python-readability-api | readability/clients.py | ParserClient.get_article_status | def get_article_status(self, url=None, article_id=None):
"""
Send a HEAD request to the `parser` endpoint to the parser API to
get the articles status.
Returned is a `requests.Response` object. The id and status for the
article can be extracted from the `X-Article-Id` and `X-Art... | python | def get_article_status(self, url=None, article_id=None):
"""
Send a HEAD request to the `parser` endpoint to the parser API to
get the articles status.
Returned is a `requests.Response` object. The id and status for the
article can be extracted from the `X-Article-Id` and `X-Art... | [
"def",
"get_article_status",
"(",
"self",
",",
"url",
"=",
"None",
",",
"article_id",
"=",
"None",
")",
":",
"query_params",
"=",
"{",
"}",
"if",
"url",
"is",
"not",
"None",
":",
"query_params",
"[",
"'url'",
"]",
"=",
"url",
"if",
"article_id",
"is",
... | Send a HEAD request to the `parser` endpoint to the parser API to
get the articles status.
Returned is a `requests.Response` object. The id and status for the
article can be extracted from the `X-Article-Id` and `X-Article-Status`
headers.
Note that either the `url` or `article... | [
"Send",
"a",
"HEAD",
"request",
"to",
"the",
"parser",
"endpoint",
"to",
"the",
"parser",
"API",
"to",
"get",
"the",
"articles",
"status",
"."
] | train | https://github.com/ReadabilityHoldings/python-readability-api/blob/4b746166877d5a8dc29222aedccb18c2506a5385/readability/clients.py#L425-L446 |
ReadabilityHoldings/python-readability-api | readability/clients.py | ParserClient.get_confidence | def get_confidence(self, url=None, article_id=None):
"""
Send a GET request to the `confidence` endpoint of the Parser API.
Note that either the `url` or `article_id` param should be passed.
:param url (optional): The url of an article whose content is wanted.
:param article_id... | python | def get_confidence(self, url=None, article_id=None):
"""
Send a GET request to the `confidence` endpoint of the Parser API.
Note that either the `url` or `article_id` param should be passed.
:param url (optional): The url of an article whose content is wanted.
:param article_id... | [
"def",
"get_confidence",
"(",
"self",
",",
"url",
"=",
"None",
",",
"article_id",
"=",
"None",
")",
":",
"query_params",
"=",
"{",
"}",
"if",
"url",
"is",
"not",
"None",
":",
"query_params",
"[",
"'url'",
"]",
"=",
"url",
"if",
"article_id",
"is",
"n... | Send a GET request to the `confidence` endpoint of the Parser API.
Note that either the `url` or `article_id` param should be passed.
:param url (optional): The url of an article whose content is wanted.
:param article_id (optional): The id of an article in the Readability
system w... | [
"Send",
"a",
"GET",
"request",
"to",
"the",
"confidence",
"endpoint",
"of",
"the",
"Parser",
"API",
"."
] | train | https://github.com/ReadabilityHoldings/python-readability-api/blob/4b746166877d5a8dc29222aedccb18c2506a5385/readability/clients.py#L448-L464 |
peterldowns/lggr | lggr/coroutine.py | coroutine | def coroutine(func):
""" Decorator for priming co-routines that use (yield) """
def wrapper(*args, **kwargs):
c = func(*args, **kwargs)
c.next() # prime it for iteration
return c
return wrapper | python | def coroutine(func):
""" Decorator for priming co-routines that use (yield) """
def wrapper(*args, **kwargs):
c = func(*args, **kwargs)
c.next() # prime it for iteration
return c
return wrapper | [
"def",
"coroutine",
"(",
"func",
")",
":",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"c",
"=",
"func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"c",
".",
"next",
"(",
")",
"# prime it for iteration",
"return",
... | Decorator for priming co-routines that use (yield) | [
"Decorator",
"for",
"priming",
"co",
"-",
"routines",
"that",
"use",
"(",
"yield",
")"
] | train | https://github.com/peterldowns/lggr/blob/622968f17133e02d9a46a4900dd20fb3b19fe961/lggr/coroutine.py#L8-L14 |
koreyou/word_embedding_loader | word_embedding_loader/saver/glove.py | save | def save(f, arr, vocab):
"""
Save word embedding file.
Args:
f (File): File to write the vectors. File should be open for writing
ascii.
arr (numpy.array): Numpy array with ``float`` dtype.
vocab (iterable): Each element is pair of a word (``bytes``) and ``arr``
... | python | def save(f, arr, vocab):
"""
Save word embedding file.
Args:
f (File): File to write the vectors. File should be open for writing
ascii.
arr (numpy.array): Numpy array with ``float`` dtype.
vocab (iterable): Each element is pair of a word (``bytes``) and ``arr``
... | [
"def",
"save",
"(",
"f",
",",
"arr",
",",
"vocab",
")",
":",
"itr",
"=",
"iter",
"(",
"vocab",
")",
"# Avoid empty line at the end",
"word",
",",
"idx",
"=",
"next",
"(",
"itr",
")",
"_write_line",
"(",
"f",
",",
"arr",
"[",
"idx",
"]",
",",
"word"... | Save word embedding file.
Args:
f (File): File to write the vectors. File should be open for writing
ascii.
arr (numpy.array): Numpy array with ``float`` dtype.
vocab (iterable): Each element is pair of a word (``bytes``) and ``arr``
index (``int``). Word should be e... | [
"Save",
"word",
"embedding",
"file",
"."
] | train | https://github.com/koreyou/word_embedding_loader/blob/1bc123f1a8bea12646576dcd768dae3ecea39c06/word_embedding_loader/saver/glove.py#L18-L35 |
koreyou/word_embedding_loader | word_embedding_loader/cli.py | convert | def convert(outputfile, inputfile, to_format, from_format):
"""
Convert pretrained word embedding file in one format to another.
"""
emb = word_embedding.WordEmbedding.load(
inputfile, format=_input_choices[from_format][1],
binary=_input_choices[from_format][2])
emb.save(outputfile, ... | python | def convert(outputfile, inputfile, to_format, from_format):
"""
Convert pretrained word embedding file in one format to another.
"""
emb = word_embedding.WordEmbedding.load(
inputfile, format=_input_choices[from_format][1],
binary=_input_choices[from_format][2])
emb.save(outputfile, ... | [
"def",
"convert",
"(",
"outputfile",
",",
"inputfile",
",",
"to_format",
",",
"from_format",
")",
":",
"emb",
"=",
"word_embedding",
".",
"WordEmbedding",
".",
"load",
"(",
"inputfile",
",",
"format",
"=",
"_input_choices",
"[",
"from_format",
"]",
"[",
"1",... | Convert pretrained word embedding file in one format to another. | [
"Convert",
"pretrained",
"word",
"embedding",
"file",
"in",
"one",
"format",
"to",
"another",
"."
] | train | https://github.com/koreyou/word_embedding_loader/blob/1bc123f1a8bea12646576dcd768dae3ecea39c06/word_embedding_loader/cli.py#L39-L47 |
koreyou/word_embedding_loader | word_embedding_loader/cli.py | check_format | def check_format(inputfile):
"""
Check format of inputfile.
"""
t = word_embedding.classify_format(inputfile)
if t == word_embedding._glove:
_echo_format_result('glove')
elif t == word_embedding._word2vec_bin:
_echo_format_result('word2vec-binary')
elif t == word_embedding._w... | python | def check_format(inputfile):
"""
Check format of inputfile.
"""
t = word_embedding.classify_format(inputfile)
if t == word_embedding._glove:
_echo_format_result('glove')
elif t == word_embedding._word2vec_bin:
_echo_format_result('word2vec-binary')
elif t == word_embedding._w... | [
"def",
"check_format",
"(",
"inputfile",
")",
":",
"t",
"=",
"word_embedding",
".",
"classify_format",
"(",
"inputfile",
")",
"if",
"t",
"==",
"word_embedding",
".",
"_glove",
":",
"_echo_format_result",
"(",
"'glove'",
")",
"elif",
"t",
"==",
"word_embedding"... | Check format of inputfile. | [
"Check",
"format",
"of",
"inputfile",
"."
] | train | https://github.com/koreyou/word_embedding_loader/blob/1bc123f1a8bea12646576dcd768dae3ecea39c06/word_embedding_loader/cli.py#L56-L68 |
koreyou/word_embedding_loader | word_embedding_loader/cli.py | list | def list():
"""
List available format.
"""
choice_len = max(map(len, _input_choices.keys()))
tmpl = " {:<%d}: {}\n" % choice_len
text = ''.join(map(
lambda k_v: tmpl.format(k_v[0], k_v[1][0]), six.iteritems(_input_choices)))
click.echo(text) | python | def list():
"""
List available format.
"""
choice_len = max(map(len, _input_choices.keys()))
tmpl = " {:<%d}: {}\n" % choice_len
text = ''.join(map(
lambda k_v: tmpl.format(k_v[0], k_v[1][0]), six.iteritems(_input_choices)))
click.echo(text) | [
"def",
"list",
"(",
")",
":",
"choice_len",
"=",
"max",
"(",
"map",
"(",
"len",
",",
"_input_choices",
".",
"keys",
"(",
")",
")",
")",
"tmpl",
"=",
"\" {:<%d}: {}\\n\"",
"%",
"choice_len",
"text",
"=",
"''",
".",
"join",
"(",
"map",
"(",
"lambda",
... | List available format. | [
"List",
"available",
"format",
"."
] | train | https://github.com/koreyou/word_embedding_loader/blob/1bc123f1a8bea12646576dcd768dae3ecea39c06/word_embedding_loader/cli.py#L72-L80 |
Parsely/birding | src/birding/twitter.py | main | def main():
"""Do the default action of `twitter` command."""
from twitter.cmdline import Action, OPTIONS
twitter = Twitter.from_oauth_file()
Action()(twitter, OPTIONS) | python | def main():
"""Do the default action of `twitter` command."""
from twitter.cmdline import Action, OPTIONS
twitter = Twitter.from_oauth_file()
Action()(twitter, OPTIONS) | [
"def",
"main",
"(",
")",
":",
"from",
"twitter",
".",
"cmdline",
"import",
"Action",
",",
"OPTIONS",
"twitter",
"=",
"Twitter",
".",
"from_oauth_file",
"(",
")",
"Action",
"(",
")",
"(",
"twitter",
",",
"OPTIONS",
")"
] | Do the default action of `twitter` command. | [
"Do",
"the",
"default",
"action",
"of",
"twitter",
"command",
"."
] | train | https://github.com/Parsely/birding/blob/c7f6eee56424234e361b1a455595de202e744dac/src/birding/twitter.py#L106-L110 |
Parsely/birding | src/birding/twitter.py | Twitter.from_oauth_file | def from_oauth_file(cls, filepath=None):
"""Get an object bound to the Twitter API using your own credentials.
The `twitter` library ships with a `twitter` command that uses PIN
OAuth. Generate your own OAuth credentials by running `twitter` from
the shell, which will open a browser win... | python | def from_oauth_file(cls, filepath=None):
"""Get an object bound to the Twitter API using your own credentials.
The `twitter` library ships with a `twitter` command that uses PIN
OAuth. Generate your own OAuth credentials by running `twitter` from
the shell, which will open a browser win... | [
"def",
"from_oauth_file",
"(",
"cls",
",",
"filepath",
"=",
"None",
")",
":",
"if",
"filepath",
"is",
"None",
":",
"# Use default OAuth filepath from `twitter` command-line program.",
"home",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'HOME'",
",",
"os",
".",
... | Get an object bound to the Twitter API using your own credentials.
The `twitter` library ships with a `twitter` command that uses PIN
OAuth. Generate your own OAuth credentials by running `twitter` from
the shell, which will open a browser window to authenticate you. Once
successfully r... | [
"Get",
"an",
"object",
"bound",
"to",
"the",
"Twitter",
"API",
"using",
"your",
"own",
"credentials",
"."
] | train | https://github.com/Parsely/birding/blob/c7f6eee56424234e361b1a455595de202e744dac/src/birding/twitter.py#L17-L43 |
Parsely/birding | src/birding/twitter.py | TwitterSearchManager.search | def search(self, q=None, **kw):
"""Search twitter for ``q``, return `results`__ directly from twitter.
__ https://dev.twitter.com/rest/reference/get/search/tweets
"""
if q is None:
raise ValueError('No search query provided for `q` keyword.')
return self.twitter.sear... | python | def search(self, q=None, **kw):
"""Search twitter for ``q``, return `results`__ directly from twitter.
__ https://dev.twitter.com/rest/reference/get/search/tweets
"""
if q is None:
raise ValueError('No search query provided for `q` keyword.')
return self.twitter.sear... | [
"def",
"search",
"(",
"self",
",",
"q",
"=",
"None",
",",
"*",
"*",
"kw",
")",
":",
"if",
"q",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'No search query provided for `q` keyword.'",
")",
"return",
"self",
".",
"twitter",
".",
"search",
".",
"tweet... | Search twitter for ``q``, return `results`__ directly from twitter.
__ https://dev.twitter.com/rest/reference/get/search/tweets | [
"Search",
"twitter",
"for",
"q",
"return",
"results",
"__",
"directly",
"from",
"twitter",
"."
] | train | https://github.com/Parsely/birding/blob/c7f6eee56424234e361b1a455595de202e744dac/src/birding/twitter.py#L52-L59 |
Parsely/birding | src/birding/twitter.py | TwitterSearchManager.lookup_search_result | def lookup_search_result(self, result, **kw):
"""Perform :meth:`lookup` on return value of :meth:`search`."""
return self.lookup(s['id_str'] for s in result['statuses'], **kw) | python | def lookup_search_result(self, result, **kw):
"""Perform :meth:`lookup` on return value of :meth:`search`."""
return self.lookup(s['id_str'] for s in result['statuses'], **kw) | [
"def",
"lookup_search_result",
"(",
"self",
",",
"result",
",",
"*",
"*",
"kw",
")",
":",
"return",
"self",
".",
"lookup",
"(",
"s",
"[",
"'id_str'",
"]",
"for",
"s",
"in",
"result",
"[",
"'statuses'",
"]",
",",
"",
"**",
"kw",
")"
] | Perform :meth:`lookup` on return value of :meth:`search`. | [
"Perform",
":",
"meth",
":",
"lookup",
"on",
"return",
"value",
"of",
":",
"meth",
":",
"search",
"."
] | train | https://github.com/Parsely/birding/blob/c7f6eee56424234e361b1a455595de202e744dac/src/birding/twitter.py#L61-L63 |
Parsely/birding | src/birding/twitter.py | TwitterSearchManager.lookup | def lookup(self, id_list, **kw):
"""Lookup list of statuses, return `results`__ directly from twitter.
Input can be any sequence of numeric or string values representing
twitter status IDs.
__ https://dev.twitter.com/rest/reference/get/statuses/lookup
"""
result_id_pack... | python | def lookup(self, id_list, **kw):
"""Lookup list of statuses, return `results`__ directly from twitter.
Input can be any sequence of numeric or string values representing
twitter status IDs.
__ https://dev.twitter.com/rest/reference/get/statuses/lookup
"""
result_id_pack... | [
"def",
"lookup",
"(",
"self",
",",
"id_list",
",",
"*",
"*",
"kw",
")",
":",
"result_id_pack",
"=",
"','",
".",
"join",
"(",
"[",
"str",
"(",
"_id",
")",
"for",
"_id",
"in",
"id_list",
"]",
")",
"if",
"not",
"result_id_pack",
":",
"return",
"[",
... | Lookup list of statuses, return `results`__ directly from twitter.
Input can be any sequence of numeric or string values representing
twitter status IDs.
__ https://dev.twitter.com/rest/reference/get/statuses/lookup | [
"Lookup",
"list",
"of",
"statuses",
"return",
"results",
"__",
"directly",
"from",
"twitter",
"."
] | train | https://github.com/Parsely/birding/blob/c7f6eee56424234e361b1a455595de202e744dac/src/birding/twitter.py#L65-L76 |
alejoe91/MEAutility | MEAutility/plotting.py | plot_probe | def plot_probe(mea, ax=None, xlim=None, ylim=None, color_currents=False, top=None, bottom=None,
cmap='viridis', type='shank', alpha_elec=0.7, alpha_prb=0.3):
'''
Parameters
----------
mea
axis
xlim
ylim
Returns
-------
'''
if ax is None:
fig = ... | python | def plot_probe(mea, ax=None, xlim=None, ylim=None, color_currents=False, top=None, bottom=None,
cmap='viridis', type='shank', alpha_elec=0.7, alpha_prb=0.3):
'''
Parameters
----------
mea
axis
xlim
ylim
Returns
-------
'''
if ax is None:
fig = ... | [
"def",
"plot_probe",
"(",
"mea",
",",
"ax",
"=",
"None",
",",
"xlim",
"=",
"None",
",",
"ylim",
"=",
"None",
",",
"color_currents",
"=",
"False",
",",
"top",
"=",
"None",
",",
"bottom",
"=",
"None",
",",
"cmap",
"=",
"'viridis'",
",",
"type",
"=",
... | Parameters
----------
mea
axis
xlim
ylim
Returns
------- | [
"Parameters",
"----------",
"mea",
"axis",
"xlim",
"ylim"
] | train | https://github.com/alejoe91/MEAutility/blob/7c2b0da52c2752a3baf04e8e248e26b0769cd088/MEAutility/plotting.py#L16-L143 |
Parsely/birding | setup.py | get_version | def get_version(filepath='src/birding/version.py'):
"""Get version without import, which avoids dependency issues."""
with open(get_abspath(filepath)) as version_file:
return re.search(
r"""__version__\s+=\s+(['"])(?P<version>.+?)\1""",
version_file.read()).group('version') | python | def get_version(filepath='src/birding/version.py'):
"""Get version without import, which avoids dependency issues."""
with open(get_abspath(filepath)) as version_file:
return re.search(
r"""__version__\s+=\s+(['"])(?P<version>.+?)\1""",
version_file.read()).group('version') | [
"def",
"get_version",
"(",
"filepath",
"=",
"'src/birding/version.py'",
")",
":",
"with",
"open",
"(",
"get_abspath",
"(",
"filepath",
")",
")",
"as",
"version_file",
":",
"return",
"re",
".",
"search",
"(",
"r\"\"\"__version__\\s+=\\s+(['\"])(?P<version>.+?)\\1\"\"\"... | Get version without import, which avoids dependency issues. | [
"Get",
"version",
"without",
"import",
"which",
"avoids",
"dependency",
"issues",
"."
] | train | https://github.com/Parsely/birding/blob/c7f6eee56424234e361b1a455595de202e744dac/setup.py#L72-L77 |
Parsely/birding | src/birding/gnip.py | Gnip.search | def search(self, q, **kw):
"""Search Gnip for given query, returning deserialized response."""
url = '{base_url}/search/{stream}'.format(**vars(self))
params = {
'q': q,
}
params.update(self.params)
params.update(kw)
response = self.session.get(url, ... | python | def search(self, q, **kw):
"""Search Gnip for given query, returning deserialized response."""
url = '{base_url}/search/{stream}'.format(**vars(self))
params = {
'q': q,
}
params.update(self.params)
params.update(kw)
response = self.session.get(url, ... | [
"def",
"search",
"(",
"self",
",",
"q",
",",
"*",
"*",
"kw",
")",
":",
"url",
"=",
"'{base_url}/search/{stream}'",
".",
"format",
"(",
"*",
"*",
"vars",
"(",
"self",
")",
")",
"params",
"=",
"{",
"'q'",
":",
"q",
",",
"}",
"params",
".",
"update"... | Search Gnip for given query, returning deserialized response. | [
"Search",
"Gnip",
"for",
"given",
"query",
"returning",
"deserialized",
"response",
"."
] | train | https://github.com/Parsely/birding/blob/c7f6eee56424234e361b1a455595de202e744dac/src/birding/gnip.py#L38-L50 |
Parsely/birding | src/birding/gnip.py | GnipSearchManager.dump | def dump(result):
"""Dump result into a string, useful for debugging."""
if isinstance(result, dict):
# Result is a search result.
statuses = result['results']
else:
# Result is a lookup result.
statuses = result
status_str_list = []
... | python | def dump(result):
"""Dump result into a string, useful for debugging."""
if isinstance(result, dict):
# Result is a search result.
statuses = result['results']
else:
# Result is a lookup result.
statuses = result
status_str_list = []
... | [
"def",
"dump",
"(",
"result",
")",
":",
"if",
"isinstance",
"(",
"result",
",",
"dict",
")",
":",
"# Result is a search result.",
"statuses",
"=",
"result",
"[",
"'results'",
"]",
"else",
":",
"# Result is a lookup result.",
"statuses",
"=",
"result",
"status_st... | Dump result into a string, useful for debugging. | [
"Dump",
"result",
"into",
"a",
"string",
"useful",
"for",
"debugging",
"."
] | train | https://github.com/Parsely/birding/blob/c7f6eee56424234e361b1a455595de202e744dac/src/birding/gnip.py#L75-L91 |
Parsely/birding | src/birding/shelf.py | shelf_from_config | def shelf_from_config(config, **default_init):
"""Get a `Shelf` instance dynamically based on config.
`config` is a dictionary containing ``shelf_*`` keys as defined in
:mod:`birding.config`.
"""
shelf_cls = import_name(config['shelf_class'], default_ns='birding.shelf')
init = {}
init.updat... | python | def shelf_from_config(config, **default_init):
"""Get a `Shelf` instance dynamically based on config.
`config` is a dictionary containing ``shelf_*`` keys as defined in
:mod:`birding.config`.
"""
shelf_cls = import_name(config['shelf_class'], default_ns='birding.shelf')
init = {}
init.updat... | [
"def",
"shelf_from_config",
"(",
"config",
",",
"*",
"*",
"default_init",
")",
":",
"shelf_cls",
"=",
"import_name",
"(",
"config",
"[",
"'shelf_class'",
"]",
",",
"default_ns",
"=",
"'birding.shelf'",
")",
"init",
"=",
"{",
"}",
"init",
".",
"update",
"("... | Get a `Shelf` instance dynamically based on config.
`config` is a dictionary containing ``shelf_*`` keys as defined in
:mod:`birding.config`. | [
"Get",
"a",
"Shelf",
"instance",
"dynamically",
"based",
"on",
"config",
"."
] | train | https://github.com/Parsely/birding/blob/c7f6eee56424234e361b1a455595de202e744dac/src/birding/shelf.py#L16-L29 |
Parsely/birding | src/birding/shelf.py | FreshPacker.unpack | def unpack(self, key, value):
"""Unpack and return value only if it is fresh."""
value, freshness = value
if not self.is_fresh(freshness):
raise KeyError('{} (stale)'.format(key))
return value | python | def unpack(self, key, value):
"""Unpack and return value only if it is fresh."""
value, freshness = value
if not self.is_fresh(freshness):
raise KeyError('{} (stale)'.format(key))
return value | [
"def",
"unpack",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"value",
",",
"freshness",
"=",
"value",
"if",
"not",
"self",
".",
"is_fresh",
"(",
"freshness",
")",
":",
"raise",
"KeyError",
"(",
"'{} (stale)'",
".",
"format",
"(",
"key",
")",
")"... | Unpack and return value only if it is fresh. | [
"Unpack",
"and",
"return",
"value",
"only",
"if",
"it",
"is",
"fresh",
"."
] | train | https://github.com/Parsely/birding/blob/c7f6eee56424234e361b1a455595de202e744dac/src/birding/shelf.py#L97-L102 |
Parsely/birding | src/birding/shelf.py | FreshPacker.is_fresh | def is_fresh(self, freshness):
"""Return False if given freshness value has expired, else True."""
if self.expire_after is None:
return True
return self.freshness() - freshness <= self.expire_after | python | def is_fresh(self, freshness):
"""Return False if given freshness value has expired, else True."""
if self.expire_after is None:
return True
return self.freshness() - freshness <= self.expire_after | [
"def",
"is_fresh",
"(",
"self",
",",
"freshness",
")",
":",
"if",
"self",
".",
"expire_after",
"is",
"None",
":",
"return",
"True",
"return",
"self",
".",
"freshness",
"(",
")",
"-",
"freshness",
"<=",
"self",
".",
"expire_after"
] | Return False if given freshness value has expired, else True. | [
"Return",
"False",
"if",
"given",
"freshness",
"value",
"has",
"expired",
"else",
"True",
"."
] | train | https://github.com/Parsely/birding/blob/c7f6eee56424234e361b1a455595de202e744dac/src/birding/shelf.py#L116-L120 |
ministryofjustice/money-to-prisoners-common | mtp_common/templatetags/mtp_common.py | get_form_errors | def get_form_errors(form):
"""
Django form errors do not obey natural field order,
this template tag returns non-field and field-specific errors
:param form: the form instance
"""
return {
'non_field': form.non_field_errors(),
'field_specific': OrderedDict(
(field, fo... | python | def get_form_errors(form):
"""
Django form errors do not obey natural field order,
this template tag returns non-field and field-specific errors
:param form: the form instance
"""
return {
'non_field': form.non_field_errors(),
'field_specific': OrderedDict(
(field, fo... | [
"def",
"get_form_errors",
"(",
"form",
")",
":",
"return",
"{",
"'non_field'",
":",
"form",
".",
"non_field_errors",
"(",
")",
",",
"'field_specific'",
":",
"OrderedDict",
"(",
"(",
"field",
",",
"form",
".",
"errors",
"[",
"field",
".",
"name",
"]",
")"... | Django form errors do not obey natural field order,
this template tag returns non-field and field-specific errors
:param form: the form instance | [
"Django",
"form",
"errors",
"do",
"not",
"obey",
"natural",
"field",
"order",
"this",
"template",
"tag",
"returns",
"non",
"-",
"field",
"and",
"field",
"-",
"specific",
"errors",
":",
"param",
"form",
":",
"the",
"form",
"instance"
] | train | https://github.com/ministryofjustice/money-to-prisoners-common/blob/33c43a2912cb990d9148da7c8718f480f07d90a1/mtp_common/templatetags/mtp_common.py#L115-L128 |
ministryofjustice/money-to-prisoners-common | mtp_common/templatetags/mtp_common.py | sub_nav | def sub_nav(context):
"""
Sub-nav displayed below proposition header
- creates alternate language links if SHOW_LANGUAGE_SWITCH is set
- takes "breadcrumbs" from the context
- takes "breadcrumbs_back" from the context to show a back link *instead* of breadcrumbs
"""
request = context.get('re... | python | def sub_nav(context):
"""
Sub-nav displayed below proposition header
- creates alternate language links if SHOW_LANGUAGE_SWITCH is set
- takes "breadcrumbs" from the context
- takes "breadcrumbs_back" from the context to show a back link *instead* of breadcrumbs
"""
request = context.get('re... | [
"def",
"sub_nav",
"(",
"context",
")",
":",
"request",
"=",
"context",
".",
"get",
"(",
"'request'",
")",
"return",
"{",
"'alt_urls'",
":",
"make_alternate_language_urls",
"(",
"request",
")",
",",
"'breadcrumbs'",
":",
"context",
".",
"get",
"(",
"'breadcru... | Sub-nav displayed below proposition header
- creates alternate language links if SHOW_LANGUAGE_SWITCH is set
- takes "breadcrumbs" from the context
- takes "breadcrumbs_back" from the context to show a back link *instead* of breadcrumbs | [
"Sub",
"-",
"nav",
"displayed",
"below",
"proposition",
"header",
"-",
"creates",
"alternate",
"language",
"links",
"if",
"SHOW_LANGUAGE_SWITCH",
"is",
"set",
"-",
"takes",
"breadcrumbs",
"from",
"the",
"context",
"-",
"takes",
"breadcrumbs_back",
"from",
"the",
... | train | https://github.com/ministryofjustice/money-to-prisoners-common/blob/33c43a2912cb990d9148da7c8718f480f07d90a1/mtp_common/templatetags/mtp_common.py#L166-L178 |
ministryofjustice/money-to-prisoners-common | mtp_common/stack.py | is_first_instance_aws | def is_first_instance_aws():
"""
Returns True if the current instance is the first instance in the ASG group,
sorted by instance_id.
"""
try:
# get instance id and aws region
instance_details = requests.get('http://169.254.169.254/latest/dynamic/instance-identity/document',
... | python | def is_first_instance_aws():
"""
Returns True if the current instance is the first instance in the ASG group,
sorted by instance_id.
"""
try:
# get instance id and aws region
instance_details = requests.get('http://169.254.169.254/latest/dynamic/instance-identity/document',
... | [
"def",
"is_first_instance_aws",
"(",
")",
":",
"try",
":",
"# get instance id and aws region",
"instance_details",
"=",
"requests",
".",
"get",
"(",
"'http://169.254.169.254/latest/dynamic/instance-identity/document'",
",",
"timeout",
"=",
"5",
")",
".",
"json",
"(",
")... | Returns True if the current instance is the first instance in the ASG group,
sorted by instance_id. | [
"Returns",
"True",
"if",
"the",
"current",
"instance",
"is",
"the",
"first",
"instance",
"in",
"the",
"ASG",
"group",
"sorted",
"by",
"instance_id",
"."
] | train | https://github.com/ministryofjustice/money-to-prisoners-common/blob/33c43a2912cb990d9148da7c8718f480f07d90a1/mtp_common/stack.py#L33-L71 |
ministryofjustice/money-to-prisoners-common | mtp_common/stack.py | is_first_instance_k8s | def is_first_instance_k8s(current_pod_name=None):
"""
Returns True if the current pod is the first replica in Kubernetes cluster.
"""
current_pod_name = current_pod_name or os.environ.get('POD_NAME')
if not current_pod_name:
raise StackInterrogationException('Pod name not known')
namesp... | python | def is_first_instance_k8s(current_pod_name=None):
"""
Returns True if the current pod is the first replica in Kubernetes cluster.
"""
current_pod_name = current_pod_name or os.environ.get('POD_NAME')
if not current_pod_name:
raise StackInterrogationException('Pod name not known')
namesp... | [
"def",
"is_first_instance_k8s",
"(",
"current_pod_name",
"=",
"None",
")",
":",
"current_pod_name",
"=",
"current_pod_name",
"or",
"os",
".",
"environ",
".",
"get",
"(",
"'POD_NAME'",
")",
"if",
"not",
"current_pod_name",
":",
"raise",
"StackInterrogationException",... | Returns True if the current pod is the first replica in Kubernetes cluster. | [
"Returns",
"True",
"if",
"the",
"current",
"pod",
"is",
"the",
"first",
"replica",
"in",
"Kubernetes",
"cluster",
"."
] | train | https://github.com/ministryofjustice/money-to-prisoners-common/blob/33c43a2912cb990d9148da7c8718f480f07d90a1/mtp_common/stack.py#L74-L96 |
harvard-nrg/yaxil | scripts/ArcGet.py | splitarg | def splitarg(args):
'''
This function will split arguments separated by spaces or commas
to be backwards compatible with the original ArcGet command line tool
'''
if not args:
return args
split = list()
for arg in args:
if ',' in arg:
split.extend([x for x in arg... | python | def splitarg(args):
'''
This function will split arguments separated by spaces or commas
to be backwards compatible with the original ArcGet command line tool
'''
if not args:
return args
split = list()
for arg in args:
if ',' in arg:
split.extend([x for x in arg... | [
"def",
"splitarg",
"(",
"args",
")",
":",
"if",
"not",
"args",
":",
"return",
"args",
"split",
"=",
"list",
"(",
")",
"for",
"arg",
"in",
"args",
":",
"if",
"','",
"in",
"arg",
":",
"split",
".",
"extend",
"(",
"[",
"x",
"for",
"x",
"in",
"arg"... | This function will split arguments separated by spaces or commas
to be backwards compatible with the original ArcGet command line tool | [
"This",
"function",
"will",
"split",
"arguments",
"separated",
"by",
"spaces",
"or",
"commas",
"to",
"be",
"backwards",
"compatible",
"with",
"the",
"original",
"ArcGet",
"command",
"line",
"tool"
] | train | https://github.com/harvard-nrg/yaxil/blob/af594082258e62d1904d6e6841fce0bb5c0bf309/scripts/ArcGet.py#L152-L165 |
ministryofjustice/money-to-prisoners-common | mtp_common/auth/views.py | login | def login(request, template_name=None,
redirect_field_name=REDIRECT_FIELD_NAME,
authentication_form=AuthenticationForm,
current_app=None, extra_context=None):
"""
Displays the login form and handles the login action.
"""
redirect_to = request.POST.get(
redirect_fiel... | python | def login(request, template_name=None,
redirect_field_name=REDIRECT_FIELD_NAME,
authentication_form=AuthenticationForm,
current_app=None, extra_context=None):
"""
Displays the login form and handles the login action.
"""
redirect_to = request.POST.get(
redirect_fiel... | [
"def",
"login",
"(",
"request",
",",
"template_name",
"=",
"None",
",",
"redirect_field_name",
"=",
"REDIRECT_FIELD_NAME",
",",
"authentication_form",
"=",
"AuthenticationForm",
",",
"current_app",
"=",
"None",
",",
"extra_context",
"=",
"None",
")",
":",
"redirec... | Displays the login form and handles the login action. | [
"Displays",
"the",
"login",
"form",
"and",
"handles",
"the",
"login",
"action",
"."
] | train | https://github.com/ministryofjustice/money-to-prisoners-common/blob/33c43a2912cb990d9148da7c8718f480f07d90a1/mtp_common/auth/views.py#L33-L79 |
ministryofjustice/money-to-prisoners-common | mtp_common/auth/views.py | logout | def logout(request, template_name=None,
next_page=None,
redirect_field_name=REDIRECT_FIELD_NAME,
current_app=None, extra_context=None):
"""
Logs out the user.
"""
auth_logout(request)
if next_page is not None:
next_page = resolve_url(next_page)
if (redi... | python | def logout(request, template_name=None,
next_page=None,
redirect_field_name=REDIRECT_FIELD_NAME,
current_app=None, extra_context=None):
"""
Logs out the user.
"""
auth_logout(request)
if next_page is not None:
next_page = resolve_url(next_page)
if (redi... | [
"def",
"logout",
"(",
"request",
",",
"template_name",
"=",
"None",
",",
"next_page",
"=",
"None",
",",
"redirect_field_name",
"=",
"REDIRECT_FIELD_NAME",
",",
"current_app",
"=",
"None",
",",
"extra_context",
"=",
"None",
")",
":",
"auth_logout",
"(",
"reques... | Logs out the user. | [
"Logs",
"out",
"the",
"user",
"."
] | train | https://github.com/ministryofjustice/money-to-prisoners-common/blob/33c43a2912cb990d9148da7c8718f480f07d90a1/mtp_common/auth/views.py#L82-L118 |
Parsely/birding | src/birding/config.py | get_config | def get_config(filepath=None, default_loader=None, on_missing=None):
"""Get a dict for the current birding configuration.
The resulting dictionary is fully populated with defaults, such that all
valid keys will resolve to valid values. Invalid and extra values in the
configuration result in an exceptio... | python | def get_config(filepath=None, default_loader=None, on_missing=None):
"""Get a dict for the current birding configuration.
The resulting dictionary is fully populated with defaults, such that all
valid keys will resolve to valid values. Invalid and extra values in the
configuration result in an exceptio... | [
"def",
"get_config",
"(",
"filepath",
"=",
"None",
",",
"default_loader",
"=",
"None",
",",
"on_missing",
"=",
"None",
")",
":",
"# Handle cache lookup explicitly in order to support keyword arguments.",
"cache_key",
"=",
"(",
"filepath",
",",
"default_loader",
",",
"... | Get a dict for the current birding configuration.
The resulting dictionary is fully populated with defaults, such that all
valid keys will resolve to valid values. Invalid and extra values in the
configuration result in an exception.
See :ref:`config` (module-level docstring) for discussion on how bir... | [
"Get",
"a",
"dict",
"for",
"the",
"current",
"birding",
"configuration",
"."
] | train | https://github.com/Parsely/birding/blob/c7f6eee56424234e361b1a455595de202e744dac/src/birding/config.py#L108-L168 |
Parsely/birding | src/birding/config.py | get_defaults_file | def get_defaults_file(*a, **kw):
"""Get a file object with YAML data of configuration defaults.
Arguments are passed through to :func:`get_defaults_str`.
"""
fd = StringIO()
fd.write(get_defaults_str(*a, **kw))
fd.seek(0)
return fd | python | def get_defaults_file(*a, **kw):
"""Get a file object with YAML data of configuration defaults.
Arguments are passed through to :func:`get_defaults_str`.
"""
fd = StringIO()
fd.write(get_defaults_str(*a, **kw))
fd.seek(0)
return fd | [
"def",
"get_defaults_file",
"(",
"*",
"a",
",",
"*",
"*",
"kw",
")",
":",
"fd",
"=",
"StringIO",
"(",
")",
"fd",
".",
"write",
"(",
"get_defaults_str",
"(",
"*",
"a",
",",
"*",
"*",
"kw",
")",
")",
"fd",
".",
"seek",
"(",
"0",
")",
"return",
... | Get a file object with YAML data of configuration defaults.
Arguments are passed through to :func:`get_defaults_str`. | [
"Get",
"a",
"file",
"object",
"with",
"YAML",
"data",
"of",
"configuration",
"defaults",
"."
] | train | https://github.com/Parsely/birding/blob/c7f6eee56424234e361b1a455595de202e744dac/src/birding/config.py#L171-L179 |
Parsely/birding | src/birding/config.py | get_defaults_str | def get_defaults_str(raw=None, after='Defaults::'):
"""Get the string YAML representation of configuration defaults."""
if raw is None:
raw = __doc__
return unicode(textwrap.dedent(raw.split(after)[-1]).strip()) | python | def get_defaults_str(raw=None, after='Defaults::'):
"""Get the string YAML representation of configuration defaults."""
if raw is None:
raw = __doc__
return unicode(textwrap.dedent(raw.split(after)[-1]).strip()) | [
"def",
"get_defaults_str",
"(",
"raw",
"=",
"None",
",",
"after",
"=",
"'Defaults::'",
")",
":",
"if",
"raw",
"is",
"None",
":",
"raw",
"=",
"__doc__",
"return",
"unicode",
"(",
"textwrap",
".",
"dedent",
"(",
"raw",
".",
"split",
"(",
"after",
")",
... | Get the string YAML representation of configuration defaults. | [
"Get",
"the",
"string",
"YAML",
"representation",
"of",
"configuration",
"defaults",
"."
] | train | https://github.com/Parsely/birding/blob/c7f6eee56424234e361b1a455595de202e744dac/src/birding/config.py#L182-L186 |
Parsely/birding | src/birding/config.py | overlay | def overlay(upper, lower):
"""Return the overlay of `upper` dict onto `lower` dict.
This operation is similar to `dict.update`, but recurses when it encounters
a dict/mapping, as to allow nested leaf values in the lower collection
which are not in the upper collection. Whenever the upper collection has... | python | def overlay(upper, lower):
"""Return the overlay of `upper` dict onto `lower` dict.
This operation is similar to `dict.update`, but recurses when it encounters
a dict/mapping, as to allow nested leaf values in the lower collection
which are not in the upper collection. Whenever the upper collection has... | [
"def",
"overlay",
"(",
"upper",
",",
"lower",
")",
":",
"result",
"=",
"{",
"}",
"for",
"key",
"in",
"upper",
":",
"if",
"is_mapping",
"(",
"upper",
"[",
"key",
"]",
")",
":",
"lower_value",
"=",
"lower",
".",
"get",
"(",
"key",
",",
"{",
"}",
... | Return the overlay of `upper` dict onto `lower` dict.
This operation is similar to `dict.update`, but recurses when it encounters
a dict/mapping, as to allow nested leaf values in the lower collection
which are not in the upper collection. Whenever the upper collection has a
value, its value is used.
... | [
"Return",
"the",
"overlay",
"of",
"upper",
"dict",
"onto",
"lower",
"dict",
"."
] | train | https://github.com/Parsely/birding/blob/c7f6eee56424234e361b1a455595de202e744dac/src/birding/config.py#L189-L224 |
Parsely/birding | src/birding/config.py | import_name | def import_name(name, default_ns=None):
"""Import an object based on the dotted string.
>>> import_name('textwrap') # doctest: +ELLIPSIS
<module 'textwrap' from '...'>
>>> import_name('birding.config') # doctest: +ELLIPSIS
<module 'birding.config' from '...'>
>>> import_name('birding.config.get... | python | def import_name(name, default_ns=None):
"""Import an object based on the dotted string.
>>> import_name('textwrap') # doctest: +ELLIPSIS
<module 'textwrap' from '...'>
>>> import_name('birding.config') # doctest: +ELLIPSIS
<module 'birding.config' from '...'>
>>> import_name('birding.config.get... | [
"def",
"import_name",
"(",
"name",
",",
"default_ns",
"=",
"None",
")",
":",
"if",
"'.'",
"not",
"in",
"name",
":",
"if",
"default_ns",
"is",
"None",
":",
"return",
"importlib",
".",
"import_module",
"(",
"name",
")",
"else",
":",
"name",
"=",
"default... | Import an object based on the dotted string.
>>> import_name('textwrap') # doctest: +ELLIPSIS
<module 'textwrap' from '...'>
>>> import_name('birding.config') # doctest: +ELLIPSIS
<module 'birding.config' from '...'>
>>> import_name('birding.config.get_config') # doctest: +ELLIPSIS
<function ge... | [
"Import",
"an",
"object",
"based",
"on",
"the",
"dotted",
"string",
"."
] | train | https://github.com/Parsely/birding/blob/c7f6eee56424234e361b1a455595de202e744dac/src/birding/config.py#L231-L261 |
Parsely/birding | src/birding/follow.py | follow_topic_from_config | def follow_topic_from_config():
"""Read kafka config, then dispatch to `follow_topic`."""
config = get_config()['ResultTopicBolt']
kafka_class = import_name(config['kafka_class'])
return follow_topic(kafka_class, config['topic'], **config['kafka_init']) | python | def follow_topic_from_config():
"""Read kafka config, then dispatch to `follow_topic`."""
config = get_config()['ResultTopicBolt']
kafka_class = import_name(config['kafka_class'])
return follow_topic(kafka_class, config['topic'], **config['kafka_init']) | [
"def",
"follow_topic_from_config",
"(",
")",
":",
"config",
"=",
"get_config",
"(",
")",
"[",
"'ResultTopicBolt'",
"]",
"kafka_class",
"=",
"import_name",
"(",
"config",
"[",
"'kafka_class'",
"]",
")",
"return",
"follow_topic",
"(",
"kafka_class",
",",
"config",... | Read kafka config, then dispatch to `follow_topic`. | [
"Read",
"kafka",
"config",
"then",
"dispatch",
"to",
"follow_topic",
"."
] | train | https://github.com/Parsely/birding/blob/c7f6eee56424234e361b1a455595de202e744dac/src/birding/follow.py#L23-L27 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.