partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | Submission.unlock | Lock thread.
Requires that the currently authenticated user has the modposts oauth
scope or has user/password authentication as a mod of the subreddit.
:returns: The json response from the server. | rtv/packages/praw/objects.py | def unlock(self):
"""Lock thread.
Requires that the currently authenticated user has the modposts oauth
scope or has user/password authentication as a mod of the subreddit.
:returns: The json response from the server.
"""
url = self.reddit_session.config['unlock']
... | def unlock(self):
"""Lock thread.
Requires that the currently authenticated user has the modposts oauth
scope or has user/password authentication as a mod of the subreddit.
:returns: The json response from the server.
"""
url = self.reddit_session.config['unlock']
... | [
"Lock",
"thread",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/objects.py#L1451-L1462 | [
"def",
"unlock",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"reddit_session",
".",
"config",
"[",
"'unlock'",
"]",
"data",
"=",
"{",
"'id'",
":",
"self",
".",
"fullname",
"}",
"return",
"self",
".",
"reddit_session",
".",
"request_json",
"(",
"url... | ccef2af042566ad384977028cf0bde01bc524dda |
train | Submission.unsticky | Unsticky this post.
:returns: The json response from the server | rtv/packages/praw/objects.py | def unsticky(self):
"""Unsticky this post.
:returns: The json response from the server
"""
url = self.reddit_session.config['sticky_submission']
data = {'id': self.fullname, 'state': False}
return self.reddit_session.request_json(url, data=data) | def unsticky(self):
"""Unsticky this post.
:returns: The json response from the server
"""
url = self.reddit_session.config['sticky_submission']
data = {'id': self.fullname, 'state': False}
return self.reddit_session.request_json(url, data=data) | [
"Unsticky",
"this",
"post",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/objects.py#L1492-L1500 | [
"def",
"unsticky",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"reddit_session",
".",
"config",
"[",
"'sticky_submission'",
"]",
"data",
"=",
"{",
"'id'",
":",
"self",
".",
"fullname",
",",
"'state'",
":",
"False",
"}",
"return",
"self",
".",
"redd... | ccef2af042566ad384977028cf0bde01bc524dda |
train | Subreddit.clear_all_flair | Remove all user flair on this subreddit.
:returns: The json response from the server when there is flair to
clear, otherwise returns None. | rtv/packages/praw/objects.py | def clear_all_flair(self):
"""Remove all user flair on this subreddit.
:returns: The json response from the server when there is flair to
clear, otherwise returns None.
"""
csv = [{'user': x['user']} for x in self.get_flair_list(limit=None)]
if csv:
retu... | def clear_all_flair(self):
"""Remove all user flair on this subreddit.
:returns: The json response from the server when there is flair to
clear, otherwise returns None.
"""
csv = [{'user': x['user']} for x in self.get_flair_list(limit=None)]
if csv:
retu... | [
"Remove",
"all",
"user",
"flair",
"on",
"this",
"subreddit",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/objects.py#L1647-L1658 | [
"def",
"clear_all_flair",
"(",
"self",
")",
":",
"csv",
"=",
"[",
"{",
"'user'",
":",
"x",
"[",
"'user'",
"]",
"}",
"for",
"x",
"in",
"self",
".",
"get_flair_list",
"(",
"limit",
"=",
"None",
")",
"]",
"if",
"csv",
":",
"return",
"self",
".",
"se... | ccef2af042566ad384977028cf0bde01bc524dda |
train | Multireddit.from_api_response | Return an instance of the appropriate class from the json dict. | rtv/packages/praw/objects.py | def from_api_response(cls, reddit_session, json_dict):
"""Return an instance of the appropriate class from the json dict."""
# The Multireddit response contains the Subreddits attribute as a list
# of dicts of the form {'name': 'subredditname'}.
# We must convert each of these into a Sub... | def from_api_response(cls, reddit_session, json_dict):
"""Return an instance of the appropriate class from the json dict."""
# The Multireddit response contains the Subreddits attribute as a list
# of dicts of the form {'name': 'subredditname'}.
# We must convert each of these into a Sub... | [
"Return",
"an",
"instance",
"of",
"the",
"appropriate",
"class",
"from",
"the",
"json",
"dict",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/objects.py#L1693-L1700 | [
"def",
"from_api_response",
"(",
"cls",
",",
"reddit_session",
",",
"json_dict",
")",
":",
"# The Multireddit response contains the Subreddits attribute as a list",
"# of dicts of the form {'name': 'subredditname'}.",
"# We must convert each of these into a Subreddit object.",
"json_dict",... | ccef2af042566ad384977028cf0bde01bc524dda |
train | Multireddit.add_subreddit | Add a subreddit to the multireddit.
:param subreddit: The subreddit name or Subreddit object to add
The additional parameters are passed directly into
:meth:`~praw.__init__.BaseReddit.request_json`. | rtv/packages/praw/objects.py | def add_subreddit(self, subreddit, _delete=False, *args, **kwargs):
"""Add a subreddit to the multireddit.
:param subreddit: The subreddit name or Subreddit object to add
The additional parameters are passed directly into
:meth:`~praw.__init__.BaseReddit.request_json`.
"""
... | def add_subreddit(self, subreddit, _delete=False, *args, **kwargs):
"""Add a subreddit to the multireddit.
:param subreddit: The subreddit name or Subreddit object to add
The additional parameters are passed directly into
:meth:`~praw.__init__.BaseReddit.request_json`.
"""
... | [
"Add",
"a",
"subreddit",
"to",
"the",
"multireddit",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/objects.py#L1749-L1773 | [
"def",
"add_subreddit",
"(",
"self",
",",
"subreddit",
",",
"_delete",
"=",
"False",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"subreddit",
"=",
"six",
".",
"text_type",
"(",
"subreddit",
")",
"url",
"=",
"self",
".",
"reddit_session",
".",
... | ccef2af042566ad384977028cf0bde01bc524dda |
train | Multireddit.copy | Copy this multireddit.
Convenience function that utilizes
:meth:`.MultiredditMixin.copy_multireddit` populating both
the `from_redditor` and `from_name` parameters. | rtv/packages/praw/objects.py | def copy(self, to_name):
"""Copy this multireddit.
Convenience function that utilizes
:meth:`.MultiredditMixin.copy_multireddit` populating both
the `from_redditor` and `from_name` parameters.
"""
return self.reddit_session.copy_multireddit(self._author, self.name,
... | def copy(self, to_name):
"""Copy this multireddit.
Convenience function that utilizes
:meth:`.MultiredditMixin.copy_multireddit` populating both
the `from_redditor` and `from_name` parameters.
"""
return self.reddit_session.copy_multireddit(self._author, self.name,
... | [
"Copy",
"this",
"multireddit",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/objects.py#L1775-L1784 | [
"def",
"copy",
"(",
"self",
",",
"to_name",
")",
":",
"return",
"self",
".",
"reddit_session",
".",
"copy_multireddit",
"(",
"self",
".",
"_author",
",",
"self",
".",
"name",
",",
"to_name",
")"
] | ccef2af042566ad384977028cf0bde01bc524dda |
train | Multireddit.edit | Edit this multireddit.
Convenience function that utilizes
:meth:`.MultiredditMixin.edit_multireddit` populating the `name`
parameter. | rtv/packages/praw/objects.py | def edit(self, *args, **kwargs):
"""Edit this multireddit.
Convenience function that utilizes
:meth:`.MultiredditMixin.edit_multireddit` populating the `name`
parameter.
"""
return self.reddit_session.edit_multireddit(name=self.name, *args,
... | def edit(self, *args, **kwargs):
"""Edit this multireddit.
Convenience function that utilizes
:meth:`.MultiredditMixin.edit_multireddit` populating the `name`
parameter.
"""
return self.reddit_session.edit_multireddit(name=self.name, *args,
... | [
"Edit",
"this",
"multireddit",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/objects.py#L1796-L1805 | [
"def",
"edit",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"reddit_session",
".",
"edit_multireddit",
"(",
"name",
"=",
"self",
".",
"name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | ccef2af042566ad384977028cf0bde01bc524dda |
train | Multireddit.remove_subreddit | Remove a subreddit from the user's multireddit. | rtv/packages/praw/objects.py | def remove_subreddit(self, subreddit, *args, **kwargs):
"""Remove a subreddit from the user's multireddit."""
return self.add_subreddit(subreddit, True, *args, **kwargs) | def remove_subreddit(self, subreddit, *args, **kwargs):
"""Remove a subreddit from the user's multireddit."""
return self.add_subreddit(subreddit, True, *args, **kwargs) | [
"Remove",
"a",
"subreddit",
"from",
"the",
"user",
"s",
"multireddit",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/objects.py#L1807-L1809 | [
"def",
"remove_subreddit",
"(",
"self",
",",
"subreddit",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"add_subreddit",
"(",
"subreddit",
",",
"True",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | ccef2af042566ad384977028cf0bde01bc524dda |
train | Multireddit.rename | Rename this multireddit.
This function is a handy shortcut to
:meth:`rename_multireddit` of the reddit_session. | rtv/packages/praw/objects.py | def rename(self, new_name, *args, **kwargs):
"""Rename this multireddit.
This function is a handy shortcut to
:meth:`rename_multireddit` of the reddit_session.
"""
new = self.reddit_session.rename_multireddit(self.name, new_name,
... | def rename(self, new_name, *args, **kwargs):
"""Rename this multireddit.
This function is a handy shortcut to
:meth:`rename_multireddit` of the reddit_session.
"""
new = self.reddit_session.rename_multireddit(self.name, new_name,
... | [
"Rename",
"this",
"multireddit",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/objects.py#L1811-L1821 | [
"def",
"rename",
"(",
"self",
",",
"new_name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"new",
"=",
"self",
".",
"reddit_session",
".",
"rename_multireddit",
"(",
"self",
".",
"name",
",",
"new_name",
",",
"*",
"args",
",",
"*",
"*",
"k... | ccef2af042566ad384977028cf0bde01bc524dda |
train | UserList._convert | Return a Redditor object from the data. | rtv/packages/praw/objects.py | def _convert(reddit_session, data):
"""Return a Redditor object from the data."""
retval = Redditor(reddit_session, data['name'], fetch=False)
retval.id = data['id'].split('_')[1] # pylint: disable=C0103,W0201
return retval | def _convert(reddit_session, data):
"""Return a Redditor object from the data."""
retval = Redditor(reddit_session, data['name'], fetch=False)
retval.id = data['id'].split('_')[1] # pylint: disable=C0103,W0201
return retval | [
"Return",
"a",
"Redditor",
"object",
"from",
"the",
"data",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/objects.py#L1875-L1879 | [
"def",
"_convert",
"(",
"reddit_session",
",",
"data",
")",
":",
"retval",
"=",
"Redditor",
"(",
"reddit_session",
",",
"data",
"[",
"'name'",
"]",
",",
"fetch",
"=",
"False",
")",
"retval",
".",
"id",
"=",
"data",
"[",
"'id'",
"]",
".",
"split",
"("... | ccef2af042566ad384977028cf0bde01bc524dda |
train | WikiPage.from_api_response | Return an instance of the appropriate class from the json_dict. | rtv/packages/praw/objects.py | def from_api_response(cls, reddit_session, json_dict):
"""Return an instance of the appropriate class from the json_dict."""
# The WikiPage response does not contain the necessary information
# in the JSON response to determine the name of the page nor the
# subreddit it belongs to. Thus... | def from_api_response(cls, reddit_session, json_dict):
"""Return an instance of the appropriate class from the json_dict."""
# The WikiPage response does not contain the necessary information
# in the JSON response to determine the name of the page nor the
# subreddit it belongs to. Thus... | [
"Return",
"an",
"instance",
"of",
"the",
"appropriate",
"class",
"from",
"the",
"json_dict",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/objects.py#L1886-L1897 | [
"def",
"from_api_response",
"(",
"cls",
",",
"reddit_session",
",",
"json_dict",
")",
":",
"# The WikiPage response does not contain the necessary information",
"# in the JSON response to determine the name of the page nor the",
"# subreddit it belongs to. Thus we must extract this informati... | ccef2af042566ad384977028cf0bde01bc524dda |
train | WikiPage.add_editor | Add an editor to this wiki page.
:param username: The name or Redditor object of the user to add.
:param _delete: If True, remove the user as an editor instead.
Please use :meth:`remove_editor` rather than setting it manually.
Additional parameters are passed into
:meth:`~p... | rtv/packages/praw/objects.py | def add_editor(self, username, _delete=False, *args, **kwargs):
"""Add an editor to this wiki page.
:param username: The name or Redditor object of the user to add.
:param _delete: If True, remove the user as an editor instead.
Please use :meth:`remove_editor` rather than setting it... | def add_editor(self, username, _delete=False, *args, **kwargs):
"""Add an editor to this wiki page.
:param username: The name or Redditor object of the user to add.
:param _delete: If True, remove the user as an editor instead.
Please use :meth:`remove_editor` rather than setting it... | [
"Add",
"an",
"editor",
"to",
"this",
"wiki",
"page",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/objects.py#L1917-L1934 | [
"def",
"add_editor",
"(",
"self",
",",
"username",
",",
"_delete",
"=",
"False",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"url",
"=",
"self",
".",
"reddit_session",
".",
"config",
"[",
"'wiki_page_editor'",
"]",
"url",
"=",
"url",
".",
"f... | ccef2af042566ad384977028cf0bde01bc524dda |
train | WikiPage.get_settings | Return the settings for this wiki page.
Includes permission level, names of editors, and whether
the page is listed on /wiki/pages.
Additional parameters are passed into
:meth:`~praw.__init__.BaseReddit.request_json` | rtv/packages/praw/objects.py | def get_settings(self, *args, **kwargs):
"""Return the settings for this wiki page.
Includes permission level, names of editors, and whether
the page is listed on /wiki/pages.
Additional parameters are passed into
:meth:`~praw.__init__.BaseReddit.request_json`
"""
... | def get_settings(self, *args, **kwargs):
"""Return the settings for this wiki page.
Includes permission level, names of editors, and whether
the page is listed on /wiki/pages.
Additional parameters are passed into
:meth:`~praw.__init__.BaseReddit.request_json`
"""
... | [
"Return",
"the",
"settings",
"for",
"this",
"wiki",
"page",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/objects.py#L1937-L1949 | [
"def",
"get_settings",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"url",
"=",
"self",
".",
"reddit_session",
".",
"config",
"[",
"'wiki_page_settings'",
"]",
"url",
"=",
"url",
".",
"format",
"(",
"subreddit",
"=",
"six",
".",
... | ccef2af042566ad384977028cf0bde01bc524dda |
train | WikiPage.edit | Edit the wiki page.
Convenience function that utilizes
:meth:`.AuthenticatedReddit.edit_wiki_page` populating both the
``subreddit`` and ``page`` parameters. | rtv/packages/praw/objects.py | def edit(self, *args, **kwargs):
"""Edit the wiki page.
Convenience function that utilizes
:meth:`.AuthenticatedReddit.edit_wiki_page` populating both the
``subreddit`` and ``page`` parameters.
"""
return self.subreddit.edit_wiki_page(self.page, *args, **kwargs) | def edit(self, *args, **kwargs):
"""Edit the wiki page.
Convenience function that utilizes
:meth:`.AuthenticatedReddit.edit_wiki_page` populating both the
``subreddit`` and ``page`` parameters.
"""
return self.subreddit.edit_wiki_page(self.page, *args, **kwargs) | [
"Edit",
"the",
"wiki",
"page",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/objects.py#L1951-L1958 | [
"def",
"edit",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"subreddit",
".",
"edit_wiki_page",
"(",
"self",
".",
"page",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | ccef2af042566ad384977028cf0bde01bc524dda |
train | WikiPage.edit_settings | Edit the settings for this individual wiki page.
:param permlevel: Who can edit this page?
(0) use subreddit wiki permissions, (1) only approved wiki
contributors for this page may edit (see
:meth:`~praw.objects.WikiPage.add_editor`), (2) only mods may edit
and v... | rtv/packages/praw/objects.py | def edit_settings(self, permlevel, listed, *args, **kwargs):
"""Edit the settings for this individual wiki page.
:param permlevel: Who can edit this page?
(0) use subreddit wiki permissions, (1) only approved wiki
contributors for this page may edit (see
:meth:`~praw... | def edit_settings(self, permlevel, listed, *args, **kwargs):
"""Edit the settings for this individual wiki page.
:param permlevel: Who can edit this page?
(0) use subreddit wiki permissions, (1) only approved wiki
contributors for this page may edit (see
:meth:`~praw... | [
"Edit",
"the",
"settings",
"for",
"this",
"individual",
"wiki",
"page",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/objects.py#L1961-L1984 | [
"def",
"edit_settings",
"(",
"self",
",",
"permlevel",
",",
"listed",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"url",
"=",
"self",
".",
"reddit_session",
".",
"config",
"[",
"'wiki_page_settings'",
"]",
"url",
"=",
"url",
".",
"format",
"("... | ccef2af042566ad384977028cf0bde01bc524dda |
train | WikiPage.remove_editor | Remove an editor from this wiki page.
:param username: The name or Redditor object of the user to remove.
This method points to :meth:`add_editor` with _delete=True.
Additional parameters are are passed to :meth:`add_editor` and
subsequently into :meth:`~praw.__init__.BaseReddit.reque... | rtv/packages/praw/objects.py | def remove_editor(self, username, *args, **kwargs):
"""Remove an editor from this wiki page.
:param username: The name or Redditor object of the user to remove.
This method points to :meth:`add_editor` with _delete=True.
Additional parameters are are passed to :meth:`add_editor` and
... | def remove_editor(self, username, *args, **kwargs):
"""Remove an editor from this wiki page.
:param username: The name or Redditor object of the user to remove.
This method points to :meth:`add_editor` with _delete=True.
Additional parameters are are passed to :meth:`add_editor` and
... | [
"Remove",
"an",
"editor",
"from",
"this",
"wiki",
"page",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/objects.py#L1986-L1997 | [
"def",
"remove_editor",
"(",
"self",
",",
"username",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"add_editor",
"(",
"username",
"=",
"username",
",",
"_delete",
"=",
"True",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
... | ccef2af042566ad384977028cf0bde01bc524dda |
train | WikiPageListing._convert | Return a WikiPage object from the data. | rtv/packages/praw/objects.py | def _convert(reddit_session, data):
"""Return a WikiPage object from the data."""
# TODO: The _request_url hack shouldn't be necessary
# pylint: disable=W0212
subreddit = reddit_session._request_url.rsplit('/', 4)[1]
# pylint: enable=W0212
return WikiPage(reddit_session, ... | def _convert(reddit_session, data):
"""Return a WikiPage object from the data."""
# TODO: The _request_url hack shouldn't be necessary
# pylint: disable=W0212
subreddit = reddit_session._request_url.rsplit('/', 4)[1]
# pylint: enable=W0212
return WikiPage(reddit_session, ... | [
"Return",
"a",
"WikiPage",
"object",
"from",
"the",
"data",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/objects.py#L2006-L2012 | [
"def",
"_convert",
"(",
"reddit_session",
",",
"data",
")",
":",
"# TODO: The _request_url hack shouldn't be necessary",
"# pylint: disable=W0212",
"subreddit",
"=",
"reddit_session",
".",
"_request_url",
".",
"rsplit",
"(",
"'/'",
",",
"4",
")",
"[",
"1",
"]",
"# p... | ccef2af042566ad384977028cf0bde01bc524dda |
train | comment_stream | Indefinitely yield new comments from the provided subreddit.
Comments are yielded from oldest to newest.
:param reddit_session: The reddit_session to make requests from. In all the
examples this is assigned to the variable ``r``.
:param subreddit: Either a subreddit object, or the name of a
... | rtv/packages/praw/helpers.py | def comment_stream(reddit_session, subreddit, limit=None, verbosity=1):
"""Indefinitely yield new comments from the provided subreddit.
Comments are yielded from oldest to newest.
:param reddit_session: The reddit_session to make requests from. In all the
examples this is assigned to the variable ... | def comment_stream(reddit_session, subreddit, limit=None, verbosity=1):
"""Indefinitely yield new comments from the provided subreddit.
Comments are yielded from oldest to newest.
:param reddit_session: The reddit_session to make requests from. In all the
examples this is assigned to the variable ... | [
"Indefinitely",
"yield",
"new",
"comments",
"from",
"the",
"provided",
"subreddit",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/helpers.py#L40-L64 | [
"def",
"comment_stream",
"(",
"reddit_session",
",",
"subreddit",
",",
"limit",
"=",
"None",
",",
"verbosity",
"=",
"1",
")",
":",
"get_function",
"=",
"partial",
"(",
"reddit_session",
".",
"get_comments",
",",
"six",
".",
"text_type",
"(",
"subreddit",
")"... | ccef2af042566ad384977028cf0bde01bc524dda |
train | submission_stream | Indefinitely yield new submissions from the provided subreddit.
Submissions are yielded from oldest to newest.
:param reddit_session: The reddit_session to make requests from. In all the
examples this is assigned to the variable ``r``.
:param subreddit: Either a subreddit object, or the name of a
... | rtv/packages/praw/helpers.py | def submission_stream(reddit_session, subreddit, limit=None, verbosity=1):
"""Indefinitely yield new submissions from the provided subreddit.
Submissions are yielded from oldest to newest.
:param reddit_session: The reddit_session to make requests from. In all the
examples this is assigned to the ... | def submission_stream(reddit_session, subreddit, limit=None, verbosity=1):
"""Indefinitely yield new submissions from the provided subreddit.
Submissions are yielded from oldest to newest.
:param reddit_session: The reddit_session to make requests from. In all the
examples this is assigned to the ... | [
"Indefinitely",
"yield",
"new",
"submissions",
"from",
"the",
"provided",
"subreddit",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/helpers.py#L67-L96 | [
"def",
"submission_stream",
"(",
"reddit_session",
",",
"subreddit",
",",
"limit",
"=",
"None",
",",
"verbosity",
"=",
"1",
")",
":",
"if",
"six",
".",
"text_type",
"(",
"subreddit",
")",
".",
"lower",
"(",
")",
"==",
"\"all\"",
":",
"if",
"limit",
"is... | ccef2af042566ad384977028cf0bde01bc524dda |
train | valid_redditors | Return a verified list of valid Redditor instances.
:param redditors: A list comprised of Redditor instances and/or strings
that are to be verified as actual redditor accounts.
:param sub: A Subreddit instance that the authenticated account has
flair changing permission on.
Note: Flair wil... | rtv/packages/praw/helpers.py | def valid_redditors(redditors, sub):
"""Return a verified list of valid Redditor instances.
:param redditors: A list comprised of Redditor instances and/or strings
that are to be verified as actual redditor accounts.
:param sub: A Subreddit instance that the authenticated account has
flair ... | def valid_redditors(redditors, sub):
"""Return a verified list of valid Redditor instances.
:param redditors: A list comprised of Redditor instances and/or strings
that are to be verified as actual redditor accounts.
:param sub: A Subreddit instance that the authenticated account has
flair ... | [
"Return",
"a",
"verified",
"list",
"of",
"valid",
"Redditor",
"instances",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/helpers.py#L99-L116 | [
"def",
"valid_redditors",
"(",
"redditors",
",",
"sub",
")",
":",
"simplified",
"=",
"list",
"(",
"set",
"(",
"six",
".",
"text_type",
"(",
"x",
")",
".",
"lower",
"(",
")",
"for",
"x",
"in",
"redditors",
")",
")",
"return",
"[",
"sub",
".",
"reddi... | ccef2af042566ad384977028cf0bde01bc524dda |
train | submissions_between | Yield submissions between two timestamps.
If both ``highest_timestamp`` and ``lowest_timestamp`` are unspecified,
yields all submissions in the ``subreddit``.
Submissions are yielded from newest to oldest(like in the "new" queue).
:param reddit_session: The reddit_session to make requests from. In al... | rtv/packages/praw/helpers.py | def submissions_between(reddit_session,
subreddit,
lowest_timestamp=None,
highest_timestamp=None,
newest_first=True,
extra_cloudsearch_fields=None,
verbosity=1):
"""Yield s... | def submissions_between(reddit_session,
subreddit,
lowest_timestamp=None,
highest_timestamp=None,
newest_first=True,
extra_cloudsearch_fields=None,
verbosity=1):
"""Yield s... | [
"Yield",
"submissions",
"between",
"two",
"timestamps",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/helpers.py#L119-L286 | [
"def",
"submissions_between",
"(",
"reddit_session",
",",
"subreddit",
",",
"lowest_timestamp",
"=",
"None",
",",
"highest_timestamp",
"=",
"None",
",",
"newest_first",
"=",
"True",
",",
"extra_cloudsearch_fields",
"=",
"None",
",",
"verbosity",
"=",
"1",
")",
"... | ccef2af042566ad384977028cf0bde01bc524dda |
train | chunk_sequence | Given a sequence, divide it into sequences of length `chunk_length`.
:param allow_incomplete: If True, allow final chunk to be shorter if the
given sequence is not an exact multiple of `chunk_length`.
If False, the incomplete chunk will be discarded. | rtv/packages/praw/helpers.py | def chunk_sequence(sequence, chunk_length, allow_incomplete=True):
"""Given a sequence, divide it into sequences of length `chunk_length`.
:param allow_incomplete: If True, allow final chunk to be shorter if the
given sequence is not an exact multiple of `chunk_length`.
If False, the incomplete... | def chunk_sequence(sequence, chunk_length, allow_incomplete=True):
"""Given a sequence, divide it into sequences of length `chunk_length`.
:param allow_incomplete: If True, allow final chunk to be shorter if the
given sequence is not an exact multiple of `chunk_length`.
If False, the incomplete... | [
"Given",
"a",
"sequence",
"divide",
"it",
"into",
"sequences",
"of",
"length",
"chunk_length",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/helpers.py#L360-L379 | [
"def",
"chunk_sequence",
"(",
"sequence",
",",
"chunk_length",
",",
"allow_incomplete",
"=",
"True",
")",
":",
"(",
"complete",
",",
"leftover",
")",
"=",
"divmod",
"(",
"len",
"(",
"sequence",
")",
",",
"chunk_length",
")",
"if",
"not",
"allow_incomplete",
... | ccef2af042566ad384977028cf0bde01bc524dda |
train | convert_id36_to_numeric_id | Convert strings representing base36 numbers into an integer. | rtv/packages/praw/helpers.py | def convert_id36_to_numeric_id(id36):
"""Convert strings representing base36 numbers into an integer."""
if not isinstance(id36, six.string_types) or id36.count("_") > 0:
raise ValueError("must supply base36 string, not fullname (e.g. use "
"xxxxx, not t3_xxxxx)")
return int... | def convert_id36_to_numeric_id(id36):
"""Convert strings representing base36 numbers into an integer."""
if not isinstance(id36, six.string_types) or id36.count("_") > 0:
raise ValueError("must supply base36 string, not fullname (e.g. use "
"xxxxx, not t3_xxxxx)")
return int... | [
"Convert",
"strings",
"representing",
"base36",
"numbers",
"into",
"an",
"integer",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/helpers.py#L382-L387 | [
"def",
"convert_id36_to_numeric_id",
"(",
"id36",
")",
":",
"if",
"not",
"isinstance",
"(",
"id36",
",",
"six",
".",
"string_types",
")",
"or",
"id36",
".",
"count",
"(",
"\"_\"",
")",
">",
"0",
":",
"raise",
"ValueError",
"(",
"\"must supply base36 string, ... | ccef2af042566ad384977028cf0bde01bc524dda |
train | convert_numeric_id_to_id36 | Convert an integer into its base36 string representation.
This method has been cleaned up slightly to improve readability. For more
info see:
https://github.com/reddit/reddit/blob/master/r2/r2/lib/utils/_utils.pyx
https://www.reddit.com/r/redditdev/comments/n624n/submission_ids_question/
https:/... | rtv/packages/praw/helpers.py | def convert_numeric_id_to_id36(numeric_id):
"""Convert an integer into its base36 string representation.
This method has been cleaned up slightly to improve readability. For more
info see:
https://github.com/reddit/reddit/blob/master/r2/r2/lib/utils/_utils.pyx
https://www.reddit.com/r/redditdev/c... | def convert_numeric_id_to_id36(numeric_id):
"""Convert an integer into its base36 string representation.
This method has been cleaned up slightly to improve readability. For more
info see:
https://github.com/reddit/reddit/blob/master/r2/r2/lib/utils/_utils.pyx
https://www.reddit.com/r/redditdev/c... | [
"Convert",
"an",
"integer",
"into",
"its",
"base36",
"string",
"representation",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/helpers.py#L390-L424 | [
"def",
"convert_numeric_id_to_id36",
"(",
"numeric_id",
")",
":",
"# base36 allows negative numbers, but reddit does not",
"if",
"not",
"isinstance",
"(",
"numeric_id",
",",
"six",
".",
"integer_types",
")",
"or",
"numeric_id",
"<",
"0",
":",
"raise",
"ValueError",
"(... | ccef2af042566ad384977028cf0bde01bc524dda |
train | flatten_tree | Return a flattened version of the passed in tree.
:param nested_attr: The attribute name that contains the nested items.
Defaults to ``replies`` which is suitable for comments.
:param depth_first: When true, add to the list in a depth-first manner
rather than the default breadth-first manner. | rtv/packages/praw/helpers.py | def flatten_tree(tree, nested_attr='replies', depth_first=False):
"""Return a flattened version of the passed in tree.
:param nested_attr: The attribute name that contains the nested items.
Defaults to ``replies`` which is suitable for comments.
:param depth_first: When true, add to the list in a d... | def flatten_tree(tree, nested_attr='replies', depth_first=False):
"""Return a flattened version of the passed in tree.
:param nested_attr: The attribute name that contains the nested items.
Defaults to ``replies`` which is suitable for comments.
:param depth_first: When true, add to the list in a d... | [
"Return",
"a",
"flattened",
"version",
"of",
"the",
"passed",
"in",
"tree",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/helpers.py#L427-L445 | [
"def",
"flatten_tree",
"(",
"tree",
",",
"nested_attr",
"=",
"'replies'",
",",
"depth_first",
"=",
"False",
")",
":",
"stack",
"=",
"deque",
"(",
"tree",
")",
"extend",
"=",
"stack",
".",
"extend",
"if",
"depth_first",
"else",
"stack",
".",
"extendleft",
... | ccef2af042566ad384977028cf0bde01bc524dda |
train | normalize_url | Return url after stripping trailing .json and trailing slashes. | rtv/packages/praw/helpers.py | def normalize_url(url):
"""Return url after stripping trailing .json and trailing slashes."""
if url.endswith('.json'):
url = url[:-5]
if url.endswith('/'):
url = url[:-1]
return url | def normalize_url(url):
"""Return url after stripping trailing .json and trailing slashes."""
if url.endswith('.json'):
url = url[:-5]
if url.endswith('/'):
url = url[:-1]
return url | [
"Return",
"url",
"after",
"stripping",
"trailing",
".",
"json",
"and",
"trailing",
"slashes",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/helpers.py#L448-L454 | [
"def",
"normalize_url",
"(",
"url",
")",
":",
"if",
"url",
".",
"endswith",
"(",
"'.json'",
")",
":",
"url",
"=",
"url",
"[",
":",
"-",
"5",
"]",
"if",
"url",
".",
"endswith",
"(",
"'/'",
")",
":",
"url",
"=",
"url",
"[",
":",
"-",
"1",
"]",
... | ccef2af042566ad384977028cf0bde01bc524dda |
train | BoundedSet.add | Add an item to the set discarding the oldest item if necessary. | rtv/packages/praw/helpers.py | def add(self, item):
"""Add an item to the set discarding the oldest item if necessary."""
if item in self._set:
self._fifo.remove(item)
elif len(self._set) == self.max_items:
self._set.remove(self._fifo.pop(0))
self._fifo.append(item)
self._set.add(item) | def add(self, item):
"""Add an item to the set discarding the oldest item if necessary."""
if item in self._set:
self._fifo.remove(item)
elif len(self._set) == self.max_items:
self._set.remove(self._fifo.pop(0))
self._fifo.append(item)
self._set.add(item) | [
"Add",
"an",
"item",
"to",
"the",
"set",
"discarding",
"the",
"oldest",
"item",
"if",
"necessary",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/helpers.py#L474-L481 | [
"def",
"add",
"(",
"self",
",",
"item",
")",
":",
"if",
"item",
"in",
"self",
".",
"_set",
":",
"self",
".",
"_fifo",
".",
"remove",
"(",
"item",
")",
"elif",
"len",
"(",
"self",
".",
"_set",
")",
"==",
"self",
".",
"max_items",
":",
"self",
".... | ccef2af042566ad384977028cf0bde01bc524dda |
train | export_table | Downloads an entire table as a zip file.
:param str datatable_code: The datatable code to download, such as MER/F1
:param str filename: The filename for the download. \
If not specified, will download to the current working directory
:param str api_key: Most databases require api_key for bulk download | quandl/export_table.py | def export_table(datatable_code, **kwargs):
"""Downloads an entire table as a zip file.
:param str datatable_code: The datatable code to download, such as MER/F1
:param str filename: The filename for the download. \
If not specified, will download to the current working directory
:param str api_key:... | def export_table(datatable_code, **kwargs):
"""Downloads an entire table as a zip file.
:param str datatable_code: The datatable code to download, such as MER/F1
:param str filename: The filename for the download. \
If not specified, will download to the current working directory
:param str api_key:... | [
"Downloads",
"an",
"entire",
"table",
"as",
"a",
"zip",
"file",
".",
":",
"param",
"str",
"datatable_code",
":",
"The",
"datatable",
"code",
"to",
"download",
"such",
"as",
"MER",
"/",
"F1",
":",
"param",
"str",
"filename",
":",
"The",
"filename",
"for",... | quandl/quandl-python | python | https://github.com/quandl/quandl-python/blob/36d9abf210e73c4bba06b25a1f26aa726f4a0ea6/quandl/export_table.py#L7-L22 | [
"def",
"export_table",
"(",
"datatable_code",
",",
"*",
"*",
"kwargs",
")",
":",
"# discourage users from using authtoken",
"if",
"'authtoken'",
"in",
"kwargs",
":",
"raise",
"InvalidRequestError",
"(",
"Message",
".",
"ERROR_AUTHTOKEN_NOT_SUPPORTED",
")",
"ApiKeyUtil",... | 36d9abf210e73c4bba06b25a1f26aa726f4a0ea6 |
train | get | Return dataframe of requested dataset from Quandl.
:param dataset: str or list, depending on single dataset usage or multiset usage
Dataset codes are available on the Quandl website
:param str api_key: Downloads are limited to 50 unless api_key is specified
:param str start_date, end_date: Optio... | quandl/get.py | def get(dataset, **kwargs):
"""Return dataframe of requested dataset from Quandl.
:param dataset: str or list, depending on single dataset usage or multiset usage
Dataset codes are available on the Quandl website
:param str api_key: Downloads are limited to 50 unless api_key is specified
:pa... | def get(dataset, **kwargs):
"""Return dataframe of requested dataset from Quandl.
:param dataset: str or list, depending on single dataset usage or multiset usage
Dataset codes are available on the Quandl website
:param str api_key: Downloads are limited to 50 unless api_key is specified
:pa... | [
"Return",
"dataframe",
"of",
"requested",
"dataset",
"from",
"Quandl",
".",
":",
"param",
"dataset",
":",
"str",
"or",
"list",
"depending",
"on",
"single",
"dataset",
"usage",
"or",
"multiset",
"usage",
"Dataset",
"codes",
"are",
"available",
"on",
"the",
"Q... | quandl/quandl-python | python | https://github.com/quandl/quandl-python/blob/36d9abf210e73c4bba06b25a1f26aa726f4a0ea6/quandl/get.py#L14-L63 | [
"def",
"get",
"(",
"dataset",
",",
"*",
"*",
"kwargs",
")",
":",
"_convert_params_to_v3",
"(",
"kwargs",
")",
"data_format",
"=",
"kwargs",
".",
"pop",
"(",
"'returns'",
",",
"'pandas'",
")",
"ApiKeyUtil",
".",
"init_api_key_from_args",
"(",
"kwargs",
")",
... | 36d9abf210e73c4bba06b25a1f26aa726f4a0ea6 |
train | bulkdownload | Downloads an entire database.
:param str database: The database code to download
:param str filename: The filename for the download. \
If not specified, will download to the current working directory
:param str api_key: Most databases require api_key for bulk download
:param str download_type: 'part... | quandl/bulkdownload.py | def bulkdownload(database, **kwargs):
"""Downloads an entire database.
:param str database: The database code to download
:param str filename: The filename for the download. \
If not specified, will download to the current working directory
:param str api_key: Most databases require api_key for bulk... | def bulkdownload(database, **kwargs):
"""Downloads an entire database.
:param str database: The database code to download
:param str filename: The filename for the download. \
If not specified, will download to the current working directory
:param str api_key: Most databases require api_key for bulk... | [
"Downloads",
"an",
"entire",
"database",
".",
":",
"param",
"str",
"database",
":",
"The",
"database",
"code",
"to",
"download",
":",
"param",
"str",
"filename",
":",
"The",
"filename",
"for",
"the",
"download",
".",
"\\",
"If",
"not",
"specified",
"will",... | quandl/quandl-python | python | https://github.com/quandl/quandl-python/blob/36d9abf210e73c4bba06b25a1f26aa726f4a0ea6/quandl/bulkdownload.py#L7-L24 | [
"def",
"bulkdownload",
"(",
"database",
",",
"*",
"*",
"kwargs",
")",
":",
"# discourage users from using authtoken",
"if",
"'authtoken'",
"in",
"kwargs",
":",
"raise",
"InvalidRequestError",
"(",
"Message",
".",
"ERROR_AUTHTOKEN_NOT_SUPPORTED",
")",
"ApiKeyUtil",
"."... | 36d9abf210e73c4bba06b25a1f26aa726f4a0ea6 |
train | JSONRPCAPI.jsonrpc_map | Map of json-rpc available calls.
:return str: | poco/utils/simplerpc/jsonrpc/backend/flask.py | def jsonrpc_map(self):
""" Map of json-rpc available calls.
:return str:
"""
result = "<h1>JSON-RPC map</h1><pre>{0}</pre>".format("\n\n".join([
"{0}: {1}".format(fname, f.__doc__)
for fname, f in self.dispatcher.items()
]))
return Response(resul... | def jsonrpc_map(self):
""" Map of json-rpc available calls.
:return str:
"""
result = "<h1>JSON-RPC map</h1><pre>{0}</pre>".format("\n\n".join([
"{0}: {1}".format(fname, f.__doc__)
for fname, f in self.dispatcher.items()
]))
return Response(resul... | [
"Map",
"of",
"json",
"-",
"rpc",
"available",
"calls",
"."
] | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/utils/simplerpc/jsonrpc/backend/flask.py#L69-L79 | [
"def",
"jsonrpc_map",
"(",
"self",
")",
":",
"result",
"=",
"\"<h1>JSON-RPC map</h1><pre>{0}</pre>\"",
".",
"format",
"(",
"\"\\n\\n\"",
".",
"join",
"(",
"[",
"\"{0}: {1}\"",
".",
"format",
"(",
"fname",
",",
"f",
".",
"__doc__",
")",
"for",
"fname",
",",
... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | HunterCommand.command | 通过hunter调用gm指令,可调用hunter指令库中定义的所有指令,也可以调用text类型的gm指令
gm指令相关功能请参考safaia GM指令扩展模块
:param cmd: 指令
:param type: 语言,默认text
:return: None | poco/utils/hunter/command.py | def command(self, cmd, type=None):
"""
通过hunter调用gm指令,可调用hunter指令库中定义的所有指令,也可以调用text类型的gm指令
gm指令相关功能请参考safaia GM指令扩展模块
:param cmd: 指令
:param type: 语言,默认text
:return: None
"""
type = type or 'text'
self.hunter.script(cmd, lang=type) | def command(self, cmd, type=None):
"""
通过hunter调用gm指令,可调用hunter指令库中定义的所有指令,也可以调用text类型的gm指令
gm指令相关功能请参考safaia GM指令扩展模块
:param cmd: 指令
:param type: 语言,默认text
:return: None
"""
type = type or 'text'
self.hunter.script(cmd, lang=type) | [
"通过hunter调用gm指令,可调用hunter指令库中定义的所有指令,也可以调用text类型的gm指令",
"gm指令相关功能请参考safaia",
"GM指令扩展模块"
] | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/utils/hunter/command.py#L12-L23 | [
"def",
"command",
"(",
"self",
",",
"cmd",
",",
"type",
"=",
"None",
")",
":",
"type",
"=",
"type",
"or",
"'text'",
"self",
".",
"hunter",
".",
"script",
"(",
"cmd",
",",
"lang",
"=",
"type",
")"
] | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | Dispatcher.add_method | Add a method to the dispatcher.
Parameters
----------
f : callable
Callable to be added.
name : str, optional
Name to register (the default is function **f** name)
Notes
-----
When used as a decorator keeps callable object unmodified.
... | poco/utils/simplerpc/jsonrpc/dispatcher.py | def add_method(self, f, name=None):
""" Add a method to the dispatcher.
Parameters
----------
f : callable
Callable to be added.
name : str, optional
Name to register (the default is function **f** name)
Notes
-----
When used as a... | def add_method(self, f, name=None):
""" Add a method to the dispatcher.
Parameters
----------
f : callable
Callable to be added.
name : str, optional
Name to register (the default is function **f** name)
Notes
-----
When used as a... | [
"Add",
"a",
"method",
"to",
"the",
"dispatcher",
"."
] | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/utils/simplerpc/jsonrpc/dispatcher.py#L66-L98 | [
"def",
"add_method",
"(",
"self",
",",
"f",
",",
"name",
"=",
"None",
")",
":",
"self",
".",
"method_map",
"[",
"name",
"or",
"f",
".",
"__name__",
"]",
"=",
"f",
"return",
"f"
] | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | Dispatcher.build_method_map | Add prototype methods to the dispatcher.
Parameters
----------
prototype : object or dict
Initial method mapping.
If given prototype is a dictionary then all callable objects will
be added to dispatcher.
If given prototype is an object then all pu... | poco/utils/simplerpc/jsonrpc/dispatcher.py | def build_method_map(self, prototype, prefix=''):
""" Add prototype methods to the dispatcher.
Parameters
----------
prototype : object or dict
Initial method mapping.
If given prototype is a dictionary then all callable objects will
be added to dispa... | def build_method_map(self, prototype, prefix=''):
""" Add prototype methods to the dispatcher.
Parameters
----------
prototype : object or dict
Initial method mapping.
If given prototype is a dictionary then all callable objects will
be added to dispa... | [
"Add",
"prototype",
"methods",
"to",
"the",
"dispatcher",
"."
] | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/utils/simplerpc/jsonrpc/dispatcher.py#L100-L122 | [
"def",
"build_method_map",
"(",
"self",
",",
"prototype",
",",
"prefix",
"=",
"''",
")",
":",
"if",
"not",
"isinstance",
"(",
"prototype",
",",
"dict",
")",
":",
"prototype",
"=",
"dict",
"(",
"(",
"method",
",",
"getattr",
"(",
"prototype",
",",
"meth... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | SimpleProtocolFilter.input | 小数据片段拼接成完整数据包
如果内容足够则yield数据包 | poco/utils/simplerpc/transport/tcp/protocol.py | def input(self, data):
""" 小数据片段拼接成完整数据包
如果内容足够则yield数据包
"""
self.buf += data
while len(self.buf) > HEADER_SIZE:
data_len = struct.unpack('i', self.buf[0:HEADER_SIZE])[0]
if len(self.buf) >= data_len + HEADER_SIZE:
content = self.buf[HE... | def input(self, data):
""" 小数据片段拼接成完整数据包
如果内容足够则yield数据包
"""
self.buf += data
while len(self.buf) > HEADER_SIZE:
data_len = struct.unpack('i', self.buf[0:HEADER_SIZE])[0]
if len(self.buf) >= data_len + HEADER_SIZE:
content = self.buf[HE... | [
"小数据片段拼接成完整数据包",
"如果内容足够则yield数据包"
] | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/utils/simplerpc/transport/tcp/protocol.py#L25-L37 | [
"def",
"input",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"buf",
"+=",
"data",
"while",
"len",
"(",
"self",
".",
"buf",
")",
">",
"HEADER_SIZE",
":",
"data_len",
"=",
"struct",
".",
"unpack",
"(",
"'i'",
",",
"self",
".",
"buf",
"[",
"0",
... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | SimpleProtocolFilter.pack | content should be str | poco/utils/simplerpc/transport/tcp/protocol.py | def pack(content):
""" content should be str
"""
if isinstance(content, six.text_type):
content = content.encode("utf-8")
return struct.pack('i', len(content)) + content | def pack(content):
""" content should be str
"""
if isinstance(content, six.text_type):
content = content.encode("utf-8")
return struct.pack('i', len(content)) + content | [
"content",
"should",
"be",
"str"
] | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/utils/simplerpc/transport/tcp/protocol.py#L40-L45 | [
"def",
"pack",
"(",
"content",
")",
":",
"if",
"isinstance",
"(",
"content",
",",
"six",
".",
"text_type",
")",
":",
"content",
"=",
"content",
".",
"encode",
"(",
"\"utf-8\"",
")",
"return",
"struct",
".",
"pack",
"(",
"'i'",
",",
"len",
"(",
"conte... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | SimpleProtocolFilter.unpack | return length, content | poco/utils/simplerpc/transport/tcp/protocol.py | def unpack(data):
""" return length, content
"""
length = struct.unpack('i', data[0:HEADER_SIZE])
return length[0], data[HEADER_SIZE:] | def unpack(data):
""" return length, content
"""
length = struct.unpack('i', data[0:HEADER_SIZE])
return length[0], data[HEADER_SIZE:] | [
"return",
"length",
"content"
] | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/utils/simplerpc/transport/tcp/protocol.py#L48-L52 | [
"def",
"unpack",
"(",
"data",
")",
":",
"length",
"=",
"struct",
".",
"unpack",
"(",
"'i'",
",",
"data",
"[",
"0",
":",
"HEADER_SIZE",
"]",
")",
"return",
"length",
"[",
"0",
"]",
",",
"data",
"[",
"HEADER_SIZE",
":",
"]"
] | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | WebSocket.sendFragmentStart | Send the start of a data fragment stream to a websocket client.
Subsequent data should be sent using sendFragment().
A fragment stream is completed when sendFragmentEnd() is called.
If data is a unicode object then the frame is sent as Text.
If the data is a bytearray ob... | poco/utils/net/transport/simple_wss.py | def sendFragmentStart(self, data):
"""
Send the start of a data fragment stream to a websocket client.
Subsequent data should be sent using sendFragment().
A fragment stream is completed when sendFragmentEnd() is called.
If data is a unicode object then the frame... | def sendFragmentStart(self, data):
"""
Send the start of a data fragment stream to a websocket client.
Subsequent data should be sent using sendFragment().
A fragment stream is completed when sendFragmentEnd() is called.
If data is a unicode object then the frame... | [
"Send",
"the",
"start",
"of",
"a",
"data",
"fragment",
"stream",
"to",
"a",
"websocket",
"client",
".",
"Subsequent",
"data",
"should",
"be",
"sent",
"using",
"sendFragment",
"()",
".",
"A",
"fragment",
"stream",
"is",
"completed",
"when",
"sendFragmentEnd",
... | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/utils/net/transport/simple_wss.py#L341-L353 | [
"def",
"sendFragmentStart",
"(",
"self",
",",
"data",
")",
":",
"opcode",
"=",
"BINARY",
"if",
"_check_unicode",
"(",
"data",
")",
":",
"opcode",
"=",
"TEXT",
"self",
".",
"_sendMessage",
"(",
"True",
",",
"opcode",
",",
"data",
")"
] | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | WebSocket.sendMessage | Send websocket data frame to the client.
If data is a unicode object then the frame is sent as Text.
If the data is a bytearray object then the frame is sent as Binary. | poco/utils/net/transport/simple_wss.py | def sendMessage(self, data):
"""
Send websocket data frame to the client.
If data is a unicode object then the frame is sent as Text.
If the data is a bytearray object then the frame is sent as Binary.
"""
opcode = BINARY
if _check_unicode(data):
... | def sendMessage(self, data):
"""
Send websocket data frame to the client.
If data is a unicode object then the frame is sent as Text.
If the data is a bytearray object then the frame is sent as Binary.
"""
opcode = BINARY
if _check_unicode(data):
... | [
"Send",
"websocket",
"data",
"frame",
"to",
"the",
"client",
"."
] | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/utils/net/transport/simple_wss.py#L373-L383 | [
"def",
"sendMessage",
"(",
"self",
",",
"data",
")",
":",
"opcode",
"=",
"BINARY",
"if",
"_check_unicode",
"(",
"data",
")",
":",
"opcode",
"=",
"TEXT",
"self",
".",
"_sendMessage",
"(",
"False",
",",
"opcode",
",",
"data",
")"
] | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | transform_node_has_been_removed_exception | 将HRpcRemoteException.NodeHasBeenRemovedException转换成PocoTargetRemovedException
:param func: 仅限getattr和setattr两个接口方法
:return: | poco/utils/hrpc/utils.py | def transform_node_has_been_removed_exception(func):
"""
将HRpcRemoteException.NodeHasBeenRemovedException转换成PocoTargetRemovedException
:param func: 仅限getattr和setattr两个接口方法
:return:
"""
@wraps(func)
def wrapped(self, nodes, name, *args, **kwargs):
"""
:param self:
... | def transform_node_has_been_removed_exception(func):
"""
将HRpcRemoteException.NodeHasBeenRemovedException转换成PocoTargetRemovedException
:param func: 仅限getattr和setattr两个接口方法
:return:
"""
@wraps(func)
def wrapped(self, nodes, name, *args, **kwargs):
"""
:param self:
... | [
"将HRpcRemoteException",
".",
"NodeHasBeenRemovedException转换成PocoTargetRemovedException"
] | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/utils/hrpc/utils.py#L11-L43 | [
"def",
"transform_node_has_been_removed_exception",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapped",
"(",
"self",
",",
"nodes",
",",
"name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"\n\n :param self:\n :... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | JSONRPCResponseManager.handle_request | Handle request data.
At this moment request has correct jsonrpc format.
:param dict request: data parsed from request_str.
:param jsonrpc.dispatcher.Dispatcher dispatcher:
.. versionadded: 1.8.0 | poco/utils/simplerpc/jsonrpc/manager.py | def handle_request(cls, request, dispatcher):
""" Handle request data.
At this moment request has correct jsonrpc format.
:param dict request: data parsed from request_str.
:param jsonrpc.dispatcher.Dispatcher dispatcher:
.. versionadded: 1.8.0
"""
rs = reques... | def handle_request(cls, request, dispatcher):
""" Handle request data.
At this moment request has correct jsonrpc format.
:param dict request: data parsed from request_str.
:param jsonrpc.dispatcher.Dispatcher dispatcher:
.. versionadded: 1.8.0
"""
rs = reques... | [
"Handle",
"request",
"data",
"."
] | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/utils/simplerpc/jsonrpc/manager.py#L62-L85 | [
"def",
"handle_request",
"(",
"cls",
",",
"request",
",",
"dispatcher",
")",
":",
"rs",
"=",
"request",
"if",
"isinstance",
"(",
"request",
",",
"JSONRPC20BatchRequest",
")",
"else",
"[",
"request",
"]",
"responses",
"=",
"[",
"r",
"for",
"r",
"in",
"cls... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | JSONRPCResponseManager._get_responses | Response to each single JSON-RPC Request.
:return iterator(JSONRPC20Response):
.. versionadded: 1.9.0
TypeError inside the function is distinguished from Invalid Params. | poco/utils/simplerpc/jsonrpc/manager.py | def _get_responses(cls, requests, dispatcher):
""" Response to each single JSON-RPC Request.
:return iterator(JSONRPC20Response):
.. versionadded: 1.9.0
TypeError inside the function is distinguished from Invalid Params.
"""
for request in requests:
def r... | def _get_responses(cls, requests, dispatcher):
""" Response to each single JSON-RPC Request.
:return iterator(JSONRPC20Response):
.. versionadded: 1.9.0
TypeError inside the function is distinguished from Invalid Params.
"""
for request in requests:
def r... | [
"Response",
"to",
"each",
"single",
"JSON",
"-",
"RPC",
"Request",
"."
] | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/utils/simplerpc/jsonrpc/manager.py#L88-L130 | [
"def",
"_get_responses",
"(",
"cls",
",",
"requests",
",",
"dispatcher",
")",
":",
"for",
"request",
"in",
"requests",
":",
"def",
"response",
"(",
"*",
"*",
"kwargs",
")",
":",
"return",
"cls",
".",
"RESPONSE_CLASS_MAP",
"[",
"request",
".",
"JSONRPC_VERS... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | JSONRPCAPI.jsonrpc | JSON-RPC 2.0 handler. | poco/utils/simplerpc/jsonrpc/backend/django.py | def jsonrpc(self, request):
""" JSON-RPC 2.0 handler."""
if request.method != "POST":
return HttpResponseNotAllowed(["POST"])
request_str = request.body.decode('utf8')
try:
jsonrpc_request = JSONRPCRequest.from_json(request_str)
except (TypeError, ValueEr... | def jsonrpc(self, request):
""" JSON-RPC 2.0 handler."""
if request.method != "POST":
return HttpResponseNotAllowed(["POST"])
request_str = request.body.decode('utf8')
try:
jsonrpc_request = JSONRPCRequest.from_json(request_str)
except (TypeError, ValueEr... | [
"JSON",
"-",
"RPC",
"2",
".",
"0",
"handler",
"."
] | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/utils/simplerpc/jsonrpc/backend/django.py#L36-L67 | [
"def",
"jsonrpc",
"(",
"self",
",",
"request",
")",
":",
"if",
"request",
".",
"method",
"!=",
"\"POST\"",
":",
"return",
"HttpResponseNotAllowed",
"(",
"[",
"\"POST\"",
"]",
")",
"request_str",
"=",
"request",
".",
"body",
".",
"decode",
"(",
"'utf8'",
... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | JSONRPCAPI.jsonrpc_map | Map of json-rpc available calls.
:return str: | poco/utils/simplerpc/jsonrpc/backend/django.py | def jsonrpc_map(self, request):
""" Map of json-rpc available calls.
:return str:
"""
result = "<h1>JSON-RPC map</h1><pre>{0}</pre>".format("\n\n".join([
"{0}: {1}".format(fname, f.__doc__)
for fname, f in self.dispatcher.items()
]))
return HttpR... | def jsonrpc_map(self, request):
""" Map of json-rpc available calls.
:return str:
"""
result = "<h1>JSON-RPC map</h1><pre>{0}</pre>".format("\n\n".join([
"{0}: {1}".format(fname, f.__doc__)
for fname, f in self.dispatcher.items()
]))
return HttpR... | [
"Map",
"of",
"json",
"-",
"rpc",
"available",
"calls",
"."
] | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/utils/simplerpc/jsonrpc/backend/django.py#L69-L79 | [
"def",
"jsonrpc_map",
"(",
"self",
",",
"request",
")",
":",
"result",
"=",
"\"<h1>JSON-RPC map</h1><pre>{0}</pre>\"",
".",
"format",
"(",
"\"\\n\\n\"",
".",
"join",
"(",
"[",
"\"{0}: {1}\"",
".",
"format",
"(",
"fname",
",",
"f",
".",
"__doc__",
")",
"for",... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | MotionTrack.discretize | Sample this motion track into discretized motion events.
Args:
contact_id: contact point id
accuracy: motion minimum difference in space
dt: sample time difference | poco/utils/track.py | def discretize(self, contact_id=0, accuracy=0.004, dt=0.001):
"""
Sample this motion track into discretized motion events.
Args:
contact_id: contact point id
accuracy: motion minimum difference in space
dt: sample time difference
"""
if not s... | def discretize(self, contact_id=0, accuracy=0.004, dt=0.001):
"""
Sample this motion track into discretized motion events.
Args:
contact_id: contact point id
accuracy: motion minimum difference in space
dt: sample time difference
"""
if not s... | [
"Sample",
"this",
"motion",
"track",
"into",
"discretized",
"motion",
"events",
"."
] | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/utils/track.py#L78-L117 | [
"def",
"discretize",
"(",
"self",
",",
"contact_id",
"=",
"0",
",",
"accuracy",
"=",
"0.004",
",",
"dt",
"=",
"0.001",
")",
":",
"if",
"not",
"self",
".",
"event_points",
":",
"return",
"[",
"]",
"events",
"=",
"[",
"]",
"action_dt",
"=",
"accuracy",... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | FrozenUIDumper.getRoot | Dump a hierarchy immediately from target runtime and store into a Node (subclass of :py:class:`AbstractNode
<poco.sdk.AbstractNode>`) object.
Returns:
:py:class:`inherit from AbstractNode <Node>`: Each time a new node instance is created by latest hierarchy
data. | poco/freezeui/hierarchy.py | def getRoot(self):
"""
Dump a hierarchy immediately from target runtime and store into a Node (subclass of :py:class:`AbstractNode
<poco.sdk.AbstractNode>`) object.
Returns:
:py:class:`inherit from AbstractNode <Node>`: Each time a new node instance is created by latest hie... | def getRoot(self):
"""
Dump a hierarchy immediately from target runtime and store into a Node (subclass of :py:class:`AbstractNode
<poco.sdk.AbstractNode>`) object.
Returns:
:py:class:`inherit from AbstractNode <Node>`: Each time a new node instance is created by latest hie... | [
"Dump",
"a",
"hierarchy",
"immediately",
"from",
"target",
"runtime",
"and",
"store",
"into",
"a",
"Node",
"(",
"subclass",
"of",
":",
"py",
":",
"class",
":",
"AbstractNode",
"<poco",
".",
"sdk",
".",
"AbstractNode",
">",
")",
"object",
"."
] | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/freezeui/hierarchy.py#L25-L37 | [
"def",
"getRoot",
"(",
"self",
")",
":",
"root",
"=",
"Node",
"(",
"self",
".",
"dumpHierarchy",
"(",
")",
")",
"self",
".",
"_linkParent",
"(",
"root",
")",
"return",
"root"
] | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | is_invalid_params | Check, whether function 'func' accepts parameters 'args', 'kwargs'.
NOTE: Method is called after funct(*args, **kwargs) generated TypeError,
it is aimed to destinguish TypeError because of invalid parameters from
TypeError from inside the function.
.. versionadded: 1.9.0 | poco/utils/simplerpc/jsonrpc/utils.py | def is_invalid_params(func, *args, **kwargs):
""" Check, whether function 'func' accepts parameters 'args', 'kwargs'.
NOTE: Method is called after funct(*args, **kwargs) generated TypeError,
it is aimed to destinguish TypeError because of invalid parameters from
TypeError from inside the function.
... | def is_invalid_params(func, *args, **kwargs):
""" Check, whether function 'func' accepts parameters 'args', 'kwargs'.
NOTE: Method is called after funct(*args, **kwargs) generated TypeError,
it is aimed to destinguish TypeError because of invalid parameters from
TypeError from inside the function.
... | [
"Check",
"whether",
"function",
"func",
"accepts",
"parameters",
"args",
"kwargs",
"."
] | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/utils/simplerpc/jsonrpc/utils.py#L56-L83 | [
"def",
"is_invalid_params",
"(",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# For builtin functions inspect.getargspec(funct) return error. If builtin",
"# function generates TypeError, it is because of wrong parameters.",
"if",
"not",
"inspect",
".",
"isfunc... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | OSXFunc.getAppRefByBundleId | Get the top level element for the application with the specified
bundle ID, such as com.vmware.fusion. | poco/drivers/osx/sdk/OSXUIFunc.py | def getAppRefByBundleId(cls, bundleId):
"""
Get the top level element for the application with the specified
bundle ID, such as com.vmware.fusion.
"""
ra = AppKit.NSRunningApplication
# return value (apps) is always an array. if there is a match it will
# have an ... | def getAppRefByBundleId(cls, bundleId):
"""
Get the top level element for the application with the specified
bundle ID, such as com.vmware.fusion.
"""
ra = AppKit.NSRunningApplication
# return value (apps) is always an array. if there is a match it will
# have an ... | [
"Get",
"the",
"top",
"level",
"element",
"for",
"the",
"application",
"with",
"the",
"specified",
"bundle",
"ID",
"such",
"as",
"com",
".",
"vmware",
".",
"fusion",
"."
] | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/drivers/osx/sdk/OSXUIFunc.py#L28-L41 | [
"def",
"getAppRefByBundleId",
"(",
"cls",
",",
"bundleId",
")",
":",
"ra",
"=",
"AppKit",
".",
"NSRunningApplication",
"# return value (apps) is always an array. if there is a match it will",
"# have an item, otherwise it won't.",
"apps",
"=",
"ra",
".",
"runningApplicationsWit... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | PocoAgent.driver | Return the driver of this agent related to. None if the driver is not ready to bind.
Returns:
:py:class:`inherit from Poco <poco.pocofw.Poco>`: the driver of this agent related to. | poco/agent.py | def driver(self):
"""
Return the driver of this agent related to. None if the driver is not ready to bind.
Returns:
:py:class:`inherit from Poco <poco.pocofw.Poco>`: the driver of this agent related to.
"""
if not self._driver:
raise AttributeError("`dri... | def driver(self):
"""
Return the driver of this agent related to. None if the driver is not ready to bind.
Returns:
:py:class:`inherit from Poco <poco.pocofw.Poco>`: the driver of this agent related to.
"""
if not self._driver:
raise AttributeError("`dri... | [
"Return",
"the",
"driver",
"of",
"this",
"agent",
"related",
"to",
".",
"None",
"if",
"the",
"driver",
"is",
"not",
"ready",
"to",
"bind",
"."
] | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/agent.py#L72-L85 | [
"def",
"driver",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_driver",
":",
"raise",
"AttributeError",
"(",
"\"`driver` is not bound on this agent implementation({}). \"",
"\"Do you forget to call `super().on_bind_driver` when you override the method \"",
"\"`on_bind_driver` ... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | AbstractDumper.dumpHierarchyImpl | Crawl the hierarchy tree using the simple DFS algorithm. The ``dump`` procedure is the engine independent as
the hierarchy structure is wrapped by :py:class:`AbstractNode <poco.sdk.AbstractNode>` and therefore the
``dump`` procedure can be algorithmized.
Following code demonstrates the simplest... | poco/sdk/AbstractDumper.py | def dumpHierarchyImpl(self, node, onlyVisibleNode=True):
"""
Crawl the hierarchy tree using the simple DFS algorithm. The ``dump`` procedure is the engine independent as
the hierarchy structure is wrapped by :py:class:`AbstractNode <poco.sdk.AbstractNode>` and therefore the
``dump`` proc... | def dumpHierarchyImpl(self, node, onlyVisibleNode=True):
"""
Crawl the hierarchy tree using the simple DFS algorithm. The ``dump`` procedure is the engine independent as
the hierarchy structure is wrapped by :py:class:`AbstractNode <poco.sdk.AbstractNode>` and therefore the
``dump`` proc... | [
"Crawl",
"the",
"hierarchy",
"tree",
"using",
"the",
"simple",
"DFS",
"algorithm",
".",
"The",
"dump",
"procedure",
"is",
"the",
"engine",
"independent",
"as",
"the",
"hierarchy",
"structure",
"is",
"wrapped",
"by",
":",
"py",
":",
"class",
":",
"AbstractNod... | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/sdk/AbstractDumper.py#L74-L117 | [
"def",
"dumpHierarchyImpl",
"(",
"self",
",",
"node",
",",
"onlyVisibleNode",
"=",
"True",
")",
":",
"if",
"not",
"node",
":",
"return",
"None",
"payload",
"=",
"{",
"}",
"# filter out all None values",
"for",
"attrName",
",",
"attrVal",
"in",
"node",
".",
... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | UIObjectProxy.child | Select the direct child(ren) from the UI element(s) given by the query expression, see ``QueryCondition`` for
more details about the selectors.
Args:
name: query expression of attribute "name", i.e. the UI elements with ``name`` name will be selected
attrs: other query expressio... | poco/proxy.py | def child(self, name=None, **attrs):
"""
Select the direct child(ren) from the UI element(s) given by the query expression, see ``QueryCondition`` for
more details about the selectors.
Args:
name: query expression of attribute "name", i.e. the UI elements with ``name`` name ... | def child(self, name=None, **attrs):
"""
Select the direct child(ren) from the UI element(s) given by the query expression, see ``QueryCondition`` for
more details about the selectors.
Args:
name: query expression of attribute "name", i.e. the UI elements with ``name`` name ... | [
"Select",
"the",
"direct",
"child",
"(",
"ren",
")",
"from",
"the",
"UI",
"element",
"(",
"s",
")",
"given",
"by",
"the",
"query",
"expression",
"see",
"QueryCondition",
"for",
"more",
"details",
"about",
"the",
"selectors",
"."
] | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/proxy.py#L121-L139 | [
"def",
"child",
"(",
"self",
",",
"name",
"=",
"None",
",",
"*",
"*",
"attrs",
")",
":",
"sub_query",
"=",
"build_query",
"(",
"name",
",",
"*",
"*",
"attrs",
")",
"query",
"=",
"(",
"'/'",
",",
"(",
"self",
".",
"query",
",",
"sub_query",
")",
... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | UIObjectProxy.parent | Select the direct child(ren) from the UI element(s) given by the query expression, see ``QueryCondition`` for
more details about the selectors.
Warnings:
Experimental method, may not be available for all drivers.
Returns:
:py:class:`UIObjectProxy <poco.proxy.UIObjectPro... | poco/proxy.py | def parent(self):
"""
Select the direct child(ren) from the UI element(s) given by the query expression, see ``QueryCondition`` for
more details about the selectors.
Warnings:
Experimental method, may not be available for all drivers.
Returns:
:py:class:... | def parent(self):
"""
Select the direct child(ren) from the UI element(s) given by the query expression, see ``QueryCondition`` for
more details about the selectors.
Warnings:
Experimental method, may not be available for all drivers.
Returns:
:py:class:... | [
"Select",
"the",
"direct",
"child",
"(",
"ren",
")",
"from",
"the",
"UI",
"element",
"(",
"s",
")",
"given",
"by",
"the",
"query",
"expression",
"see",
"QueryCondition",
"for",
"more",
"details",
"about",
"the",
"selectors",
"."
] | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/proxy.py#L192-L209 | [
"def",
"parent",
"(",
"self",
")",
":",
"sub_query",
"=",
"build_query",
"(",
"None",
")",
"# as placeholder",
"query",
"=",
"(",
"'^'",
",",
"(",
"self",
".",
"query",
",",
"sub_query",
")",
")",
"obj",
"=",
"UIObjectProxy",
"(",
"self",
".",
"poco",
... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | UIObjectProxy.click | Perform the click action on the UI element(s) represented by the UI proxy. If this UI proxy represents a set of
UI elements, the first one in the set is clicked and the anchor point of the UI element is used as the default
one. It is also possible to click another point offset by providing ``focus`` arg... | poco/proxy.py | def click(self, focus=None, sleep_interval=None):
"""
Perform the click action on the UI element(s) represented by the UI proxy. If this UI proxy represents a set of
UI elements, the first one in the set is clicked and the anchor point of the UI element is used as the default
one. It is ... | def click(self, focus=None, sleep_interval=None):
"""
Perform the click action on the UI element(s) represented by the UI proxy. If this UI proxy represents a set of
UI elements, the first one in the set is clicked and the anchor point of the UI element is used as the default
one. It is ... | [
"Perform",
"the",
"click",
"action",
"on",
"the",
"UI",
"element",
"(",
"s",
")",
"represented",
"by",
"the",
"UI",
"proxy",
".",
"If",
"this",
"UI",
"proxy",
"represents",
"a",
"set",
"of",
"UI",
"elements",
"the",
"first",
"one",
"in",
"the",
"set",
... | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/proxy.py#L311-L340 | [
"def",
"click",
"(",
"self",
",",
"focus",
"=",
"None",
",",
"sleep_interval",
"=",
"None",
")",
":",
"focus",
"=",
"focus",
"or",
"self",
".",
"_focus",
"or",
"'anchor'",
"pos_in_percentage",
"=",
"self",
".",
"get_position",
"(",
"focus",
")",
"self",
... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | UIObjectProxy.long_click | Perform the long click action on the UI element(s) represented by the UI proxy. If this UI proxy represents a
set of UI elements, the first one in the set is clicked and the anchor point of the UI element is used as the
default one. Similar to click but press the screen for the given time interval and... | poco/proxy.py | def long_click(self, duration=2.0):
"""
Perform the long click action on the UI element(s) represented by the UI proxy. If this UI proxy represents a
set of UI elements, the first one in the set is clicked and the anchor point of the UI element is used as the
default one. Similar to cl... | def long_click(self, duration=2.0):
"""
Perform the long click action on the UI element(s) represented by the UI proxy. If this UI proxy represents a
set of UI elements, the first one in the set is clicked and the anchor point of the UI element is used as the
default one. Similar to cl... | [
"Perform",
"the",
"long",
"click",
"action",
"on",
"the",
"UI",
"element",
"(",
"s",
")",
"represented",
"by",
"the",
"UI",
"proxy",
".",
"If",
"this",
"UI",
"proxy",
"represents",
"a",
"set",
"of",
"UI",
"elements",
"the",
"first",
"one",
"in",
"the",... | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/proxy.py#L407-L429 | [
"def",
"long_click",
"(",
"self",
",",
"duration",
"=",
"2.0",
")",
":",
"try",
":",
"duration",
"=",
"float",
"(",
"duration",
")",
"except",
"ValueError",
":",
"raise",
"ValueError",
"(",
"'Argument `duration` should be <float>. Got {}'",
".",
"format",
"(",
... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | UIObjectProxy.swipe | Perform a swipe action given by the direction from this UI element. For notices and limitations see
:py:meth:`.click() <poco.proxy.UIObjectProxy.click>`.
Args:
direction (2-:obj:`tuple`/2-:obj:`list`/:obj:`str`): coordinates (x, y) in NormalizedCoordinate system, it
can be al... | poco/proxy.py | def swipe(self, direction, focus=None, duration=0.5):
"""
Perform a swipe action given by the direction from this UI element. For notices and limitations see
:py:meth:`.click() <poco.proxy.UIObjectProxy.click>`.
Args:
direction (2-:obj:`tuple`/2-:obj:`list`/:obj:`str`): co... | def swipe(self, direction, focus=None, duration=0.5):
"""
Perform a swipe action given by the direction from this UI element. For notices and limitations see
:py:meth:`.click() <poco.proxy.UIObjectProxy.click>`.
Args:
direction (2-:obj:`tuple`/2-:obj:`list`/:obj:`str`): co... | [
"Perform",
"a",
"swipe",
"action",
"given",
"by",
"the",
"direction",
"from",
"this",
"UI",
"element",
".",
"For",
"notices",
"and",
"limitations",
"see",
":",
"py",
":",
"meth",
":",
".",
"click",
"()",
"<poco",
".",
"proxy",
".",
"UIObjectProxy",
".",
... | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/proxy.py#L432-L461 | [
"def",
"swipe",
"(",
"self",
",",
"direction",
",",
"focus",
"=",
"None",
",",
"duration",
"=",
"0.5",
")",
":",
"try",
":",
"duration",
"=",
"float",
"(",
"duration",
")",
"except",
"ValueError",
":",
"raise",
"ValueError",
"(",
"'Argument `duration` shou... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | UIObjectProxy.drag_to | Similar to swipe action, but the end point is provide by a UI proxy or by fixed coordinates.
Args:
target (:py:class:`UIObjectProxy <poco.proxy.UIObjectProxy>`): a UI proxy or 2-list/2-tuple coordinates
(x, y) in NormalizedCoordinate system
duration (:py:obj:`float`): time ... | poco/proxy.py | def drag_to(self, target, duration=2.0):
"""
Similar to swipe action, but the end point is provide by a UI proxy or by fixed coordinates.
Args:
target (:py:class:`UIObjectProxy <poco.proxy.UIObjectProxy>`): a UI proxy or 2-list/2-tuple coordinates
(x, y) in NormalizedCo... | def drag_to(self, target, duration=2.0):
"""
Similar to swipe action, but the end point is provide by a UI proxy or by fixed coordinates.
Args:
target (:py:class:`UIObjectProxy <poco.proxy.UIObjectProxy>`): a UI proxy or 2-list/2-tuple coordinates
(x, y) in NormalizedCo... | [
"Similar",
"to",
"swipe",
"action",
"but",
"the",
"end",
"point",
"is",
"provide",
"by",
"a",
"UI",
"proxy",
"or",
"by",
"fixed",
"coordinates",
"."
] | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/proxy.py#L463-L487 | [
"def",
"drag_to",
"(",
"self",
",",
"target",
",",
"duration",
"=",
"2.0",
")",
":",
"try",
":",
"duration",
"=",
"float",
"(",
"duration",
")",
"except",
"ValueError",
":",
"raise",
"ValueError",
"(",
"'Argument `duration` should be <float>. Got {}'",
".",
"f... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | UIObjectProxy.scroll | Simply touch down from point A and move to point B then release up finally. This action is performed within
specific motion range and duration.
Args:
direction (:py:obj:`str`): scrolling direction. "vertical" or "horizontal"
percent (:py:obj:`float`): scrolling distance percenta... | poco/proxy.py | def scroll(self, direction='vertical', percent=0.6, duration=2.0):
"""
Simply touch down from point A and move to point B then release up finally. This action is performed within
specific motion range and duration.
Args:
direction (:py:obj:`str`): scrolling direction. "verti... | def scroll(self, direction='vertical', percent=0.6, duration=2.0):
"""
Simply touch down from point A and move to point B then release up finally. This action is performed within
specific motion range and duration.
Args:
direction (:py:obj:`str`): scrolling direction. "verti... | [
"Simply",
"touch",
"down",
"from",
"point",
"A",
"and",
"move",
"to",
"point",
"B",
"then",
"release",
"up",
"finally",
".",
"This",
"action",
"is",
"performed",
"within",
"specific",
"motion",
"range",
"and",
"duration",
"."
] | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/proxy.py#L489-L518 | [
"def",
"scroll",
"(",
"self",
",",
"direction",
"=",
"'vertical'",
",",
"percent",
"=",
"0.6",
",",
"duration",
"=",
"2.0",
")",
":",
"if",
"direction",
"not",
"in",
"(",
"'vertical'",
",",
"'horizontal'",
")",
":",
"raise",
"ValueError",
"(",
"'Argument... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | UIObjectProxy.pinch | Squeezing or expanding 2 fingers on this UI with given motion range and duration.
Args:
direction (:py:obj:`str`): pinching direction, only "in" or "out". "in" for squeezing, "out" for expanding
percent (:py:obj:`float`): squeezing range from or expanding range to of the bounds of the U... | poco/proxy.py | def pinch(self, direction='in', percent=0.6, duration=2.0, dead_zone=0.1):
"""
Squeezing or expanding 2 fingers on this UI with given motion range and duration.
Args:
direction (:py:obj:`str`): pinching direction, only "in" or "out". "in" for squeezing, "out" for expanding
... | def pinch(self, direction='in', percent=0.6, duration=2.0, dead_zone=0.1):
"""
Squeezing or expanding 2 fingers on this UI with given motion range and duration.
Args:
direction (:py:obj:`str`): pinching direction, only "in" or "out". "in" for squeezing, "out" for expanding
... | [
"Squeezing",
"or",
"expanding",
"2",
"fingers",
"on",
"this",
"UI",
"with",
"given",
"motion",
"range",
"and",
"duration",
"."
] | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/proxy.py#L520-L548 | [
"def",
"pinch",
"(",
"self",
",",
"direction",
"=",
"'in'",
",",
"percent",
"=",
"0.6",
",",
"duration",
"=",
"2.0",
",",
"dead_zone",
"=",
"0.1",
")",
":",
"if",
"direction",
"not",
"in",
"(",
"'in'",
",",
"'out'",
")",
":",
"raise",
"ValueError",
... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | UIObjectProxy.focus | Get a new UI proxy copy with the given focus. Return a new UI proxy object as the UI proxy is immutable.
Args:
f (2-:obj:`tuple`/2-:obj:`list`/:obj:`str`): the focus point, it can be specified as 2-list/2-tuple
coordinates (x, y) in NormalizedCoordinate system or as 'center' or 'anchor... | poco/proxy.py | def focus(self, f):
"""
Get a new UI proxy copy with the given focus. Return a new UI proxy object as the UI proxy is immutable.
Args:
f (2-:obj:`tuple`/2-:obj:`list`/:obj:`str`): the focus point, it can be specified as 2-list/2-tuple
coordinates (x, y) in NormalizedCoo... | def focus(self, f):
"""
Get a new UI proxy copy with the given focus. Return a new UI proxy object as the UI proxy is immutable.
Args:
f (2-:obj:`tuple`/2-:obj:`list`/:obj:`str`): the focus point, it can be specified as 2-list/2-tuple
coordinates (x, y) in NormalizedCoo... | [
"Get",
"a",
"new",
"UI",
"proxy",
"copy",
"with",
"the",
"given",
"focus",
".",
"Return",
"a",
"new",
"UI",
"proxy",
"object",
"as",
"the",
"UI",
"proxy",
"is",
"immutable",
"."
] | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/proxy.py#L580-L594 | [
"def",
"focus",
"(",
"self",
",",
"f",
")",
":",
"ret",
"=",
"copy",
".",
"copy",
"(",
"self",
")",
"ret",
".",
"_focus",
"=",
"f",
"return",
"ret"
] | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | UIObjectProxy.get_position | Get the position of the UI elements.
Args:
focus: focus point of UI proxy, see :py:meth:`.focus() <poco.proxy.UIObjectProxy.focus>` for more details
Returns:
2-list/2-tuple: coordinates (x, y) in NormalizedCoordinate system
Raises:
TypeError: raised when u... | poco/proxy.py | def get_position(self, focus=None):
"""
Get the position of the UI elements.
Args:
focus: focus point of UI proxy, see :py:meth:`.focus() <poco.proxy.UIObjectProxy.focus>` for more details
Returns:
2-list/2-tuple: coordinates (x, y) in NormalizedCoordinate syst... | def get_position(self, focus=None):
"""
Get the position of the UI elements.
Args:
focus: focus point of UI proxy, see :py:meth:`.focus() <poco.proxy.UIObjectProxy.focus>` for more details
Returns:
2-list/2-tuple: coordinates (x, y) in NormalizedCoordinate syst... | [
"Get",
"the",
"position",
"of",
"the",
"UI",
"elements",
"."
] | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/proxy.py#L597-L629 | [
"def",
"get_position",
"(",
"self",
",",
"focus",
"=",
"None",
")",
":",
"focus",
"=",
"focus",
"or",
"self",
".",
"_focus",
"or",
"'anchor'",
"if",
"focus",
"==",
"'anchor'",
":",
"pos",
"=",
"self",
".",
"attr",
"(",
"'pos'",
")",
"elif",
"focus",
... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | UIObjectProxy.wait | Block and wait for max given time before the UI element appears.
Args:
timeout: maximum waiting time in seconds
Returns:
:py:class:`UIObjectProxy <poco.proxy.UIObjectProxy>`: self | poco/proxy.py | def wait(self, timeout=3):
"""
Block and wait for max given time before the UI element appears.
Args:
timeout: maximum waiting time in seconds
Returns:
:py:class:`UIObjectProxy <poco.proxy.UIObjectProxy>`: self
"""
start = time.time()
wh... | def wait(self, timeout=3):
"""
Block and wait for max given time before the UI element appears.
Args:
timeout: maximum waiting time in seconds
Returns:
:py:class:`UIObjectProxy <poco.proxy.UIObjectProxy>`: self
"""
start = time.time()
wh... | [
"Block",
"and",
"wait",
"for",
"max",
"given",
"time",
"before",
"the",
"UI",
"element",
"appears",
"."
] | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/proxy.py#L647-L663 | [
"def",
"wait",
"(",
"self",
",",
"timeout",
"=",
"3",
")",
":",
"start",
"=",
"time",
".",
"time",
"(",
")",
"while",
"not",
"self",
".",
"exists",
"(",
")",
":",
"self",
".",
"poco",
".",
"sleep_for_polling_interval",
"(",
")",
"if",
"time",
".",
... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | UIObjectProxy.wait_for_disappearance | Block and wait until the UI element **disappears** within the given timeout.
Args:
timeout: maximum waiting time in seconds
Raises:
PocoTargetTimeout: when timeout | poco/proxy.py | def wait_for_disappearance(self, timeout=120):
"""
Block and wait until the UI element **disappears** within the given timeout.
Args:
timeout: maximum waiting time in seconds
Raises:
PocoTargetTimeout: when timeout
"""
start = time.time()
... | def wait_for_disappearance(self, timeout=120):
"""
Block and wait until the UI element **disappears** within the given timeout.
Args:
timeout: maximum waiting time in seconds
Raises:
PocoTargetTimeout: when timeout
"""
start = time.time()
... | [
"Block",
"and",
"wait",
"until",
"the",
"UI",
"element",
"**",
"disappears",
"**",
"within",
"the",
"given",
"timeout",
"."
] | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/proxy.py#L683-L698 | [
"def",
"wait_for_disappearance",
"(",
"self",
",",
"timeout",
"=",
"120",
")",
":",
"start",
"=",
"time",
".",
"time",
"(",
")",
"while",
"self",
".",
"exists",
"(",
")",
":",
"self",
".",
"poco",
".",
"sleep_for_polling_interval",
"(",
")",
"if",
"tim... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | UIObjectProxy.attr | Retrieve the attribute of UI element by given attribute name. Return None if attribute does not exist.
If attribute type is :obj:`str`, it is encoded to utf-8 as :obj:`str` in Python2.7.
Args:
name:
attribute name, it can be one of the following or any other customized type... | poco/proxy.py | def attr(self, name):
"""
Retrieve the attribute of UI element by given attribute name. Return None if attribute does not exist.
If attribute type is :obj:`str`, it is encoded to utf-8 as :obj:`str` in Python2.7.
Args:
name:
attribute name, it can be one of ... | def attr(self, name):
"""
Retrieve the attribute of UI element by given attribute name. Return None if attribute does not exist.
If attribute type is :obj:`str`, it is encoded to utf-8 as :obj:`str` in Python2.7.
Args:
name:
attribute name, it can be one of ... | [
"Retrieve",
"the",
"attribute",
"of",
"UI",
"element",
"by",
"given",
"attribute",
"name",
".",
"Return",
"None",
"if",
"attribute",
"does",
"not",
"exist",
".",
"If",
"attribute",
"type",
"is",
":",
"obj",
":",
"str",
"it",
"is",
"encoded",
"to",
"utf",... | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/proxy.py#L701-L741 | [
"def",
"attr",
"(",
"self",
",",
"name",
")",
":",
"# to optimize performance speed, retrieve only the first matched element.",
"# 优化速度,只选择第一个匹配到的节点",
"nodes",
"=",
"self",
".",
"_do_query",
"(",
"multiple",
"=",
"False",
")",
"val",
"=",
"self",
".",
"poco",
".",
... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | UIObjectProxy.setattr | Change the attribute value of the UI element. Not all attributes can be casted to text. If changing the
immutable attributes or attributes which do not exist, the InvalidOperationException exception is raised.
Args:
name: attribute name
val: new attribute value to cast
... | poco/proxy.py | def setattr(self, name, val):
"""
Change the attribute value of the UI element. Not all attributes can be casted to text. If changing the
immutable attributes or attributes which do not exist, the InvalidOperationException exception is raised.
Args:
name: attribute name
... | def setattr(self, name, val):
"""
Change the attribute value of the UI element. Not all attributes can be casted to text. If changing the
immutable attributes or attributes which do not exist, the InvalidOperationException exception is raised.
Args:
name: attribute name
... | [
"Change",
"the",
"attribute",
"value",
"of",
"the",
"UI",
"element",
".",
"Not",
"all",
"attributes",
"can",
"be",
"casted",
"to",
"text",
".",
"If",
"changing",
"the",
"immutable",
"attributes",
"or",
"attributes",
"which",
"do",
"not",
"exist",
"the",
"I... | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/proxy.py#L744-L761 | [
"def",
"setattr",
"(",
"self",
",",
"name",
",",
"val",
")",
":",
"nodes",
"=",
"self",
".",
"_do_query",
"(",
"multiple",
"=",
"False",
")",
"try",
":",
"return",
"self",
".",
"poco",
".",
"agent",
".",
"hierarchy",
".",
"setAttr",
"(",
"nodes",
"... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | UIObjectProxy.get_bounds | Get the parameters of bounding box of the UI element.
Returns:
:obj:`list` <:obj:`float`>: 4-list (top, right, bottom, left) coordinates related to the edge of screen in
NormalizedCoordinate system | poco/proxy.py | def get_bounds(self):
"""
Get the parameters of bounding box of the UI element.
Returns:
:obj:`list` <:obj:`float`>: 4-list (top, right, bottom, left) coordinates related to the edge of screen in
NormalizedCoordinate system
"""
size = self.get_size()
... | def get_bounds(self):
"""
Get the parameters of bounding box of the UI element.
Returns:
:obj:`list` <:obj:`float`>: 4-list (top, right, bottom, left) coordinates related to the edge of screen in
NormalizedCoordinate system
"""
size = self.get_size()
... | [
"Get",
"the",
"parameters",
"of",
"bounding",
"box",
"of",
"the",
"UI",
"element",
"."
] | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/proxy.py#L826-L840 | [
"def",
"get_bounds",
"(",
"self",
")",
":",
"size",
"=",
"self",
".",
"get_size",
"(",
")",
"top_left",
"=",
"self",
".",
"get_position",
"(",
"[",
"0",
",",
"0",
"]",
")",
"# t, r, b, l",
"bounds",
"=",
"[",
"top_left",
"[",
"1",
"]",
",",
"top_le... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | RegexpComparator.compare | Args:
origin (:obj:`str`): original string
pattern (:obj:`str`): Regexp pattern string
Returns:
bool: True if matches otherwise False. | poco/sdk/DefaultMatcher.py | def compare(self, origin, pattern):
"""
Args:
origin (:obj:`str`): original string
pattern (:obj:`str`): Regexp pattern string
Returns:
bool: True if matches otherwise False.
"""
if origin is None or pattern is None:
return False
... | def compare(self, origin, pattern):
"""
Args:
origin (:obj:`str`): original string
pattern (:obj:`str`): Regexp pattern string
Returns:
bool: True if matches otherwise False.
"""
if origin is None or pattern is None:
return False
... | [
"Args",
":",
"origin",
"(",
":",
"obj",
":",
"str",
")",
":",
"original",
"string",
"pattern",
"(",
":",
"obj",
":",
"str",
")",
":",
"Regexp",
"pattern",
"string"
] | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/sdk/DefaultMatcher.py#L41-L53 | [
"def",
"compare",
"(",
"self",
",",
"origin",
",",
"pattern",
")",
":",
"if",
"origin",
"is",
"None",
"or",
"pattern",
"is",
"None",
":",
"return",
"False",
"return",
"re",
".",
"match",
"(",
"pattern",
",",
"origin",
")",
"is",
"not",
"None"
] | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | DefaultMatcher.match | See Also: :py:meth:`IMatcher.match <poco.sdk.DefaultMatcher.IMatcher.match>` | poco/sdk/DefaultMatcher.py | def match(self, cond, node):
"""
See Also: :py:meth:`IMatcher.match <poco.sdk.DefaultMatcher.IMatcher.match>`
"""
op, args = cond
# 条件匹配
if op == 'and':
for arg in args:
if not self.match(arg, node):
return False
... | def match(self, cond, node):
"""
See Also: :py:meth:`IMatcher.match <poco.sdk.DefaultMatcher.IMatcher.match>`
"""
op, args = cond
# 条件匹配
if op == 'and':
for arg in args:
if not self.match(arg, node):
return False
... | [
"See",
"Also",
":",
":",
"py",
":",
"meth",
":",
"IMatcher",
".",
"match",
"<poco",
".",
"sdk",
".",
"DefaultMatcher",
".",
"IMatcher",
".",
"match",
">"
] | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/sdk/DefaultMatcher.py#L87-L114 | [
"def",
"match",
"(",
"self",
",",
"cond",
",",
"node",
")",
":",
"op",
",",
"args",
"=",
"cond",
"# 条件匹配",
"if",
"op",
"==",
"'and'",
":",
"for",
"arg",
"in",
"args",
":",
"if",
"not",
"self",
".",
"match",
"(",
"arg",
",",
"node",
")",
":",
... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | Poco.wait_for_any | Wait until any of given UI proxies show up before timeout and return the first appeared UI proxy.
All UI proxies will be polled periodically. See options :py:class:`poll_interval <poco.pocofw.Poco>` in
``Poco``'s initialization for more details.
Args:
objects (Iterable<:py:class:`UI... | poco/pocofw.py | def wait_for_any(self, objects, timeout=120):
"""
Wait until any of given UI proxies show up before timeout and return the first appeared UI proxy.
All UI proxies will be polled periodically. See options :py:class:`poll_interval <poco.pocofw.Poco>` in
``Poco``'s initialization for more d... | def wait_for_any(self, objects, timeout=120):
"""
Wait until any of given UI proxies show up before timeout and return the first appeared UI proxy.
All UI proxies will be polled periodically. See options :py:class:`poll_interval <poco.pocofw.Poco>` in
``Poco``'s initialization for more d... | [
"Wait",
"until",
"any",
"of",
"given",
"UI",
"proxies",
"show",
"up",
"before",
"timeout",
"and",
"return",
"the",
"first",
"appeared",
"UI",
"proxy",
".",
"All",
"UI",
"proxies",
"will",
"be",
"polled",
"periodically",
".",
"See",
"options",
":",
"py",
... | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/pocofw.py#L107-L132 | [
"def",
"wait_for_any",
"(",
"self",
",",
"objects",
",",
"timeout",
"=",
"120",
")",
":",
"start",
"=",
"time",
".",
"time",
"(",
")",
"while",
"True",
":",
"for",
"obj",
"in",
"objects",
":",
"if",
"obj",
".",
"exists",
"(",
")",
":",
"return",
... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | Poco.wait_for_all | Wait until all of given UI proxies show up before timeout.
All UI proxies will be polled periodically. See option :py:class:`poll_interval <poco.pocofw.Poco>` in
``Poco``'s initialization for more details.
Args:
objects (Iterable<:py:class:`UIObjectProxy <poco.proxy.UIObjectProxy>`... | poco/pocofw.py | def wait_for_all(self, objects, timeout=120):
"""
Wait until all of given UI proxies show up before timeout.
All UI proxies will be polled periodically. See option :py:class:`poll_interval <poco.pocofw.Poco>` in
``Poco``'s initialization for more details.
Args:
obje... | def wait_for_all(self, objects, timeout=120):
"""
Wait until all of given UI proxies show up before timeout.
All UI proxies will be polled periodically. See option :py:class:`poll_interval <poco.pocofw.Poco>` in
``Poco``'s initialization for more details.
Args:
obje... | [
"Wait",
"until",
"all",
"of",
"given",
"UI",
"proxies",
"show",
"up",
"before",
"timeout",
".",
"All",
"UI",
"proxies",
"will",
"be",
"polled",
"periodically",
".",
"See",
"option",
":",
"py",
":",
"class",
":",
"poll_interval",
"<poco",
".",
"pocofw",
"... | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/pocofw.py#L134-L160 | [
"def",
"wait_for_all",
"(",
"self",
",",
"objects",
",",
"timeout",
"=",
"120",
")",
":",
"start",
"=",
"time",
".",
"time",
"(",
")",
"while",
"True",
":",
"all_exist",
"=",
"True",
"for",
"obj",
"in",
"objects",
":",
"if",
"not",
"obj",
".",
"exi... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | Poco.freeze | Snapshot current **hierarchy** and cache it into a new poco instance. This new poco instance is a copy from
current poco instance (``self``). The hierarchy of the new poco instance is fixed and immutable. It will be
super fast when calling ``dump`` function from frozen poco. See the example below.
... | poco/pocofw.py | def freeze(this):
"""
Snapshot current **hierarchy** and cache it into a new poco instance. This new poco instance is a copy from
current poco instance (``self``). The hierarchy of the new poco instance is fixed and immutable. It will be
super fast when calling ``dump`` function from fro... | def freeze(this):
"""
Snapshot current **hierarchy** and cache it into a new poco instance. This new poco instance is a copy from
current poco instance (``self``). The hierarchy of the new poco instance is fixed and immutable. It will be
super fast when calling ``dump`` function from fro... | [
"Snapshot",
"current",
"**",
"hierarchy",
"**",
"and",
"cache",
"it",
"into",
"a",
"new",
"poco",
"instance",
".",
"This",
"new",
"poco",
"instance",
"is",
"a",
"copy",
"from",
"current",
"poco",
"instance",
"(",
"self",
")",
".",
"The",
"hierarchy",
"of... | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/pocofw.py#L162-L199 | [
"def",
"freeze",
"(",
"this",
")",
":",
"class",
"FrozenPoco",
"(",
"Poco",
")",
":",
"def",
"__init__",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"hierarchy_dict",
"=",
"this",
".",
"agent",
".",
"hierarchy",
".",
"dump",
"(",
")",
"hierarchy"... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | Poco.click | Perform click (touch, tap, etc.) action on target device at given coordinates.
The coordinates (x, y) are either a 2-list or 2-tuple. The coordinates values for x and y must be in the
interval between 0 ~ 1 to represent the percentage of the screen. For example, the coordinates ``[0.5, 0.5]``
r... | poco/pocofw.py | def click(self, pos):
"""
Perform click (touch, tap, etc.) action on target device at given coordinates.
The coordinates (x, y) are either a 2-list or 2-tuple. The coordinates values for x and y must be in the
interval between 0 ~ 1 to represent the percentage of the screen. For example... | def click(self, pos):
"""
Perform click (touch, tap, etc.) action on target device at given coordinates.
The coordinates (x, y) are either a 2-list or 2-tuple. The coordinates values for x and y must be in the
interval between 0 ~ 1 to represent the percentage of the screen. For example... | [
"Perform",
"click",
"(",
"touch",
"tap",
"etc",
".",
")",
"action",
"on",
"target",
"device",
"at",
"given",
"coordinates",
"."
] | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/pocofw.py#L228-L254 | [
"def",
"click",
"(",
"self",
",",
"pos",
")",
":",
"if",
"not",
"(",
"0",
"<=",
"pos",
"[",
"0",
"]",
"<=",
"1",
")",
"or",
"not",
"(",
"0",
"<=",
"pos",
"[",
"1",
"]",
"<=",
"1",
")",
":",
"raise",
"InvalidOperationException",
"(",
"'Click pos... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | Poco.swipe | Perform swipe action on target device from point to point given by start point and end point, or by the
direction vector. At least one of the end point or direction must be provided.
The coordinates (x, y) definition for points is the same as for ``click`` event. The components of the
direction... | poco/pocofw.py | def swipe(self, p1, p2=None, direction=None, duration=2.0):
"""
Perform swipe action on target device from point to point given by start point and end point, or by the
direction vector. At least one of the end point or direction must be provided.
The coordinates (x, y) definition for po... | def swipe(self, p1, p2=None, direction=None, duration=2.0):
"""
Perform swipe action on target device from point to point given by start point and end point, or by the
direction vector. At least one of the end point or direction must be provided.
The coordinates (x, y) definition for po... | [
"Perform",
"swipe",
"action",
"on",
"target",
"device",
"from",
"point",
"to",
"point",
"given",
"by",
"start",
"point",
"and",
"end",
"point",
"or",
"by",
"the",
"direction",
"vector",
".",
"At",
"least",
"one",
"of",
"the",
"end",
"point",
"or",
"direc... | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/pocofw.py#L262-L305 | [
"def",
"swipe",
"(",
"self",
",",
"p1",
",",
"p2",
"=",
"None",
",",
"direction",
"=",
"None",
",",
"duration",
"=",
"2.0",
")",
":",
"try",
":",
"duration",
"=",
"float",
"(",
"duration",
")",
"except",
"ValueError",
":",
"raise",
"ValueError",
"(",... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | Poco.long_click | Similar to click but press the screen for the given time interval and then release
Args:
pos (:obj:`2-list/2-tuple`): coordinates (x, y) in range from 0 to 1
duration: duration of press the screen | poco/pocofw.py | def long_click(self, pos, duration=2.0):
"""
Similar to click but press the screen for the given time interval and then release
Args:
pos (:obj:`2-list/2-tuple`): coordinates (x, y) in range from 0 to 1
duration: duration of press the screen
"""
try:
... | def long_click(self, pos, duration=2.0):
"""
Similar to click but press the screen for the given time interval and then release
Args:
pos (:obj:`2-list/2-tuple`): coordinates (x, y) in range from 0 to 1
duration: duration of press the screen
"""
try:
... | [
"Similar",
"to",
"click",
"but",
"press",
"the",
"screen",
"for",
"the",
"given",
"time",
"interval",
"and",
"then",
"release"
] | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/pocofw.py#L307-L323 | [
"def",
"long_click",
"(",
"self",
",",
"pos",
",",
"duration",
"=",
"2.0",
")",
":",
"try",
":",
"duration",
"=",
"float",
"(",
"duration",
")",
"except",
"ValueError",
":",
"raise",
"ValueError",
"(",
"'Argument `duration` should be <float>. Got {}'",
".",
"f... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | Poco.scroll | Scroll from the lower part to the upper part of the entire screen.
Args:
direction (:py:obj:`str`): scrolling direction. "vertical" or "horizontal"
percent (:py:obj:`float`): scrolling distance percentage of the entire screen height or width according to
direction
... | poco/pocofw.py | def scroll(self, direction='vertical', percent=0.6, duration=2.0):
"""
Scroll from the lower part to the upper part of the entire screen.
Args:
direction (:py:obj:`str`): scrolling direction. "vertical" or "horizontal"
percent (:py:obj:`float`): scrolling distance percen... | def scroll(self, direction='vertical', percent=0.6, duration=2.0):
"""
Scroll from the lower part to the upper part of the entire screen.
Args:
direction (:py:obj:`str`): scrolling direction. "vertical" or "horizontal"
percent (:py:obj:`float`): scrolling distance percen... | [
"Scroll",
"from",
"the",
"lower",
"part",
"to",
"the",
"upper",
"part",
"of",
"the",
"entire",
"screen",
"."
] | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/pocofw.py#L325-L349 | [
"def",
"scroll",
"(",
"self",
",",
"direction",
"=",
"'vertical'",
",",
"percent",
"=",
"0.6",
",",
"duration",
"=",
"2.0",
")",
":",
"if",
"direction",
"not",
"in",
"(",
"'vertical'",
",",
"'horizontal'",
")",
":",
"raise",
"ValueError",
"(",
"'Argument... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | Poco.pinch | Squeezing or expanding 2 fingers on the entire screen.
Args:
direction (:py:obj:`str`): pinching direction, only "in" or "out". "in" for squeezing, "out" for expanding
percent (:py:obj:`float`): squeezing range from or expanding range to of the entire screen
duration (:py:ob... | poco/pocofw.py | def pinch(self, direction='in', percent=0.6, duration=2.0, dead_zone=0.1):
"""
Squeezing or expanding 2 fingers on the entire screen.
Args:
direction (:py:obj:`str`): pinching direction, only "in" or "out". "in" for squeezing, "out" for expanding
percent (:py:obj:`float`... | def pinch(self, direction='in', percent=0.6, duration=2.0, dead_zone=0.1):
"""
Squeezing or expanding 2 fingers on the entire screen.
Args:
direction (:py:obj:`str`): pinching direction, only "in" or "out". "in" for squeezing, "out" for expanding
percent (:py:obj:`float`... | [
"Squeezing",
"or",
"expanding",
"2",
"fingers",
"on",
"the",
"entire",
"screen",
"."
] | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/pocofw.py#L351-L373 | [
"def",
"pinch",
"(",
"self",
",",
"direction",
"=",
"'in'",
",",
"percent",
"=",
"0.6",
",",
"duration",
"=",
"2.0",
",",
"dead_zone",
"=",
"0.1",
")",
":",
"if",
"direction",
"not",
"in",
"(",
"'in'",
",",
"'out'",
")",
":",
"raise",
"ValueError",
... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | Poco.apply_motion_tracks | Similar to click but press the screen for the given time interval and then release
Args:
tracks (:py:obj:`list`): list of :py:class:`poco.utils.track.MotionTrack` object
accuracy (:py:obj:`float`): motion accuracy for each motion steps in normalized coordinate metrics. | poco/pocofw.py | def apply_motion_tracks(self, tracks, accuracy=0.004):
"""
Similar to click but press the screen for the given time interval and then release
Args:
tracks (:py:obj:`list`): list of :py:class:`poco.utils.track.MotionTrack` object
accuracy (:py:obj:`float`): motion accuracy ... | def apply_motion_tracks(self, tracks, accuracy=0.004):
"""
Similar to click but press the screen for the given time interval and then release
Args:
tracks (:py:obj:`list`): list of :py:class:`poco.utils.track.MotionTrack` object
accuracy (:py:obj:`float`): motion accuracy ... | [
"Similar",
"to",
"click",
"but",
"press",
"the",
"screen",
"for",
"the",
"given",
"time",
"interval",
"and",
"then",
"release"
] | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/pocofw.py#L403-L416 | [
"def",
"apply_motion_tracks",
"(",
"self",
",",
"tracks",
",",
"accuracy",
"=",
"0.004",
")",
":",
"if",
"not",
"tracks",
":",
"raise",
"ValueError",
"(",
"'Please provide at least one track. Got {}'",
".",
"format",
"(",
"repr",
"(",
"tracks",
")",
")",
")",
... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | AndroidUiautomationHelper.get_instance | This is only a slot to store and get already initialized poco instance rather than initializing again. You can
simply pass the ``current device instance`` provided by ``airtest`` to get the AndroidUiautomationPoco instance.
If no such AndroidUiautomationPoco instance, a new instance will be created and ... | poco/drivers/android/uiautomation.py | def get_instance(cls, device):
"""
This is only a slot to store and get already initialized poco instance rather than initializing again. You can
simply pass the ``current device instance`` provided by ``airtest`` to get the AndroidUiautomationPoco instance.
If no such AndroidUiautomatio... | def get_instance(cls, device):
"""
This is only a slot to store and get already initialized poco instance rather than initializing again. You can
simply pass the ``current device instance`` provided by ``airtest`` to get the AndroidUiautomationPoco instance.
If no such AndroidUiautomatio... | [
"This",
"is",
"only",
"a",
"slot",
"to",
"store",
"and",
"get",
"already",
"initialized",
"poco",
"instance",
"rather",
"than",
"initializing",
"again",
".",
"You",
"can",
"simply",
"pass",
"the",
"current",
"device",
"instance",
"provided",
"by",
"airtest",
... | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/drivers/android/uiautomation.py#L307-L322 | [
"def",
"get_instance",
"(",
"cls",
",",
"device",
")",
":",
"if",
"cls",
".",
"_nuis",
".",
"get",
"(",
"device",
")",
"is",
"None",
":",
"cls",
".",
"_nuis",
"[",
"device",
"]",
"=",
"AndroidUiautomationPoco",
"(",
"device",
")",
"return",
"cls",
".... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | PocoAccelerationMixin.dismiss | Automatically dismiss the target objects
Args:
targets (:obj:`list`): list of poco objects to be dropped
exit_when: termination condition, default is None which means to automatically exit when list of
``targets`` is empty
sleep_interval: time interval between e... | poco/acceleration.py | def dismiss(self, targets, exit_when=None, sleep_interval=0.5, appearance_timeout=20, timeout=120):
"""
Automatically dismiss the target objects
Args:
targets (:obj:`list`): list of poco objects to be dropped
exit_when: termination condition, default is None which means ... | def dismiss(self, targets, exit_when=None, sleep_interval=0.5, appearance_timeout=20, timeout=120):
"""
Automatically dismiss the target objects
Args:
targets (:obj:`list`): list of poco objects to be dropped
exit_when: termination condition, default is None which means ... | [
"Automatically",
"dismiss",
"the",
"target",
"objects"
] | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/acceleration.py#L18-L69 | [
"def",
"dismiss",
"(",
"self",
",",
"targets",
",",
"exit_when",
"=",
"None",
",",
"sleep_interval",
"=",
"0.5",
",",
"appearance_timeout",
"=",
"20",
",",
"timeout",
"=",
"120",
")",
":",
"try",
":",
"self",
".",
"wait_for_any",
"(",
"targets",
",",
"... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | Selector.select | See Also: :py:meth:`select <poco.sdk.Selector.ISelector.select>` method in ``ISelector``. | poco/sdk/Selector.py | def select(self, cond, multiple=False):
"""
See Also: :py:meth:`select <poco.sdk.Selector.ISelector.select>` method in ``ISelector``.
"""
return self.selectImpl(cond, multiple, self.getRoot(), 9999, True, True) | def select(self, cond, multiple=False):
"""
See Also: :py:meth:`select <poco.sdk.Selector.ISelector.select>` method in ``ISelector``.
"""
return self.selectImpl(cond, multiple, self.getRoot(), 9999, True, True) | [
"See",
"Also",
":",
":",
"py",
":",
"meth",
":",
"select",
"<poco",
".",
"sdk",
".",
"Selector",
".",
"ISelector",
".",
"select",
">",
"method",
"in",
"ISelector",
"."
] | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/sdk/Selector.py#L73-L78 | [
"def",
"select",
"(",
"self",
",",
"cond",
",",
"multiple",
"=",
"False",
")",
":",
"return",
"self",
".",
"selectImpl",
"(",
"cond",
",",
"multiple",
",",
"self",
".",
"getRoot",
"(",
")",
",",
"9999",
",",
"True",
",",
"True",
")"
] | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | Selector.selectImpl | Selector internal implementation.
TODO: add later.
.. note:: This doc shows only the outline of the algorithm. Do not call this method in your code as this
is an internal method.
Args:
cond (:obj:`tuple`): query expression
multiple (:obj:`bool`): whether or no... | poco/sdk/Selector.py | def selectImpl(self, cond, multiple, root, maxDepth, onlyVisibleNode, includeRoot):
"""
Selector internal implementation.
TODO: add later.
.. note:: This doc shows only the outline of the algorithm. Do not call this method in your code as this
is an internal method.
A... | def selectImpl(self, cond, multiple, root, maxDepth, onlyVisibleNode, includeRoot):
"""
Selector internal implementation.
TODO: add later.
.. note:: This doc shows only the outline of the algorithm. Do not call this method in your code as this
is an internal method.
A... | [
"Selector",
"internal",
"implementation",
".",
"TODO",
":",
"add",
"later",
"."
] | AirtestProject/Poco | python | https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/sdk/Selector.py#L80-L153 | [
"def",
"selectImpl",
"(",
"self",
",",
"cond",
",",
"multiple",
",",
"root",
",",
"maxDepth",
",",
"onlyVisibleNode",
",",
"includeRoot",
")",
":",
"result",
"=",
"[",
"]",
"if",
"not",
"root",
":",
"return",
"result",
"op",
",",
"args",
"=",
"cond",
... | 2c559a586adf3fd11ee81cabc446d4d3f6f2d119 |
train | ApiKey.find_by_id | Get API key details. | alerta/models/key.py | def find_by_id(key: str, user: str=None) -> Optional['ApiKey']:
"""
Get API key details.
"""
return ApiKey.from_db(db.get_key(key, user)) | def find_by_id(key: str, user: str=None) -> Optional['ApiKey']:
"""
Get API key details.
"""
return ApiKey.from_db(db.get_key(key, user)) | [
"Get",
"API",
"key",
"details",
"."
] | alerta/alerta | python | https://github.com/alerta/alerta/blob/6478d6addc217c96a4a6688fab841035bef134e1/alerta/models/key.py#L113-L117 | [
"def",
"find_by_id",
"(",
"key",
":",
"str",
",",
"user",
":",
"str",
"=",
"None",
")",
"->",
"Optional",
"[",
"'ApiKey'",
"]",
":",
"return",
"ApiKey",
".",
"from_db",
"(",
"db",
".",
"get_key",
"(",
"key",
",",
"user",
")",
")"
] | 6478d6addc217c96a4a6688fab841035bef134e1 |
train | ApiKey.find_all | List all API keys. | alerta/models/key.py | def find_all(query: Query=None) -> List['ApiKey']:
"""
List all API keys.
"""
return [ApiKey.from_db(key) for key in db.get_keys(query)] | def find_all(query: Query=None) -> List['ApiKey']:
"""
List all API keys.
"""
return [ApiKey.from_db(key) for key in db.get_keys(query)] | [
"List",
"all",
"API",
"keys",
"."
] | alerta/alerta | python | https://github.com/alerta/alerta/blob/6478d6addc217c96a4a6688fab841035bef134e1/alerta/models/key.py#L120-L124 | [
"def",
"find_all",
"(",
"query",
":",
"Query",
"=",
"None",
")",
"->",
"List",
"[",
"'ApiKey'",
"]",
":",
"return",
"[",
"ApiKey",
".",
"from_db",
"(",
"key",
")",
"for",
"key",
"in",
"db",
".",
"get_keys",
"(",
"query",
")",
"]"
] | 6478d6addc217c96a4a6688fab841035bef134e1 |
train | ApiKey.find_by_user | List API keys for a user. | alerta/models/key.py | def find_by_user(user: str) -> List['ApiKey']:
"""
List API keys for a user.
"""
return [ApiKey.from_db(key) for key in db.get_keys(qb.from_dict({'user': user}))] | def find_by_user(user: str) -> List['ApiKey']:
"""
List API keys for a user.
"""
return [ApiKey.from_db(key) for key in db.get_keys(qb.from_dict({'user': user}))] | [
"List",
"API",
"keys",
"for",
"a",
"user",
"."
] | alerta/alerta | python | https://github.com/alerta/alerta/blob/6478d6addc217c96a4a6688fab841035bef134e1/alerta/models/key.py#L127-L131 | [
"def",
"find_by_user",
"(",
"user",
":",
"str",
")",
"->",
"List",
"[",
"'ApiKey'",
"]",
":",
"return",
"[",
"ApiKey",
".",
"from_db",
"(",
"key",
")",
"for",
"key",
"in",
"db",
".",
"get_keys",
"(",
"qb",
".",
"from_dict",
"(",
"{",
"'user'",
":",... | 6478d6addc217c96a4a6688fab841035bef134e1 |
train | key | Create an admin API key. | alerta/commands.py | def key(username, key, all):
"""Create an admin API key."""
if username and username not in current_app.config['ADMIN_USERS']:
raise click.UsageError('User {} not an admin'.format(username))
def create_key(admin, key):
key = ApiKey(
user=admin,
key=key,
s... | def key(username, key, all):
"""Create an admin API key."""
if username and username not in current_app.config['ADMIN_USERS']:
raise click.UsageError('User {} not an admin'.format(username))
def create_key(admin, key):
key = ApiKey(
user=admin,
key=key,
s... | [
"Create",
"an",
"admin",
"API",
"key",
"."
] | alerta/alerta | python | https://github.com/alerta/alerta/blob/6478d6addc217c96a4a6688fab841035bef134e1/alerta/commands.py#L28-L55 | [
"def",
"key",
"(",
"username",
",",
"key",
",",
"all",
")",
":",
"if",
"username",
"and",
"username",
"not",
"in",
"current_app",
".",
"config",
"[",
"'ADMIN_USERS'",
"]",
":",
"raise",
"click",
".",
"UsageError",
"(",
"'User {} not an admin'",
".",
"forma... | 6478d6addc217c96a4a6688fab841035bef134e1 |
train | keys | List admin API keys. | alerta/commands.py | def keys():
"""List admin API keys."""
for admin in current_app.config['ADMIN_USERS']:
try:
db.get_db() # init db on global app context
keys = ApiKey.find_by_user(admin)
except Exception as e:
click.echo('ERROR: {}'.format(e))
else:
for ke... | def keys():
"""List admin API keys."""
for admin in current_app.config['ADMIN_USERS']:
try:
db.get_db() # init db on global app context
keys = ApiKey.find_by_user(admin)
except Exception as e:
click.echo('ERROR: {}'.format(e))
else:
for ke... | [
"List",
"admin",
"API",
"keys",
"."
] | alerta/alerta | python | https://github.com/alerta/alerta/blob/6478d6addc217c96a4a6688fab841035bef134e1/alerta/commands.py#L60-L70 | [
"def",
"keys",
"(",
")",
":",
"for",
"admin",
"in",
"current_app",
".",
"config",
"[",
"'ADMIN_USERS'",
"]",
":",
"try",
":",
"db",
".",
"get_db",
"(",
")",
"# init db on global app context",
"keys",
"=",
"ApiKey",
".",
"find_by_user",
"(",
"admin",
")",
... | 6478d6addc217c96a4a6688fab841035bef134e1 |
train | user | Create admin users (BasicAuth only). | alerta/commands.py | def user(username, password, all):
"""Create admin users (BasicAuth only)."""
if current_app.config['AUTH_PROVIDER'] != 'basic':
raise click.UsageError('Not required for {} admin users'.format(current_app.config['AUTH_PROVIDER']))
if username and username not in current_app.config['ADMIN_USERS']:
... | def user(username, password, all):
"""Create admin users (BasicAuth only)."""
if current_app.config['AUTH_PROVIDER'] != 'basic':
raise click.UsageError('Not required for {} admin users'.format(current_app.config['AUTH_PROVIDER']))
if username and username not in current_app.config['ADMIN_USERS']:
... | [
"Create",
"admin",
"users",
"(",
"BasicAuth",
"only",
")",
"."
] | alerta/alerta | python | https://github.com/alerta/alerta/blob/6478d6addc217c96a4a6688fab841035bef134e1/alerta/commands.py#L78-L110 | [
"def",
"user",
"(",
"username",
",",
"password",
",",
"all",
")",
":",
"if",
"current_app",
".",
"config",
"[",
"'AUTH_PROVIDER'",
"]",
"!=",
"'basic'",
":",
"raise",
"click",
".",
"UsageError",
"(",
"'Not required for {} admin users'",
".",
"format",
"(",
"... | 6478d6addc217c96a4a6688fab841035bef134e1 |
train | users | List admin users. | alerta/commands.py | def users():
"""List admin users."""
for admin in current_app.config['ADMIN_USERS']:
try:
db.get_db() # init db on global app context
user = User.find_by_username(admin)
except Exception as e:
click.echo('ERROR: {}'.format(e))
else:
if use... | def users():
"""List admin users."""
for admin in current_app.config['ADMIN_USERS']:
try:
db.get_db() # init db on global app context
user = User.find_by_username(admin)
except Exception as e:
click.echo('ERROR: {}'.format(e))
else:
if use... | [
"List",
"admin",
"users",
"."
] | alerta/alerta | python | https://github.com/alerta/alerta/blob/6478d6addc217c96a4a6688fab841035bef134e1/alerta/commands.py#L115-L125 | [
"def",
"users",
"(",
")",
":",
"for",
"admin",
"in",
"current_app",
".",
"config",
"[",
"'ADMIN_USERS'",
"]",
":",
"try",
":",
"db",
".",
"get_db",
"(",
")",
"# init db on global app context",
"user",
"=",
"User",
".",
"find_by_username",
"(",
"admin",
")"... | 6478d6addc217c96a4a6688fab841035bef134e1 |
train | Backend.get_severity | Get severity of correlated alert. Used to determine previous severity. | alerta/database/backends/mongodb/base.py | def get_severity(self, alert):
"""
Get severity of correlated alert. Used to determine previous severity.
"""
query = {
'environment': alert.environment,
'resource': alert.resource,
'$or': [
{
'event': alert.event,
... | def get_severity(self, alert):
"""
Get severity of correlated alert. Used to determine previous severity.
"""
query = {
'environment': alert.environment,
'resource': alert.resource,
'$or': [
{
'event': alert.event,
... | [
"Get",
"severity",
"of",
"correlated",
"alert",
".",
"Used",
"to",
"determine",
"previous",
"severity",
"."
] | alerta/alerta | python | https://github.com/alerta/alerta/blob/6478d6addc217c96a4a6688fab841035bef134e1/alerta/database/backends/mongodb/base.py#L79-L98 | [
"def",
"get_severity",
"(",
"self",
",",
"alert",
")",
":",
"query",
"=",
"{",
"'environment'",
":",
"alert",
".",
"environment",
",",
"'resource'",
":",
"alert",
".",
"resource",
",",
"'$or'",
":",
"[",
"{",
"'event'",
":",
"alert",
".",
"event",
",",... | 6478d6addc217c96a4a6688fab841035bef134e1 |
train | Backend.is_flapping | Return true if alert severity has changed more than X times in Y seconds | alerta/database/backends/mongodb/base.py | def is_flapping(self, alert, window=1800, count=2):
"""
Return true if alert severity has changed more than X times in Y seconds
"""
pipeline = [
{'$match': {
'environment': alert.environment,
'resource': alert.resource,
'event'... | def is_flapping(self, alert, window=1800, count=2):
"""
Return true if alert severity has changed more than X times in Y seconds
"""
pipeline = [
{'$match': {
'environment': alert.environment,
'resource': alert.resource,
'event'... | [
"Return",
"true",
"if",
"alert",
"severity",
"has",
"changed",
"more",
"than",
"X",
"times",
"in",
"Y",
"seconds"
] | alerta/alerta | python | https://github.com/alerta/alerta/blob/6478d6addc217c96a4a6688fab841035bef134e1/alerta/database/backends/mongodb/base.py#L147-L169 | [
"def",
"is_flapping",
"(",
"self",
",",
"alert",
",",
"window",
"=",
"1800",
",",
"count",
"=",
"2",
")",
":",
"pipeline",
"=",
"[",
"{",
"'$match'",
":",
"{",
"'environment'",
":",
"alert",
".",
"environment",
",",
"'resource'",
":",
"alert",
".",
"... | 6478d6addc217c96a4a6688fab841035bef134e1 |
train | Backend.dedup_alert | Update alert status, service, value, text, timeout and rawData, increment duplicate count and set
repeat=True, and keep track of last receive id and time but don't append to history unless status changes. | alerta/database/backends/mongodb/base.py | def dedup_alert(self, alert, history):
"""
Update alert status, service, value, text, timeout and rawData, increment duplicate count and set
repeat=True, and keep track of last receive id and time but don't append to history unless status changes.
"""
query = {
'envir... | def dedup_alert(self, alert, history):
"""
Update alert status, service, value, text, timeout and rawData, increment duplicate count and set
repeat=True, and keep track of last receive id and time but don't append to history unless status changes.
"""
query = {
'envir... | [
"Update",
"alert",
"status",
"service",
"value",
"text",
"timeout",
"and",
"rawData",
"increment",
"duplicate",
"count",
"and",
"set",
"repeat",
"=",
"True",
"and",
"keep",
"track",
"of",
"last",
"receive",
"id",
"and",
"time",
"but",
"don",
"t",
"append",
... | alerta/alerta | python | https://github.com/alerta/alerta/blob/6478d6addc217c96a4a6688fab841035bef134e1/alerta/database/backends/mongodb/base.py#L171-L220 | [
"def",
"dedup_alert",
"(",
"self",
",",
"alert",
",",
"history",
")",
":",
"query",
"=",
"{",
"'environment'",
":",
"alert",
".",
"environment",
",",
"'resource'",
":",
"alert",
".",
"resource",
",",
"'event'",
":",
"alert",
".",
"event",
",",
"'severity... | 6478d6addc217c96a4a6688fab841035bef134e1 |
train | Backend.correlate_alert | Update alert key attributes, reset duplicate count and set repeat=False, keep track of last
receive id and time, appending all to history. Append to history again if status changes. | alerta/database/backends/mongodb/base.py | def correlate_alert(self, alert, history):
"""
Update alert key attributes, reset duplicate count and set repeat=False, keep track of last
receive id and time, appending all to history. Append to history again if status changes.
"""
query = {
'environment': alert.envi... | def correlate_alert(self, alert, history):
"""
Update alert key attributes, reset duplicate count and set repeat=False, keep track of last
receive id and time, appending all to history. Append to history again if status changes.
"""
query = {
'environment': alert.envi... | [
"Update",
"alert",
"key",
"attributes",
"reset",
"duplicate",
"count",
"and",
"set",
"repeat",
"=",
"False",
"keep",
"track",
"of",
"last",
"receive",
"id",
"and",
"time",
"appending",
"all",
"to",
"history",
".",
"Append",
"to",
"history",
"again",
"if",
... | alerta/alerta | python | https://github.com/alerta/alerta/blob/6478d6addc217c96a4a6688fab841035bef134e1/alerta/database/backends/mongodb/base.py#L222-L281 | [
"def",
"correlate_alert",
"(",
"self",
",",
"alert",
",",
"history",
")",
":",
"query",
"=",
"{",
"'environment'",
":",
"alert",
".",
"environment",
",",
"'resource'",
":",
"alert",
".",
"resource",
",",
"'$or'",
":",
"[",
"{",
"'event'",
":",
"alert",
... | 6478d6addc217c96a4a6688fab841035bef134e1 |
train | Backend.set_status | Set status and update history. | alerta/database/backends/mongodb/base.py | def set_status(self, id, status, timeout, update_time, history=None):
"""
Set status and update history.
"""
query = {'_id': {'$regex': '^' + id}}
update = {
'$set': {'status': status, 'timeout': timeout, 'updateTime': update_time},
'$push': {
... | def set_status(self, id, status, timeout, update_time, history=None):
"""
Set status and update history.
"""
query = {'_id': {'$regex': '^' + id}}
update = {
'$set': {'status': status, 'timeout': timeout, 'updateTime': update_time},
'$push': {
... | [
"Set",
"status",
"and",
"update",
"history",
"."
] | alerta/alerta | python | https://github.com/alerta/alerta/blob/6478d6addc217c96a4a6688fab841035bef134e1/alerta/database/backends/mongodb/base.py#L357-L377 | [
"def",
"set_status",
"(",
"self",
",",
"id",
",",
"status",
",",
"timeout",
",",
"update_time",
",",
"history",
"=",
"None",
")",
":",
"query",
"=",
"{",
"'_id'",
":",
"{",
"'$regex'",
":",
"'^'",
"+",
"id",
"}",
"}",
"update",
"=",
"{",
"'$set'",
... | 6478d6addc217c96a4a6688fab841035bef134e1 |
train | Backend.tag_alert | Append tags to tag list. Don't add same tag more than once. | alerta/database/backends/mongodb/base.py | def tag_alert(self, id, tags):
"""
Append tags to tag list. Don't add same tag more than once.
"""
response = self.get_db().alerts.update_one(
{'_id': {'$regex': '^' + id}}, {'$addToSet': {'tags': {'$each': tags}}})
return response.matched_count > 0 | def tag_alert(self, id, tags):
"""
Append tags to tag list. Don't add same tag more than once.
"""
response = self.get_db().alerts.update_one(
{'_id': {'$regex': '^' + id}}, {'$addToSet': {'tags': {'$each': tags}}})
return response.matched_count > 0 | [
"Append",
"tags",
"to",
"tag",
"list",
".",
"Don",
"t",
"add",
"same",
"tag",
"more",
"than",
"once",
"."
] | alerta/alerta | python | https://github.com/alerta/alerta/blob/6478d6addc217c96a4a6688fab841035bef134e1/alerta/database/backends/mongodb/base.py#L379-L385 | [
"def",
"tag_alert",
"(",
"self",
",",
"id",
",",
"tags",
")",
":",
"response",
"=",
"self",
".",
"get_db",
"(",
")",
".",
"alerts",
".",
"update_one",
"(",
"{",
"'_id'",
":",
"{",
"'$regex'",
":",
"'^'",
"+",
"id",
"}",
"}",
",",
"{",
"'$addToSet... | 6478d6addc217c96a4a6688fab841035bef134e1 |
train | Backend.update_attributes | Set all attributes and unset attributes by using a value of 'null'. | alerta/database/backends/mongodb/base.py | def update_attributes(self, id, old_attrs, new_attrs):
"""
Set all attributes and unset attributes by using a value of 'null'.
"""
update = dict()
set_value = {'attributes.' + k: v for k, v in new_attrs.items() if v is not None}
if set_value:
update['$set'] = ... | def update_attributes(self, id, old_attrs, new_attrs):
"""
Set all attributes and unset attributes by using a value of 'null'.
"""
update = dict()
set_value = {'attributes.' + k: v for k, v in new_attrs.items() if v is not None}
if set_value:
update['$set'] = ... | [
"Set",
"all",
"attributes",
"and",
"unset",
"attributes",
"by",
"using",
"a",
"value",
"of",
"null",
"."
] | alerta/alerta | python | https://github.com/alerta/alerta/blob/6478d6addc217c96a4a6688fab841035bef134e1/alerta/database/backends/mongodb/base.py#L394-L408 | [
"def",
"update_attributes",
"(",
"self",
",",
"id",
",",
"old_attrs",
",",
"new_attrs",
")",
":",
"update",
"=",
"dict",
"(",
")",
"set_value",
"=",
"{",
"'attributes.'",
"+",
"k",
":",
"v",
"for",
"k",
",",
"v",
"in",
"new_attrs",
".",
"items",
"(",... | 6478d6addc217c96a4a6688fab841035bef134e1 |
train | Backend.get_count | Return total number of alerts that meet the query filter. | alerta/database/backends/mongodb/base.py | def get_count(self, query=None):
"""
Return total number of alerts that meet the query filter.
"""
query = query or Query()
return self.get_db().alerts.find(query.where).count() | def get_count(self, query=None):
"""
Return total number of alerts that meet the query filter.
"""
query = query or Query()
return self.get_db().alerts.find(query.where).count() | [
"Return",
"total",
"number",
"of",
"alerts",
"that",
"meet",
"the",
"query",
"filter",
"."
] | alerta/alerta | python | https://github.com/alerta/alerta/blob/6478d6addc217c96a4a6688fab841035bef134e1/alerta/database/backends/mongodb/base.py#L591-L596 | [
"def",
"get_count",
"(",
"self",
",",
"query",
"=",
"None",
")",
":",
"query",
"=",
"query",
"or",
"Query",
"(",
")",
"return",
"self",
".",
"get_db",
"(",
")",
".",
"alerts",
".",
"find",
"(",
"query",
".",
"where",
")",
".",
"count",
"(",
")"
] | 6478d6addc217c96a4a6688fab841035bef134e1 |
train | Backend.update_user_attributes | Set all attributes and unset attributes by using a value of 'null'. | alerta/database/backends/mongodb/base.py | def update_user_attributes(self, id, old_attrs, new_attrs):
"""
Set all attributes and unset attributes by using a value of 'null'.
"""
from alerta.utils.collections import merge
merge(old_attrs, new_attrs)
attrs = {k: v for k, v in old_attrs.items() if v is not None}
... | def update_user_attributes(self, id, old_attrs, new_attrs):
"""
Set all attributes and unset attributes by using a value of 'null'.
"""
from alerta.utils.collections import merge
merge(old_attrs, new_attrs)
attrs = {k: v for k, v in old_attrs.items() if v is not None}
... | [
"Set",
"all",
"attributes",
"and",
"unset",
"attributes",
"by",
"using",
"a",
"value",
"of",
"null",
"."
] | alerta/alerta | python | https://github.com/alerta/alerta/blob/6478d6addc217c96a4a6688fab841035bef134e1/alerta/database/backends/mongodb/base.py#L1314-L1325 | [
"def",
"update_user_attributes",
"(",
"self",
",",
"id",
",",
"old_attrs",
",",
"new_attrs",
")",
":",
"from",
"alerta",
".",
"utils",
".",
"collections",
"import",
"merge",
"merge",
"(",
"old_attrs",
",",
"new_attrs",
")",
"attrs",
"=",
"{",
"k",
":",
"... | 6478d6addc217c96a4a6688fab841035bef134e1 |
train | Alert.is_blackout | Does this alert match a blackout period? | alerta/models/alert.py | def is_blackout(self) -> bool:
"""Does this alert match a blackout period?"""
if not current_app.config['NOTIFICATION_BLACKOUT']:
if self.severity in current_app.config['BLACKOUT_ACCEPT']:
return False
return db.is_blackout_period(self) | def is_blackout(self) -> bool:
"""Does this alert match a blackout period?"""
if not current_app.config['NOTIFICATION_BLACKOUT']:
if self.severity in current_app.config['BLACKOUT_ACCEPT']:
return False
return db.is_blackout_period(self) | [
"Does",
"this",
"alert",
"match",
"a",
"blackout",
"period?"
] | alerta/alerta | python | https://github.com/alerta/alerta/blob/6478d6addc217c96a4a6688fab841035bef134e1/alerta/models/alert.py#L401-L406 | [
"def",
"is_blackout",
"(",
"self",
")",
"->",
"bool",
":",
"if",
"not",
"current_app",
".",
"config",
"[",
"'NOTIFICATION_BLACKOUT'",
"]",
":",
"if",
"self",
".",
"severity",
"in",
"current_app",
".",
"config",
"[",
"'BLACKOUT_ACCEPT'",
"]",
":",
"return",
... | 6478d6addc217c96a4a6688fab841035bef134e1 |
train | GitlabIssue.take_action | should return internal id of external system | contrib/plugins/gitlab/alerta_gitlab.py | def take_action(self, alert, action, text, **kwargs):
"""should return internal id of external system"""
BASE_URL = '{}/projects/{}'.format(GITLAB_URL, quote(GITLAB_PROJECT_ID, safe=''))
if action == 'createIssue':
if 'issue_iid' not in alert.attributes:
url = BASE_... | def take_action(self, alert, action, text, **kwargs):
"""should return internal id of external system"""
BASE_URL = '{}/projects/{}'.format(GITLAB_URL, quote(GITLAB_PROJECT_ID, safe=''))
if action == 'createIssue':
if 'issue_iid' not in alert.attributes:
url = BASE_... | [
"should",
"return",
"internal",
"id",
"of",
"external",
"system"
] | alerta/alerta | python | https://github.com/alerta/alerta/blob/6478d6addc217c96a4a6688fab841035bef134e1/contrib/plugins/gitlab/alerta_gitlab.py#L32-L55 | [
"def",
"take_action",
"(",
"self",
",",
"alert",
",",
"action",
",",
"text",
",",
"*",
"*",
"kwargs",
")",
":",
"BASE_URL",
"=",
"'{}/projects/{}'",
".",
"format",
"(",
"GITLAB_URL",
",",
"quote",
"(",
"GITLAB_PROJECT_ID",
",",
"safe",
"=",
"''",
")",
... | 6478d6addc217c96a4a6688fab841035bef134e1 |
train | jsonp | Wraps JSONified output for JSONP requests. | alerta/utils/response.py | def jsonp(func):
"""Wraps JSONified output for JSONP requests."""
@wraps(func)
def decorated(*args, **kwargs):
callback = request.args.get('callback', False)
if callback:
data = str(func(*args, **kwargs).data)
content = str(callback) + '(' + data + ')'
mim... | def jsonp(func):
"""Wraps JSONified output for JSONP requests."""
@wraps(func)
def decorated(*args, **kwargs):
callback = request.args.get('callback', False)
if callback:
data = str(func(*args, **kwargs).data)
content = str(callback) + '(' + data + ')'
mim... | [
"Wraps",
"JSONified",
"output",
"for",
"JSONP",
"requests",
"."
] | alerta/alerta | python | https://github.com/alerta/alerta/blob/6478d6addc217c96a4a6688fab841035bef134e1/alerta/utils/response.py#L8-L20 | [
"def",
"jsonp",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"decorated",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"callback",
"=",
"request",
".",
"args",
".",
"get",
"(",
"'callback'",
",",
"False",
")",
"if",
"call... | 6478d6addc217c96a4a6688fab841035bef134e1 |
train | Backend.is_flapping | Return true if alert severity has changed more than X times in Y seconds | alerta/database/backends/postgres/base.py | def is_flapping(self, alert, window=1800, count=2):
"""
Return true if alert severity has changed more than X times in Y seconds
"""
select = """
SELECT COUNT(*)
FROM alerts, unnest(history) h
WHERE environment=%(environment)s
AND res... | def is_flapping(self, alert, window=1800, count=2):
"""
Return true if alert severity has changed more than X times in Y seconds
"""
select = """
SELECT COUNT(*)
FROM alerts, unnest(history) h
WHERE environment=%(environment)s
AND res... | [
"Return",
"true",
"if",
"alert",
"severity",
"has",
"changed",
"more",
"than",
"X",
"times",
"in",
"Y",
"seconds"
] | alerta/alerta | python | https://github.com/alerta/alerta/blob/6478d6addc217c96a4a6688fab841035bef134e1/alerta/database/backends/postgres/base.py#L186-L200 | [
"def",
"is_flapping",
"(",
"self",
",",
"alert",
",",
"window",
"=",
"1800",
",",
"count",
"=",
"2",
")",
":",
"select",
"=",
"\"\"\"\n SELECT COUNT(*)\n FROM alerts, unnest(history) h\n WHERE environment=%(environment)s\n AND res... | 6478d6addc217c96a4a6688fab841035bef134e1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.