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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
wrap_session | (config, doit) | Skeleton command line program | Skeleton command line program | def wrap_session(config, doit):
"""Skeleton command line program"""
session = Session(config)
session.exitstatus = EXIT_OK
initstate = 0
try:
try:
config._do_configure()
initstate = 1
config.hook.pytest_sessionstart(session=session)
initstate =... | [
"def",
"wrap_session",
"(",
"config",
",",
"doit",
")",
":",
"session",
"=",
"Session",
"(",
"config",
")",
"session",
".",
"exitstatus",
"=",
"EXIT_OK",
"initstate",
"=",
"0",
"try",
":",
"try",
":",
"config",
".",
"_do_configure",
"(",
")",
"initstate"... | [
88,
0
] | [
126,
29
] | python | en | ['en', 'no', 'en'] | True |
_main | (config, session) | default command line protocol for initialization, session,
running tests and reporting. | default command line protocol for initialization, session,
running tests and reporting. | def _main(config, session):
""" default command line protocol for initialization, session,
running tests and reporting. """
config.hook.pytest_collection(session=session)
config.hook.pytest_runtestloop(session=session)
if session.testsfailed:
return EXIT_TESTSFAILED
elif session.testsco... | [
"def",
"_main",
"(",
"config",
",",
"session",
")",
":",
"config",
".",
"hook",
".",
"pytest_collection",
"(",
"session",
"=",
"session",
")",
"config",
".",
"hook",
".",
"pytest_runtestloop",
"(",
"session",
"=",
"session",
")",
"if",
"session",
".",
"t... | [
133,
0
] | [
142,
36
] | python | en | ['en', 'en', 'en'] | True |
_in_venv | (path) | Attempts to detect if ``path`` is the root of a Virtual Environment by
checking for the existence of the appropriate activate script | Attempts to detect if ``path`` is the root of a Virtual Environment by
checking for the existence of the appropriate activate script | def _in_venv(path):
"""Attempts to detect if ``path`` is the root of a Virtual Environment by
checking for the existence of the appropriate activate script"""
bindir = path.join('Scripts' if sys.platform.startswith('win') else 'bin')
if not bindir.isdir():
return False
activates = ('activate... | [
"def",
"_in_venv",
"(",
"path",
")",
":",
"bindir",
"=",
"path",
".",
"join",
"(",
"'Scripts'",
"if",
"sys",
".",
"platform",
".",
"startswith",
"(",
"'win'",
")",
"else",
"'bin'",
")",
"if",
"not",
"bindir",
".",
"isdir",
"(",
")",
":",
"return",
... | [
168,
0
] | [
176,
75
] | python | en | ['en', 'en', 'en'] | True |
_patched_find_module | () | Patch bug in pkgutil.ImpImporter.find_module
When using pkgutil.find_loader on python<3.4 it removes symlinks
from the path due to a call to os.path.realpath. This is not consistent
with actually doing the import (in these versions, pkgutil and __import__
did not share the same underlying code). This c... | Patch bug in pkgutil.ImpImporter.find_module | def _patched_find_module():
"""Patch bug in pkgutil.ImpImporter.find_module
When using pkgutil.find_loader on python<3.4 it removes symlinks
from the path due to a call to os.path.realpath. This is not consistent
with actually doing the import (in these versions, pkgutil and __import__
did not shar... | [
"def",
"_patched_find_module",
"(",
")",
":",
"if",
"six",
".",
"PY2",
":",
"# python 3.4+ uses importlib instead",
"def",
"find_module_patched",
"(",
"self",
",",
"fullname",
",",
"path",
"=",
"None",
")",
":",
"# Note: we ignore 'path' argument since it is only used v... | [
206,
0
] | [
242,
13
] | python | de | ['de', 'ro', 'nl'] | False |
Session._tryconvertpyarg | (self, x) | Convert a dotted module name to path.
| Convert a dotted module name to path. | def _tryconvertpyarg(self, x):
"""Convert a dotted module name to path.
"""
try:
with _patched_find_module():
loader = pkgutil.find_loader(x)
except ImportError:
return x
if loader is None:
return x
# This method is so... | [
"def",
"_tryconvertpyarg",
"(",
"self",
",",
"x",
")",
":",
"try",
":",
"with",
"_patched_find_module",
"(",
")",
":",
"loader",
"=",
"pkgutil",
".",
"find_loader",
"(",
"x",
")",
"except",
"ImportError",
":",
"return",
"x",
"if",
"loader",
"is",
"None",... | [
414,
4
] | [
436,
19
] | python | en | ['en', 'en', 'en'] | True |
Session._parsearg | (self, arg) | return (fspath, names) tuple after checking the file exists. | return (fspath, names) tuple after checking the file exists. | def _parsearg(self, arg):
""" return (fspath, names) tuple after checking the file exists. """
parts = str(arg).split("::")
if self.config.option.pyargs:
parts[0] = self._tryconvertpyarg(parts[0])
relpath = parts[0].replace("/", os.sep)
path = self.config.invocation_d... | [
"def",
"_parsearg",
"(",
"self",
",",
"arg",
")",
":",
"parts",
"=",
"str",
"(",
"arg",
")",
".",
"split",
"(",
"\"::\"",
")",
"if",
"self",
".",
"config",
".",
"option",
".",
"pyargs",
":",
"parts",
"[",
"0",
"]",
"=",
"self",
".",
"_tryconvertp... | [
438,
4
] | [
453,
20
] | python | en | ['en', 'en', 'en'] | True |
test_exit_on_collection_error | (testdir) | Verify that all collection errors are collected and no tests executed | Verify that all collection errors are collected and no tests executed | def test_exit_on_collection_error(testdir):
"""Verify that all collection errors are collected and no tests executed"""
testdir.makepyfile(**COLLECTION_ERROR_PY_FILES)
res = testdir.runpytest()
assert res.ret == 2
res.stdout.fnmatch_lines([
"collected 2 items / 2 errors",
"*ERROR c... | [
"def",
"test_exit_on_collection_error",
"(",
"testdir",
")",
":",
"testdir",
".",
"makepyfile",
"(",
"*",
"*",
"COLLECTION_ERROR_PY_FILES",
")",
"res",
"=",
"testdir",
".",
"runpytest",
"(",
")",
"assert",
"res",
".",
"ret",
"==",
"2",
"res",
".",
"stdout",
... | [
747,
0
] | [
760,
6
] | python | en | ['en', 'en', 'en'] | True |
test_exit_on_collection_with_maxfail_smaller_than_n_errors | (testdir) |
Verify collection is aborted once maxfail errors are encountered ignoring
further modules which would cause more collection errors.
|
Verify collection is aborted once maxfail errors are encountered ignoring
further modules which would cause more collection errors.
| def test_exit_on_collection_with_maxfail_smaller_than_n_errors(testdir):
"""
Verify collection is aborted once maxfail errors are encountered ignoring
further modules which would cause more collection errors.
"""
testdir.makepyfile(**COLLECTION_ERROR_PY_FILES)
res = testdir.runpytest("--maxfail... | [
"def",
"test_exit_on_collection_with_maxfail_smaller_than_n_errors",
"(",
"testdir",
")",
":",
"testdir",
".",
"makepyfile",
"(",
"*",
"*",
"COLLECTION_ERROR_PY_FILES",
")",
"res",
"=",
"testdir",
".",
"runpytest",
"(",
"\"--maxfail=1\"",
")",
"assert",
"res",
".",
... | [
763,
0
] | [
778,
44
] | python | en | ['en', 'error', 'th'] | False |
test_exit_on_collection_with_maxfail_bigger_than_n_errors | (testdir) |
Verify the test run aborts due to collection errors even if maxfail count of
errors was not reached.
|
Verify the test run aborts due to collection errors even if maxfail count of
errors was not reached.
| def test_exit_on_collection_with_maxfail_bigger_than_n_errors(testdir):
"""
Verify the test run aborts due to collection errors even if maxfail count of
errors was not reached.
"""
testdir.makepyfile(**COLLECTION_ERROR_PY_FILES)
res = testdir.runpytest("--maxfail=4")
assert res.ret == 2
... | [
"def",
"test_exit_on_collection_with_maxfail_bigger_than_n_errors",
"(",
"testdir",
")",
":",
"testdir",
".",
"makepyfile",
"(",
"*",
"*",
"COLLECTION_ERROR_PY_FILES",
")",
"res",
"=",
"testdir",
".",
"runpytest",
"(",
"\"--maxfail=4\"",
")",
"assert",
"res",
".",
"... | [
781,
0
] | [
797,
6
] | python | en | ['en', 'error', 'th'] | False |
test_continue_on_collection_errors | (testdir) |
Verify tests are executed even when collection errors occur when the
--continue-on-collection-errors flag is set
|
Verify tests are executed even when collection errors occur when the
--continue-on-collection-errors flag is set
| def test_continue_on_collection_errors(testdir):
"""
Verify tests are executed even when collection errors occur when the
--continue-on-collection-errors flag is set
"""
testdir.makepyfile(**COLLECTION_ERROR_PY_FILES)
res = testdir.runpytest("--continue-on-collection-errors")
assert res.ret... | [
"def",
"test_continue_on_collection_errors",
"(",
"testdir",
")",
":",
"testdir",
".",
"makepyfile",
"(",
"*",
"*",
"COLLECTION_ERROR_PY_FILES",
")",
"res",
"=",
"testdir",
".",
"runpytest",
"(",
"\"--continue-on-collection-errors\"",
")",
"assert",
"res",
".",
"ret... | [
800,
0
] | [
813,
6
] | python | en | ['en', 'error', 'th'] | False |
test_continue_on_collection_errors_maxfail | (testdir) |
Verify tests are executed even when collection errors occur and that maxfail
is honoured (including the collection error count).
4 tests: 2 collection errors + 1 failure + 1 success
test_4 is never executed because the test run is with --maxfail=3 which
means it is interrupted after the 2 collectio... |
Verify tests are executed even when collection errors occur and that maxfail
is honoured (including the collection error count).
4 tests: 2 collection errors + 1 failure + 1 success
test_4 is never executed because the test run is with --maxfail=3 which
means it is interrupted after the 2 collectio... | def test_continue_on_collection_errors_maxfail(testdir):
"""
Verify tests are executed even when collection errors occur and that maxfail
is honoured (including the collection error count).
4 tests: 2 collection errors + 1 failure + 1 success
test_4 is never executed because the test run is with --m... | [
"def",
"test_continue_on_collection_errors_maxfail",
"(",
"testdir",
")",
":",
"testdir",
".",
"makepyfile",
"(",
"*",
"*",
"COLLECTION_ERROR_PY_FILES",
")",
"res",
"=",
"testdir",
".",
"runpytest",
"(",
"\"--continue-on-collection-errors\"",
",",
"\"--maxfail=3\"",
")"... | [
816,
0
] | [
832,
6
] | python | en | ['en', 'error', 'th'] | False |
test_fixture_scope_sibling_conftests | (testdir) | Regression test case for https://github.com/pytest-dev/pytest/issues/2836 | Regression test case for https://github.com/pytest-dev/pytest/issues/2836 | def test_fixture_scope_sibling_conftests(testdir):
"""Regression test case for https://github.com/pytest-dev/pytest/issues/2836"""
foo_path = testdir.mkpydir("foo")
foo_path.join("conftest.py").write(_pytest._code.Source("""
import pytest
@pytest.fixture
def fix():
return... | [
"def",
"test_fixture_scope_sibling_conftests",
"(",
"testdir",
")",
":",
"foo_path",
"=",
"testdir",
".",
"mkpydir",
"(",
"\"foo\"",
")",
"foo_path",
".",
"join",
"(",
"\"conftest.py\"",
")",
".",
"write",
"(",
"_pytest",
".",
"_code",
".",
"Source",
"(",
"\... | [
835,
0
] | [
857,
6
] | python | en | ['en', 'no', 'en'] | True |
TestCollector.test_can_skip_class_with_test_attr | (self, testdir) | Assure test class is skipped when using `__test__=False` (See #2007). | Assure test class is skipped when using `__test__=False` (See #2007). | def test_can_skip_class_with_test_attr(self, testdir):
"""Assure test class is skipped when using `__test__=False` (See #2007)."""
testdir.makepyfile("""
class TestFoo(object):
__test__ = False
def __init__(self):
pass
def t... | [
"def",
"test_can_skip_class_with_test_attr",
"(",
"self",
",",
"testdir",
")",
":",
"testdir",
".",
"makepyfile",
"(",
"\"\"\"\n class TestFoo(object):\n __test__ = False\n def __init__(self):\n pass\n def test_foo():... | [
91,
4
] | [
105,
10
] | python | en | ['en', 'en', 'en'] | True |
TestCollectFS.test__in_venv | (self, testdir, fname) | Directly test the virtual env detection function | Directly test the virtual env detection function | def test__in_venv(self, testdir, fname):
"""Directly test the virtual env detection function"""
bindir = "Scripts" if sys.platform.startswith("win") else "bin"
# no bin/activate, not a virtualenv
base_path = testdir.tmpdir.mkdir('venv')
assert _in_venv(base_path) is False
... | [
"def",
"test__in_venv",
"(",
"self",
",",
"testdir",
",",
"fname",
")",
":",
"bindir",
"=",
"\"Scripts\"",
"if",
"sys",
".",
"platform",
".",
"startswith",
"(",
"\"win\"",
")",
"else",
"\"bin\"",
"# no bin/activate, not a virtualenv",
"base_path",
"=",
"testdir"... | [
164,
4
] | [
172,
42
] | python | en | ['en', 'en', 'en'] | True |
TestSession.get_reported_items | (self, hookrec) | Return pytest.Item instances reported by the pytest_collectreport hook | Return pytest.Item instances reported by the pytest_collectreport hook | def get_reported_items(self, hookrec):
"""Return pytest.Item instances reported by the pytest_collectreport hook"""
calls = hookrec.getcalls('pytest_collectreport')
return [x for call in calls for x in call.report.result
if isinstance(x, pytest.Item)] | [
"def",
"get_reported_items",
"(",
"self",
",",
"hookrec",
")",
":",
"calls",
"=",
"hookrec",
".",
"getcalls",
"(",
"'pytest_collectreport'",
")",
"return",
"[",
"x",
"for",
"call",
"in",
"calls",
"for",
"x",
"in",
"call",
".",
"report",
".",
"result",
"i... | [
425,
4
] | [
429,
46
] | python | en | ['en', 'en', 'en'] | True |
Test_genitems.test_class_and_functions_discovery_using_glob | (self, testdir) |
tests that python_classes and python_functions config options work
as prefixes and glob-like patterns (issue #600).
|
tests that python_classes and python_functions config options work
as prefixes and glob-like patterns (issue #600).
| def test_class_and_functions_discovery_using_glob(self, testdir):
"""
tests that python_classes and python_functions config options work
as prefixes and glob-like patterns (issue #600).
"""
testdir.makeini("""
[pytest]
python_classes = *Suite Test
... | [
"def",
"test_class_and_functions_discovery_using_glob",
"(",
"self",
",",
"testdir",
")",
":",
"testdir",
".",
"makeini",
"(",
"\"\"\"\n [pytest]\n python_classes = *Suite Test\n python_functions = *_test test\n \"\"\"",
")",
"p",
"=",
"testdir... | [
639,
4
] | [
660,
63
] | python | en | ['en', 'error', 'th'] | False |
delete_old_scheduled_jobs | (apps: StateApps, schema_editor: DatabaseSchemaEditor) | Delete any old scheduled jobs, to handle changes in the format of
that table. Ideally, we'd translate the jobs, but it's not really
worth the development effort to save a few invitation reminders
and day2 followup emails.
| Delete any old scheduled jobs, to handle changes in the format of
that table. Ideally, we'd translate the jobs, but it's not really
worth the development effort to save a few invitation reminders
and day2 followup emails.
| def delete_old_scheduled_jobs(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:
"""Delete any old scheduled jobs, to handle changes in the format of
that table. Ideally, we'd translate the jobs, but it's not really
worth the development effort to save a few invitation reminders
and day2 fo... | [
"def",
"delete_old_scheduled_jobs",
"(",
"apps",
":",
"StateApps",
",",
"schema_editor",
":",
"DatabaseSchemaEditor",
")",
"->",
"None",
":",
"ScheduledJob",
"=",
"apps",
".",
"get_model",
"(",
"\"zerver\"",
",",
"\"ScheduledJob\"",
")",
"ScheduledJob",
".",
"obje... | [
6,
0
] | [
13,
39
] | python | en | ['en', 'en', 'en'] | True |
path_to_url | (path) |
Convert a path to a file: URL. The path will be made absolute and have
quoted path parts.
|
Convert a path to a file: URL. The path will be made absolute and have
quoted path parts.
| def path_to_url(path):
# type: (Union[str, Text]) -> str
"""
Convert a path to a file: URL. The path will be made absolute and have
quoted path parts.
"""
path = os.path.normpath(os.path.abspath(path))
url = urllib_parse.urljoin('file:', urllib_request.pathname2url(path))
return url | [
"def",
"path_to_url",
"(",
"path",
")",
":",
"# type: (Union[str, Text]) -> str",
"path",
"=",
"os",
".",
"path",
".",
"normpath",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"path",
")",
")",
"url",
"=",
"urllib_parse",
".",
"urljoin",
"(",
"'file:'",
... | [
19,
0
] | [
27,
14
] | python | en | ['en', 'error', 'th'] | False |
url_to_path | (url) |
Convert a file: URL to a path.
|
Convert a file: URL to a path.
| def url_to_path(url):
# type: (str) -> str
"""
Convert a file: URL to a path.
"""
assert url.startswith('file:'), (
"You can only turn file: urls into filenames (not {url!r})"
.format(**locals()))
_, netloc, path, _, _ = urllib_parse.urlsplit(url)
if not netloc or netloc ==... | [
"def",
"url_to_path",
"(",
"url",
")",
":",
"# type: (str) -> str",
"assert",
"url",
".",
"startswith",
"(",
"'file:'",
")",
",",
"(",
"\"You can only turn file: urls into filenames (not {url!r})\"",
".",
"format",
"(",
"*",
"*",
"locals",
"(",
")",
")",
")",
"_... | [
30,
0
] | [
54,
15
] | python | en | ['en', 'error', 'th'] | False |
add_message | (request, level, message, extra_tags='', fail_silently=False) | Attempts to add a message to the request using the 'messages' app. | Attempts to add a message to the request using the 'messages' app. | def add_message(request, level, message, extra_tags='', fail_silently=False):
"""Attempts to add a message to the request using the 'messages' app."""
if not horizon_message_already_queued(request, message):
if request.is_ajax():
tag = constants.DEFAULT_TAGS[level]
# if message i... | [
"def",
"add_message",
"(",
"request",
",",
"level",
",",
"message",
",",
"extra_tags",
"=",
"''",
",",
"fail_silently",
"=",
"False",
")",
":",
"if",
"not",
"horizon_message_already_queued",
"(",
"request",
",",
"message",
")",
":",
"if",
"request",
".",
"... | [
38,
0
] | [
52,
67
] | python | en | ['en', 'en', 'en'] | True |
debug | (request, message, extra_tags='', fail_silently=False) | Adds a message with the ``DEBUG`` level. | Adds a message with the ``DEBUG`` level. | def debug(request, message, extra_tags='', fail_silently=False):
"""Adds a message with the ``DEBUG`` level."""
add_message(request, constants.DEBUG, message, extra_tags=extra_tags,
fail_silently=fail_silently) | [
"def",
"debug",
"(",
"request",
",",
"message",
",",
"extra_tags",
"=",
"''",
",",
"fail_silently",
"=",
"False",
")",
":",
"add_message",
"(",
"request",
",",
"constants",
".",
"DEBUG",
",",
"message",
",",
"extra_tags",
"=",
"extra_tags",
",",
"fail_sile... | [
55,
0
] | [
58,
44
] | python | en | ['en', 'en', 'en'] | True |
info | (request, message, extra_tags='', fail_silently=False) | Adds a message with the ``INFO`` level. | Adds a message with the ``INFO`` level. | def info(request, message, extra_tags='', fail_silently=False):
"""Adds a message with the ``INFO`` level."""
add_message(request, constants.INFO, message, extra_tags=extra_tags,
fail_silently=fail_silently) | [
"def",
"info",
"(",
"request",
",",
"message",
",",
"extra_tags",
"=",
"''",
",",
"fail_silently",
"=",
"False",
")",
":",
"add_message",
"(",
"request",
",",
"constants",
".",
"INFO",
",",
"message",
",",
"extra_tags",
"=",
"extra_tags",
",",
"fail_silent... | [
61,
0
] | [
64,
44
] | python | en | ['en', 'en', 'en'] | True |
success | (request, message, extra_tags='', fail_silently=False) | Adds a message with the ``SUCCESS`` level. | Adds a message with the ``SUCCESS`` level. | def success(request, message, extra_tags='', fail_silently=False):
"""Adds a message with the ``SUCCESS`` level."""
add_message(request, constants.SUCCESS, message, extra_tags=extra_tags,
fail_silently=fail_silently) | [
"def",
"success",
"(",
"request",
",",
"message",
",",
"extra_tags",
"=",
"''",
",",
"fail_silently",
"=",
"False",
")",
":",
"add_message",
"(",
"request",
",",
"constants",
".",
"SUCCESS",
",",
"message",
",",
"extra_tags",
"=",
"extra_tags",
",",
"fail_... | [
67,
0
] | [
70,
44
] | python | en | ['en', 'en', 'en'] | True |
warning | (request, message, extra_tags='', fail_silently=False) | Adds a message with the ``WARNING`` level. | Adds a message with the ``WARNING`` level. | def warning(request, message, extra_tags='', fail_silently=False):
"""Adds a message with the ``WARNING`` level."""
add_message(request, constants.WARNING, message, extra_tags=extra_tags,
fail_silently=fail_silently) | [
"def",
"warning",
"(",
"request",
",",
"message",
",",
"extra_tags",
"=",
"''",
",",
"fail_silently",
"=",
"False",
")",
":",
"add_message",
"(",
"request",
",",
"constants",
".",
"WARNING",
",",
"message",
",",
"extra_tags",
"=",
"extra_tags",
",",
"fail_... | [
73,
0
] | [
76,
44
] | python | en | ['en', 'en', 'en'] | True |
error | (request, message, extra_tags='', fail_silently=False) | Adds a message with the ``ERROR`` level. | Adds a message with the ``ERROR`` level. | def error(request, message, extra_tags='', fail_silently=False):
"""Adds a message with the ``ERROR`` level."""
add_message(request, constants.ERROR, message, extra_tags=extra_tags,
fail_silently=fail_silently) | [
"def",
"error",
"(",
"request",
",",
"message",
",",
"extra_tags",
"=",
"''",
",",
"fail_silently",
"=",
"False",
")",
":",
"add_message",
"(",
"request",
",",
"constants",
".",
"ERROR",
",",
"message",
",",
"extra_tags",
"=",
"extra_tags",
",",
"fail_sile... | [
79,
0
] | [
82,
44
] | python | en | ['en', 'en', 'en'] | True |
call_functions_parallel | (*worker_defs) | Call specified functions in parallel.
:param *worker_defs: Each positional argument can be either of
a function to be called or a tuple which consists of a function,
a list of positional arguments) and keyword arguments (optional).
If you need to pass arguments, you need to pass a tuple.
... | Call specified functions in parallel. | def call_functions_parallel(*worker_defs):
"""Call specified functions in parallel.
:param *worker_defs: Each positional argument can be either of
a function to be called or a tuple which consists of a function,
a list of positional arguments) and keyword arguments (optional).
If you ne... | [
"def",
"call_functions_parallel",
"(",
"*",
"worker_defs",
")",
":",
"# TODO(amotoki): Needs to figure out what max_workers can be specified.",
"# According to e0ne, the apache default configuration in devstack allows",
"# only 10 threads. What happens if max_worker=11 is specified?",
"max_work... | [
17,
0
] | [
49,
45
] | python | en | ['en', 'en', 'en'] | True |
TestDashboardHelp.test_dashboard_help_redirection | (self) | Verifies Help link redirects to the right URL. | Verifies Help link redirects to the right URL. | def test_dashboard_help_redirection(self):
"""Verifies Help link redirects to the right URL."""
self.home_pg.go_to_help_page()
self.home_pg._wait_until(lambda _: self.home_pg.is_nth_window_opened(2)
)
self.home_pg.switch_window()
self.home_pg.is_... | [
"def",
"test_dashboard_help_redirection",
"(",
"self",
")",
":",
"self",
".",
"home_pg",
".",
"go_to_help_page",
"(",
")",
"self",
".",
"home_pg",
".",
"_wait_until",
"(",
"lambda",
"_",
":",
"self",
".",
"home_pg",
".",
"is_nth_window_opened",
"(",
"2",
")"... | [
17,
4
] | [
31,
36
] | python | en | ['en', 'en', 'en'] | True |
TestThemePicker.test_switch_to_material_theme | (self) | Verifies that material theme is available and switchable to. | Verifies that material theme is available and switchable to. | def test_switch_to_material_theme(self):
"""Verifies that material theme is available and switchable to."""
self.home_pg.choose_theme(self.MATERIAL_THEME)
self.assertTrue(self.home_pg.topbar.is_material_theme_enabled)
self.home_pg.choose_theme(self.DEFAULT_THEME)
self.assertFalse... | [
"def",
"test_switch_to_material_theme",
"(",
"self",
")",
":",
"self",
".",
"home_pg",
".",
"choose_theme",
"(",
"self",
".",
"MATERIAL_THEME",
")",
"self",
".",
"assertTrue",
"(",
"self",
".",
"home_pg",
".",
"topbar",
".",
"is_material_theme_enabled",
")",
"... | [
38,
4
] | [
43,
71
] | python | en | ['en', 'en', 'en'] | True |
TestUserSettings.test_user_settings_change | (self) | tests the user's settings options:
* changes the system's language
* changes the timezone
* changes the number of items per page (page size)
* changes the number of log lines to be shown per instance
* verifies all changes were successfully executed
| tests the user's settings options: | def test_user_settings_change(self):
"""tests the user's settings options:
* changes the system's language
* changes the timezone
* changes the number of items per page (page size)
* changes the number of log lines to be shown per instance
* verifies all changes were suc... | [
"def",
"test_user_settings_change",
"(",
"self",
")",
":",
"settings_page",
"=",
"self",
".",
"home_pg",
".",
"go_to_settings_usersettingspage",
"(",
")",
"settings_page",
".",
"change_language",
"(",
"\"es\"",
")",
"self",
".",
"assertTrue",
"(",
"settings_page",
... | [
126,
4
] | [
170,
72
] | python | en | ['en', 'en', 'en'] | True |
to_sax | (walker, handler) | Call SAX-like content handler based on treewalker walker
:arg walker: the treewalker to use to walk the tree to convert it
:arg handler: SAX handler to use
| Call SAX-like content handler based on treewalker walker | def to_sax(walker, handler):
"""Call SAX-like content handler based on treewalker walker
:arg walker: the treewalker to use to walk the tree to convert it
:arg handler: SAX handler to use
"""
handler.startDocument()
for prefix, namespace in prefix_mapping.items():
handler.startPrefixM... | [
"def",
"to_sax",
"(",
"walker",
",",
"handler",
")",
":",
"handler",
".",
"startDocument",
"(",
")",
"for",
"prefix",
",",
"namespace",
"in",
"prefix_mapping",
".",
"items",
"(",
")",
":",
"handler",
".",
"startPrefixMapping",
"(",
"prefix",
",",
"namespac... | [
12,
0
] | [
49,
25
] | python | en | ['en', 'no', 'en'] | True |
FlavorFilterAction.filter | (self, table, flavors, filter_string) | Really naive case-insensitive search. | Really naive case-insensitive search. | def filter(self, table, flavors, filter_string):
"""Really naive case-insensitive search."""
q = filter_string.lower()
def comp(flavor):
return q in flavor.name.lower()
return filter(comp, flavors) | [
"def",
"filter",
"(",
"self",
",",
"table",
",",
"flavors",
",",
"filter_string",
")",
":",
"q",
"=",
"filter_string",
".",
"lower",
"(",
")",
"def",
"comp",
"(",
"flavor",
")",
":",
"return",
"q",
"in",
"flavor",
".",
"name",
".",
"lower",
"(",
")... | [
103,
4
] | [
110,
36
] | python | en | ['en', 'en', 'en'] | True |
PatchedTemplateCommand._get_conf_dir_parent_path | (self) |
Возвращает абсолютный путь директории, содержащей директорию conf с шаблонами внутри
|
Возвращает абсолютный путь директории, содержащей директорию conf с шаблонами внутри
| def _get_conf_dir_parent_path(self):
"""
Возвращает абсолютный путь директории, содержащей директорию conf с шаблонами внутри
"""
return django.__path__[0] | [
"def",
"_get_conf_dir_parent_path",
"(",
"self",
")",
":",
"return",
"django",
".",
"__path__",
"[",
"0",
"]"
] | [
85,
4
] | [
89,
33
] | python | en | ['en', 'error', 'th'] | False |
PatchedTemplateCommand._sort_imports | (
self,
content: str,
) |
Сортировка импортов при помощи isort
|
Сортировка импортов при помощи isort
| def _sort_imports(
self,
content: str,
):
"""
Сортировка импортов при помощи isort
"""
return sort_code_string(
code=content,
config=getattr(settings, 'ISORT_CONFIG') or DEFAULT_CONFIG,
) | [
"def",
"_sort_imports",
"(",
"self",
",",
"content",
":",
"str",
",",
")",
":",
"return",
"sort_code_string",
"(",
"code",
"=",
"content",
",",
"config",
"=",
"getattr",
"(",
"settings",
",",
"'ISORT_CONFIG'",
")",
"or",
"DEFAULT_CONFIG",
",",
")"
] | [
91,
4
] | [
101,
9
] | python | en | ['en', 'error', 'th'] | False |
PatchedTemplateCommand.handle_template | (self, template=None, subdir=None) |
Поиск директории с шаблоном функции
|
Поиск директории с шаблоном функции
| def handle_template(self, template=None, subdir=None):
"""
Поиск директории с шаблоном функции
"""
template_directory_path = None
for app_name in settings.INSTALLED_APPS:
app_module = import_module(app_name)
app_path = app_module.__path__
app... | [
"def",
"handle_template",
"(",
"self",
",",
"template",
"=",
"None",
",",
"subdir",
"=",
"None",
")",
":",
"template_directory_path",
"=",
"None",
"for",
"app_name",
"in",
"settings",
".",
"INSTALLED_APPS",
":",
"app_module",
"=",
"import_module",
"(",
"app_na... | [
103,
4
] | [
126,
38
] | python | en | ['en', 'error', 'th'] | False |
PatchedTemplateCommand._make_top_dir | (self, target, name) |
Создание корневой директории
|
Создание корневой директории
| def _make_top_dir(self, target, name):
"""
Создание корневой директории
"""
# if some directory is given, make sure it's nicely expanded
if target is None:
self._top_dir_path = path.join(os.getcwd(), name)
try:
os.makedirs(self._top_dir_pat... | [
"def",
"_make_top_dir",
"(",
"self",
",",
"target",
",",
"name",
")",
":",
"# if some directory is given, make sure it's nicely expanded",
"if",
"target",
"is",
"None",
":",
"self",
".",
"_top_dir_path",
"=",
"path",
".",
"join",
"(",
"os",
".",
"getcwd",
"(",
... | [
128,
4
] | [
146,
17
] | python | en | ['en', 'error', 'th'] | False |
PatchedTemplateCommand._prepare_top_module_python_path | (self) |
Формирование пути создаваемого пакета для дальнейшего использования в генерируемых импортах
|
Формирование пути создаваемого пакета для дальнейшего использования в генерируемых импортах
| def _prepare_top_module_python_path(self):
"""
Формирование пути создаваемого пакета для дальнейшего использования в генерируемых импортах
"""
top_dir_path = self._top_dir_path
paths = [
path_item
for path_item in sys.path
if path_item in top_d... | [
"def",
"_prepare_top_module_python_path",
"(",
"self",
")",
":",
"top_dir_path",
"=",
"self",
".",
"_top_dir_path",
"paths",
"=",
"[",
"path_item",
"for",
"path_item",
"in",
"sys",
".",
"path",
"if",
"path_item",
"in",
"top_dir_path",
"# при запуске через django-adm... | [
148,
4
] | [
167,
79
] | python | en | ['en', 'error', 'th'] | False |
PatchedTemplateCommand._prepare_extensions | (self, options) |
Подготовка расширений файлов
|
Подготовка расширений файлов
| def _prepare_extensions(self, options):
"""
Подготовка расширений файлов
"""
self.extensions = tuple(handle_extensions(options['extensions']))
if self.verbosity >= 2:
self.stdout.write(
f'Rendering {self.app_or_project} template files with extensions:... | [
"def",
"_prepare_extensions",
"(",
"self",
",",
"options",
")",
":",
"self",
".",
"extensions",
"=",
"tuple",
"(",
"handle_extensions",
"(",
"options",
"[",
"'extensions'",
"]",
")",
")",
"if",
"self",
".",
"verbosity",
">=",
"2",
":",
"self",
".",
"stdo... | [
174,
4
] | [
187,
13
] | python | en | ['en', 'error', 'th'] | False |
PatchedTemplateCommand._prepare_new_path_file | (self, filename, relative_dir, options) |
Подготовка пути генерируемого из шаблона файла
|
Подготовка пути генерируемого из шаблона файла
| def _prepare_new_path_file(self, filename, relative_dir, options):
"""
Подготовка пути генерируемого из шаблона файла
"""
new_path = path.join(self._top_dir_path, relative_dir, filename.replace(self.base_name, self.name))
for old_suffix, new_suffix in self.rewrite_template_suffi... | [
"def",
"_prepare_new_path_file",
"(",
"self",
",",
"filename",
",",
"relative_dir",
",",
"options",
")",
":",
"new_path",
"=",
"path",
".",
"join",
"(",
"self",
".",
"_top_dir_path",
",",
"relative_dir",
",",
"filename",
".",
"replace",
"(",
"self",
".",
"... | [
189,
4
] | [
206,
23
] | python | en | ['en', 'error', 'th'] | False |
PatchedTemplateCommand._prepare_context | (self, options) |
Создание контекста
|
Создание контекста
| def _prepare_context(self, options):
"""
Создание контекста
"""
self.context = Context({
**options,
self.base_name: self.name,
self.base_directory: self._top_dir_path,
self.camel_case_name: self.camel_case_value,
self.base_pytho... | [
"def",
"_prepare_context",
"(",
"self",
",",
"options",
")",
":",
"self",
".",
"context",
"=",
"Context",
"(",
"{",
"*",
"*",
"options",
",",
"self",
".",
"base_name",
":",
"self",
".",
"name",
",",
"self",
".",
"base_directory",
":",
"self",
".",
"_... | [
270,
4
] | [
282,
28
] | python | en | ['en', 'error', 'th'] | False |
PatchedTemplateCommand._django_setup | (self) |
Инициализация Django для рендеринга шаблонов
|
Инициализация Django для рендеринга шаблонов
| def _django_setup(self):
"""
Инициализация Django для рендеринга шаблонов
"""
if not settings.configured:
settings.configure()
django.setup() | [
"def",
"_django_setup",
"(",
"self",
")",
":",
"if",
"not",
"settings",
".",
"configured",
":",
"settings",
".",
"configure",
"(",
")",
"django",
".",
"setup",
"(",
")"
] | [
284,
4
] | [
290,
26
] | python | en | ['en', 'error', 'th'] | False |
PatchedTemplateCommand._remove_paths | (self) |
Удаление помеченных файлов и директорий
|
Удаление помеченных файлов и директорий
| def _remove_paths(self):
"""
Удаление помеченных файлов и директорий
"""
if self.paths_to_remove:
if self.verbosity >= 2:
self.stdout.write('Cleaning up temporary files.\n')
for path_to_remove in self.paths_to_remove:
if path.isfile... | [
"def",
"_remove_paths",
"(",
"self",
")",
":",
"if",
"self",
".",
"paths_to_remove",
":",
"if",
"self",
".",
"verbosity",
">=",
"2",
":",
"self",
".",
"stdout",
".",
"write",
"(",
"'Cleaning up temporary files.\\n'",
")",
"for",
"path_to_remove",
"in",
"self... | [
292,
4
] | [
303,
49
] | python | en | ['en', 'error', 'th'] | False |
PatchedTemplateCommand._prepare_parameters | (self, app_or_project, name, options) |
Подготовка параметров для дальнейшей работы
|
Подготовка параметров для дальнейшей работы
| def _prepare_parameters(self, app_or_project, name, options):
"""
Подготовка параметров для дальнейшей работы
"""
self.name = name
self.app_or_project = app_or_project
self.paths_to_remove = []
self.verbosity = options['verbosity']
self.base_name = f'{app_... | [
"def",
"_prepare_parameters",
"(",
"self",
",",
"app_or_project",
",",
"name",
",",
"options",
")",
":",
"self",
".",
"name",
"=",
"name",
"self",
".",
"app_or_project",
"=",
"app_or_project",
"self",
".",
"paths_to_remove",
"=",
"[",
"]",
"self",
".",
"ve... | [
305,
4
] | [
319,
48
] | python | en | ['en', 'error', 'th'] | False |
PatchedTemplateCommand.handle | (self, app_or_project, name, target=None, **options) |
Template command handler
|
Template command handler
| def handle(self, app_or_project, name, target=None, **options):
"""
Template command handler
"""
self._prepare_parameters(app_or_project, name, options)
self._make_top_dir(target=target, name=name)
self._prepare_top_module_python_path()
self._prepare_extra_files(o... | [
"def",
"handle",
"(",
"self",
",",
"app_or_project",
",",
"name",
",",
"target",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"self",
".",
"_prepare_parameters",
"(",
"app_or_project",
",",
"name",
",",
"options",
")",
"self",
".",
"_make_top_dir",
"... | [
321,
4
] | [
332,
28
] | python | en | ['en', 'error', 'th'] | False |
Command.add_arguments | (self, parser) |
Добавление параметров команды
|
Добавление параметров команды
| def add_arguments(self, parser):
"""
Добавление параметров команды
"""
super().add_arguments(parser)
strategy_help = '\n'.join([
f'{strategy.key} - {strategy.title};'
for strategy in ImplementationStrategy.get_enum_data().values()
])
pars... | [
"def",
"add_arguments",
"(",
"self",
",",
"parser",
")",
":",
"super",
"(",
")",
".",
"add_arguments",
"(",
"parser",
")",
"strategy_help",
"=",
"'\\n'",
".",
"join",
"(",
"[",
"f'{strategy.key} - {strategy.title};'",
"for",
"strategy",
"in",
"ImplementationStra... | [
352,
4
] | [
395,
9
] | python | en | ['en', 'error', 'th'] | False |
Command._get_conf_dir_parent_path | (self) |
Возвращает абсолютный путь директории, содержащей директорию conf с шаблонами внутри
|
Возвращает абсолютный путь директории, содержащей директорию conf с шаблонами внутри
| def _get_conf_dir_parent_path(self):
"""
Возвращает абсолютный путь директории, содержащей директорию conf с шаблонами внутри
"""
return function_tools.__path__[0] | [
"def",
"_get_conf_dir_parent_path",
"(",
"self",
")",
":",
"return",
"function_tools",
".",
"__path__",
"[",
"0",
"]"
] | [
397,
4
] | [
401,
41
] | python | en | ['en', 'error', 'th'] | False |
Command._prepare_new_path_file | (self, filename, relative_dir, options) |
Подготовка пути генерируемого из шаблона файла
|
Подготовка пути генерируемого из шаблона файла
| def _prepare_new_path_file(self, filename, relative_dir, options):
"""
Подготовка пути генерируемого из шаблона файла
"""
new_path = super()._prepare_new_path_file(filename, relative_dir, options)
if PARAMETERS_DIALOG_WINDOW in new_path:
if options['is_parameterized'... | [
"def",
"_prepare_new_path_file",
"(",
"self",
",",
"filename",
",",
"relative_dir",
",",
"options",
")",
":",
"new_path",
"=",
"super",
"(",
")",
".",
"_prepare_new_path_file",
"(",
"filename",
",",
"relative_dir",
",",
"options",
")",
"if",
"PARAMETERS_DIALOG_W... | [
409,
4
] | [
421,
23
] | python | en | ['en', 'error', 'th'] | False |
Command._prepare_base_subdir_parameter | (self, app_or_project, options) |
Формирование параметра base_subdir
|
Формирование параметра base_subdir
| def _prepare_base_subdir_parameter(self, app_or_project, options):
"""
Формирование параметра base_subdir
"""
function_type = options['function_type']
self.base_subdir = f'{app_or_project}_{function_type.name.lower()}_template' | [
"def",
"_prepare_base_subdir_parameter",
"(",
"self",
",",
"app_or_project",
",",
"options",
")",
":",
"function_type",
"=",
"options",
"[",
"'function_type'",
"]",
"self",
".",
"base_subdir",
"=",
"f'{app_or_project}_{function_type.name.lower()}_template'"
] | [
427,
4
] | [
433,
84
] | python | en | ['en', 'error', 'th'] | False |
Command._prepare_parameters | (self, app_or_project, name, options) |
Подготовка параметров для дальнейшей работы
|
Подготовка параметров для дальнейшей работы
| def _prepare_parameters(self, app_or_project, name, options):
"""
Подготовка параметров для дальнейшей работы
"""
super()._prepare_parameters(app_or_project, name, options)
self.url_name = self.name.replace('_', '-')
self.base_url_name = f'{app_or_project}_url_name' | [
"def",
"_prepare_parameters",
"(",
"self",
",",
"app_or_project",
",",
"name",
",",
"options",
")",
":",
"super",
"(",
")",
".",
"_prepare_parameters",
"(",
"app_or_project",
",",
"name",
",",
"options",
")",
"self",
".",
"url_name",
"=",
"self",
".",
"nam... | [
435,
4
] | [
442,
57
] | python | en | ['en', 'error', 'th'] | False |
Command._prepare_context | (self, options) |
Создание контекста
|
Создание контекста
| def _prepare_context(self, options):
"""
Создание контекста
"""
self.context = Context({
**options,
self.base_name: self.name,
self.base_url_name: self.url_name,
self.base_directory: self._top_dir_path,
self.camel_case_name: sel... | [
"def",
"_prepare_context",
"(",
"self",
",",
"options",
")",
":",
"self",
".",
"context",
"=",
"Context",
"(",
"{",
"*",
"*",
"options",
",",
"self",
".",
"base_name",
":",
"self",
".",
"name",
",",
"self",
".",
"base_url_name",
":",
"self",
".",
"ur... | [
444,
4
] | [
457,
28
] | python | en | ['en', 'error', 'th'] | False |
find_wrapper_interface | (env, interface_type) | Unwrap the env until we find the wrapper that implements interface_type. | Unwrap the env until we find the wrapper that implements interface_type. | def find_wrapper_interface(env, interface_type):
"""Unwrap the env until we find the wrapper that implements interface_type."""
unwrapped = env.unwrapped
while True:
if isinstance(env, interface_type):
return env
elif env == unwrapped:
return None # unwrapped all the... | [
"def",
"find_wrapper_interface",
"(",
"env",
",",
"interface_type",
")",
":",
"unwrapped",
"=",
"env",
".",
"unwrapped",
"while",
"True",
":",
"if",
"isinstance",
"(",
"env",
",",
"interface_type",
")",
":",
"return",
"env",
"elif",
"env",
"==",
"unwrapped",... | [
48,
0
] | [
57,
25
] | python | en | ['en', 'en', 'en'] | True |
get_default_reward_shaping | (env) |
The current convention is that when the environment supports reward shaping, the env.unwrapped should contain
a reference to the object implementing RewardShapingInterface.
We use this object to get/set reward shaping schemes generated by PBT.
|
The current convention is that when the environment supports reward shaping, the env.unwrapped should contain
a reference to the object implementing RewardShapingInterface.
We use this object to get/set reward shaping schemes generated by PBT.
| def get_default_reward_shaping(env):
"""
The current convention is that when the environment supports reward shaping, the env.unwrapped should contain
a reference to the object implementing RewardShapingInterface.
We use this object to get/set reward shaping schemes generated by PBT.
"""
reward... | [
"def",
"get_default_reward_shaping",
"(",
"env",
")",
":",
"reward_shaping_interface",
"=",
"find_wrapper_interface",
"(",
"env",
",",
"RewardShapingInterface",
")",
"if",
"reward_shaping_interface",
":",
"return",
"reward_shaping_interface",
".",
"get_default_reward_shaping"... | [
80,
0
] | [
91,
15
] | python | en | ['en', 'error', 'th'] | False |
find_training_info_interface | (env) | Unwrap the env until we find the wrapper that implements TrainingInfoInterface. | Unwrap the env until we find the wrapper that implements TrainingInfoInterface. | def find_training_info_interface(env):
"""Unwrap the env until we find the wrapper that implements TrainingInfoInterface."""
return find_wrapper_interface(env, TrainingInfoInterface) | [
"def",
"find_training_info_interface",
"(",
"env",
")",
":",
"return",
"find_wrapper_interface",
"(",
"env",
",",
"TrainingInfoInterface",
")"
] | [
114,
0
] | [
116,
61
] | python | en | ['en', 'en', 'en'] | True |
RewardShapingInterface.get_default_reward_shaping | (self) | Should return a dictionary of string:float key-value pairs defining the current reward shaping scheme. | Should return a dictionary of string:float key-value pairs defining the current reward shaping scheme. | def get_default_reward_shaping(self):
"""Should return a dictionary of string:float key-value pairs defining the current reward shaping scheme."""
raise NotImplementedError | [
"def",
"get_default_reward_shaping",
"(",
"self",
")",
":",
"raise",
"NotImplementedError"
] | [
64,
4
] | [
66,
33
] | python | en | ['en', 'en', 'en'] | True |
RewardShapingInterface.set_reward_shaping | (self, reward_shaping: dict, agent_idx: int) |
Sets the new reward shaping scheme.
:param reward_shaping dictionary of string-float key-value pairs
:param agent_idx: integer agent index (for multi-agent envs)
|
Sets the new reward shaping scheme.
:param reward_shaping dictionary of string-float key-value pairs
:param agent_idx: integer agent index (for multi-agent envs)
| def set_reward_shaping(self, reward_shaping: dict, agent_idx: int):
"""
Sets the new reward shaping scheme.
:param reward_shaping dictionary of string-float key-value pairs
:param agent_idx: integer agent index (for multi-agent envs)
"""
raise NotImplementedError | [
"def",
"set_reward_shaping",
"(",
"self",
",",
"reward_shaping",
":",
"dict",
",",
"agent_idx",
":",
"int",
")",
":",
"raise",
"NotImplementedError"
] | [
71,
4
] | [
77,
33
] | python | en | ['en', 'error', 'th'] | False |
TrainingInfoInterface.set_training_info | (self, training_info) |
Send the training information to the environment, i.e. number of training steps so far.
Some environments rely on that i.e. to implement curricula.
:param training_info: dictionary containing information about the current training session. Guaranteed to
contain 'approx_total_training_st... |
Send the training information to the environment, i.e. number of training steps so far.
Some environments rely on that i.e. to implement curricula.
:param training_info: dictionary containing information about the current training session. Guaranteed to
contain 'approx_total_training_st... | def set_training_info(self, training_info):
"""
Send the training information to the environment, i.e. number of training steps so far.
Some environments rely on that i.e. to implement curricula.
:param training_info: dictionary containing information about the current training session. ... | [
"def",
"set_training_info",
"(",
"self",
",",
"training_info",
")",
":",
"self",
".",
"training_info",
"=",
"training_info"
] | [
104,
4
] | [
111,
42
] | python | en | ['en', 'error', 'th'] | False |
closeWechatBlackFrame | () |
关闭微信小黑框
:return:
|
关闭微信小黑框
:return:
| def closeWechatBlackFrame():
"""
关闭微信小黑框
:return:
"""
for win in MyWindow.by_class('wechat.exe.Wine'):
if win.wm_name == "" or win.wm_name == "ChatContactMenu":
# print(win)
win.close() | [
"def",
"closeWechatBlackFrame",
"(",
")",
":",
"for",
"win",
"in",
"MyWindow",
".",
"by_class",
"(",
"'wechat.exe.Wine'",
")",
":",
"if",
"win",
".",
"wm_name",
"==",
"\"\"",
"or",
"win",
".",
"wm_name",
"==",
"\"ChatContactMenu\"",
":",
"# print(win)",
"win... | [
17,
0
] | [
25,
23
] | python | en | ['en', 'error', 'th'] | False |
MyWindow.close | (self) |
关闭窗口
:param win:
:return:
|
关闭窗口
:param win:
:return:
| def close(self):
"""
关闭窗口
:param win:
:return:
"""
cmd = 'xdotool windowunmap {0}'.format(self.id)
getoutput(cmd) | [
"def",
"close",
"(",
"self",
")",
":",
"cmd",
"=",
"'xdotool windowunmap {0}'",
".",
"format",
"(",
"self",
".",
"id",
")",
"getoutput",
"(",
"cmd",
")"
] | [
7,
4
] | [
14,
22
] | python | en | ['en', 'error', 'th'] | False |
_check_all_skipped | (test) | raises pytest.skip() if all examples in the given DocTest have the SKIP
option set.
| raises pytest.skip() if all examples in the given DocTest have the SKIP
option set.
| def _check_all_skipped(test):
"""raises pytest.skip() if all examples in the given DocTest have the SKIP
option set.
"""
import doctest
all_skipped = all(x.options.get(doctest.SKIP, False) for x in test.examples)
if all_skipped:
pytest.skip('all tests skipped by +SKIP option') | [
"def",
"_check_all_skipped",
"(",
"test",
")",
":",
"import",
"doctest",
"all_skipped",
"=",
"all",
"(",
"x",
".",
"options",
".",
"get",
"(",
"doctest",
".",
"SKIP",
",",
"False",
")",
"for",
"x",
"in",
"test",
".",
"examples",
")",
"if",
"all_skipped... | [
214,
0
] | [
221,
56
] | python | en | ['en', 'en', 'en'] | True |
_setup_fixtures | (doctest_item) |
Used by DoctestTextfile and DoctestItem to setup fixture information.
|
Used by DoctestTextfile and DoctestItem to setup fixture information.
| def _setup_fixtures(doctest_item):
"""
Used by DoctestTextfile and DoctestItem to setup fixture information.
"""
def func():
pass
doctest_item.funcargs = {}
fm = doctest_item.session._fixturemanager
doctest_item._fixtureinfo = fm.getfixtureinfo(node=doctest_item, func=func,
... | [
"def",
"_setup_fixtures",
"(",
"doctest_item",
")",
":",
"def",
"func",
"(",
")",
":",
"pass",
"doctest_item",
".",
"funcargs",
"=",
"{",
"}",
"fm",
"=",
"doctest_item",
".",
"session",
".",
"_fixturemanager",
"doctest_item",
".",
"_fixtureinfo",
"=",
"fm",
... | [
248,
0
] | [
261,
26
] | python | en | ['en', 'error', 'th'] | False |
_get_checker | () |
Returns a doctest.OutputChecker subclass that takes in account the
ALLOW_UNICODE option to ignore u'' prefixes in strings and ALLOW_BYTES
to strip b'' prefixes.
Useful when the same doctest should run in Python 2 and Python 3.
An inner class is used to avoid importing "doctest" at the module
l... |
Returns a doctest.OutputChecker subclass that takes in account the
ALLOW_UNICODE option to ignore u'' prefixes in strings and ALLOW_BYTES
to strip b'' prefixes.
Useful when the same doctest should run in Python 2 and Python 3. | def _get_checker():
"""
Returns a doctest.OutputChecker subclass that takes in account the
ALLOW_UNICODE option to ignore u'' prefixes in strings and ALLOW_BYTES
to strip b'' prefixes.
Useful when the same doctest should run in Python 2 and Python 3.
An inner class is used to avoid importing "d... | [
"def",
"_get_checker",
"(",
")",
":",
"if",
"hasattr",
"(",
"_get_checker",
",",
"'LiteralsOutputChecker'",
")",
":",
"return",
"_get_checker",
".",
"LiteralsOutputChecker",
"(",
")",
"import",
"doctest",
"import",
"re",
"class",
"LiteralsOutputChecker",
"(",
"doc... | [
264,
0
] | [
317,
47
] | python | en | ['en', 'error', 'th'] | False |
_get_allow_unicode_flag | () |
Registers and returns the ALLOW_UNICODE flag.
|
Registers and returns the ALLOW_UNICODE flag.
| def _get_allow_unicode_flag():
"""
Registers and returns the ALLOW_UNICODE flag.
"""
import doctest
return doctest.register_optionflag('ALLOW_UNICODE') | [
"def",
"_get_allow_unicode_flag",
"(",
")",
":",
"import",
"doctest",
"return",
"doctest",
".",
"register_optionflag",
"(",
"'ALLOW_UNICODE'",
")"
] | [
320,
0
] | [
325,
55
] | python | en | ['en', 'error', 'th'] | False |
_get_allow_bytes_flag | () |
Registers and returns the ALLOW_BYTES flag.
|
Registers and returns the ALLOW_BYTES flag.
| def _get_allow_bytes_flag():
"""
Registers and returns the ALLOW_BYTES flag.
"""
import doctest
return doctest.register_optionflag('ALLOW_BYTES') | [
"def",
"_get_allow_bytes_flag",
"(",
")",
":",
"import",
"doctest",
"return",
"doctest",
".",
"register_optionflag",
"(",
"'ALLOW_BYTES'",
")"
] | [
328,
0
] | [
333,
53
] | python | en | ['en', 'error', 'th'] | False |
_get_report_choice | (key) |
This function returns the actual `doctest` module flag value, we want to do it as late as possible to avoid
importing `doctest` and all its dependencies when parsing options, as it adds overhead and breaks tests.
|
This function returns the actual `doctest` module flag value, we want to do it as late as possible to avoid
importing `doctest` and all its dependencies when parsing options, as it adds overhead and breaks tests.
| def _get_report_choice(key):
"""
This function returns the actual `doctest` module flag value, we want to do it as late as possible to avoid
importing `doctest` and all its dependencies when parsing options, as it adds overhead and breaks tests.
"""
import doctest
return {
DOCTEST_REPOR... | [
"def",
"_get_report_choice",
"(",
"key",
")",
":",
"import",
"doctest",
"return",
"{",
"DOCTEST_REPORT_CHOICE_UDIFF",
":",
"doctest",
".",
"REPORT_UDIFF",
",",
"DOCTEST_REPORT_CHOICE_CDIFF",
":",
"doctest",
".",
"REPORT_CDIFF",
",",
"DOCTEST_REPORT_CHOICE_NDIFF",
":",
... | [
336,
0
] | [
349,
10
] | python | en | ['en', 'error', 'th'] | False |
_fix_spoof_python2 | (runner, encoding) |
Installs a "SpoofOut" into the given DebugRunner so it properly deals with unicode output. This
should patch only doctests for text files because they don't have a way to declare their
encoding. Doctests in docstrings from Python modules don't have the same problem given that
Python already decoded the... |
Installs a "SpoofOut" into the given DebugRunner so it properly deals with unicode output. This
should patch only doctests for text files because they don't have a way to declare their
encoding. Doctests in docstrings from Python modules don't have the same problem given that
Python already decoded the... | def _fix_spoof_python2(runner, encoding):
"""
Installs a "SpoofOut" into the given DebugRunner so it properly deals with unicode output. This
should patch only doctests for text files because they don't have a way to declare their
encoding. Doctests in docstrings from Python modules don't have the same ... | [
"def",
"_fix_spoof_python2",
"(",
"runner",
",",
"encoding",
")",
":",
"from",
"_pytest",
".",
"compat",
"import",
"_PY2",
"if",
"not",
"_PY2",
":",
"return",
"from",
"doctest",
"import",
"_SpoofOut",
"class",
"UnicodeSpoof",
"(",
"_SpoofOut",
")",
":",
"def... | [
352,
0
] | [
375,
36
] | python | en | ['en', 'error', 'th'] | False |
doctest_namespace | () |
Inject names into the doctest namespace.
|
Inject names into the doctest namespace.
| def doctest_namespace():
"""
Inject names into the doctest namespace.
"""
return dict() | [
"def",
"doctest_namespace",
"(",
")",
":",
"return",
"dict",
"(",
")"
] | [
379,
0
] | [
383,
17
] | python | en | ['en', 'error', 'th'] | False |
DoctestItem._disable_output_capturing_for_darwin | (self) |
Disable output capturing. Otherwise, stdout is lost to doctest (#985)
|
Disable output capturing. Otherwise, stdout is lost to doctest (#985)
| def _disable_output_capturing_for_darwin(self):
"""
Disable output capturing. Otherwise, stdout is lost to doctest (#985)
"""
if platform.system() != 'Darwin':
return
capman = self.config.pluginmanager.getplugin("capturemanager")
if capman:
out, er... | [
"def",
"_disable_output_capturing_for_darwin",
"(",
"self",
")",
":",
"if",
"platform",
".",
"system",
"(",
")",
"!=",
"'Darwin'",
":",
"return",
"capman",
"=",
"self",
".",
"config",
".",
"pluginmanager",
".",
"getplugin",
"(",
"\"capturemanager\"",
")",
"if"... | [
110,
4
] | [
120,
33
] | python | en | ['en', 'error', 'th'] | False |
get_host_platform | () | Return a string that identifies the current platform. This is used mainly to
distinguish platform-specific build directories and platform-specific built
distributions. Typically includes the OS name and version and the
architecture (as supplied by 'os.uname()'), although the exact information
included... | Return a string that identifies the current platform. This is used mainly to
distinguish platform-specific build directories and platform-specific built
distributions. Typically includes the OS name and version and the
architecture (as supplied by 'os.uname()'), although the exact information
included... | def get_host_platform():
"""Return a string that identifies the current platform. This is used mainly to
distinguish platform-specific build directories and platform-specific built
distributions. Typically includes the OS name and version and the
architecture (as supplied by 'os.uname()'), although th... | [
"def",
"get_host_platform",
"(",
")",
":",
"if",
"os",
".",
"name",
"==",
"'nt'",
":",
"if",
"'amd64'",
"in",
"sys",
".",
"version",
".",
"lower",
"(",
")",
":",
"return",
"'win-amd64'",
"if",
"'(arm)'",
"in",
"sys",
".",
"version",
".",
"lower",
"("... | [
19,
0
] | [
97,
50
] | python | en | ['en', 'en', 'en'] | True |
convert_path | (pathname) | Return 'pathname' as a name that will work on the native filesystem,
i.e. split it on '/' and put it back together again using the current
directory separator. Needed because filenames in the setup script are
always supplied in Unix style, and have to be converted to the local
convention before we can ... | Return 'pathname' as a name that will work on the native filesystem,
i.e. split it on '/' and put it back together again using the current
directory separator. Needed because filenames in the setup script are
always supplied in Unix style, and have to be converted to the local
convention before we can ... | def convert_path (pathname):
"""Return 'pathname' as a name that will work on the native filesystem,
i.e. split it on '/' and put it back together again using the current
directory separator. Needed because filenames in the setup script are
always supplied in Unix style, and have to be converted to the... | [
"def",
"convert_path",
"(",
"pathname",
")",
":",
"if",
"os",
".",
"sep",
"==",
"'/'",
":",
"return",
"pathname",
"if",
"not",
"pathname",
":",
"return",
"pathname",
"if",
"pathname",
"[",
"0",
"]",
"==",
"'/'",
":",
"raise",
"ValueError",
"(",
"\"path... | [
110,
0
] | [
133,
31
] | python | en | ['en', 'en', 'en'] | True |
change_root | (new_root, pathname) | Return 'pathname' with 'new_root' prepended. If 'pathname' is
relative, this is equivalent to "os.path.join(new_root,pathname)".
Otherwise, it requires making 'pathname' relative and then joining the
two, which is tricky on DOS/Windows and Mac OS.
| Return 'pathname' with 'new_root' prepended. If 'pathname' is
relative, this is equivalent to "os.path.join(new_root,pathname)".
Otherwise, it requires making 'pathname' relative and then joining the
two, which is tricky on DOS/Windows and Mac OS.
| def change_root (new_root, pathname):
"""Return 'pathname' with 'new_root' prepended. If 'pathname' is
relative, this is equivalent to "os.path.join(new_root,pathname)".
Otherwise, it requires making 'pathname' relative and then joining the
two, which is tricky on DOS/Windows and Mac OS.
"""
if... | [
"def",
"change_root",
"(",
"new_root",
",",
"pathname",
")",
":",
"if",
"os",
".",
"name",
"==",
"'posix'",
":",
"if",
"not",
"os",
".",
"path",
".",
"isabs",
"(",
"pathname",
")",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"new_root",
","... | [
138,
0
] | [
157,
83
] | python | en | ['en', 'en', 'en'] | True |
check_environ | () | Ensure that 'os.environ' has all the environment variables we
guarantee that users can use in config files, command-line options,
etc. Currently this includes:
HOME - user's home directory (Unix only)
PLAT - description of the current platform, including hardware
and OS (see 'get_platf... | Ensure that 'os.environ' has all the environment variables we
guarantee that users can use in config files, command-line options,
etc. Currently this includes:
HOME - user's home directory (Unix only)
PLAT - description of the current platform, including hardware
and OS (see 'get_platf... | def check_environ ():
"""Ensure that 'os.environ' has all the environment variables we
guarantee that users can use in config files, command-line options,
etc. Currently this includes:
HOME - user's home directory (Unix only)
PLAT - description of the current platform, including hardware
... | [
"def",
"check_environ",
"(",
")",
":",
"global",
"_environ_checked",
"if",
"_environ_checked",
":",
"return",
"if",
"os",
".",
"name",
"==",
"'posix'",
"and",
"'HOME'",
"not",
"in",
"os",
".",
"environ",
":",
"try",
":",
"import",
"pwd",
"os",
".",
"envi... | [
161,
0
] | [
185,
24
] | python | en | ['en', 'en', 'en'] | True |
subst_vars | (s, local_vars) | Perform shell/Perl-style variable substitution on 'string'. Every
occurrence of '$' followed by a name is considered a variable, and
variable is substituted by the value found in the 'local_vars'
dictionary, or in 'os.environ' if it's not in 'local_vars'.
'os.environ' is first checked/augmented to guar... | Perform shell/Perl-style variable substitution on 'string'. Every
occurrence of '$' followed by a name is considered a variable, and
variable is substituted by the value found in the 'local_vars'
dictionary, or in 'os.environ' if it's not in 'local_vars'.
'os.environ' is first checked/augmented to guar... | def subst_vars (s, local_vars):
"""Perform shell/Perl-style variable substitution on 'string'. Every
occurrence of '$' followed by a name is considered a variable, and
variable is substituted by the value found in the 'local_vars'
dictionary, or in 'os.environ' if it's not in 'local_vars'.
'os.envi... | [
"def",
"subst_vars",
"(",
"s",
",",
"local_vars",
")",
":",
"check_environ",
"(",
")",
"def",
"_subst",
"(",
"match",
",",
"local_vars",
"=",
"local_vars",
")",
":",
"var_name",
"=",
"match",
".",
"group",
"(",
"1",
")",
"if",
"var_name",
"in",
"local_... | [
188,
0
] | [
208,
56
] | python | en | ['en', 'en', 'en'] | True |
split_quoted | (s) | Split a string up according to Unix shell-like rules for quotes and
backslashes. In short: words are delimited by spaces, as long as those
spaces are not escaped by a backslash, or inside a quoted string.
Single and double quotes are equivalent, and the quote characters can
be backslash-escaped. The b... | Split a string up according to Unix shell-like rules for quotes and
backslashes. In short: words are delimited by spaces, as long as those
spaces are not escaped by a backslash, or inside a quoted string.
Single and double quotes are equivalent, and the quote characters can
be backslash-escaped. The b... | def split_quoted (s):
"""Split a string up according to Unix shell-like rules for quotes and
backslashes. In short: words are delimited by spaces, as long as those
spaces are not escaped by a backslash, or inside a quoted string.
Single and double quotes are equivalent, and the quote characters can
... | [
"def",
"split_quoted",
"(",
"s",
")",
":",
"# This is a nice algorithm for splitting up a single string, since it",
"# doesn't require character-by-character examination. It was a little",
"# bit of a brain-bender to get it working right, though...",
"if",
"_wordchars_re",
"is",
"None",
"... | [
228,
0
] | [
284,
16
] | python | en | ['en', 'en', 'en'] | True |
execute | (func, args, msg=None, verbose=0, dry_run=0) | Perform some action that affects the outside world (eg. by
writing to the filesystem). Such actions are special because they
are disabled by the 'dry_run' flag. This method takes care of all
that bureaucracy for you; all you have to do is supply the
function to call and an argument tuple for it (to e... | Perform some action that affects the outside world (eg. by
writing to the filesystem). Such actions are special because they
are disabled by the 'dry_run' flag. This method takes care of all
that bureaucracy for you; all you have to do is supply the
function to call and an argument tuple for it (to e... | def execute (func, args, msg=None, verbose=0, dry_run=0):
"""Perform some action that affects the outside world (eg. by
writing to the filesystem). Such actions are special because they
are disabled by the 'dry_run' flag. This method takes care of all
that bureaucracy for you; all you have to do is s... | [
"def",
"execute",
"(",
"func",
",",
"args",
",",
"msg",
"=",
"None",
",",
"verbose",
"=",
"0",
",",
"dry_run",
"=",
"0",
")",
":",
"if",
"msg",
"is",
"None",
":",
"msg",
"=",
"\"%s%r\"",
"%",
"(",
"func",
".",
"__name__",
",",
"args",
")",
"if"... | [
289,
0
] | [
305,
19
] | python | en | ['en', 'en', 'en'] | True |
strtobool | (val) | Convert a string representation of truth to true (1) or false (0).
True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if
'val' is anything else.
| Convert a string representation of truth to true (1) or false (0). | def strtobool (val):
"""Convert a string representation of truth to true (1) or false (0).
True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if
'val' is anything else.
"""
val = val.lower()
if val in ('y', 'y... | [
"def",
"strtobool",
"(",
"val",
")",
":",
"val",
"=",
"val",
".",
"lower",
"(",
")",
"if",
"val",
"in",
"(",
"'y'",
",",
"'yes'",
",",
"'t'",
",",
"'true'",
",",
"'on'",
",",
"'1'",
")",
":",
"return",
"1",
"elif",
"val",
"in",
"(",
"'n'",
",... | [
308,
0
] | [
321,
59
] | python | en | ['en', 'pt', 'en'] | True |
byte_compile | (py_files,
optimize=0, force=0,
prefix=None, base_dir=None,
verbose=1, dry_run=0,
direct=None) | Byte-compile a collection of Python source files to .pyc
files in a __pycache__ subdirectory. 'py_files' is a list
of files to compile; any files that don't end in ".py" are silently
skipped. 'optimize' must be one of the following:
0 - don't optimize
1 - normal optimization (like "python -O")... | Byte-compile a collection of Python source files to .pyc
files in a __pycache__ subdirectory. 'py_files' is a list
of files to compile; any files that don't end in ".py" are silently
skipped. 'optimize' must be one of the following:
0 - don't optimize
1 - normal optimization (like "python -O")... | def byte_compile (py_files,
optimize=0, force=0,
prefix=None, base_dir=None,
verbose=1, dry_run=0,
direct=None):
"""Byte-compile a collection of Python source files to .pyc
files in a __pycache__ subdirectory. 'py_files' is a list
of f... | [
"def",
"byte_compile",
"(",
"py_files",
",",
"optimize",
"=",
"0",
",",
"force",
"=",
"0",
",",
"prefix",
"=",
"None",
",",
"base_dir",
"=",
"None",
",",
"verbose",
"=",
"1",
",",
"dry_run",
"=",
"0",
",",
"direct",
"=",
"None",
")",
":",
"# Late i... | [
324,
0
] | [
469,
47
] | python | en | ['en', 'en', 'en'] | True |
rfc822_escape | (header) | Return a version of the string escaped for inclusion in an
RFC-822 header, by ensuring there are 8 spaces space after each newline.
| Return a version of the string escaped for inclusion in an
RFC-822 header, by ensuring there are 8 spaces space after each newline.
| def rfc822_escape (header):
"""Return a version of the string escaped for inclusion in an
RFC-822 header, by ensuring there are 8 spaces space after each newline.
"""
lines = header.split('\n')
sep = '\n' + 8 * ' '
return sep.join(lines) | [
"def",
"rfc822_escape",
"(",
"header",
")",
":",
"lines",
"=",
"header",
".",
"split",
"(",
"'\\n'",
")",
"sep",
"=",
"'\\n'",
"+",
"8",
"*",
"' '",
"return",
"sep",
".",
"join",
"(",
"lines",
")"
] | [
473,
0
] | [
479,
26
] | python | en | ['en', 'en', 'en'] | True |
run_2to3 | (files, fixer_names=None, options=None, explicit=None) | Invoke 2to3 on a list of Python files.
The files should all come from the build area, as the
modification is done in-place. To reduce the build time,
only files modified since the last invocation of this
function should be passed in the files argument. | Invoke 2to3 on a list of Python files.
The files should all come from the build area, as the
modification is done in-place. To reduce the build time,
only files modified since the last invocation of this
function should be passed in the files argument. | def run_2to3(files, fixer_names=None, options=None, explicit=None):
"""Invoke 2to3 on a list of Python files.
The files should all come from the build area, as the
modification is done in-place. To reduce the build time,
only files modified since the last invocation of this
function should be passed... | [
"def",
"run_2to3",
"(",
"files",
",",
"fixer_names",
"=",
"None",
",",
"options",
"=",
"None",
",",
"explicit",
"=",
"None",
")",
":",
"if",
"not",
"files",
":",
"return",
"# Make this class local, to delay import of 2to3",
"from",
"lib2to3",
".",
"refactor",
... | [
483,
0
] | [
508,
33
] | python | en | ['en', 'haw', 'en'] | True |
copydir_run_2to3 | (src, dest, template=None, fixer_names=None,
options=None, explicit=None) | Recursively copy a directory, only copying new and changed files,
running run_2to3 over all newly copied Python modules afterward.
If you give a template string, it's parsed like a MANIFEST.in.
| Recursively copy a directory, only copying new and changed files,
running run_2to3 over all newly copied Python modules afterward. | def copydir_run_2to3(src, dest, template=None, fixer_names=None,
options=None, explicit=None):
"""Recursively copy a directory, only copying new and changed files,
running run_2to3 over all newly copied Python modules afterward.
If you give a template string, it's parsed like a MANIFES... | [
"def",
"copydir_run_2to3",
"(",
"src",
",",
"dest",
",",
"template",
"=",
"None",
",",
"fixer_names",
"=",
"None",
",",
"options",
"=",
"None",
",",
"explicit",
"=",
"None",
")",
":",
"from",
"distutils",
".",
"dir_util",
"import",
"mkpath",
"from",
"dis... | [
510,
0
] | [
541,
17
] | python | en | ['en', 'en', 'en'] | True |
check_emoji_admin | (user_profile: UserProfile, emoji_name: Optional[str] = None) | Raises an exception if the user cannot administer the target realm
emoji name in their organization. | Raises an exception if the user cannot administer the target realm
emoji name in their organization. | def check_emoji_admin(user_profile: UserProfile, emoji_name: Optional[str] = None) -> None:
"""Raises an exception if the user cannot administer the target realm
emoji name in their organization."""
# Realm administrators can always administer emoji
if user_profile.is_realm_admin:
return
if... | [
"def",
"check_emoji_admin",
"(",
"user_profile",
":",
"UserProfile",
",",
"emoji_name",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"None",
":",
"# Realm administrators can always administer emoji",
"if",
"user_profile",
".",
"is_realm_admin",
":",
"re... | [
87,
0
] | [
109,
87
] | python | en | ['en', 'en', 'en'] | True |
WebsocketClient._init_synchronization_primitives | (self) |
Used to initialise synchronization primitives that require
an event loop
|
Used to initialise synchronization primitives that require
an event loop
| async def _init_synchronization_primitives(self):
"""
Used to initialise synchronization primitives that require
an event loop
"""
self._recognition_started = asyncio.Event()
self._buffer_semaphore = asyncio.BoundedSemaphore(
self.connection_settings.message_b... | [
"async",
"def",
"_init_synchronization_primitives",
"(",
"self",
")",
":",
"self",
".",
"_recognition_started",
"=",
"asyncio",
".",
"Event",
"(",
")",
"self",
".",
"_buffer_semaphore",
"=",
"asyncio",
".",
"BoundedSemaphore",
"(",
"self",
".",
"connection_setting... | [
64,
4
] | [
72,
9
] | python | en | ['en', 'error', 'th'] | False |
WebsocketClient._flag_recognition_started | (self) |
Handle a
:py:attr:`speechmatics.models.ClientMessageType.SetRecognitionConfig`
message from the server.
This updates an internal flag to mark the recognition session
as started meaning, AddAudio is now allowed.
|
Handle a
:py:attr:`speechmatics.models.ClientMessageType.SetRecognitionConfig`
message from the server.
This updates an internal flag to mark the recognition session
as started meaning, AddAudio is now allowed.
| def _flag_recognition_started(self):
"""
Handle a
:py:attr:`speechmatics.models.ClientMessageType.SetRecognitionConfig`
message from the server.
This updates an internal flag to mark the recognition session
as started meaning, AddAudio is now allowed.
"""
... | [
"def",
"_flag_recognition_started",
"(",
"self",
")",
":",
"self",
".",
"_recognition_started",
".",
"set",
"(",
")"
] | [
74,
4
] | [
82,
39
] | python | en | ['en', 'error', 'th'] | False |
WebsocketClient._set_recognition_config | (self) |
Constructs a
:py:attr:`speechmatics.models.ClientMessageType.SetRecognitionConfig`
message.
|
Constructs a
:py:attr:`speechmatics.models.ClientMessageType.SetRecognitionConfig`
message.
| def _set_recognition_config(self):
"""
Constructs a
:py:attr:`speechmatics.models.ClientMessageType.SetRecognitionConfig`
message.
"""
msg = {
"message": ClientMessageType.SetRecognitionConfig,
"transcription_config": self.transcription_config.asdi... | [
"def",
"_set_recognition_config",
"(",
"self",
")",
":",
"msg",
"=",
"{",
"\"message\"",
":",
"ClientMessageType",
".",
"SetRecognitionConfig",
",",
"\"transcription_config\"",
":",
"self",
".",
"transcription_config",
".",
"asdict",
"(",
")",
",",
"}",
"call_midd... | [
85,
4
] | [
99,
18
] | python | en | ['en', 'error', 'th'] | False |
WebsocketClient._start_recognition | (self, audio_settings) |
Constructs a
:py:attr:`speechmatics.models.ClientMessageType.StartRecognition`
message.
This initiates the recognition session.
:param audio_settings: Audio settings to use.
:type audio_settings: speechmatics.models.AudioSettings
|
Constructs a
:py:attr:`speechmatics.models.ClientMessageType.StartRecognition`
message.
This initiates the recognition session. | def _start_recognition(self, audio_settings):
"""
Constructs a
:py:attr:`speechmatics.models.ClientMessageType.StartRecognition`
message.
This initiates the recognition session.
:param audio_settings: Audio settings to use.
:type audio_settings: speechmatics.mode... | [
"def",
"_start_recognition",
"(",
"self",
",",
"audio_settings",
")",
":",
"msg",
"=",
"{",
"\"message\"",
":",
"ClientMessageType",
".",
"StartRecognition",
",",
"\"audio_format\"",
":",
"audio_settings",
".",
"asdict",
"(",
")",
",",
"\"transcription_config\"",
... | [
102,
4
] | [
122,
18
] | python | en | ['en', 'error', 'th'] | False |
WebsocketClient._end_of_stream | (self) |
Constructs an
:py:attr:`speechmatics.models.ClientMessageType.EndOfStream`
message.
|
Constructs an
:py:attr:`speechmatics.models.ClientMessageType.EndOfStream`
message.
| def _end_of_stream(self):
"""
Constructs an
:py:attr:`speechmatics.models.ClientMessageType.EndOfStream`
message.
"""
msg = {
"message": ClientMessageType.EndOfStream,
"last_seq_no": self.seq_no
}
call_middleware(
self.m... | [
"def",
"_end_of_stream",
"(",
"self",
")",
":",
"msg",
"=",
"{",
"\"message\"",
":",
"ClientMessageType",
".",
"EndOfStream",
",",
"\"last_seq_no\"",
":",
"self",
".",
"seq_no",
"}",
"call_middleware",
"(",
"self",
".",
"middlewares",
",",
"ClientMessageType",
... | [
125,
4
] | [
138,
18
] | python | en | ['en', 'error', 'th'] | False |
WebsocketClient._consumer | (self, message) |
Consumes messages and acts on them.
:param message: Message received from the server.
:type message: str
:raises TranscriptionError: on an error message received from the
server.
:raises EndOfTranscriptException: on EndOfTranscription message.
|
Consumes messages and acts on them. | def _consumer(self, message):
"""
Consumes messages and acts on them.
:param message: Message received from the server.
:type message: str
:raises TranscriptionError: on an error message received from the
server.
:raises EndOfTranscriptException: on EndOfTra... | [
"def",
"_consumer",
"(",
"self",
",",
"message",
")",
":",
"LOGGER",
".",
"debug",
"(",
"message",
")",
"message",
"=",
"json",
".",
"loads",
"(",
"message",
")",
"message_type",
"=",
"message",
"[",
"\"message\"",
"]",
"for",
"handler",
"in",
"self",
... | [
140,
4
] | [
167,
55
] | python | en | ['en', 'error', 'th'] | False |
WebsocketClient._producer | (self, stream, audio_chunk_size) |
Yields messages to send to the server.
:param stream: File-like object which an audio stream can be read from.
:type stream: io.IOBase
:param audio_chunk_size: Size of audio chunks to send.
:type audio_chunk_size: int
|
Yields messages to send to the server. | async def _producer(self, stream, audio_chunk_size):
"""
Yields messages to send to the server.
:param stream: File-like object which an audio stream can be read from.
:type stream: io.IOBase
:param audio_chunk_size: Size of audio chunks to send.
:type audio_chunk_size:... | [
"async",
"def",
"_producer",
"(",
"self",
",",
"stream",
",",
"audio_chunk_size",
")",
":",
"async",
"for",
"audio_chunk",
"in",
"read_in_chunks",
"(",
"stream",
",",
"audio_chunk_size",
")",
":",
"if",
"self",
".",
"_session_needs_closing",
":",
"break",
"if"... | [
169,
4
] | [
197,
35
] | python | en | ['en', 'error', 'th'] | False |
WebsocketClient._consumer_handler | (self) |
Controls the consumer loop for handling messages from the server.
|
Controls the consumer loop for handling messages from the server.
| async def _consumer_handler(self):
"""
Controls the consumer loop for handling messages from the server.
"""
while self.session_running:
message = await self.websocket.recv()
self._consumer(message) | [
"async",
"def",
"_consumer_handler",
"(",
"self",
")",
":",
"while",
"self",
".",
"session_running",
":",
"message",
"=",
"await",
"self",
".",
"websocket",
".",
"recv",
"(",
")",
"self",
".",
"_consumer",
"(",
"message",
")"
] | [
199,
4
] | [
205,
35
] | python | en | ['en', 'error', 'th'] | False |
WebsocketClient._producer_handler | (self, stream, audio_chunk_size) |
Controls the producer loop for sending messages to the server.
|
Controls the producer loop for sending messages to the server.
| async def _producer_handler(self, stream, audio_chunk_size):
"""
Controls the producer loop for sending messages to the server.
"""
await self._recognition_started.wait()
async for message in self._producer(stream, audio_chunk_size):
await self.websocket.send(message) | [
"async",
"def",
"_producer_handler",
"(",
"self",
",",
"stream",
",",
"audio_chunk_size",
")",
":",
"await",
"self",
".",
"_recognition_started",
".",
"wait",
"(",
")",
"async",
"for",
"message",
"in",
"self",
".",
"_producer",
"(",
"stream",
",",
"audio_chu... | [
207,
4
] | [
213,
46
] | python | en | ['en', 'error', 'th'] | False |
WebsocketClient.update_transcription_config | (self, new_transcription_config) |
Updates the transcription config used for the session.
This results in a SetRecognitionConfig message sent to the server.
:param new_transcription_config: The new config object.
:type new_transcription_config: speechmatics.models.TranscriptionConfig
|
Updates the transcription config used for the session.
This results in a SetRecognitionConfig message sent to the server. | def update_transcription_config(self, new_transcription_config):
"""
Updates the transcription config used for the session.
This results in a SetRecognitionConfig message sent to the server.
:param new_transcription_config: The new config object.
:type new_transcription_config: ... | [
"def",
"update_transcription_config",
"(",
"self",
",",
"new_transcription_config",
")",
":",
"if",
"new_transcription_config",
"!=",
"self",
".",
"transcription_config",
":",
"self",
".",
"transcription_config",
"=",
"new_transcription_config",
"self",
".",
"_transcripti... | [
215,
4
] | [
225,
58
] | python | en | ['en', 'error', 'th'] | False |
WebsocketClient.add_event_handler | (self, event_name, event_handler) |
Add an event handler (callback function) to handle an incoming
message from the server. Event handlers are passed a copy of the
incoming message from the server. If `event_name` is set to 'all' then
the handler will be added for every event.
For example, a simple handler that j... |
Add an event handler (callback function) to handle an incoming
message from the server. Event handlers are passed a copy of the
incoming message from the server. If `event_name` is set to 'all' then
the handler will be added for every event. | def add_event_handler(self, event_name, event_handler):
"""
Add an event handler (callback function) to handle an incoming
message from the server. Event handlers are passed a copy of the
incoming message from the server. If `event_name` is set to 'all' then
the handler will be a... | [
"def",
"add_event_handler",
"(",
"self",
",",
"event_name",
",",
"event_handler",
")",
":",
"if",
"event_name",
"==",
"\"all\"",
":",
"for",
"name",
"in",
"self",
".",
"event_handlers",
".",
"keys",
"(",
")",
":",
"self",
".",
"event_handlers",
"[",
"name"... | [
227,
4
] | [
264,
65
] | python | en | ['en', 'error', 'th'] | False |
WebsocketClient.add_middleware | (self, event_name, middleware) |
Add a middleware to handle outgoing messages sent to the server.
Middlewares are passed a reference to the outgoing message, which
they may alter.
If `event_name` is set to 'all' then the handler will be added for
every event.
:param event_name: The name of the message ... |
Add a middleware to handle outgoing messages sent to the server.
Middlewares are passed a reference to the outgoing message, which
they may alter.
If `event_name` is set to 'all' then the handler will be added for
every event. | def add_middleware(self, event_name, middleware):
"""
Add a middleware to handle outgoing messages sent to the server.
Middlewares are passed a reference to the outgoing message, which
they may alter.
If `event_name` is set to 'all' then the handler will be added for
ever... | [
"def",
"add_middleware",
"(",
"self",
",",
"event_name",
",",
"middleware",
")",
":",
"if",
"event_name",
"==",
"\"all\"",
":",
"for",
"name",
"in",
"self",
".",
"middlewares",
".",
"keys",
"(",
")",
":",
"self",
".",
"middlewares",
"[",
"name",
"]",
"... | [
266,
4
] | [
299,
59
] | python | en | ['en', 'error', 'th'] | False |
WebsocketClient.run | (self, stream, transcription_config, audio_settings) |
Begin a new recognition session.
This will run asynchronously. Most callers may prefer to use
:py:meth:`run_synchronously` which will block until the session is
finished.
:param stream: File-like object which an audio stream can be read from.
:type stream: io.IOBase
... |
Begin a new recognition session.
This will run asynchronously. Most callers may prefer to use
:py:meth:`run_synchronously` which will block until the session is
finished. | async def run(self, stream, transcription_config, audio_settings):
"""
Begin a new recognition session.
This will run asynchronously. Most callers may prefer to use
:py:meth:`run_synchronously` which will block until the session is
finished.
:param stream: File-like obje... | [
"async",
"def",
"run",
"(",
"self",
",",
"stream",
",",
"transcription_config",
",",
"audio_settings",
")",
":",
"self",
".",
"transcription_config",
"=",
"transcription_config",
"self",
".",
"seq_no",
"=",
"0",
"await",
"self",
".",
"_init_synchronization_primiti... | [
301,
4
] | [
373,
29
] | python | en | ['en', 'error', 'th'] | False |
WebsocketClient.stop | (self) |
Indicates that the recognition session should be forcefully stopped.
Only used in conjunction with `run`.
You probably don't need to call this if you're running the client via
:py:meth:`run_synchronously`.
|
Indicates that the recognition session should be forcefully stopped.
Only used in conjunction with `run`.
You probably don't need to call this if you're running the client via
:py:meth:`run_synchronously`.
| def stop(self):
"""
Indicates that the recognition session should be forcefully stopped.
Only used in conjunction with `run`.
You probably don't need to call this if you're running the client via
:py:meth:`run_synchronously`.
"""
self._session_needs_closing = True | [
"def",
"stop",
"(",
"self",
")",
":",
"self",
".",
"_session_needs_closing",
"=",
"True"
] | [
375,
4
] | [
382,
42
] | python | en | ['en', 'error', 'th'] | False |
WebsocketClient.run_synchronously | (self, *args, timeout=None, **kwargs) |
Run the transcription synchronously.
|
Run the transcription synchronously.
| def run_synchronously(self, *args, timeout=None, **kwargs):
"""
Run the transcription synchronously.
"""
# pylint: disable=no-value-for-parameter
asyncio.run(
asyncio.wait_for(self.run(*args, **kwargs), timeout=timeout)) | [
"def",
"run_synchronously",
"(",
"self",
",",
"*",
"args",
",",
"timeout",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# pylint: disable=no-value-for-parameter",
"asyncio",
".",
"run",
"(",
"asyncio",
".",
"wait_for",
"(",
"self",
".",
"run",
"(",
"*"... | [
384,
4
] | [
390,
73
] | python | en | ['en', 'error', 'th'] | False |
AnalyzeQueueStatsTests.test_queue_stuck | (self) | Last update > 5 minutes ago and there's events in the queue. | Last update > 5 minutes ago and there's events in the queue. | def test_queue_stuck(self) -> None:
"""Last update > 5 minutes ago and there's events in the queue."""
result = analyze_queue_stats("name", {"update_time": time.time() - 301}, 100)
self.assertEqual(result["status"], CRITICAL)
self.assertIn("queue appears to be stuck", result["message"]) | [
"def",
"test_queue_stuck",
"(",
"self",
")",
"->",
"None",
":",
"result",
"=",
"analyze_queue_stats",
"(",
"\"name\"",
",",
"{",
"\"update_time\"",
":",
"time",
".",
"time",
"(",
")",
"-",
"301",
"}",
",",
"100",
")",
"self",
".",
"assertEqual",
"(",
"... | [
11,
4
] | [
16,
69
] | python | en | ['en', 'en', 'en'] | True |
AnalyzeQueueStatsTests.test_queue_just_started | (self) |
We just started processing a burst of events, and haven't processed enough
to log productivity statistics yet.
|
We just started processing a burst of events, and haven't processed enough
to log productivity statistics yet.
| def test_queue_just_started(self) -> None:
"""
We just started processing a burst of events, and haven't processed enough
to log productivity statistics yet.
"""
result = analyze_queue_stats(
"name",
{
"update_time": time.time(),
... | [
"def",
"test_queue_just_started",
"(",
"self",
")",
"->",
"None",
":",
"result",
"=",
"analyze_queue_stats",
"(",
"\"name\"",
",",
"{",
"\"update_time\"",
":",
"time",
".",
"time",
"(",
")",
",",
"\"current_queue_size\"",
":",
"10000",
",",
"\"recent_average_con... | [
18,
4
] | [
32,
46
] | python | en | ['en', 'error', 'th'] | False |
AnalyzeQueueStatsTests.test_queue_normal | (self) | 10000 events and each takes a second => it'll take a long time to empty. | 10000 events and each takes a second => it'll take a long time to empty. | def test_queue_normal(self) -> None:
"""10000 events and each takes a second => it'll take a long time to empty."""
result = analyze_queue_stats(
"name",
{
"update_time": time.time(),
"current_queue_size": 10000,
"queue_last_emptied... | [
"def",
"test_queue_normal",
"(",
"self",
")",
"->",
"None",
":",
"result",
"=",
"analyze_queue_stats",
"(",
"\"name\"",
",",
"{",
"\"update_time\"",
":",
"time",
".",
"time",
"(",
")",
",",
"\"current_queue_size\"",
":",
"10000",
",",
"\"queue_last_emptied_times... | [
34,
4
] | [
87,
50
] | python | en | ['en', 'en', 'en'] | True |
TestHostAggregates.test_host_aggregate_create | (self) | tests the host aggregate creation and deletion functionalities:
* creates a new host aggregate
* verifies the host aggregate appears in the host aggregates table
* deletes the newly created host aggregate
* verifies the host aggregate does not appear in the table
* after deletio... | tests the host aggregate creation and deletion functionalities: | def test_host_aggregate_create(self):
"""tests the host aggregate creation and deletion functionalities:
* creates a new host aggregate
* verifies the host aggregate appears in the host aggregates table
* deletes the newly created host aggregate
* verifies the host aggregate doe... | [
"def",
"test_host_aggregate_create",
"(",
"self",
")",
":",
"hostaggregates_page",
"=",
"self",
".",
"home_pg",
".",
"go_to_admin_compute_hostaggregatespage",
"(",
")",
"hostaggregates_page",
".",
"create_host_aggregate",
"(",
"name",
"=",
"self",
".",
"HOST_AGGREGATE_N... | [
20,
4
] | [
49,
38
] | python | en | ['en', 'en', 'en'] | True |
HeaderIdProcessor._get_meta | (self) | Return meta data suported by this ext as a tuple | Return meta data suported by this ext as a tuple | def _get_meta(self):
""" Return meta data suported by this ext as a tuple """
level = int(self.config['level'][0]) - 1
force = self._str2bool(self.config['forceid'][0])
if hasattr(self.md, 'Meta'):
if self.md.Meta.has_key('header_level'):
level = int(self.md.M... | [
"def",
"_get_meta",
"(",
"self",
")",
":",
"level",
"=",
"int",
"(",
"self",
".",
"config",
"[",
"'level'",
"]",
"[",
"0",
"]",
")",
"-",
"1",
"force",
"=",
"self",
".",
"_str2bool",
"(",
"self",
".",
"config",
"[",
"'forceid'",
"]",
"[",
"0",
... | [
123,
4
] | [
132,
27
] | python | en | ['en', 'en', 'en'] | True |
HeaderIdProcessor._str2bool | (self, s, default=False) | Convert a string to a booleen value. | Convert a string to a booleen value. | def _str2bool(self, s, default=False):
""" Convert a string to a booleen value. """
s = str(s)
if s.lower() in ['0', 'f', 'false', 'off', 'no', 'n']:
return False
elif s.lower() in ['1', 't', 'true', 'on', 'yes', 'y']:
return True
return default | [
"def",
"_str2bool",
"(",
"self",
",",
"s",
",",
"default",
"=",
"False",
")",
":",
"s",
"=",
"str",
"(",
"s",
")",
"if",
"s",
".",
"lower",
"(",
")",
"in",
"[",
"'0'",
",",
"'f'",
",",
"'false'",
",",
"'off'",
",",
"'no'",
",",
"'n'",
"]",
... | [
134,
4
] | [
141,
22
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.