Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
build_sdist | (source_dir, sdist_dir, config_settings=None) | Build an sdist from a source directory using PEP 517 hooks.
:param str source_dir: Source directory containing pyproject.toml
:param str sdist_dir: Target directory to place sdist in
:param dict config_settings: Options to pass to build backend
This is a blocking function which will run pip in a subpr... | Build an sdist from a source directory using PEP 517 hooks. | def build_sdist(source_dir, sdist_dir, config_settings=None):
"""Build an sdist from a source directory using PEP 517 hooks.
:param str source_dir: Source directory containing pyproject.toml
:param str sdist_dir: Target directory to place sdist in
:param dict config_settings: Options to pass to build b... | [
"def",
"build_sdist",
"(",
"source_dir",
",",
"sdist_dir",
",",
"config_settings",
"=",
"None",
")",
":",
"if",
"config_settings",
"is",
"None",
":",
"config_settings",
"=",
"{",
"}",
"requires",
",",
"backend",
",",
"backend_path",
"=",
"_load_pyproject",
"("... | [
147,
0
] | [
166,
60
] | python | en | ['en', 'en', 'en'] | True |
BuildEnvironment.pip_install | (self, reqs) | Install dependencies into this env by calling pip in a subprocess | Install dependencies into this env by calling pip in a subprocess | def pip_install(self, reqs):
"""Install dependencies into this env by calling pip in a subprocess"""
if not reqs:
return
log.info('Calling pip to install %s', reqs)
cmd = [
sys.executable, '-m', 'pip', 'install', '--ignore-installed',
'--prefix', self.... | [
"def",
"pip_install",
"(",
"self",
",",
"reqs",
")",
":",
"if",
"not",
"reqs",
":",
"return",
"log",
".",
"info",
"(",
"'Calling pip to install %s'",
",",
"reqs",
")",
"cmd",
"=",
"[",
"sys",
".",
"executable",
",",
"'-m'",
",",
"'pip'",
",",
"'install... | [
91,
4
] | [
103,
9
] | python | en | ['en', 'en', 'en'] | True |
compile_ | (source, filename=None, mode='exec', flags=generators.compiler_flag, dont_inherit=0) | compile the given source to a raw code object,
and maintain an internal cache which allows later
retrieval of the source code for the code object
and any recursively created code objects.
| compile the given source to a raw code object,
and maintain an internal cache which allows later
retrieval of the source code for the code object
and any recursively created code objects.
| def compile_(source, filename=None, mode='exec', flags=generators.compiler_flag, dont_inherit=0):
""" compile the given source to a raw code object,
and maintain an internal cache which allows later
retrieval of the source code for the code object
and any recursively created code objects.
... | [
"def",
"compile_",
"(",
"source",
",",
"filename",
"=",
"None",
",",
"mode",
"=",
"'exec'",
",",
"flags",
"=",
"generators",
".",
"compiler_flag",
",",
"dont_inherit",
"=",
"0",
")",
":",
"if",
"isinstance",
"(",
"source",
",",
"ast",
".",
"AST",
")",
... | [
202,
0
] | [
214,
13
] | python | en | ['en', 'en', 'en'] | True |
getfslineno | (obj) | Return source location (path, lineno) for the given object.
If the source cannot be determined return ("", -1)
| Return source location (path, lineno) for the given object.
If the source cannot be determined return ("", -1)
| def getfslineno(obj):
""" Return source location (path, lineno) for the given object.
If the source cannot be determined return ("", -1)
"""
import _pytest._code
try:
code = _pytest._code.Code(obj)
except TypeError:
try:
fn = inspect.getsourcefile(obj) or inspect.getf... | [
"def",
"getfslineno",
"(",
"obj",
")",
":",
"import",
"_pytest",
".",
"_code",
"try",
":",
"code",
"=",
"_pytest",
".",
"_code",
".",
"Code",
"(",
"obj",
")",
"except",
"TypeError",
":",
"try",
":",
"fn",
"=",
"inspect",
".",
"getsourcefile",
"(",
"o... | [
217,
0
] | [
241,
25
] | python | en | ['en', 'en', 'en'] | True |
getstatementrange_old | (lineno, source, assertion=False) | return (start, end) tuple which spans the minimal
statement region which containing the given lineno.
raise an IndexError if no such statementrange can be found.
| return (start, end) tuple which spans the minimal
statement region which containing the given lineno.
raise an IndexError if no such statementrange can be found.
| def getstatementrange_old(lineno, source, assertion=False):
""" return (start, end) tuple which spans the minimal
statement region which containing the given lineno.
raise an IndexError if no such statementrange can be found.
"""
# XXX this logic is only used on python2.4 and below
# 1. ... | [
"def",
"getstatementrange_old",
"(",
"lineno",
",",
"source",
",",
"assertion",
"=",
"False",
")",
":",
"# XXX this logic is only used on python2.4 and below",
"# 1. find the start of the statement",
"from",
"codeop",
"import",
"compile_command",
"for",
"start",
"in",
"rang... | [
378,
0
] | [
410,
74
] | python | en | ['en', 'en', 'en'] | True |
Source.strip | (self) | return new source object with trailing
and leading blank lines removed.
| return new source object with trailing
and leading blank lines removed.
| def strip(self):
""" return new source object with trailing
and leading blank lines removed.
"""
start, end = 0, len(self)
while start < end and not self.lines[start].strip():
start += 1
while end > start and not self.lines[end - 1].strip():
en... | [
"def",
"strip",
"(",
"self",
")",
":",
"start",
",",
"end",
"=",
"0",
",",
"len",
"(",
"self",
")",
"while",
"start",
"<",
"end",
"and",
"not",
"self",
".",
"lines",
"[",
"start",
"]",
".",
"strip",
"(",
")",
":",
"start",
"+=",
"1",
"while",
... | [
68,
4
] | [
79,
21
] | python | en | ['en', 'en', 'en'] | True |
Source.putaround | (self, before='', after='', indent=' ' * 4) | return a copy of the source object with
'before' and 'after' wrapped around it.
| return a copy of the source object with
'before' and 'after' wrapped around it.
| def putaround(self, before='', after='', indent=' ' * 4):
""" return a copy of the source object with
'before' and 'after' wrapped around it.
"""
before = Source(before)
after = Source(after)
newsource = Source()
lines = [(indent + line) for line in self.lines... | [
"def",
"putaround",
"(",
"self",
",",
"before",
"=",
"''",
",",
"after",
"=",
"''",
",",
"indent",
"=",
"' '",
"*",
"4",
")",
":",
"before",
"=",
"Source",
"(",
"before",
")",
"after",
"=",
"Source",
"(",
"after",
")",
"newsource",
"=",
"Source",
... | [
81,
4
] | [
90,
24
] | python | en | ['en', 'en', 'en'] | True |
Source.indent | (self, indent=' ' * 4) | return a copy of the source object with
all lines indented by the given indent-string.
| return a copy of the source object with
all lines indented by the given indent-string.
| def indent(self, indent=' ' * 4):
""" return a copy of the source object with
all lines indented by the given indent-string.
"""
newsource = Source()
newsource.lines = [(indent + line) for line in self.lines]
return newsource | [
"def",
"indent",
"(",
"self",
",",
"indent",
"=",
"' '",
"*",
"4",
")",
":",
"newsource",
"=",
"Source",
"(",
")",
"newsource",
".",
"lines",
"=",
"[",
"(",
"indent",
"+",
"line",
")",
"for",
"line",
"in",
"self",
".",
"lines",
"]",
"return",
"ne... | [
92,
4
] | [
98,
24
] | python | en | ['en', 'en', 'en'] | True |
Source.getstatement | (self, lineno, assertion=False) | return Source statement which contains the
given linenumber (counted from 0).
| return Source statement which contains the
given linenumber (counted from 0).
| def getstatement(self, lineno, assertion=False):
""" return Source statement which contains the
given linenumber (counted from 0).
"""
start, end = self.getstatementrange(lineno, assertion)
return self[start:end] | [
"def",
"getstatement",
"(",
"self",
",",
"lineno",
",",
"assertion",
"=",
"False",
")",
":",
"start",
",",
"end",
"=",
"self",
".",
"getstatementrange",
"(",
"lineno",
",",
"assertion",
")",
"return",
"self",
"[",
"start",
":",
"end",
"]"
] | [
100,
4
] | [
105,
30
] | python | en | ['en', 'en', 'en'] | True |
Source.getstatementrange | (self, lineno, assertion=False) | return (start, end) tuple which spans the minimal
statement region which containing the given lineno.
| return (start, end) tuple which spans the minimal
statement region which containing the given lineno.
| def getstatementrange(self, lineno, assertion=False):
""" return (start, end) tuple which spans the minimal
statement region which containing the given lineno.
"""
if not (0 <= lineno < len(self)):
raise IndexError("lineno out of range")
ast, start, end = getstate... | [
"def",
"getstatementrange",
"(",
"self",
",",
"lineno",
",",
"assertion",
"=",
"False",
")",
":",
"if",
"not",
"(",
"0",
"<=",
"lineno",
"<",
"len",
"(",
"self",
")",
")",
":",
"raise",
"IndexError",
"(",
"\"lineno out of range\"",
")",
"ast",
",",
"st... | [
107,
4
] | [
114,
25
] | python | en | ['en', 'en', 'en'] | True |
Source.deindent | (self, offset=None) | return a new source object deindented by offset.
If offset is None then guess an indentation offset from
the first non-blank line. Subsequent lines which have a
lower indentation offset will be copied verbatim as
they are assumed to be part of multilines.
| return a new source object deindented by offset.
If offset is None then guess an indentation offset from
the first non-blank line. Subsequent lines which have a
lower indentation offset will be copied verbatim as
they are assumed to be part of multilines.
| def deindent(self, offset=None):
""" return a new source object deindented by offset.
If offset is None then guess an indentation offset from
the first non-blank line. Subsequent lines which have a
lower indentation offset will be copied verbatim as
they are assu... | [
"def",
"deindent",
"(",
"self",
",",
"offset",
"=",
"None",
")",
":",
"# XXX maybe use the tokenizer to properly handle multiline",
"# strings etc.pp?",
"newsource",
"=",
"Source",
"(",
")",
"newsource",
".",
"lines",
"[",
":",
"]",
"=",
"deindent",
"(",
"self... | [
116,
4
] | [
127,
24
] | python | en | ['en', 'en', 'en'] | True |
Source.isparseable | (self, deindent=True) | return True if source is parseable, heuristically
deindenting it by default.
| return True if source is parseable, heuristically
deindenting it by default.
| def isparseable(self, deindent=True):
""" return True if source is parseable, heuristically
deindenting it by default.
"""
try:
import parser
except ImportError:
def syntax_checker(x):
return compile(x, 'asd', 'exec')
else:
... | [
"def",
"isparseable",
"(",
"self",
",",
"deindent",
"=",
"True",
")",
":",
"try",
":",
"import",
"parser",
"except",
"ImportError",
":",
"def",
"syntax_checker",
"(",
"x",
")",
":",
"return",
"compile",
"(",
"x",
",",
"'asd'",
",",
"'exec'",
")",
"else... | [
129,
4
] | [
153,
23
] | python | en | ['en', 'en', 'en'] | True |
Source.compile | (self, filename=None, mode='exec',
flag=generators.compiler_flag,
dont_inherit=0, _genframe=None) | return compiled code object. if filename is None
invent an artificial filename which displays
the source/line position of the caller frame.
| return compiled code object. if filename is None
invent an artificial filename which displays
the source/line position of the caller frame.
| def compile(self, filename=None, mode='exec',
flag=generators.compiler_flag,
dont_inherit=0, _genframe=None):
""" return compiled code object. if filename is None
invent an artificial filename which displays
the source/line position of the caller frame.
... | [
"def",
"compile",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"mode",
"=",
"'exec'",
",",
"flag",
"=",
"generators",
".",
"compiler_flag",
",",
"dont_inherit",
"=",
"0",
",",
"_genframe",
"=",
"None",
")",
":",
"if",
"not",
"filename",
"or",
"py",
... | [
158,
4
] | [
195,
21
] | python | en | ['en', 'en', 'en'] | True |
TestDownloadRCFile.test_download_rc_v3_file | (self) | This is a basic scenario test:
Steps:
1) Login to Horizon Dashboard as admin user
2) Navigate to Project > API Access tab
3) Click on "Download OpenStack RC File" dropdown button
4) Click on "OpenStack RC File (Identity API v3" button
5) File named by template "<tenant_n... | This is a basic scenario test: | def test_download_rc_v3_file(self):
"""This is a basic scenario test:
Steps:
1) Login to Horizon Dashboard as admin user
2) Navigate to Project > API Access tab
3) Click on "Download OpenStack RC File" dropdown button
4) Click on "OpenStack RC File (Identity API v3" butt... | [
"def",
"test_download_rc_v3_file",
"(",
"self",
")",
":",
"api_access_page",
"=",
"self",
".",
"home_pg",
".",
"go_to_project_apiaccesspage",
"(",
")",
"api_access_page",
".",
"download_openstack_rc_file",
"(",
"3",
",",
"self",
".",
"_directory",
",",
"self",
"."... | [
42,
4
] | [
60,
53
] | python | en | ['en', 'en', 'en'] | True |
recursive_repr | (fillvalue='...') | Decorator to make a repr function return fillvalue for a recursive call | Decorator to make a repr function return fillvalue for a recursive call | def recursive_repr(fillvalue='...'):
'Decorator to make a repr function return fillvalue for a recursive call'
def decorating_function(user_function):
repr_running = set()
def wrapper(self):
key = id(self), get_ident()
if key in repr_running:
return fill... | [
"def",
"recursive_repr",
"(",
"fillvalue",
"=",
"'...'",
")",
":",
"def",
"decorating_function",
"(",
"user_function",
")",
":",
"repr_running",
"=",
"set",
"(",
")",
"def",
"wrapper",
"(",
"self",
")",
":",
"key",
"=",
"id",
"(",
"self",
")",
",",
"ge... | [
11,
0
] | [
36,
30
] | python | en | ['en', 'en', 'en'] | True |
uts46_remap | (domain, std3_rules=True, transitional=False) | Re-map the characters in the string according to UTS46 processing. | Re-map the characters in the string according to UTS46 processing. | def uts46_remap(domain, std3_rules=True, transitional=False):
"""Re-map the characters in the string according to UTS46 processing."""
from .uts46data import uts46data
output = u""
try:
for pos, char in enumerate(domain):
code_point = ord(char)
uts46row = uts46data[code_p... | [
"def",
"uts46_remap",
"(",
"domain",
",",
"std3_rules",
"=",
"True",
",",
"transitional",
"=",
"False",
")",
":",
"from",
".",
"uts46data",
"import",
"uts46data",
"output",
"=",
"u\"\"",
"try",
":",
"for",
"pos",
",",
"char",
"in",
"enumerate",
"(",
"dom... | [
315,
0
] | [
340,
54
] | python | en | ['en', 'en', 'en'] | True |
Conf.setUp | (self) | Setting up test. | Setting up test. | def setUp(self):
"""Setting up test."""
self.server_url = self.conf_get('main', 'url') | [
"def",
"setUp",
"(",
"self",
")",
":",
"self",
".",
"server_url",
"=",
"self",
".",
"conf_get",
"(",
"'main'",
",",
"'url'",
")"
] | [
12,
4
] | [
14,
54
] | python | en | ['en', 'en', 'en'] | True |
test_dashboard_working_examples | (input_data, tmpdir) | Testing if creating a default Dashboard with included examples works (no Exceptions are raised). | Testing if creating a default Dashboard with included examples works (no Exceptions are raised). | def test_dashboard_working_examples(input_data, tmpdir):
"""Testing if creating a default Dashboard with included examples works (no Exceptions are raised)."""
X, y, descriptions = input_data()
dsh = Dashboard(X, y, tmpdir, descriptions)
dsh.create_dashboard()
assert True | [
"def",
"test_dashboard_working_examples",
"(",
"input_data",
",",
"tmpdir",
")",
":",
"X",
",",
"y",
",",
"descriptions",
"=",
"input_data",
"(",
")",
"dsh",
"=",
"Dashboard",
"(",
"X",
",",
"y",
",",
"tmpdir",
",",
"descriptions",
")",
"dsh",
".",
"crea... | [
16,
0
] | [
22,
15
] | python | en | ['en', 'en', 'en'] | True |
_generate_overlap_table | (prefix) |
Generate an overlap table for the following prefix.
An overlap table is a table of the same size as the prefix which
informs about the potential self-overlap for each index in the prefix:
- if overlap[i] == 0, prefix[i:] can't overlap prefix[0:...]
- if overlap[i] == k with 0 < k <= i, prefix[i-k+1... |
Generate an overlap table for the following prefix.
An overlap table is a table of the same size as the prefix which
informs about the potential self-overlap for each index in the prefix:
- if overlap[i] == 0, prefix[i:] can't overlap prefix[0:...]
- if overlap[i] == k with 0 < k <= i, prefix[i-k+1... | def _generate_overlap_table(prefix):
"""
Generate an overlap table for the following prefix.
An overlap table is a table of the same size as the prefix which
informs about the potential self-overlap for each index in the prefix:
- if overlap[i] == 0, prefix[i:] can't overlap prefix[0:...]
- if o... | [
"def",
"_generate_overlap_table",
"(",
"prefix",
")",
":",
"table",
"=",
"[",
"0",
"]",
"*",
"len",
"(",
"prefix",
")",
"for",
"i",
"in",
"range",
"(",
"1",
",",
"len",
"(",
"prefix",
")",
")",
":",
"idx",
"=",
"table",
"[",
"i",
"-",
"1",
"]",... | [
392,
0
] | [
411,
16
] | python | en | ['en', 'error', 'th'] | False |
fill_edit_history_entries | (message_history: List[Dict[str, Any]], message: Message) | This fills out the message edit history entries from the database,
which are designed to have the minimum data possible, to instead
have the current topic + content as of that time, plus data on
whatever changed. This makes it much simpler to do future
processing.
Note that this mutates what is pa... | This fills out the message edit history entries from the database,
which are designed to have the minimum data possible, to instead
have the current topic + content as of that time, plus data on
whatever changed. This makes it much simpler to do future
processing. | def fill_edit_history_entries(message_history: List[Dict[str, Any]], message: Message) -> None:
"""This fills out the message edit history entries from the database,
which are designed to have the minimum data possible, to instead
have the current topic + content as of that time, plus data on
whatever c... | [
"def",
"fill_edit_history_entries",
"(",
"message_history",
":",
"List",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
",",
"message",
":",
"Message",
")",
"->",
"None",
":",
"prev_content",
"=",
"message",
".",
"content",
"prev_rendered_content",
"=",
"mes... | [
21,
0
] | [
66,
5
] | python | en | ['en', 'en', 'en'] | True |
add_new_user_history | (user_profile: UserProfile, streams: Iterable[Stream]) | Give you the last ONBOARDING_TOTAL_MESSAGES messages on your public
streams, so you have something to look at in your home view once
you finish the tutorial. The most recent ONBOARDING_UNREAD_MESSAGES
are marked unread.
| Give you the last ONBOARDING_TOTAL_MESSAGES messages on your public
streams, so you have something to look at in your home view once
you finish the tutorial. The most recent ONBOARDING_UNREAD_MESSAGES
are marked unread.
| def add_new_user_history(user_profile: UserProfile, streams: Iterable[Stream]) -> None:
"""Give you the last ONBOARDING_TOTAL_MESSAGES messages on your public
streams, so you have something to look at in your home view once
you finish the tutorial. The most recent ONBOARDING_UNREAD_MESSAGES
are marked ... | [
"def",
"add_new_user_history",
"(",
"user_profile",
":",
"UserProfile",
",",
"streams",
":",
"Iterable",
"[",
"Stream",
"]",
")",
"->",
"None",
":",
"one_week_ago",
"=",
"timezone_now",
"(",
")",
"-",
"datetime",
".",
"timedelta",
"(",
"weeks",
"=",
"1",
"... | [
394,
0
] | [
434,
60
] | python | en | ['en', 'en', 'en'] | True |
do_set_realm_property | (
realm: Realm, name: str, value: Any, *, acting_user: Optional[UserProfile]
) | Takes in a realm object, the name of an attribute to update, the
value to update and and the user who initiated the update.
| Takes in a realm object, the name of an attribute to update, the
value to update and and the user who initiated the update.
| def do_set_realm_property(
realm: Realm, name: str, value: Any, *, acting_user: Optional[UserProfile]
) -> None:
"""Takes in a realm object, the name of an attribute to update, the
value to update and and the user who initiated the update.
"""
property_type = Realm.property_types[name]
assert is... | [
"def",
"do_set_realm_property",
"(",
"realm",
":",
"Realm",
",",
"name",
":",
"str",
",",
"value",
":",
"Any",
",",
"*",
",",
"acting_user",
":",
"Optional",
"[",
"UserProfile",
"]",
")",
"->",
"None",
":",
"property_type",
"=",
"Realm",
".",
"property_t... | [
772,
0
] | [
826,
73
] | python | en | ['en', 'en', 'en'] | True |
do_deactivate_realm | (realm: Realm, *, acting_user: Optional[UserProfile]) |
Deactivate this realm. Do NOT deactivate the users -- we need to be able to
tell the difference between users that were intentionally deactivated,
e.g. by a realm admin, and users who can't currently use Zulip because their
realm has been deactivated.
|
Deactivate this realm. Do NOT deactivate the users -- we need to be able to
tell the difference between users that were intentionally deactivated,
e.g. by a realm admin, and users who can't currently use Zulip because their
realm has been deactivated.
| def do_deactivate_realm(realm: Realm, *, acting_user: Optional[UserProfile]) -> None:
"""
Deactivate this realm. Do NOT deactivate the users -- we need to be able to
tell the difference between users that were intentionally deactivated,
e.g. by a realm admin, and users who can't currently use Zulip beca... | [
"def",
"do_deactivate_realm",
"(",
"realm",
":",
"Realm",
",",
"*",
",",
"acting_user",
":",
"Optional",
"[",
"UserProfile",
"]",
")",
"->",
"None",
":",
"if",
"realm",
".",
"deactivated",
":",
"return",
"realm",
".",
"deactivated",
"=",
"True",
"realm",
... | [
973,
0
] | [
1016,
55
] | python | en | ['en', 'error', 'th'] | False |
change_user_is_active | (user_profile: UserProfile, value: bool) |
Helper function for changing the .is_active field. Not meant as a standalone function
in production code as properly activating/deactivating users requires more steps.
This changes the is_active value and saves it, while ensuring
Subscription.is_user_active values are updated in the same db transaction... |
Helper function for changing the .is_active field. Not meant as a standalone function
in production code as properly activating/deactivating users requires more steps.
This changes the is_active value and saves it, while ensuring
Subscription.is_user_active values are updated in the same db transaction... | def change_user_is_active(user_profile: UserProfile, value: bool) -> None:
"""
Helper function for changing the .is_active field. Not meant as a standalone function
in production code as properly activating/deactivating users requires more steps.
This changes the is_active value and saves it, while ensu... | [
"def",
"change_user_is_active",
"(",
"user_profile",
":",
"UserProfile",
",",
"value",
":",
"bool",
")",
"->",
"None",
":",
"with",
"transaction",
".",
"atomic",
"(",
"savepoint",
"=",
"False",
")",
":",
"user_profile",
".",
"is_active",
"=",
"value",
"user_... | [
1135,
0
] | [
1145,
91
] | python | en | ['en', 'error', 'th'] | False |
build_message_send_dict | (
message_dict: Dict[str, Any], email_gateway: bool = False
) | Returns a dictionary that can be passed into do_send_messages. In
production, this is always called by check_message, but some
testing code paths call it directly.
| Returns a dictionary that can be passed into do_send_messages. In
production, this is always called by check_message, but some
testing code paths call it directly.
| def build_message_send_dict(
message_dict: Dict[str, Any], email_gateway: bool = False
) -> SendMessageRequest:
"""Returns a dictionary that can be passed into do_send_messages. In
production, this is always called by check_message, but some
testing code paths call it directly.
"""
realm = mess... | [
"def",
"build_message_send_dict",
"(",
"message_dict",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"email_gateway",
":",
"bool",
"=",
"False",
")",
"->",
"SendMessageRequest",
":",
"realm",
"=",
"message_dict",
".",
"get",
"(",
"\"realm\"",
",",
"message_... | [
1726,
0
] | [
1818,
28
] | python | en | ['en', 'en', 'en'] | True |
do_send_messages | (
send_message_requests_maybe_none: Sequence[Optional[SendMessageRequest]],
email_gateway: bool = False,
mark_as_read: Sequence[int] = [],
) | See
https://zulip.readthedocs.io/en/latest/subsystems/sending-messages.html
for high-level documentation on this subsystem.
| See
https://zulip.readthedocs.io/en/latest/subsystems/sending-messages.html
for high-level documentation on this subsystem.
| def do_send_messages(
send_message_requests_maybe_none: Sequence[Optional[SendMessageRequest]],
email_gateway: bool = False,
mark_as_read: Sequence[int] = [],
) -> List[int]:
"""See
https://zulip.readthedocs.io/en/latest/subsystems/sending-messages.html
for high-level documentation on this subsy... | [
"def",
"do_send_messages",
"(",
"send_message_requests_maybe_none",
":",
"Sequence",
"[",
"Optional",
"[",
"SendMessageRequest",
"]",
"]",
",",
"email_gateway",
":",
"bool",
"=",
"False",
",",
"mark_as_read",
":",
"Sequence",
"[",
"int",
"]",
"=",
"[",
"]",
",... | [
1821,
0
] | [
2017,
78
] | python | en | ['en', 'en', 'ur'] | False |
bulk_insert_ums | (ums: List[UserMessageLite]) |
Doing bulk inserts this way is much faster than using Django,
since we don't have any ORM overhead. Profiling with 1000
users shows a speedup of 0.436 -> 0.027 seconds, so we're
talking about a 15x speedup.
|
Doing bulk inserts this way is much faster than using Django,
since we don't have any ORM overhead. Profiling with 1000
users shows a speedup of 0.436 -> 0.027 seconds, so we're
talking about a 15x speedup.
| def bulk_insert_ums(ums: List[UserMessageLite]) -> None:
"""
Doing bulk inserts this way is much faster than using Django,
since we don't have any ORM overhead. Profiling with 1000
users shows a speedup of 0.436 -> 0.027 seconds, so we're
talking about a 15x speedup.
"""
if not ums:
... | [
"def",
"bulk_insert_ums",
"(",
"ums",
":",
"List",
"[",
"UserMessageLite",
"]",
")",
"->",
"None",
":",
"if",
"not",
"ums",
":",
"return",
"vals",
"=",
"[",
"(",
"um",
".",
"user_profile_id",
",",
"um",
".",
"message_id",
",",
"um",
".",
"flags",
")"... | [
2107,
0
] | [
2127,
50
] | python | en | ['en', 'error', 'th'] | False |
pytestPDB.set_trace | (cls) | invoke PDB set_trace debugging, dropping any IO capturing. | invoke PDB set_trace debugging, dropping any IO capturing. | def set_trace(cls):
""" invoke PDB set_trace debugging, dropping any IO capturing. """
import _pytest.config
frame = sys._getframe().f_back
if cls._pluginmanager is not None:
capman = cls._pluginmanager.getplugin("capturemanager")
if capman:
capman... | [
"def",
"set_trace",
"(",
"cls",
")",
":",
"import",
"_pytest",
".",
"config",
"frame",
"=",
"sys",
".",
"_getframe",
"(",
")",
".",
"f_back",
"if",
"cls",
".",
"_pluginmanager",
"is",
"not",
"None",
":",
"capman",
"=",
"cls",
".",
"_pluginmanager",
"."... | [
50,
4
] | [
62,
39
] | python | en | ['en', 'fil', 'en'] | True |
migrate_fix_invalid_bot_owner_values | (
apps: StateApps, schema_editor: DatabaseSchemaEditor
) | Fixes UserProfile objects that incorrectly had a bot_owner set | Fixes UserProfile objects that incorrectly had a bot_owner set | def migrate_fix_invalid_bot_owner_values(
apps: StateApps, schema_editor: DatabaseSchemaEditor
) -> None:
"""Fixes UserProfile objects that incorrectly had a bot_owner set"""
UserProfile = apps.get_model("zerver", "UserProfile")
UserProfile.objects.filter(is_bot=False).exclude(bot_owner=None).update(bot... | [
"def",
"migrate_fix_invalid_bot_owner_values",
"(",
"apps",
":",
"StateApps",
",",
"schema_editor",
":",
"DatabaseSchemaEditor",
")",
"->",
"None",
":",
"UserProfile",
"=",
"apps",
".",
"get_model",
"(",
"\"zerver\"",
",",
"\"UserProfile\"",
")",
"UserProfile",
".",... | [
7,
0
] | [
12,
91
] | python | en | ['en', 'en', 'en'] | True |
my_check_output | (*popenargs, **kwargs) |
If we had python 2.7, we should simply use subprocess.check_output.
This is a stop-gap solution for python 2.6
|
If we had python 2.7, we should simply use subprocess.check_output.
This is a stop-gap solution for python 2.6
| def my_check_output(*popenargs, **kwargs):
"""
If we had python 2.7, we should simply use subprocess.check_output.
This is a stop-gap solution for python 2.6
"""
if 'stdout' in kwargs:
raise ValueError('stdout argument not allowed, it will be overridden.')
process = subprocess.Popen(stde... | [
"def",
"my_check_output",
"(",
"*",
"popenargs",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'stdout'",
"in",
"kwargs",
":",
"raise",
"ValueError",
"(",
"'stdout argument not allowed, it will be overridden.'",
")",
"process",
"=",
"subprocess",
".",
"Popen",
"(",
... | [
12,
0
] | [
29,
17
] | python | en | ['en', 'error', 'th'] | False |
LDBTestCase.assertRunOKFull | (self, params, expectedOutput, unexpected=False,
isPattern=False) |
All command-line params must be specified.
Allows full flexibility in testing; for example: missing db param.
|
All command-line params must be specified.
Allows full flexibility in testing; for example: missing db param. | def assertRunOKFull(self, params, expectedOutput, unexpected=False,
isPattern=False):
"""
All command-line params must be specified.
Allows full flexibility in testing; for example: missing db param.
"""
output = my_check_output("./ldb %s |grep -v \"Creat... | [
"def",
"assertRunOKFull",
"(",
"self",
",",
"params",
",",
"expectedOutput",
",",
"unexpected",
"=",
"False",
",",
"isPattern",
"=",
"False",
")",
":",
"output",
"=",
"my_check_output",
"(",
"\"./ldb %s |grep -v \\\"Created bg thread\\\"\"",
"%",
"params",
",",
"s... | [
49,
4
] | [
68,
75
] | python | en | ['en', 'error', 'th'] | False |
LDBTestCase.assertRunFAILFull | (self, params) |
All command-line params must be specified.
Allows full flexibility in testing; for example: missing db param.
|
All command-line params must be specified.
Allows full flexibility in testing; for example: missing db param. | def assertRunFAILFull(self, params):
"""
All command-line params must be specified.
Allows full flexibility in testing; for example: missing db param.
"""
try:
my_check_output("./ldb %s >/dev/null 2>&1 |grep -v \"Created bg \
thread\"" % params, shel... | [
"def",
"assertRunFAILFull",
"(",
"self",
",",
"params",
")",
":",
"try",
":",
"my_check_output",
"(",
"\"./ldb %s >/dev/null 2>&1 |grep -v \\\"Created bg \\\n thread\\\"\"",
"%",
"params",
",",
"shell",
"=",
"True",
")",
"except",
"Exception",
":",
"retur... | [
70,
4
] | [
84,
19
] | python | en | ['en', 'error', 'th'] | False |
LDBTestCase.assertRunOK | (self, params, expectedOutput, unexpected=False) |
Uses the default test db.
|
Uses the default test db. | def assertRunOK(self, params, expectedOutput, unexpected=False):
"""
Uses the default test db.
"""
self.assertRunOKFull("%s %s" % (self.dbParam(self.DB_NAME), params),
expectedOutput, unexpected) | [
"def",
"assertRunOK",
"(",
"self",
",",
"params",
",",
"expectedOutput",
",",
"unexpected",
"=",
"False",
")",
":",
"self",
".",
"assertRunOKFull",
"(",
"\"%s %s\"",
"%",
"(",
"self",
".",
"dbParam",
"(",
"self",
".",
"DB_NAME",
")",
",",
"params",
")",
... | [
86,
4
] | [
92,
56
] | python | en | ['en', 'error', 'th'] | False |
LDBTestCase.assertRunFAIL | (self, params) |
Uses the default test db.
|
Uses the default test db.
| def assertRunFAIL(self, params):
"""
Uses the default test db.
"""
self.assertRunFAILFull("%s %s" % (self.dbParam(self.DB_NAME), params)) | [
"def",
"assertRunFAIL",
"(",
"self",
",",
"params",
")",
":",
"self",
".",
"assertRunFAILFull",
"(",
"\"%s %s\"",
"%",
"(",
"self",
".",
"dbParam",
"(",
"self",
".",
"DB_NAME",
")",
",",
"params",
")",
")"
] | [
94,
4
] | [
98,
78
] | python | en | ['en', 'error', 'th'] | False |
render_tex | (tex: str, is_inline: bool = True) | r"""Render a TeX string into HTML using KaTeX
Returns the HTML string, or None if there was some error in the TeX syntax
Keyword arguments:
tex -- Text string with the TeX to render
Don't include delimiters ('$$', '\[ \]', etc.)
is_inline -- Boolean setting that indicates whether the render... | r"""Render a TeX string into HTML using KaTeX | def render_tex(tex: str, is_inline: bool = True) -> Optional[str]:
r"""Render a TeX string into HTML using KaTeX
Returns the HTML string, or None if there was some error in the TeX syntax
Keyword arguments:
tex -- Text string with the TeX to render
Don't include delimiters ('$$', '\[ \]', e... | [
"def",
"render_tex",
"(",
"tex",
":",
"str",
",",
"is_inline",
":",
"bool",
"=",
"True",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"katex_path",
"=",
"(",
"static_path",
"(",
"\"webpack-bundles/katex-cli.js\"",
")",
"if",
"settings",
".",
"PRODUCTION",
... | [
10,
0
] | [
42,
19
] | python | en | ['it', 'en', 'en'] | True |
Installer._get_all_ns_packages | (self) | Return sorted list of all package namespaces | Return sorted list of all package namespaces | def _get_all_ns_packages(self):
"""Return sorted list of all package namespaces"""
pkgs = self.distribution.namespace_packages or []
return sorted(flatten(map(self._pkg_names, pkgs))) | [
"def",
"_get_all_ns_packages",
"(",
"self",
")",
":",
"pkgs",
"=",
"self",
".",
"distribution",
".",
"namespace_packages",
"or",
"[",
"]",
"return",
"sorted",
"(",
"flatten",
"(",
"map",
"(",
"self",
".",
"_pkg_names",
",",
"pkgs",
")",
")",
")"
] | [
80,
4
] | [
83,
58
] | python | en | ['en', 'en', 'en'] | True |
Installer._pkg_names | (pkg) |
Given a namespace package, yield the components of that
package.
>>> names = Installer._pkg_names('a.b.c')
>>> set(names) == set(['a', 'a.b', 'a.b.c'])
True
|
Given a namespace package, yield the components of that
package. | def _pkg_names(pkg):
"""
Given a namespace package, yield the components of that
package.
>>> names = Installer._pkg_names('a.b.c')
>>> set(names) == set(['a', 'a.b', 'a.b.c'])
True
"""
parts = pkg.split('.')
while parts:
yield '.'.joi... | [
"def",
"_pkg_names",
"(",
"pkg",
")",
":",
"parts",
"=",
"pkg",
".",
"split",
"(",
"'.'",
")",
"while",
"parts",
":",
"yield",
"'.'",
".",
"join",
"(",
"parts",
")",
"parts",
".",
"pop",
"(",
")"
] | [
86,
4
] | [
98,
23
] | python | en | ['en', 'error', 'th'] | False |
Criterion.from_requirement | (cls, provider, requirement, parent) | Build an instance from a requirement.
| Build an instance from a requirement.
| def from_requirement(cls, provider, requirement, parent):
"""Build an instance from a requirement.
"""
candidates = provider.find_matches([requirement])
if not isinstance(candidates, collections_abc.Sequence):
candidates = list(candidates)
criterion = cls(
... | [
"def",
"from_requirement",
"(",
"cls",
",",
"provider",
",",
"requirement",
",",
"parent",
")",
":",
"candidates",
"=",
"provider",
".",
"find_matches",
"(",
"[",
"requirement",
"]",
")",
"if",
"not",
"isinstance",
"(",
"candidates",
",",
"collections_abc",
... | [
77,
4
] | [
90,
24
] | python | en | ['en', 'en', 'en'] | True |
Criterion.merged_with | (self, provider, requirement, parent) | Build a new instance from this and a new requirement.
| Build a new instance from this and a new requirement.
| def merged_with(self, provider, requirement, parent):
"""Build a new instance from this and a new requirement.
"""
infos = list(self.information)
infos.append(RequirementInformation(requirement, parent))
candidates = provider.find_matches([r for r, _ in infos])
if not isi... | [
"def",
"merged_with",
"(",
"self",
",",
"provider",
",",
"requirement",
",",
"parent",
")",
":",
"infos",
"=",
"list",
"(",
"self",
".",
"information",
")",
"infos",
".",
"append",
"(",
"RequirementInformation",
"(",
"requirement",
",",
"parent",
")",
")",... | [
98,
4
] | [
109,
24
] | python | en | ['en', 'en', 'en'] | True |
Criterion.excluded_of | (self, candidate) | Build a new instance from this, but excluding specified candidate.
Returns the new instance, or None if we still have no valid candidates.
| Build a new instance from this, but excluding specified candidate. | def excluded_of(self, candidate):
"""Build a new instance from this, but excluding specified candidate.
Returns the new instance, or None if we still have no valid candidates.
"""
incompats = list(self.incompatibilities)
incompats.append(candidate)
candidates = [c for c ... | [
"def",
"excluded_of",
"(",
"self",
",",
"candidate",
")",
":",
"incompats",
"=",
"list",
"(",
"self",
".",
"incompatibilities",
")",
"incompats",
".",
"append",
"(",
"candidate",
")",
"candidates",
"=",
"[",
"c",
"for",
"c",
"in",
"self",
".",
"candidate... | [
111,
4
] | [
122,
24
] | python | en | ['en', 'en', 'en'] | True |
Resolution._push_new_state | (self) | Push a new state into history.
This new state will be used to hold resolution results of the next
coming round.
| Push a new state into history. | def _push_new_state(self):
"""Push a new state into history.
This new state will be used to hold resolution results of the next
coming round.
"""
try:
base = self._states[-1]
except IndexError:
state = State(mapping=collections.OrderedDict(), crit... | [
"def",
"_push_new_state",
"(",
"self",
")",
":",
"try",
":",
"base",
"=",
"self",
".",
"_states",
"[",
"-",
"1",
"]",
"except",
"IndexError",
":",
"state",
"=",
"State",
"(",
"mapping",
"=",
"collections",
".",
"OrderedDict",
"(",
")",
",",
"criteria",... | [
165,
4
] | [
179,
34
] | python | en | ['en', 'en', 'en'] | True |
Resolver.resolve | (self, requirements, max_rounds=100) | Take a collection of constraints, spit out the resolution result.
The return value is a representation to the final resolution result. It
is a tuple subclass with three public members:
* `mapping`: A dict of resolved candidates. Each key is an identifier
of a requirement (as return... | Take a collection of constraints, spit out the resolution result. | def resolve(self, requirements, max_rounds=100):
"""Take a collection of constraints, spit out the resolution result.
The return value is a representation to the final resolution result. It
is a tuple subclass with three public members:
* `mapping`: A dict of resolved candidates. Each ... | [
"def",
"resolve",
"(",
"self",
",",
"requirements",
",",
"max_rounds",
"=",
"100",
")",
":",
"resolution",
"=",
"Resolution",
"(",
"self",
".",
"provider",
",",
"self",
".",
"reporter",
")",
"state",
"=",
"resolution",
".",
"resolve",
"(",
"requirements",
... | [
397,
4
] | [
427,
35
] | python | en | ['en', 'en', 'en'] | True |
IMU.enable | (self, gyroAccel=True, barometer=True, magnetometer=True) | Enable the given devices. | Enable the given devices. | def enable(self, gyroAccel=True, barometer=True, magnetometer=True):
""" Enable the given devices. """
if gyroAccel:
self.lsm6ds33.enable()
self.gyroAccelEnabled = True
if barometer:
self.lps25h.enable()
self.barometerEnabled = True
if mag... | [
"def",
"enable",
"(",
"self",
",",
"gyroAccel",
"=",
"True",
",",
"barometer",
"=",
"True",
",",
"magnetometer",
"=",
"True",
")",
":",
"if",
"gyroAccel",
":",
"self",
".",
"lsm6ds33",
".",
"enable",
"(",
")",
"self",
".",
"gyroAccelEnabled",
"=",
"Tru... | [
29,
4
] | [
40,
43
] | python | en | ['en', 'en', 'en'] | True |
IMU.get_complementary_angles | (self, delta_t=0.05) | Calculate combined angles of accelerometer and gyroscope
using a complementary filter.
| Calculate combined angles of accelerometer and gyroscope
using a complementary filter.
| def get_complementary_angles(self, delta_t=0.05):
""" Calculate combined angles of accelerometer and gyroscope
using a complementary filter.
"""
if not self.gyroAccelEnabled:
raise(Exception('Gyroscope and accelerometer are not enabled!'))
self.complementary_angl... | [
"def",
"get_complementary_angles",
"(",
"self",
",",
"delta_t",
"=",
"0.05",
")",
":",
"if",
"not",
"self",
".",
"gyroAccelEnabled",
":",
"raise",
"(",
"Exception",
"(",
"'Gyroscope and accelerometer are not enabled!'",
")",
")",
"self",
".",
"complementary_angles",... | [
42,
4
] | [
64,
40
] | python | en | ['en', 'en', 'en'] | True |
ObjectDetectionNode.__init__ | (
self,
video_source_uri: str,
video_source_args: List[str] = None,
network: str = 'ssd-mobilenet-v2',
threshold: float = 0.5,
log_level: Literal['silent', 'error', 'warning', 'success', 'info', 'verbose', 'debug'] = 'success',
log_dete... |
Object detection node.
Publishes on topic 'detected_objects', with data set to a list of
Detection instances.
For reference, the Intel Realsense D435i supports these settings:
- RGB camera:
- Resolutions: 320x180, 320x240, 424x240, 640x360, 640x480, 848x480*, 960x540... |
Object detection node. | def __init__(
self,
video_source_uri: str,
video_source_args: List[str] = None,
network: str = 'ssd-mobilenet-v2',
threshold: float = 0.5,
log_level: Literal['silent', 'error', 'warning', 'success', 'info', 'verbose', 'debug'] = 'success',
... | [
"def",
"__init__",
"(",
"self",
",",
"video_source_uri",
":",
"str",
",",
"video_source_args",
":",
"List",
"[",
"str",
"]",
"=",
"None",
",",
"network",
":",
"str",
"=",
"'ssd-mobilenet-v2'",
",",
"threshold",
":",
"float",
"=",
"0.5",
",",
"log_level",
... | [
32,
4
] | [
72,
34
] | python | en | ['en', 'error', 'th'] | False |
PlotDesign.__init__ | (self) | Create PlotDesign object. | Create PlotDesign object. | def __init__(self):
"""Create PlotDesign object."""
self.text_color = "#8C8C8C"
self.text_font = "Lato"
self.pairplot_color = "#19529c"
self.fill_color = "#8CA8CD"
self.base_color_tints = [
"#19529c",
"#3063a6",
"#4775b0",
... | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"text_color",
"=",
"\"#8C8C8C\"",
"self",
".",
"text_font",
"=",
"\"Lato\"",
"self",
".",
"pairplot_color",
"=",
"\"#19529c\"",
"self",
".",
"fill_color",
"=",
"\"#8CA8CD\"",
"self",
".",
"base_color_tints... | [
17,
4
] | [
69,
89
] | python | en | ['en', 'fi', 'en'] | True |
sanitize_content_filename | (filename) |
Sanitize the "filename" value from a Content-Disposition header.
|
Sanitize the "filename" value from a Content-Disposition header.
| def sanitize_content_filename(filename):
# type: (str) -> str
"""
Sanitize the "filename" value from a Content-Disposition header.
"""
return os.path.basename(filename) | [
"def",
"sanitize_content_filename",
"(",
"filename",
")",
":",
"# type: (str) -> str",
"return",
"os",
".",
"path",
".",
"basename",
"(",
"filename",
")"
] | [
88,
0
] | [
93,
37
] | python | en | ['en', 'error', 'th'] | False |
parse_content_disposition | (content_disposition, default_filename) |
Parse the "filename" value from a Content-Disposition header, and
return the default filename if the result is empty.
|
Parse the "filename" value from a Content-Disposition header, and
return the default filename if the result is empty.
| def parse_content_disposition(content_disposition, default_filename):
# type: (str, str) -> str
"""
Parse the "filename" value from a Content-Disposition header, and
return the default filename if the result is empty.
"""
_type, params = cgi.parse_header(content_disposition)
filename = param... | [
"def",
"parse_content_disposition",
"(",
"content_disposition",
",",
"default_filename",
")",
":",
"# type: (str, str) -> str",
"_type",
",",
"params",
"=",
"cgi",
".",
"parse_header",
"(",
"content_disposition",
")",
"filename",
"=",
"params",
".",
"get",
"(",
"'fi... | [
96,
0
] | [
108,
39
] | python | en | ['en', 'error', 'th'] | False |
_get_http_response_filename | (resp, link) | Get an ideal filename from the given HTTP response, falling back to
the link filename if not provided.
| Get an ideal filename from the given HTTP response, falling back to
the link filename if not provided.
| def _get_http_response_filename(resp, link):
# type: (Response, Link) -> str
"""Get an ideal filename from the given HTTP response, falling back to
the link filename if not provided.
"""
filename = link.filename # fallback
# Have a look at the Content-Disposition header for a better guess
c... | [
"def",
"_get_http_response_filename",
"(",
"resp",
",",
"link",
")",
":",
"# type: (Response, Link) -> str",
"filename",
"=",
"link",
".",
"filename",
"# fallback",
"# Have a look at the Content-Disposition header for a better guess",
"content_disposition",
"=",
"resp",
".",
... | [
111,
0
] | [
132,
19
] | python | en | ['en', 'en', 'en'] | True |
find_module | (module, paths=None) | Just like 'imp.find_module()', but with package support | Just like 'imp.find_module()', but with package support | def find_module(module, paths=None):
"""Just like 'imp.find_module()', but with package support"""
spec = find_spec(module, paths)
if spec is None:
raise ImportError("Can't find %s" % module)
if not spec.has_location and hasattr(spec, 'submodule_search_locations'):
spec = importlib.util.... | [
"def",
"find_module",
"(",
"module",
",",
"paths",
"=",
"None",
")",
":",
"spec",
"=",
"find_spec",
"(",
"module",
",",
"paths",
")",
"if",
"spec",
"is",
"None",
":",
"raise",
"ImportError",
"(",
"\"Can't find %s\"",
"%",
"module",
")",
"if",
"not",
"s... | [
28,
0
] | [
67,
43
] | python | en | ['en', 'en', 'en'] | True |
shquote | (arg) | Quote an argument for later parsing by shlex.split() | Quote an argument for later parsing by shlex.split() | def shquote(arg):
"""Quote an argument for later parsing by shlex.split()"""
for c in '"', "'", "\\", "#":
if c in arg:
return repr(arg)
if arg.split() != [arg]:
return repr(arg)
return arg | [
"def",
"shquote",
"(",
"arg",
")",
":",
"for",
"c",
"in",
"'\"'",
",",
"\"'\"",
",",
"\"\\\\\"",
",",
"\"#\"",
":",
"if",
"c",
"in",
"arg",
":",
"return",
"repr",
"(",
"arg",
")",
"if",
"arg",
".",
"split",
"(",
")",
"!=",
"[",
"arg",
"]",
":... | [
5,
0
] | [
12,
14
] | python | en | ['en', 'en', 'en'] | True |
bulk_create_users | (
realm: Realm,
users_raw: Set[Tuple[str, str, bool]],
bot_type: Optional[int] = None,
bot_owner: Optional[UserProfile] = None,
tos_version: Optional[str] = None,
timezone: str = "",
) |
Creates and saves a UserProfile with the given email.
Has some code based off of UserManage.create_user, but doesn't .save()
|
Creates and saves a UserProfile with the given email.
Has some code based off of UserManage.create_user, but doesn't .save()
| def bulk_create_users(
realm: Realm,
users_raw: Set[Tuple[str, str, bool]],
bot_type: Optional[int] = None,
bot_owner: Optional[UserProfile] = None,
tos_version: Optional[str] = None,
timezone: str = "",
) -> None:
"""
Creates and saves a UserProfile with the given email.
Has some co... | [
"def",
"bulk_create_users",
"(",
"realm",
":",
"Realm",
",",
"users_raw",
":",
"Set",
"[",
"Tuple",
"[",
"str",
",",
"str",
",",
"bool",
"]",
"]",
",",
"bot_type",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
",",
"bot_owner",
":",
"Optional",
"[",... | [
10,
0
] | [
95,
61
] | python | en | ['en', 'error', 'th'] | False |
TypingValidateOperatorTest.test_missing_parameter | (self) |
Sending typing notification without op parameter fails
|
Sending typing notification without op parameter fails
| def test_missing_parameter(self) -> None:
"""
Sending typing notification without op parameter fails
"""
sender = self.example_user("hamlet")
params = dict(
to=orjson.dumps([sender.id]).decode(),
)
result = self.api_post(sender, "/api/v1/typing", param... | [
"def",
"test_missing_parameter",
"(",
"self",
")",
"->",
"None",
":",
"sender",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"params",
"=",
"dict",
"(",
"to",
"=",
"orjson",
".",
"dumps",
"(",
"[",
"sender",
".",
"id",
"]",
")",
".",
"de... | [
10,
4
] | [
19,
63
] | python | en | ['en', 'error', 'th'] | False |
TypingValidateOperatorTest.test_invalid_parameter_pm | (self) |
Sending typing notification with invalid value for op parameter fails
|
Sending typing notification with invalid value for op parameter fails
| def test_invalid_parameter_pm(self) -> None:
"""
Sending typing notification with invalid value for op parameter fails
"""
sender = self.example_user("hamlet")
params = dict(
to=orjson.dumps([sender.id]).decode(),
op="foo",
)
result = self.... | [
"def",
"test_invalid_parameter_pm",
"(",
"self",
")",
"->",
"None",
":",
"sender",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"params",
"=",
"dict",
"(",
"to",
"=",
"orjson",
".",
"dumps",
"(",
"[",
"sender",
".",
"id",
"]",
")",
".",
... | [
21,
4
] | [
31,
52
] | python | en | ['en', 'error', 'th'] | False |
TypingValidateToArgumentsTest.test_empty_to_array_pms | (self) |
Sending pms typing notification without recipient fails
|
Sending pms typing notification without recipient fails
| def test_empty_to_array_pms(self) -> None:
"""
Sending pms typing notification without recipient fails
"""
sender = self.example_user("hamlet")
result = self.api_post(sender, "/api/v1/typing", {"op": "start", "to": "[]"})
self.assert_json_error(result, "Empty 'to' list") | [
"def",
"test_empty_to_array_pms",
"(",
"self",
")",
"->",
"None",
":",
"sender",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"result",
"=",
"self",
".",
"api_post",
"(",
"sender",
",",
"\"/api/v1/typing\"",
",",
"{",
"\"op\"",
":",
"\"start\"",... | [
55,
4
] | [
61,
57
] | python | en | ['en', 'error', 'th'] | False |
TypingValidateToArgumentsTest.test_empty_to_array_stream | (self) |
Sending stream typing notification without recipient fails
|
Sending stream typing notification without recipient fails
| def test_empty_to_array_stream(self) -> None:
"""
Sending stream typing notification without recipient fails
"""
sender = self.example_user("hamlet")
result = self.api_post(
sender, "/api/v1/typing", {"type": "stream", "op": "start", "to": "[]"}
)
self... | [
"def",
"test_empty_to_array_stream",
"(",
"self",
")",
"->",
"None",
":",
"sender",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"result",
"=",
"self",
".",
"api_post",
"(",
"sender",
",",
"\"/api/v1/typing\"",
",",
"{",
"\"type\"",
":",
"\"stre... | [
63,
4
] | [
71,
57
] | python | en | ['en', 'error', 'th'] | False |
TypingValidateToArgumentsTest.test_missing_recipient | (self) |
Sending typing notification without recipient fails
|
Sending typing notification without recipient fails
| def test_missing_recipient(self) -> None:
"""
Sending typing notification without recipient fails
"""
sender = self.example_user("hamlet")
result = self.api_post(sender, "/api/v1/typing", {"op": "start"})
self.assert_json_error(result, "Missing 'to' argument") | [
"def",
"test_missing_recipient",
"(",
"self",
")",
"->",
"None",
":",
"sender",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"result",
"=",
"self",
".",
"api_post",
"(",
"sender",
",",
"\"/api/v1/typing\"",
",",
"{",
"\"op\"",
":",
"\"start\"",
... | [
73,
4
] | [
79,
63
] | python | en | ['en', 'error', 'th'] | False |
TypingValidateToArgumentsTest.test_argument_to_is_not_valid_json | (self) |
Sending typing notification to invalid recipient fails
|
Sending typing notification to invalid recipient fails
| def test_argument_to_is_not_valid_json(self) -> None:
"""
Sending typing notification to invalid recipient fails
"""
sender = self.example_user("hamlet")
invalid = "bad email"
result = self.api_post(sender, "/api/v1/typing", {"op": "start", "to": invalid})
self.as... | [
"def",
"test_argument_to_is_not_valid_json",
"(",
"self",
")",
"->",
"None",
":",
"sender",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"invalid",
"=",
"\"bad email\"",
"result",
"=",
"self",
".",
"api_post",
"(",
"sender",
",",
"\"/api/v1/typing\"... | [
81,
4
] | [
88,
74
] | python | en | ['en', 'error', 'th'] | False |
TypingValidateToArgumentsTest.test_bogus_user_id | (self) |
Sending typing notification to invalid recipient fails
|
Sending typing notification to invalid recipient fails
| def test_bogus_user_id(self) -> None:
"""
Sending typing notification to invalid recipient fails
"""
sender = self.example_user("hamlet")
invalid = "[9999999]"
result = self.api_post(sender, "/api/v1/typing", {"op": "start", "to": invalid})
self.assert_json_error(... | [
"def",
"test_bogus_user_id",
"(",
"self",
")",
"->",
"None",
":",
"sender",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"invalid",
"=",
"\"[9999999]\"",
"result",
"=",
"self",
".",
"api_post",
"(",
"sender",
",",
"\"/api/v1/typing\"",
",",
"{",... | [
90,
4
] | [
97,
65
] | python | en | ['en', 'error', 'th'] | False |
TypingHappyPathTestPMs.test_start_to_self | (self) |
Sending typing notification to yourself (using user IDs)
is successful.
|
Sending typing notification to yourself (using user IDs)
is successful.
| def test_start_to_self(self) -> None:
"""
Sending typing notification to yourself (using user IDs)
is successful.
"""
user = self.example_user("hamlet")
email = user.email
expected_recipient_emails = {email}
expected_recipient_ids = {user.id}
event... | [
"def",
"test_start_to_self",
"(",
"self",
")",
"->",
"None",
":",
"user",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"email",
"=",
"user",
".",
"email",
"expected_recipient_emails",
"=",
"{",
"email",
"}",
"expected_recipient_ids",
"=",
"{",
"... | [
211,
4
] | [
243,
46
] | python | en | ['en', 'error', 'th'] | False |
TypingHappyPathTestPMs.test_start_to_another_user | (self) |
Sending typing notification to another user
is successful.
|
Sending typing notification to another user
is successful.
| def test_start_to_another_user(self) -> None:
"""
Sending typing notification to another user
is successful.
"""
sender = self.example_user("hamlet")
recipient = self.example_user("othello")
expected_recipients = {sender, recipient}
expected_recipient_emai... | [
"def",
"test_start_to_another_user",
"(",
"self",
")",
"->",
"None",
":",
"sender",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"recipient",
"=",
"self",
".",
"example_user",
"(",
"\"othello\"",
")",
"expected_recipients",
"=",
"{",
"sender",
","... | [
245,
4
] | [
278,
46
] | python | en | ['en', 'error', 'th'] | False |
TypingHappyPathTestPMs.test_stop_to_self | (self) |
Sending stopped typing notification to yourself
is successful.
|
Sending stopped typing notification to yourself
is successful.
| def test_stop_to_self(self) -> None:
"""
Sending stopped typing notification to yourself
is successful.
"""
user = self.example_user("hamlet")
email = user.email
expected_recipient_emails = {email}
expected_recipient_ids = {user.id}
events: List[M... | [
"def",
"test_stop_to_self",
"(",
"self",
")",
"->",
"None",
":",
"user",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"email",
"=",
"user",
".",
"email",
"expected_recipient_emails",
"=",
"{",
"email",
"}",
"expected_recipient_ids",
"=",
"{",
"u... | [
280,
4
] | [
311,
45
] | python | en | ['en', 'error', 'th'] | False |
TypingHappyPathTestPMs.test_stop_to_another_user | (self) |
Sending stopped typing notification to another user
is successful.
|
Sending stopped typing notification to another user
is successful.
| def test_stop_to_another_user(self) -> None:
"""
Sending stopped typing notification to another user
is successful.
"""
sender = self.example_user("hamlet")
recipient = self.example_user("othello")
expected_recipients = {sender, recipient}
expected_recipie... | [
"def",
"test_stop_to_another_user",
"(",
"self",
")",
"->",
"None",
":",
"sender",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"recipient",
"=",
"self",
".",
"example_user",
"(",
"\"othello\"",
")",
"expected_recipients",
"=",
"{",
"sender",
",",... | [
313,
4
] | [
345,
45
] | python | en | ['en', 'error', 'th'] | False |
SalesforceOAuth2Adapter.parse_token | (self, data) | Wrap OAuth2Base.parse_token to encrypt tokens for storage.
Called from OAuth2CallbackView | Wrap OAuth2Base.parse_token to encrypt tokens for storage. | def parse_token(self, data):
"""Wrap OAuth2Base.parse_token to encrypt tokens for storage.
Called from OAuth2CallbackView"""
data["access_token"] = fernet_encrypt(data["access_token"])
data["refresh_token"] = fernet_encrypt(data["refresh_token"])
return super().parse_token(data) | [
"def",
"parse_token",
"(",
"self",
",",
"data",
")",
":",
"data",
"[",
"\"access_token\"",
"]",
"=",
"fernet_encrypt",
"(",
"data",
"[",
"\"access_token\"",
"]",
")",
"data",
"[",
"\"refresh_token\"",
"]",
"=",
"fernet_encrypt",
"(",
"data",
"[",
"\"refresh_... | [
96,
4
] | [
102,
40
] | python | en | ['en', 'el-Latn', 'en'] | True |
TestMissedMessages.test_multiple_stream_messages_and_mentions | (self) | Subject should be stream name and topic as usual. | Subject should be stream name and topic as usual. | def test_multiple_stream_messages_and_mentions(self) -> None:
"""Subject should be stream name and topic as usual."""
hamlet = self.example_user("hamlet")
msg_id_1 = self.send_stream_message(self.example_user("iago"), "Denmark", "Regular message")
msg_id_2 = self.send_stream_message(
... | [
"def",
"test_multiple_stream_messages_and_mentions",
"(",
"self",
")",
"->",
"None",
":",
"hamlet",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"msg_id_1",
"=",
"self",
".",
"send_stream_message",
"(",
"self",
".",
"example_user",
"(",
"\"iago\"",
... | [
980,
4
] | [
997,
63
] | python | en | ['en', 'en', 'en'] | True |
TestMissedMessages.test_stream_mentions_multiple_people | (self) | Subject should be stream name and topic as usual. | Subject should be stream name and topic as usual. | def test_stream_mentions_multiple_people(self) -> None:
"""Subject should be stream name and topic as usual."""
hamlet = self.example_user("hamlet")
msg_id_1 = self.send_stream_message(
self.example_user("iago"), "Denmark", "@**King Hamlet**"
)
msg_id_2 = self.send_st... | [
"def",
"test_stream_mentions_multiple_people",
"(",
"self",
")",
"->",
"None",
":",
"hamlet",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"msg_id_1",
"=",
"self",
".",
"send_stream_message",
"(",
"self",
".",
"example_user",
"(",
"\"iago\"",
")",
... | [
1030,
4
] | [
1053,
63
] | python | en | ['en', 'en', 'en'] | True |
TestMissedMessages.test_multiple_stream_messages_different_topics | (self) | Should receive separate emails for each topic within a stream. | Should receive separate emails for each topic within a stream. | def test_multiple_stream_messages_different_topics(self) -> None:
"""Should receive separate emails for each topic within a stream."""
hamlet = self.example_user("hamlet")
msg_id_1 = self.send_stream_message(self.example_user("othello"), "Denmark", "Message1")
msg_id_2 = self.send_stream... | [
"def",
"test_multiple_stream_messages_different_topics",
"(",
"self",
")",
"->",
"None",
":",
"hamlet",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"msg_id_1",
"=",
"self",
".",
"send_stream_message",
"(",
"self",
".",
"example_user",
"(",
"\"othello... | [
1055,
4
] | [
1073,
62
] | python | en | ['en', 'en', 'en'] | True |
test_makedir_for_resultlog | (testdir, LineMatcher) | --resultlog should automatically create directories for the log file | --resultlog should automatically create directories for the log file | def test_makedir_for_resultlog(testdir, LineMatcher):
"""--resultlog should automatically create directories for the log file"""
testdir.plugins.append("resultlog")
testdir.makepyfile("""
import pytest
def test_pass():
pass
""")
testdir.runpytest("--resultlog=path/to/resu... | [
"def",
"test_makedir_for_resultlog",
"(",
"testdir",
",",
"LineMatcher",
")",
":",
"testdir",
".",
"plugins",
".",
"append",
"(",
"\"resultlog\"",
")",
"testdir",
".",
"makepyfile",
"(",
"\"\"\"\n import pytest\n def test_pass():\n pass\n \"\"\"",
... | [
180,
0
] | [
192,
6
] | python | en | ['en', 'en', 'en'] | True |
test_tmpdir_fallback_tox_env | (testdir, monkeypatch) | Test that tmpdir works even if environment variables required by getpass
module are missing (#1010).
| Test that tmpdir works even if environment variables required by getpass
module are missing (#1010).
| def test_tmpdir_fallback_tox_env(testdir, monkeypatch):
"""Test that tmpdir works even if environment variables required by getpass
module are missing (#1010).
"""
monkeypatch.delenv('USER', raising=False)
monkeypatch.delenv('USERNAME', raising=False)
testdir.makepyfile("""
import pytest... | [
"def",
"test_tmpdir_fallback_tox_env",
"(",
"testdir",
",",
"monkeypatch",
")",
":",
"monkeypatch",
".",
"delenv",
"(",
"'USER'",
",",
"raising",
"=",
"False",
")",
"monkeypatch",
".",
"delenv",
"(",
"'USERNAME'",
",",
"raising",
"=",
"False",
")",
"testdir",
... | [
128,
0
] | [
140,
34
] | python | en | ['en', 'en', 'en'] | True |
test_tmpdir_fallback_uid_not_found | (testdir) | Test that tmpdir works even if the current process's user id does not
correspond to a valid user.
| Test that tmpdir works even if the current process's user id does not
correspond to a valid user.
| def test_tmpdir_fallback_uid_not_found(testdir):
"""Test that tmpdir works even if the current process's user id does not
correspond to a valid user.
"""
testdir.makepyfile("""
import pytest
def test_some(tmpdir):
assert tmpdir.isdir()
""")
reprec = testdir.inline_ru... | [
"def",
"test_tmpdir_fallback_uid_not_found",
"(",
"testdir",
")",
":",
"testdir",
".",
"makepyfile",
"(",
"\"\"\"\n import pytest\n def test_some(tmpdir):\n assert tmpdir.isdir()\n \"\"\"",
")",
"reprec",
"=",
"testdir",
".",
"inline_run",
"(",
")",
... | [
153,
0
] | [
164,
34
] | python | en | ['en', 'en', 'en'] | True |
test_get_user_uid_not_found | () | Test that get_user() function works even if the current process's
user id does not correspond to a valid user (e.g. running pytest in a
Docker container with 'docker run -u'.
| Test that get_user() function works even if the current process's
user id does not correspond to a valid user (e.g. running pytest in a
Docker container with 'docker run -u'.
| def test_get_user_uid_not_found():
"""Test that get_user() function works even if the current process's
user id does not correspond to a valid user (e.g. running pytest in a
Docker container with 'docker run -u'.
"""
from _pytest.tmpdir import get_user
assert get_user() is None | [
"def",
"test_get_user_uid_not_found",
"(",
")",
":",
"from",
"_pytest",
".",
"tmpdir",
"import",
"get_user",
"assert",
"get_user",
"(",
")",
"is",
"None"
] | [
169,
0
] | [
175,
29
] | python | en | ['en', 'en', 'en'] | True |
test_get_user | (monkeypatch) | Test that get_user() function works even if environment variables
required by getpass module are missing from the environment on Windows
(#1010).
| Test that get_user() function works even if environment variables
required by getpass module are missing from the environment on Windows
(#1010).
| def test_get_user(monkeypatch):
"""Test that get_user() function works even if environment variables
required by getpass module are missing from the environment on Windows
(#1010).
"""
from _pytest.tmpdir import get_user
monkeypatch.delenv('USER', raising=False)
monkeypatch.delenv('USERNAME'... | [
"def",
"test_get_user",
"(",
"monkeypatch",
")",
":",
"from",
"_pytest",
".",
"tmpdir",
"import",
"get_user",
"monkeypatch",
".",
"delenv",
"(",
"'USER'",
",",
"raising",
"=",
"False",
")",
"monkeypatch",
".",
"delenv",
"(",
"'USERNAME'",
",",
"raising",
"="... | [
179,
0
] | [
187,
29
] | python | en | ['en', 'en', 'en'] | True |
S_IMODE | (mode) | Return the portion of the file's mode that can be set by
os.chmod().
| Return the portion of the file's mode that can be set by
os.chmod().
| def S_IMODE(mode):
"""Return the portion of the file's mode that can be set by
os.chmod().
"""
return mode & 0o7777 | [
"def",
"S_IMODE",
"(",
"mode",
")",
":",
"return",
"mode",
"&",
"0o7777"
] | [
20,
0
] | [
24,
24
] | python | en | ['en', 'en', 'en'] | True |
S_IFMT | (mode) | Return the portion of the file's mode that describes the
file type.
| Return the portion of the file's mode that describes the
file type.
| def S_IFMT(mode):
"""Return the portion of the file's mode that describes the
file type.
"""
return mode & 0o170000 | [
"def",
"S_IFMT",
"(",
"mode",
")",
":",
"return",
"mode",
"&",
"0o170000"
] | [
26,
0
] | [
30,
26
] | python | en | ['en', 'en', 'en'] | True |
S_ISDIR | (mode) | Return True if mode is from a directory. | Return True if mode is from a directory. | def S_ISDIR(mode):
"""Return True if mode is from a directory."""
return S_IFMT(mode) == S_IFDIR | [
"def",
"S_ISDIR",
"(",
"mode",
")",
":",
"return",
"S_IFMT",
"(",
"mode",
")",
"==",
"S_IFDIR"
] | [
45,
0
] | [
47,
34
] | python | en | ['en', 'en', 'en'] | True |
S_ISCHR | (mode) | Return True if mode is from a character special device file. | Return True if mode is from a character special device file. | def S_ISCHR(mode):
"""Return True if mode is from a character special device file."""
return S_IFMT(mode) == S_IFCHR | [
"def",
"S_ISCHR",
"(",
"mode",
")",
":",
"return",
"S_IFMT",
"(",
"mode",
")",
"==",
"S_IFCHR"
] | [
49,
0
] | [
51,
34
] | python | en | ['en', 'en', 'en'] | True |
S_ISBLK | (mode) | Return True if mode is from a block special device file. | Return True if mode is from a block special device file. | def S_ISBLK(mode):
"""Return True if mode is from a block special device file."""
return S_IFMT(mode) == S_IFBLK | [
"def",
"S_ISBLK",
"(",
"mode",
")",
":",
"return",
"S_IFMT",
"(",
"mode",
")",
"==",
"S_IFBLK"
] | [
53,
0
] | [
55,
34
] | python | en | ['en', 'en', 'en'] | True |
S_ISREG | (mode) | Return True if mode is from a regular file. | Return True if mode is from a regular file. | def S_ISREG(mode):
"""Return True if mode is from a regular file."""
return S_IFMT(mode) == S_IFREG | [
"def",
"S_ISREG",
"(",
"mode",
")",
":",
"return",
"S_IFMT",
"(",
"mode",
")",
"==",
"S_IFREG"
] | [
57,
0
] | [
59,
34
] | python | en | ['en', 'en', 'en'] | True |
S_ISFIFO | (mode) | Return True if mode is from a FIFO (named pipe). | Return True if mode is from a FIFO (named pipe). | def S_ISFIFO(mode):
"""Return True if mode is from a FIFO (named pipe)."""
return S_IFMT(mode) == S_IFIFO | [
"def",
"S_ISFIFO",
"(",
"mode",
")",
":",
"return",
"S_IFMT",
"(",
"mode",
")",
"==",
"S_IFIFO"
] | [
61,
0
] | [
63,
34
] | python | en | ['en', 'en', 'en'] | True |
S_ISLNK | (mode) | Return True if mode is from a symbolic link. | Return True if mode is from a symbolic link. | def S_ISLNK(mode):
"""Return True if mode is from a symbolic link."""
return S_IFMT(mode) == S_IFLNK | [
"def",
"S_ISLNK",
"(",
"mode",
")",
":",
"return",
"S_IFMT",
"(",
"mode",
")",
"==",
"S_IFLNK"
] | [
65,
0
] | [
67,
34
] | python | en | ['en', 'en', 'en'] | True |
S_ISSOCK | (mode) | Return True if mode is from a socket. | Return True if mode is from a socket. | def S_ISSOCK(mode):
"""Return True if mode is from a socket."""
return S_IFMT(mode) == S_IFSOCK | [
"def",
"S_ISSOCK",
"(",
"mode",
")",
":",
"return",
"S_IFMT",
"(",
"mode",
")",
"==",
"S_IFSOCK"
] | [
69,
0
] | [
71,
35
] | python | en | ['en', 'fy', 'en'] | True |
filemode | (mode) | Convert a file's mode to a string of the form '-rwxrwxrwx'. | Convert a file's mode to a string of the form '-rwxrwxrwx'. | def filemode(mode):
"""Convert a file's mode to a string of the form '-rwxrwxrwx'."""
perm = []
for table in _filemode_table:
for bit, char in table:
if mode & bit == bit:
perm.append(char)
break
else:
perm.append("-")
return "".joi... | [
"def",
"filemode",
"(",
"mode",
")",
":",
"perm",
"=",
"[",
"]",
"for",
"table",
"in",
"_filemode_table",
":",
"for",
"bit",
",",
"char",
"in",
"table",
":",
"if",
"mode",
"&",
"bit",
"==",
"bit",
":",
"perm",
".",
"append",
"(",
"char",
")",
"br... | [
138,
0
] | [
148,
24
] | python | en | ['en', 'en', 'en'] | True |
post_auth | () | サインアップ・サインイン | サインアップ・サインイン | def post_auth():
"""サインアップ・サインイン"""
req_authorization_header = request.headers.get("Authorization")
if req_authorization_header is None:
raise Forbidden("forbidden")
try:
req_jwt = req_authorization_header.removeprefix("Bearer ")
req_jwt_header = jwt.get_unverified_header(req_jw... | [
"def",
"post_auth",
"(",
")",
":",
"req_authorization_header",
"=",
"request",
".",
"headers",
".",
"get",
"(",
"\"Authorization\"",
")",
"if",
"req_authorization_header",
"is",
"None",
":",
"raise",
"Forbidden",
"(",
"\"forbidden\"",
")",
"try",
":",
"req_jwt",... | [
246,
0
] | [
274,
13
] | python | ja | ['ja', 'ja', 'ja'] | False |
get_me | () | サインインしている自分自身の情報を取得 | サインインしている自分自身の情報を取得 | def get_me():
"""サインインしている自分自身の情報を取得"""
jia_user_id = get_user_id_from_session()
return {"jia_user_id": jia_user_id} | [
"def",
"get_me",
"(",
")",
":",
"jia_user_id",
"=",
"get_user_id_from_session",
"(",
")",
"return",
"{",
"\"jia_user_id\"",
":",
"jia_user_id",
"}"
] | [
286,
0
] | [
289,
39
] | python | ja | ['ja', 'ja', 'ja'] | False |
get_isu_icon | (jia_isu_uuid) | ISUのアイコンを取得 | ISUのアイコンを取得 | def get_isu_icon(jia_isu_uuid):
"""ISUのアイコンを取得"""
jia_user_id = get_user_id_from_session()
query = "SELECT `image` FROM `isu` WHERE `jia_user_id` = %s AND `jia_isu_uuid` = %s"
res = select_row(query, (jia_user_id, jia_isu_uuid))
if res is None:
raise NotFound("not found: isu")
return m... | [
"def",
"get_isu_icon",
"(",
"jia_isu_uuid",
")",
":",
"jia_user_id",
"=",
"get_user_id_from_session",
"(",
")",
"query",
"=",
"\"SELECT `image` FROM `isu` WHERE `jia_user_id` = %s AND `jia_isu_uuid` = %s\"",
"res",
"=",
"select_row",
"(",
"query",
",",
"(",
"jia_user_id",
... | [
421,
0
] | [
430,
75
] | python | ja | ['ja', 'xh', 'ja'] | False |
get_isu_graph | (jia_isu_uuid) | ISUのコンディショングラフ描画のための情報を取得 | ISUのコンディショングラフ描画のための情報を取得 | def get_isu_graph(jia_isu_uuid):
"""ISUのコンディショングラフ描画のための情報を取得"""
jia_user_id = get_user_id_from_session()
dt = request.args.get("datetime")
if dt is None:
raise BadRequest("missing: datetime")
try:
dt = datetime.fromtimestamp(int(dt), tz=TZ)
except:
raise BadRequest("bad... | [
"def",
"get_isu_graph",
"(",
"jia_isu_uuid",
")",
":",
"jia_user_id",
"=",
"get_user_id_from_session",
"(",
")",
"dt",
"=",
"request",
".",
"args",
".",
"get",
"(",
"\"datetime\"",
")",
"if",
"dt",
"is",
"None",
":",
"raise",
"BadRequest",
"(",
"\"missing: d... | [
434,
0
] | [
453,
23
] | python | ja | ['ja', 'ja', 'ja'] | False |
truncate_datetime | (dt: datetime, duration: timedelta) | datetime 値の指定した粒度で切り捨てる | datetime 値の指定した粒度で切り捨てる | def truncate_datetime(dt: datetime, duration: timedelta) -> datetime:
"""datetime 値の指定した粒度で切り捨てる"""
if duration == timedelta(hours=1):
return datetime(dt.year, dt.month, dt.day, dt.hour, tzinfo=dt.tzinfo)
raise Exception("unsupported duration") | [
"def",
"truncate_datetime",
"(",
"dt",
":",
"datetime",
",",
"duration",
":",
"timedelta",
")",
"->",
"datetime",
":",
"if",
"duration",
"==",
"timedelta",
"(",
"hours",
"=",
"1",
")",
":",
"return",
"datetime",
"(",
"dt",
".",
"year",
",",
"dt",
".",
... | [
456,
0
] | [
460,
43
] | python | ja | ['ja', 'ja', 'ja'] | False |
generate_isu_graph_response | (jia_isu_uuid: str, graph_date: datetime) | グラフのデータ点を一日分生成 | グラフのデータ点を一日分生成 | def generate_isu_graph_response(jia_isu_uuid: str, graph_date: datetime) -> list[GraphResponse]:
"""グラフのデータ点を一日分生成"""
data_points = []
conditions_in_this_hour = []
timestamps_in_this_hour = []
start_time_in_this_hour = None
query = "SELECT * FROM `isu_condition` WHERE `jia_isu_uuid` = %s ORDER ... | [
"def",
"generate_isu_graph_response",
"(",
"jia_isu_uuid",
":",
"str",
",",
"graph_date",
":",
"datetime",
")",
"->",
"list",
"[",
"GraphResponse",
"]",
":",
"data_points",
"=",
"[",
"]",
"conditions_in_this_hour",
"=",
"[",
"]",
"timestamps_in_this_hour",
"=",
... | [
463,
0
] | [
541,
24
] | python | ja | ['ja', 'ja', 'ja'] | False |
calculate_graph_data_point | (isu_conditions: list[IsuCondition]) | 複数のISUのコンディションからグラフの一つのデータ点を計算 | 複数のISUのコンディションからグラフの一つのデータ点を計算 | def calculate_graph_data_point(isu_conditions: list[IsuCondition]) -> GraphDataPoint:
"""複数のISUのコンディションからグラフの一つのデータ点を計算"""
conditions_count = {"is_broken": 0, "is_dirty": 0, "is_overweight": 0}
raw_score = 0
for condition in isu_conditions:
bad_conditions_count = 0
if not is_valid_condi... | [
"def",
"calculate_graph_data_point",
"(",
"isu_conditions",
":",
"list",
"[",
"IsuCondition",
"]",
")",
"->",
"GraphDataPoint",
":",
"conditions_count",
"=",
"{",
"\"is_broken\"",
":",
"0",
",",
"\"is_dirty\"",
":",
"0",
",",
"\"is_overweight\"",
":",
"0",
"}",
... | [
544,
0
] | [
584,
5
] | python | ja | ['ja', 'ja', 'ja'] | False |
get_isu_confitions | (jia_isu_uuid) | ISUのコンディションを取得 | ISUのコンディションを取得 | def get_isu_confitions(jia_isu_uuid):
"""ISUのコンディションを取得"""
jia_user_id = get_user_id_from_session()
try:
end_time = datetime.fromtimestamp(int(request.args.get("end_time")), tz=TZ)
except:
raise BadRequest("bad format: end_time")
condition_level_csv = request.args.get("condition_le... | [
"def",
"get_isu_confitions",
"(",
"jia_isu_uuid",
")",
":",
"jia_user_id",
"=",
"get_user_id_from_session",
"(",
")",
"try",
":",
"end_time",
"=",
"datetime",
".",
"fromtimestamp",
"(",
"int",
"(",
"request",
".",
"args",
".",
"get",
"(",
"\"end_time\"",
")",
... | [
588,
0
] | [
625,
38
] | python | ja | ['ja', 'ja', 'ja'] | False |
get_isu_conditions_from_db | (
jia_isu_uuid: str,
end_time: datetime,
condition_level: set,
start_time: datetime,
limit: int,
isu_name: str,
) | ISUのコンディションをDBから取得 | ISUのコンディションをDBから取得 | def get_isu_conditions_from_db(
jia_isu_uuid: str,
end_time: datetime,
condition_level: set,
start_time: datetime,
limit: int,
isu_name: str,
) -> list[GetIsuConditionResponse]:
"""ISUのコンディションをDBから取得"""
if start_time is None:
query = """
SELECT *
FROM `isu... | [
"def",
"get_isu_conditions_from_db",
"(",
"jia_isu_uuid",
":",
"str",
",",
"end_time",
":",
"datetime",
",",
"condition_level",
":",
"set",
",",
"start_time",
":",
"datetime",
",",
"limit",
":",
"int",
",",
"isu_name",
":",
"str",
",",
")",
"->",
"list",
"... | [
628,
0
] | [
677,
29
] | python | ja | ['ja', 'ja', 'ja'] | False |
get_trend | () | ISUの性格毎の最新のコンディション情報 | ISUの性格毎の最新のコンディション情報 | def get_trend():
"""ISUの性格毎の最新のコンディション情報"""
query = "SELECT `character` FROM `isu` GROUP BY `character`"
character_list = [row["character"] for row in select_all(query)]
res = []
for character in character_list:
query = "SELECT * FROM `isu` WHERE `character` = %s"
isu_list = [Isu(*... | [
"def",
"get_trend",
"(",
")",
":",
"query",
"=",
"\"SELECT `character` FROM `isu` GROUP BY `character`\"",
"character_list",
"=",
"[",
"row",
"[",
"\"character\"",
"]",
"for",
"row",
"in",
"select_all",
"(",
"query",
")",
"]",
"res",
"=",
"[",
"]",
"for",
"cha... | [
681,
0
] | [
725,
23
] | python | ja | ['ja', 'bg', 'ja'] | False |
post_isu_condition | (jia_isu_uuid) | ISUからのコンディションを受け取る | ISUからのコンディションを受け取る | def post_isu_condition(jia_isu_uuid):
"""ISUからのコンディションを受け取る"""
# TODO: 一定割合リクエストを落としてしのぐようにしたが、本来は全量さばけるようにすべき
drop_probability = 0.9
if random() <= drop_probability:
app.logger.warning("drop post isu condition request")
return "", 202
try:
req = [PostIsuConditionRequest(**ro... | [
"def",
"post_isu_condition",
"(",
"jia_isu_uuid",
")",
":",
"# TODO: 一定割合リクエストを落としてしのぐようにしたが、本来は全量さばけるようにすべき",
"drop_probability",
"=",
"0.9",
"if",
"random",
"(",
")",
"<=",
"drop_probability",
":",
"app",
".",
"logger",
".",
"warning",
"(",
"\"drop post isu condition ... | [
729,
0
] | [
779,
18
] | python | ja | ['ja', 'ja', 'ja'] | False |
calculate_condition_level | (condition: str) | ISUのコンディションの文字列からコンディションレベルを計算 | ISUのコンディションの文字列からコンディションレベルを計算 | def calculate_condition_level(condition: str) -> CONDITION_LEVEL:
"""ISUのコンディションの文字列からコンディションレベルを計算"""
warn_count = condition.count("=true")
if warn_count == 0:
condition_level = CONDITION_LEVEL.INFO
elif warn_count in (1, 2):
condition_level = CONDITION_LEVEL.WARNING
elif warn_coun... | [
"def",
"calculate_condition_level",
"(",
"condition",
":",
"str",
")",
"->",
"CONDITION_LEVEL",
":",
"warn_count",
"=",
"condition",
".",
"count",
"(",
"\"=true\"",
")",
"if",
"warn_count",
"==",
"0",
":",
"condition_level",
"=",
"CONDITION_LEVEL",
".",
"INFO",
... | [
793,
0
] | [
806,
26
] | python | ja | ['ja', 'ja', 'ja'] | False |
is_valid_condition_format | (condition_str: str) | ISUのコンディションの文字列がcsv形式になっているか検証 | ISUのコンディションの文字列がcsv形式になっているか検証 | def is_valid_condition_format(condition_str: str) -> bool:
"""ISUのコンディションの文字列がcsv形式になっているか検証"""
keys = ["is_dirty=", "is_overweight=", "is_broken="]
value_true = "true"
value_false = "false"
idx_cond_str = 0
for idx_keys, key in enumerate(keys):
if not condition_str[idx_cond_str:].start... | [
"def",
"is_valid_condition_format",
"(",
"condition_str",
":",
"str",
")",
"->",
"bool",
":",
"keys",
"=",
"[",
"\"is_dirty=\"",
",",
"\"is_overweight=\"",
",",
"\"is_broken=\"",
"]",
"value_true",
"=",
"\"true\"",
"value_false",
"=",
"\"false\"",
"idx_cond_str",
... | [
809,
0
] | [
833,
45
] | python | ja | ['ja', 'ja', 'ja'] | False |
_InstallRequirementBackedCandidate.name | (self) | The normalised name of the project the candidate refers to | The normalised name of the project the candidate refers to | def name(self):
# type: () -> str
"""The normalised name of the project the candidate refers to"""
if self._name is None:
self._name = canonicalize_name(self.dist.project_name)
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"# type: () -> str",
"if",
"self",
".",
"_name",
"is",
"None",
":",
"self",
".",
"_name",
"=",
"canonicalize_name",
"(",
"self",
".",
"dist",
".",
"project_name",
")",
"return",
"self",
".",
"_name"
] | [
180,
4
] | [
185,
25
] | python | en | ['en', 'en', 'en'] | True |
_InstallRequirementBackedCandidate._check_metadata_consistency | (self) | Check for consistency of project name and version of dist. | Check for consistency of project name and version of dist. | def _check_metadata_consistency(self):
# type: () -> None
"""Check for consistency of project name and version of dist."""
# TODO: (Longer term) Rather than abort, reject this candidate
# and backtrack. This would need resolvelib support.
dist = self._dist # type: Distribu... | [
"def",
"_check_metadata_consistency",
"(",
"self",
")",
":",
"# type: () -> None",
"# TODO: (Longer term) Rather than abort, reject this candidate",
"# and backtrack. This would need resolvelib support.",
"dist",
"=",
"self",
".",
"_dist",
"# type: Distribution",
"name",
"=",
... | [
206,
4
] | [
217,
75
] | python | en | ['en', 'en', 'en'] | True |
_InstallRequirementBackedCandidate._fetch_metadata | (self) | Fetch metadata, using lazy wheel if possible. | Fetch metadata, using lazy wheel if possible. | def _fetch_metadata(self):
# type: () -> None
"""Fetch metadata, using lazy wheel if possible."""
preparer = self._factory.preparer
use_lazy_wheel = self._factory.use_lazy_wheel
remote_wheel = self._link.is_wheel and not self._link.is_file
if use_lazy_wheel and remote_whe... | [
"def",
"_fetch_metadata",
"(",
"self",
")",
":",
"# type: () -> None",
"preparer",
"=",
"self",
".",
"_factory",
".",
"preparer",
"use_lazy_wheel",
"=",
"self",
".",
"_factory",
".",
"use_lazy_wheel",
"remote_wheel",
"=",
"self",
".",
"_link",
".",
"is_wheel",
... | [
234,
4
] | [
254,
27
] | python | en | ['en', 'en', 'en'] | True |
ExtrasCandidate.name | (self) | The normalised name of the project the candidate refers to | The normalised name of the project the candidate refers to | def name(self):
# type: () -> str
"""The normalised name of the project the candidate refers to"""
return format_name(self.base.name, self.extras) | [
"def",
"name",
"(",
"self",
")",
":",
"# type: () -> str",
"return",
"format_name",
"(",
"self",
".",
"base",
".",
"name",
",",
"self",
".",
"extras",
")"
] | [
493,
4
] | [
496,
55
] | python | en | ['en', 'en', 'en'] | True |
_unique_everseen | (iterable, key=None) | List unique elements, preserving order. Remember all elements ever seen. | List unique elements, preserving order. Remember all elements ever seen. | def _unique_everseen(iterable, key=None):
"List unique elements, preserving order. Remember all elements ever seen."
# unique_everseen('AAAABBBCCDAABBB') --> A B C D
# unique_everseen('ABBCcAD', str.lower) --> A B C D
seen = set()
seen_add = seen.add
if key is None:
for element in iterto... | [
"def",
"_unique_everseen",
"(",
"iterable",
",",
"key",
"=",
"None",
")",
":",
"# unique_everseen('AAAABBBCCDAABBB') --> A B C D",
"# unique_everseen('ABBCcAD', str.lower) --> A B C D",
"seen",
"=",
"set",
"(",
")",
"seen_add",
"=",
"seen",
".",
"add",
"if",
"key",
"i... | [
238,
0
] | [
253,
29
] | python | ca | ['ca', 'ca', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.