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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
test_expect_column_values_to_be_in_type_list | (spark_session, test_dataframe) |
data asset expectation
|
data asset expectation
| def test_expect_column_values_to_be_in_type_list(spark_session, test_dataframe):
"""
data asset expectation
"""
from pyspark.sql.utils import AnalysisException
assert test_dataframe.expect_column_values_to_be_in_type_list(
"address.street", ["StringType", "IntegerType"]
).success
as... | [
"def",
"test_expect_column_values_to_be_in_type_list",
"(",
"spark_session",
",",
"test_dataframe",
")",
":",
"from",
"pyspark",
".",
"sql",
".",
"utils",
"import",
"AnalysisException",
"assert",
"test_dataframe",
".",
"expect_column_values_to_be_in_type_list",
"(",
"\"addr... | [
168,
0
] | [
184,
85
] | python | en | ['en', 'error', 'th'] | False |
test_expect_column_pair_values_to_be_equal | (spark_session, test_dataframe) |
column_pair_map_expectation
|
column_pair_map_expectation
| def test_expect_column_pair_values_to_be_equal(spark_session, test_dataframe):
"""
column_pair_map_expectation
"""
from pyspark.sql.utils import AnalysisException
assert test_dataframe.expect_column_pair_values_to_be_equal(
"name", "name_duplicate"
).success
assert not test_datafram... | [
"def",
"test_expect_column_pair_values_to_be_equal",
"(",
"spark_session",
",",
"test_dataframe",
")",
":",
"from",
"pyspark",
".",
"sql",
".",
"utils",
"import",
"AnalysisException",
"assert",
"test_dataframe",
".",
"expect_column_pair_values_to_be_equal",
"(",
"\"name\"",... | [
191,
0
] | [
209,
82
] | python | en | ['en', 'error', 'th'] | False |
test_expect_column_pair_values_A_to_be_greater_than_B | (
spark_session, test_dataframe
) |
column_pair_map_expectation
|
column_pair_map_expectation
| def test_expect_column_pair_values_A_to_be_greater_than_B(
spark_session, test_dataframe
):
"""
column_pair_map_expectation
"""
assert test_dataframe.expect_column_pair_values_A_to_be_greater_than_B(
"address.house_number", "age"
).success
assert test_dataframe.expect_column_pair_val... | [
"def",
"test_expect_column_pair_values_A_to_be_greater_than_B",
"(",
"spark_session",
",",
"test_dataframe",
")",
":",
"assert",
"test_dataframe",
".",
"expect_column_pair_values_A_to_be_greater_than_B",
"(",
"\"address.house_number\"",
",",
"\"age\"",
")",
".",
"success",
"ass... | [
216,
0
] | [
227,
13
] | python | en | ['en', 'error', 'th'] | False |
test_expect_select_column_values_to_be_unique_within_record | (
spark_session, test_dataframe
) |
multicolumn_map_expectation
|
multicolumn_map_expectation
| def test_expect_select_column_values_to_be_unique_within_record(
spark_session, test_dataframe
):
"""
multicolumn_map_expectation
"""
from pyspark.sql.utils import AnalysisException
assert test_dataframe.expect_select_column_values_to_be_unique_within_record(
["name", "age"]
).succe... | [
"def",
"test_expect_select_column_values_to_be_unique_within_record",
"(",
"spark_session",
",",
"test_dataframe",
")",
":",
"from",
"pyspark",
".",
"sql",
".",
"utils",
"import",
"AnalysisException",
"assert",
"test_dataframe",
".",
"expect_select_column_values_to_be_unique_wi... | [
234,
0
] | [
256,
9
] | python | en | ['en', 'error', 'th'] | False |
test_expect_compound_columns_to_be_unique | (spark_session, test_dataframe) |
multicolumn_map_expectation
|
multicolumn_map_expectation
| def test_expect_compound_columns_to_be_unique(spark_session, test_dataframe):
"""
multicolumn_map_expectation
"""
from pyspark.sql.utils import AnalysisException
# Positive tests
assert test_dataframe.expect_compound_columns_to_be_unique(["name", "age"]).success
assert test_dataframe.expect... | [
"def",
"test_expect_compound_columns_to_be_unique",
"(",
"spark_session",
",",
"test_dataframe",
")",
":",
"from",
"pyspark",
".",
"sql",
".",
"utils",
"import",
"AnalysisException",
"# Positive tests",
"assert",
"test_dataframe",
".",
"expect_compound_columns_to_be_unique",
... | [
263,
0
] | [
318,
9
] | python | en | ['en', 'error', 'th'] | False |
test_expect_column_values_to_be_unique | (spark_session, test_dataframe) |
column_map_expectation
|
column_map_expectation
| def test_expect_column_values_to_be_unique(spark_session, test_dataframe):
"""
column_map_expectation
"""
from pyspark.sql.utils import AnalysisException
assert test_dataframe.expect_column_values_to_be_unique("name").success
assert not test_dataframe.expect_column_values_to_be_unique("address.... | [
"def",
"test_expect_column_values_to_be_unique",
"(",
"spark_session",
",",
"test_dataframe",
")",
":",
"from",
"pyspark",
".",
"sql",
".",
"utils",
"import",
"AnalysisException",
"assert",
"test_dataframe",
".",
"expect_column_values_to_be_unique",
"(",
"\"name\"",
")",
... | [
325,
0
] | [
337,
70
] | python | en | ['en', 'error', 'th'] | False |
test_expect_column_value_lengths_to_be_between | (spark_session, test_dataframe) |
column_map_expectation
|
column_map_expectation
| def test_expect_column_value_lengths_to_be_between(spark_session, test_dataframe):
"""
column_map_expectation
"""
assert test_dataframe.expect_column_value_lengths_to_be_between(
"name", 3, 7
).success
assert test_dataframe.expect_column_value_lengths_to_be_between(
"address.stre... | [
"def",
"test_expect_column_value_lengths_to_be_between",
"(",
"spark_session",
",",
"test_dataframe",
")",
":",
"assert",
"test_dataframe",
".",
"expect_column_value_lengths_to_be_between",
"(",
"\"name\"",
",",
"3",
",",
"7",
")",
".",
"success",
"assert",
"test_datafram... | [
344,
0
] | [
353,
13
] | python | en | ['en', 'error', 'th'] | False |
test_expect_column_value_lengths_to_equal | (spark_session, test_dataframe) |
column_map_expectation
|
column_map_expectation
| def test_expect_column_value_lengths_to_equal(spark_session, test_dataframe):
"""
column_map_expectation
"""
assert test_dataframe.expect_column_value_lengths_to_equal("age", 1).success
assert test_dataframe.expect_column_value_lengths_to_equal(
"address.street", 8
).success | [
"def",
"test_expect_column_value_lengths_to_equal",
"(",
"spark_session",
",",
"test_dataframe",
")",
":",
"assert",
"test_dataframe",
".",
"expect_column_value_lengths_to_equal",
"(",
"\"age\"",
",",
"1",
")",
".",
"success",
"assert",
"test_dataframe",
".",
"expect_colu... | [
360,
0
] | [
367,
13
] | python | en | ['en', 'error', 'th'] | False |
BaseTranslator.translate | (
self,
query: Optional[str] = None,
documents: Optional[Union[List[Document], List[str], List[Dict[str, Any]]]] = None,
dict_key: Optional[str] = None,
**kwargs
) |
Translate the passed query or a list of documents from language A to B.
|
Translate the passed query or a list of documents from language A to B.
| def translate(
self,
query: Optional[str] = None,
documents: Optional[Union[List[Document], List[str], List[Dict[str, Any]]]] = None,
dict_key: Optional[str] = None,
**kwargs
) -> Union[str, List[Document], List[str], List[Dict[str, Any]]]:
"""
Translate the p... | [
"def",
"translate",
"(",
"self",
",",
"query",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"documents",
":",
"Optional",
"[",
"Union",
"[",
"List",
"[",
"Document",
"]",
",",
"List",
"[",
"str",
"]",
",",
"List",
"[",
"Dict",
"[",
"str",
... | [
14,
4
] | [
24,
12
] | python | en | ['en', 'error', 'th'] | False |
BaseTranslator.run | (
self,
query: Optional[str] = None,
documents: Optional[Union[List[Document], List[str], List[Dict[str, Any]]]] = None,
answers: Optional[Union[Dict[str, Any], List[Dict[str, Any]]]] = None,
dict_key: Optional[str] = None,
**kwargs
) | Method that gets executed when this class is used as a Node in a Haystack Pipeline | Method that gets executed when this class is used as a Node in a Haystack Pipeline | def run(
self,
query: Optional[str] = None,
documents: Optional[Union[List[Document], List[str], List[Dict[str, Any]]]] = None,
answers: Optional[Union[Dict[str, Any], List[Dict[str, Any]]]] = None,
dict_key: Optional[str] = None,
**kwargs
):
"""Method that ge... | [
"def",
"run",
"(",
"self",
",",
"query",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"documents",
":",
"Optional",
"[",
"Union",
"[",
"List",
"[",
"Document",
"]",
",",
"List",
"[",
"str",
"]",
",",
"List",
"[",
"Dict",
"[",
"str",
",",
... | [
26,
4
] | [
57,
34
] | python | en | ['en', 'en', 'en'] | True |
pytest_addoption | (parser) |
This parser plugin includes the following command-line options for pytest:
--browser=BROWSER (The web browser to use.)
--cap-file=FILE (The web browser's desired capabilities to use.)
--cap-string=STRING (The web browser's desired capabilities to use.)
--settings-file=FILE (Overrides SeleniumBa... |
This parser plugin includes the following command-line options for pytest:
--browser=BROWSER (The web browser to use.)
--cap-file=FILE (The web browser's desired capabilities to use.)
--cap-string=STRING (The web browser's desired capabilities to use.)
--settings-file=FILE (Overrides SeleniumBa... | def pytest_addoption(parser):
"""
This parser plugin includes the following command-line options for pytest:
--browser=BROWSER (The web browser to use.)
--cap-file=FILE (The web browser's desired capabilities to use.)
--cap-string=STRING (The web browser's desired capabilities to use.)
--sett... | [
"def",
"pytest_addoption",
"(",
"parser",
")",
":",
"parser",
"=",
"parser",
".",
"getgroup",
"(",
"'SeleniumBase'",
",",
"'SeleniumBase specific configuration options'",
")",
"parser",
".",
"addoption",
"(",
"'--browser'",
",",
"action",
"=",
"\"store\"",
",",
"d... | [
11,
0
] | [
433,
70
] | python | en | ['en', 'error', 'th'] | False |
pytest_configure | (config) | This runs after command line options have been parsed | This runs after command line options have been parsed | def pytest_configure(config):
""" This runs after command line options have been parsed """
sb_config.is_pytest = True
sb_config.browser = config.getoption('browser')
sb_config.data = config.getoption('data')
sb_config.var1 = config.getoption('var1')
sb_config.var2 = config.getoption('var2')
... | [
"def",
"pytest_configure",
"(",
"config",
")",
":",
"sb_config",
".",
"is_pytest",
"=",
"True",
"sb_config",
".",
"browser",
"=",
"config",
".",
"getoption",
"(",
"'browser'",
")",
"sb_config",
".",
"data",
"=",
"config",
".",
"getoption",
"(",
"'data'",
"... | [
436,
0
] | [
514,
46
] | python | en | ['en', 'en', 'en'] | True |
pytest_unconfigure | () | This runs after all tests have completed with pytest. | This runs after all tests have completed with pytest. | def pytest_unconfigure():
""" This runs after all tests have completed with pytest. """
proxy_helper.remove_proxy_zip_if_present()
if sb_config.reuse_session:
# Close the shared browser session
if sb_config.shared_driver:
try:
sb_config.shared_driver.quit()
... | [
"def",
"pytest_unconfigure",
"(",
")",
":",
"proxy_helper",
".",
"remove_proxy_zip_if_present",
"(",
")",
"if",
"sb_config",
".",
"reuse_session",
":",
"# Close the shared browser session",
"if",
"sb_config",
".",
"shared_driver",
":",
"try",
":",
"sb_config",
".",
... | [
517,
0
] | [
530,
78
] | python | en | ['en', 'en', 'en'] | True |
pytest_runtest_setup | () | This runs before every test with pytest | This runs before every test with pytest | def pytest_runtest_setup():
""" This runs before every test with pytest """
pass | [
"def",
"pytest_runtest_setup",
"(",
")",
":",
"pass"
] | [
533,
0
] | [
535,
8
] | python | en | ['en', 'en', 'en'] | True |
pytest_runtest_teardown | (item) | This runs after every test with pytest | This runs after every test with pytest | def pytest_runtest_teardown(item):
""" This runs after every test with pytest """
# Make sure webdriver has exited properly and any headless display
try:
self = item._testcase
try:
if hasattr(self, 'driver') and self.driver:
self.driver.quit()
except Exce... | [
"def",
"pytest_runtest_teardown",
"(",
"item",
")",
":",
"# Make sure webdriver has exited properly and any headless display",
"try",
":",
"self",
"=",
"item",
".",
"_testcase",
"try",
":",
"if",
"hasattr",
"(",
"self",
",",
"'driver'",
")",
"and",
"self",
".",
"d... | [
538,
0
] | [
557,
12
] | python | en | ['en', 'en', 'en'] | True |
sb | (request) | SeleniumBase as a pytest fixture.
Usage example: "def test_one(sb):"
You'll need to use this for tests that use other pytest fixtures. | SeleniumBase as a pytest fixture.
Usage example: "def test_one(sb):"
You'll need to use this for tests that use other pytest fixtures. | def sb(request):
""" SeleniumBase as a pytest fixture.
Usage example: "def test_one(sb):"
You'll need to use this for tests that use other pytest fixtures. """
from seleniumbase import BaseCase
class BaseClass(BaseCase):
def base_method():
pass
if request.cls:
... | [
"def",
"sb",
"(",
"request",
")",
":",
"from",
"seleniumbase",
"import",
"BaseCase",
"class",
"BaseClass",
"(",
"BaseCase",
")",
":",
"def",
"base_method",
"(",
")",
":",
"pass",
"if",
"request",
".",
"cls",
":",
"request",
".",
"cls",
".",
"sb",
"=",
... | [
561,
0
] | [
580,
21
] | python | en | ['en', 'hu', 'en'] | True |
get_all_styles | () | Return an generator for all styles by name,
both builtin and plugin. | Return an generator for all styles by name,
both builtin and plugin. | def get_all_styles():
"""Return an generator for all styles by name,
both builtin and plugin."""
for name in STYLE_MAP:
yield name
for name, _ in find_plugin_styles():
yield name | [
"def",
"get_all_styles",
"(",
")",
":",
"for",
"name",
"in",
"STYLE_MAP",
":",
"yield",
"name",
"for",
"name",
",",
"_",
"in",
"find_plugin_styles",
"(",
")",
":",
"yield",
"name"
] | [
70,
0
] | [
76,
18
] | python | en | ['en', 'en', 'en'] | True |
is_function | (node) | Check if the AST node is either a function
or an async function
| Check if the AST node is either a function
or an async function
| def is_function(node):
"""Check if the AST node is either a function
or an async function
"""
if isinstance(node, ast.FunctionDef) or isinstance(node, ast.AsyncFunctionDef):
return True
return False | [
"def",
"is_function",
"(",
"node",
")",
":",
"if",
"isinstance",
"(",
"node",
",",
"ast",
".",
"FunctionDef",
")",
"or",
"isinstance",
"(",
"node",
",",
"ast",
".",
"AsyncFunctionDef",
")",
":",
"return",
"True",
"return",
"False"
] | [
38,
0
] | [
44,
16
] | python | en | ['en', 'en', 'en'] | True |
is_public | (node) | Check if the AST node has a _public decorator | Check if the AST node has a _public decorator | def is_public(node):
"""Check if the AST node has a _public decorator"""
if not is_function(node):
return False
for decorator in node.decorator_list:
if isinstance(decorator, ast.Name) and decorator.id == "_public":
return True
return False | [
"def",
"is_public",
"(",
"node",
")",
":",
"if",
"not",
"is_function",
"(",
"node",
")",
":",
"return",
"False",
"for",
"decorator",
"in",
"node",
".",
"decorator_list",
":",
"if",
"isinstance",
"(",
"decorator",
",",
"ast",
".",
"Name",
")",
"and",
"d... | [
47,
0
] | [
54,
16
] | python | en | ['en', 'en', 'en'] | True |
get_public_methods | (tree) | Return a list of methods marked as public.
The function walks the given tree and extracts
all objects that are functions which are marked
public.
| Return a list of methods marked as public.
The function walks the given tree and extracts
all objects that are functions which are marked
public.
| def get_public_methods(tree):
"""Return a list of methods marked as public.
The function walks the given tree and extracts
all objects that are functions which are marked
public.
"""
for node in ast.walk(tree):
if is_public(node):
yield node | [
"def",
"get_public_methods",
"(",
"tree",
")",
":",
"for",
"node",
"in",
"ast",
".",
"walk",
"(",
"tree",
")",
":",
"if",
"is_public",
"(",
"node",
")",
":",
"yield",
"node"
] | [
57,
0
] | [
65,
22
] | python | en | ['en', 'en', 'en'] | True |
create_passthrough_args | (funcdef) | Given a function definition, create a string that represents taking all
the arguments from the function, and passing them through to another
invocation of the same function.
Example input: ast.parse("def f(a, *, b): ...")
Example output: "(a, b=b)"
| Given a function definition, create a string that represents taking all
the arguments from the function, and passing them through to another
invocation of the same function. | def create_passthrough_args(funcdef):
"""Given a function definition, create a string that represents taking all
the arguments from the function, and passing them through to another
invocation of the same function.
Example input: ast.parse("def f(a, *, b): ...")
Example output: "(a, b=b)"
"""
... | [
"def",
"create_passthrough_args",
"(",
"funcdef",
")",
":",
"call_args",
"=",
"[",
"]",
"for",
"arg",
"in",
"funcdef",
".",
"args",
".",
"args",
":",
"call_args",
".",
"append",
"(",
"arg",
".",
"arg",
")",
"if",
"funcdef",
".",
"args",
".",
"vararg",
... | [
68,
0
] | [
85,
46
] | python | en | ['en', 'en', 'en'] | True |
gen_public_wrappers_source | (source_path: Path, lookup_path: str) | Scan the given .py file for @_public decorators, and generate wrapper
functions.
| Scan the given .py file for @_public decorators, and generate wrapper
functions. | def gen_public_wrappers_source(source_path: Path, lookup_path: str) -> str:
"""Scan the given .py file for @_public decorators, and generate wrapper
functions.
"""
generated = [HEADER]
source = astor.code_to_ast.parse_file(source_path)
for method in get_public_methods(source):
# Remove ... | [
"def",
"gen_public_wrappers_source",
"(",
"source_path",
":",
"Path",
",",
"lookup_path",
":",
"str",
")",
"->",
"str",
":",
"generated",
"=",
"[",
"HEADER",
"]",
"source",
"=",
"astor",
".",
"code_to_ast",
".",
"parse_file",
"(",
"source_path",
")",
"for",
... | [
88,
0
] | [
129,
33
] | python | en | ['en', 'en', 'en'] | True |
is_installed | () |
Return whether or not xauth is installed.
|
Return whether or not xauth is installed.
| def is_installed():
'''
Return whether or not xauth is installed.
'''
try:
p = EasyProcess(['xauth', '-V'])
p.enable_stdout_log = False
p.enable_stderr_log = False
p.call()
except Exception:
return False
else:
return True | [
"def",
"is_installed",
"(",
")",
":",
"try",
":",
"p",
"=",
"EasyProcess",
"(",
"[",
"'xauth'",
",",
"'-V'",
"]",
")",
"p",
".",
"enable_stdout_log",
"=",
"False",
"p",
".",
"enable_stderr_log",
"=",
"False",
"p",
".",
"call",
"(",
")",
"except",
"Ex... | [
11,
0
] | [
23,
19
] | python | en | ['en', 'error', 'th'] | False |
generate_mcookie | () |
Generate a cookie string suitable for xauth.
|
Generate a cookie string suitable for xauth.
| def generate_mcookie():
'''
Generate a cookie string suitable for xauth.
'''
data = os.urandom(16) # 16 bytes = 128 bit
return hashlib.md5(data).hexdigest() | [
"def",
"generate_mcookie",
"(",
")",
":",
"data",
"=",
"os",
".",
"urandom",
"(",
"16",
")",
"# 16 bytes = 128 bit",
"return",
"hashlib",
".",
"md5",
"(",
"data",
")",
".",
"hexdigest",
"(",
")"
] | [
26,
0
] | [
31,
40
] | python | en | ['en', 'error', 'th'] | False |
call | (*args) |
Call xauth with the given args.
|
Call xauth with the given args.
| def call(*args):
'''
Call xauth with the given args.
'''
EasyProcess(['xauth'] + list(args)).call() | [
"def",
"call",
"(",
"*",
"args",
")",
":",
"EasyProcess",
"(",
"[",
"'xauth'",
"]",
"+",
"list",
"(",
"args",
")",
")",
".",
"call",
"(",
")"
] | [
34,
0
] | [
38,
46
] | python | en | ['en', 'error', 'th'] | False |
CheckpointStore.ge_cloud_response_json_to_object_dict | (self, response_json: Dict) |
This method takes full json response from GE cloud and outputs a dict appropriate for
deserialization into a GE object
|
This method takes full json response from GE cloud and outputs a dict appropriate for
deserialization into a GE object
| def ge_cloud_response_json_to_object_dict(self, response_json: Dict) -> Dict:
"""
This method takes full json response from GE cloud and outputs a dict appropriate for
deserialization into a GE object
"""
ge_cloud_checkpoint_id = response_json["data"]["id"]
checkpoint_con... | [
"def",
"ge_cloud_response_json_to_object_dict",
"(",
"self",
",",
"response_json",
":",
"Dict",
")",
"->",
"Dict",
":",
"ge_cloud_checkpoint_id",
"=",
"response_json",
"[",
"\"data\"",
"]",
"[",
"\"id\"",
"]",
"checkpoint_config_dict",
"=",
"response_json",
"[",
"\"... | [
21,
4
] | [
32,
37
] | python | en | ['en', 'error', 'th'] | False |
ExpectColumnUniqueValueCountToBeBetween.validate_configuration | (self, configuration: Optional[ExpectationConfiguration]) |
Validates that a configuration has been set, and sets a configuration if it has yet to be set. Ensures that
necessary configuration arguments have been provided for the validation of the expectation.
Args:
configuration (OPTIONAL[ExpectationConfiguration]): \
An opt... |
Validates that a configuration has been set, and sets a configuration if it has yet to be set. Ensures that
necessary configuration arguments have been provided for the validation of the expectation. | def validate_configuration(self, configuration: Optional[ExpectationConfiguration]):
"""
Validates that a configuration has been set, and sets a configuration if it has yet to be set. Ensures that
necessary configuration arguments have been provided for the validation of the expectation.
... | [
"def",
"validate_configuration",
"(",
"self",
",",
"configuration",
":",
"Optional",
"[",
"ExpectationConfiguration",
"]",
")",
":",
"super",
"(",
")",
".",
"validate_configuration",
"(",
"configuration",
")",
"self",
".",
"validate_metric_value_between_configuration",
... | [
104,
4
] | [
116,
85
] | python | en | ['en', 'error', 'th'] | False |
step_impl | (context) |
:type context: behave.runner.Context
|
:type context: behave.runner.Context
| def step_impl(context):
"""
:type context: behave.runner.Context
"""
print("Hello") | [
"def",
"step_impl",
"(",
"context",
")",
":",
"print",
"(",
"\"Hello\"",
")"
] | [
6,
0
] | [
10,
18
] | python | en | ['en', 'error', 'th'] | False |
step_impl | (context, country) |
:type context: behave.runner.Context
:type country: str
|
:type context: behave.runner.Context
:type country: str
| def step_impl(context, country):
"""
:type context: behave.runner.Context
:type country: str
"""
context.country = country | [
"def",
"step_impl",
"(",
"context",
",",
"country",
")",
":",
"context",
".",
"country",
"=",
"country"
] | [
14,
0
] | [
19,
29
] | python | en | ['en', 'error', 'th'] | False |
step_impl | (context, city) |
:type context: behave.runner.Context
:type city: str
|
:type context: behave.runner.Context
:type city: str
| def step_impl(context, city):
"""
:type context: behave.runner.Context
:type city: str
"""
capitals = {"USA": "Washington", "Japan": "Tokio"}
assert capitals[context.country] == city | [
"def",
"step_impl",
"(",
"context",
",",
"city",
")",
":",
"capitals",
"=",
"{",
"\"USA\"",
":",
"\"Washington\"",
",",
"\"Japan\"",
":",
"\"Tokio\"",
"}",
"assert",
"capitals",
"[",
"context",
".",
"country",
"]",
"==",
"city"
] | [
23,
0
] | [
29,
44
] | python | en | ['en', 'error', 'th'] | False |
step_impl | (context) |
:type context: behave.runner.Context
|
:type context: behave.runner.Context
| def step_impl(context):
"""
:type context: behave.runner.Context
"""
raise Exception("fail") | [
"def",
"step_impl",
"(",
"context",
")",
":",
"raise",
"Exception",
"(",
"\"fail\"",
")"
] | [
33,
0
] | [
37,
27
] | python | en | ['en', 'error', 'th'] | False |
step_impl | (context) |
:type context: behave.runner.Context
|
:type context: behave.runner.Context
| def step_impl(context):
"""
:type context: behave.runner.Context
"""
print("Background") | [
"def",
"step_impl",
"(",
"context",
")",
":",
"print",
"(",
"\"Background\"",
")"
] | [
41,
0
] | [
45,
23
] | python | en | ['en', 'error', 'th'] | False |
step_impl | (context) |
:type context: behave.runner.Context
|
:type context: behave.runner.Context
| def step_impl(context):
"""
:type context: behave.runner.Context
"""
pass | [
"def",
"step_impl",
"(",
"context",
")",
":",
"pass"
] | [
49,
0
] | [
53,
8
] | python | en | ['en', 'error', 'th'] | False |
step_impl | (context) |
:type context: behave.runner.Context
|
:type context: behave.runner.Context
| def step_impl(context):
"""
:type context: behave.runner.Context
"""
pass | [
"def",
"step_impl",
"(",
"context",
")",
":",
"pass"
] | [
57,
0
] | [
61,
8
] | python | en | ['en', 'error', 'th'] | False |
step_impl | (context) |
:type context: behave.runner.Context
|
:type context: behave.runner.Context
| def step_impl(context):
"""
:type context: behave.runner.Context
"""
pass | [
"def",
"step_impl",
"(",
"context",
")",
":",
"pass"
] | [
65,
0
] | [
69,
8
] | python | en | ['en', 'error', 'th'] | False |
step_impl | (context) |
:type context: behave.runner.Context
|
:type context: behave.runner.Context
| def step_impl(context):
"""
:type context: behave.runner.Context
"""
pass | [
"def",
"step_impl",
"(",
"context",
")",
":",
"pass"
] | [
73,
0
] | [
77,
8
] | python | en | ['en', 'error', 'th'] | False |
series_to_supervised | (data, n_in=1, n_out=1, dropnan=True) |
Frame a time series as a supervised learning dataset.
Arguments:
:param data: Sequence of observations as a list or NumPy array.
:param n_in: Number of lag observations as input (X).
:param n_out: Number of observations as output (y).
:param dropnan: Boolean whether or not to drop rows with NaN value... |
Frame a time series as a supervised learning dataset.
Arguments:
:param data: Sequence of observations as a list or NumPy array.
:param n_in: Number of lag observations as input (X).
:param n_out: Number of observations as output (y).
:param dropnan: Boolean whether or not to drop rows with NaN value... | def series_to_supervised(data, n_in=1, n_out=1, dropnan=True):
"""
Frame a time series as a supervised learning dataset.
Arguments:
:param data: Sequence of observations as a list or NumPy array.
:param n_in: Number of lag observations as input (X).
:param n_out: Number of observations as output (y).
... | [
"def",
"series_to_supervised",
"(",
"data",
",",
"n_in",
"=",
"1",
",",
"n_out",
"=",
"1",
",",
"dropnan",
"=",
"True",
")",
":",
"n_vars",
"=",
"1",
"if",
"type",
"(",
"data",
")",
"is",
"list",
"else",
"data",
".",
"shape",
"[",
"1",
"]",
"data... | [
28,
0
] | [
59,
14
] | python | en | ['en', 'error', 'th'] | False |
_RegistryQueryBase | (sysdir, key, value) | Use reg.exe to read a particular key.
While ideally we might use the win32 module, we would like gyp to be
python neutral, so for instance cygwin python lacks this module.
Arguments:
sysdir: The system subdirectory to attempt to launch reg.exe from.
key: The registry key to read from.
value: The par... | Use reg.exe to read a particular key. | def _RegistryQueryBase(sysdir, key, value):
"""Use reg.exe to read a particular key.
While ideally we might use the win32 module, we would like gyp to be
python neutral, so for instance cygwin python lacks this module.
Arguments:
sysdir: The system subdirectory to attempt to launch reg.exe from.
key: ... | [
"def",
"_RegistryQueryBase",
"(",
"sysdir",
",",
"key",
",",
"value",
")",
":",
"# Skip if not on Windows or Python Win32 setup issue",
"if",
"sys",
".",
"platform",
"not",
"in",
"(",
"'win32'",
",",
"'cygwin'",
")",
":",
"return",
"None",
"# Setup params to pass to... | [
109,
0
] | [
137,
13
] | python | en | ['en', 'en', 'en'] | True |
_RegistryQuery | (key, value=None) | r"""Use reg.exe to read a particular key through _RegistryQueryBase.
First tries to launch from %WinDir%\Sysnative to avoid WoW64 redirection. If
that fails, it falls back to System32. Sysnative is available on Vista and
up and available on Windows Server 2003 and XP through KB patch 942589. Note
that Sysnati... | r"""Use reg.exe to read a particular key through _RegistryQueryBase. | def _RegistryQuery(key, value=None):
r"""Use reg.exe to read a particular key through _RegistryQueryBase.
First tries to launch from %WinDir%\Sysnative to avoid WoW64 redirection. If
that fails, it falls back to System32. Sysnative is available on Vista and
up and available on Windows Server 2003 and XP throu... | [
"def",
"_RegistryQuery",
"(",
"key",
",",
"value",
"=",
"None",
")",
":",
"text",
"=",
"None",
"try",
":",
"text",
"=",
"_RegistryQueryBase",
"(",
"'Sysnative'",
",",
"key",
",",
"value",
")",
"except",
"OSError",
",",
"e",
":",
"if",
"e",
".",
"errn... | [
140,
0
] | [
165,
13
] | python | en | ['en', 'en', 'en'] | True |
_RegistryGetValueUsingWinReg | (key, value) | Use the _winreg module to obtain the value of a registry key.
Args:
key: The registry key.
value: The particular registry value to read.
Return:
contents of the registry key's value, or None on failure. Throws
ImportError if _winreg is unavailable.
| Use the _winreg module to obtain the value of a registry key. | def _RegistryGetValueUsingWinReg(key, value):
"""Use the _winreg module to obtain the value of a registry key.
Args:
key: The registry key.
value: The particular registry value to read.
Return:
contents of the registry key's value, or None on failure. Throws
ImportError if _winreg is unavailable... | [
"def",
"_RegistryGetValueUsingWinReg",
"(",
"key",
",",
"value",
")",
":",
"import",
"_winreg",
"try",
":",
"root",
",",
"subkey",
"=",
"key",
".",
"split",
"(",
"'\\\\'",
",",
"1",
")",
"assert",
"root",
"==",
"'HKLM'",
"# Only need HKLM for now.",
"with",
... | [
168,
0
] | [
185,
15
] | python | en | ['en', 'en', 'en'] | True |
_RegistryGetValue | (key, value) | Use _winreg or reg.exe to obtain the value of a registry key.
Using _winreg is preferable because it solves an issue on some corporate
environments where access to reg.exe is locked down. However, we still need
to fallback to reg.exe for the case where the _winreg module is not available
(for example in cygwin... | Use _winreg or reg.exe to obtain the value of a registry key. | def _RegistryGetValue(key, value):
"""Use _winreg or reg.exe to obtain the value of a registry key.
Using _winreg is preferable because it solves an issue on some corporate
environments where access to reg.exe is locked down. However, we still need
to fallback to reg.exe for the case where the _winreg module i... | [
"def",
"_RegistryGetValue",
"(",
"key",
",",
"value",
")",
":",
"try",
":",
"return",
"_RegistryGetValueUsingWinReg",
"(",
"key",
",",
"value",
")",
"except",
"ImportError",
":",
"pass",
"# Fallback to reg.exe if we fail to import _winreg.",
"text",
"=",
"_RegistryQue... | [
188,
0
] | [
215,
23
] | python | en | ['en', 'en', 'en'] | True |
_CreateVersion | (name, path, sdk_based=False) | Sets up MSVS project generation.
Setup is based off the GYP_MSVS_VERSION environment variable or whatever is
autodetected if GYP_MSVS_VERSION is not explicitly specified. If a version is
passed in that doesn't match a value in versions python will throw a error.
| Sets up MSVS project generation. | def _CreateVersion(name, path, sdk_based=False):
"""Sets up MSVS project generation.
Setup is based off the GYP_MSVS_VERSION environment variable or whatever is
autodetected if GYP_MSVS_VERSION is not explicitly specified. If a version is
passed in that doesn't match a value in versions python will throw a err... | [
"def",
"_CreateVersion",
"(",
"name",
",",
"path",
",",
"sdk_based",
"=",
"False",
")",
":",
"if",
"path",
":",
"path",
"=",
"os",
".",
"path",
".",
"normpath",
"(",
"path",
")",
"versions",
"=",
"{",
"'2015'",
":",
"VisualStudioVersion",
"(",
"'2015'"... | [
218,
0
] | [
322,
28
] | python | en | ['en', 'en', 'en'] | True |
_ConvertToCygpath | (path) | Convert to cygwin path if we are using cygwin. | Convert to cygwin path if we are using cygwin. | def _ConvertToCygpath(path):
"""Convert to cygwin path if we are using cygwin."""
if sys.platform == 'cygwin':
p = subprocess.Popen(['cygpath', path], stdout=subprocess.PIPE)
path = p.communicate()[0].strip()
return path | [
"def",
"_ConvertToCygpath",
"(",
"path",
")",
":",
"if",
"sys",
".",
"platform",
"==",
"'cygwin'",
":",
"p",
"=",
"subprocess",
".",
"Popen",
"(",
"[",
"'cygpath'",
",",
"path",
"]",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
")",
"path",
"=",
"p... | [
325,
0
] | [
330,
13
] | python | en | ['en', 'en', 'en'] | True |
_DetectVisualStudioVersions | (versions_to_check, force_express) | Collect the list of installed visual studio versions.
Returns:
A list of visual studio versions installed in descending order of
usage preference.
Base this on the registry and a quick check if devenv.exe exists.
Only versions 8-10 are considered.
Possibilities are:
2005(e) - Visual Studio ... | Collect the list of installed visual studio versions. | def _DetectVisualStudioVersions(versions_to_check, force_express):
"""Collect the list of installed visual studio versions.
Returns:
A list of visual studio versions installed in descending order of
usage preference.
Base this on the registry and a quick check if devenv.exe exists.
Only versions 8-... | [
"def",
"_DetectVisualStudioVersions",
"(",
"versions_to_check",
",",
"force_express",
")",
":",
"version_to_year",
"=",
"{",
"'8.0'",
":",
"'2005'",
",",
"'9.0'",
":",
"'2008'",
",",
"'10.0'",
":",
"'2010'",
",",
"'11.0'",
":",
"'2012'",
",",
"'12.0'",
":",
... | [
333,
0
] | [
397,
17
] | python | en | ['en', 'en', 'en'] | True |
SelectVisualStudioVersion | (version='auto', allow_fallback=True) | Select which version of Visual Studio projects to generate.
Arguments:
version: Hook to allow caller to force a particular version (vs auto).
Returns:
An object representing a visual studio project format version.
| Select which version of Visual Studio projects to generate. | def SelectVisualStudioVersion(version='auto', allow_fallback=True):
"""Select which version of Visual Studio projects to generate.
Arguments:
version: Hook to allow caller to force a particular version (vs auto).
Returns:
An object representing a visual studio project format version.
"""
# In auto mo... | [
"def",
"SelectVisualStudioVersion",
"(",
"version",
"=",
"'auto'",
",",
"allow_fallback",
"=",
"True",
")",
":",
"# In auto mode, check environment variable for override.",
"if",
"version",
"==",
"'auto'",
":",
"version",
"=",
"os",
".",
"environ",
".",
"get",
"(",
... | [
400,
0
] | [
442,
20
] | python | en | ['en', 'en', 'en'] | True |
VisualStudioVersion.Description | (self) | Get the full description of the version. | Get the full description of the version. | def Description(self):
"""Get the full description of the version."""
return self.description | [
"def",
"Description",
"(",
"self",
")",
":",
"return",
"self",
".",
"description"
] | [
34,
2
] | [
36,
27
] | python | en | ['en', 'en', 'en'] | True |
VisualStudioVersion.SolutionVersion | (self) | Get the version number of the sln files. | Get the version number of the sln files. | def SolutionVersion(self):
"""Get the version number of the sln files."""
return self.solution_version | [
"def",
"SolutionVersion",
"(",
"self",
")",
":",
"return",
"self",
".",
"solution_version"
] | [
38,
2
] | [
40,
32
] | python | en | ['en', 'en', 'en'] | True |
VisualStudioVersion.ProjectVersion | (self) | Get the version number of the vcproj or vcxproj files. | Get the version number of the vcproj or vcxproj files. | def ProjectVersion(self):
"""Get the version number of the vcproj or vcxproj files."""
return self.project_version | [
"def",
"ProjectVersion",
"(",
"self",
")",
":",
"return",
"self",
".",
"project_version"
] | [
42,
2
] | [
44,
31
] | python | en | ['en', 'en', 'pt'] | True |
VisualStudioVersion.UsesVcxproj | (self) | Returns true if this version uses a vcxproj file. | Returns true if this version uses a vcxproj file. | def UsesVcxproj(self):
"""Returns true if this version uses a vcxproj file."""
return self.uses_vcxproj | [
"def",
"UsesVcxproj",
"(",
"self",
")",
":",
"return",
"self",
".",
"uses_vcxproj"
] | [
49,
2
] | [
51,
28
] | python | en | ['en', 'en', 'en'] | True |
VisualStudioVersion.ProjectExtension | (self) | Returns the file extension for the project. | Returns the file extension for the project. | def ProjectExtension(self):
"""Returns the file extension for the project."""
return self.uses_vcxproj and '.vcxproj' or '.vcproj' | [
"def",
"ProjectExtension",
"(",
"self",
")",
":",
"return",
"self",
".",
"uses_vcxproj",
"and",
"'.vcxproj'",
"or",
"'.vcproj'"
] | [
53,
2
] | [
55,
56
] | python | en | ['en', 'en', 'en'] | True |
VisualStudioVersion.Path | (self) | Returns the path to Visual Studio installation. | Returns the path to Visual Studio installation. | def Path(self):
"""Returns the path to Visual Studio installation."""
return self.path | [
"def",
"Path",
"(",
"self",
")",
":",
"return",
"self",
".",
"path"
] | [
57,
2
] | [
59,
20
] | python | en | ['en', 'en', 'en'] | True |
VisualStudioVersion.ToolPath | (self, tool) | Returns the path to a given compiler tool. | Returns the path to a given compiler tool. | def ToolPath(self, tool):
"""Returns the path to a given compiler tool. """
return os.path.normpath(os.path.join(self.path, "VC/bin", tool)) | [
"def",
"ToolPath",
"(",
"self",
",",
"tool",
")",
":",
"return",
"os",
".",
"path",
".",
"normpath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"path",
",",
"\"VC/bin\"",
",",
"tool",
")",
")"
] | [
61,
2
] | [
63,
68
] | python | en | ['en', 'en', 'en'] | True |
VisualStudioVersion.DefaultToolset | (self) | Returns the msbuild toolset version that will be used in the absence
of a user override. | Returns the msbuild toolset version that will be used in the absence
of a user override. | def DefaultToolset(self):
"""Returns the msbuild toolset version that will be used in the absence
of a user override."""
return self.default_toolset | [
"def",
"DefaultToolset",
"(",
"self",
")",
":",
"return",
"self",
".",
"default_toolset"
] | [
65,
2
] | [
68,
31
] | python | en | ['en', 'en', 'en'] | True |
VisualStudioVersion.SetupScript | (self, target_arch) | Returns a command (with arguments) to be used to set up the
environment. | Returns a command (with arguments) to be used to set up the
environment. | def SetupScript(self, target_arch):
"""Returns a command (with arguments) to be used to set up the
environment."""
# Check if we are running in the SDK command line environment and use
# the setup script from the SDK if so. |target_arch| should be either
# 'x86' or 'x64'.
assert target_arch in (... | [
"def",
"SetupScript",
"(",
"self",
",",
"target_arch",
")",
":",
"# Check if we are running in the SDK command line environment and use",
"# the setup script from the SDK if so. |target_arch| should be either",
"# 'x86' or 'x64'.",
"assert",
"target_arch",
"in",
"(",
"'x86'",
",",
... | [
70,
2
] | [
106,
62
] | python | en | ['en', 'en', 'en'] | True |
SeleniumBrowser.finalize | (self, result) | This runs after all tests have completed with nosetests. | This runs after all tests have completed with nosetests. | def finalize(self, result):
""" This runs after all tests have completed with nosetests. """
proxy_helper.remove_proxy_zip_if_present() | [
"def",
"finalize",
"(",
"self",
",",
"result",
")",
":",
"proxy_helper",
".",
"remove_proxy_zip_if_present",
"(",
")"
] | [
412,
4
] | [
414,
50
] | python | en | ['en', 'en', 'en'] | True |
open_memory_channel | (max_buffer_size) | Open a channel for passing objects between tasks within a process.
Memory channels are lightweight, cheap to allocate, and entirely
in-memory. They don't involve any operating-system resources, or any kind
of serialization. They just pass Python objects directly between tasks
(with a possible stop in a... | Open a channel for passing objects between tasks within a process. | def open_memory_channel(max_buffer_size):
"""Open a channel for passing objects between tasks within a process.
Memory channels are lightweight, cheap to allocate, and entirely
in-memory. They don't involve any operating-system resources, or any kind
of serialization. They just pass Python objects dire... | [
"def",
"open_memory_channel",
"(",
"max_buffer_size",
")",
":",
"if",
"max_buffer_size",
"!=",
"inf",
"and",
"not",
"isinstance",
"(",
"max_buffer_size",
",",
"int",
")",
":",
"raise",
"TypeError",
"(",
"\"max_buffer_size must be an integer or math.inf\"",
")",
"if",
... | [
14,
0
] | [
74,
5
] | python | en | ['en', 'en', 'en'] | True |
Tool.__init__ | (self, name, attrs=None) | Initializes the tool.
Args:
name: Tool name.
attrs: Dict of tool attributes; may be None.
| Initializes the tool. | def __init__(self, name, attrs=None):
"""Initializes the tool.
Args:
name: Tool name.
attrs: Dict of tool attributes; may be None.
"""
self._attrs = attrs or {}
self._attrs['Name'] = name | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"attrs",
"=",
"None",
")",
":",
"self",
".",
"_attrs",
"=",
"attrs",
"or",
"{",
"}",
"self",
".",
"_attrs",
"[",
"'Name'",
"]",
"=",
"name"
] | [
15,
2
] | [
23,
30
] | python | en | ['en', 'en', 'en'] | True |
Tool._GetSpecification | (self) | Creates an element for the tool.
Returns:
A new xml.dom.Element for the tool.
| Creates an element for the tool. | def _GetSpecification(self):
"""Creates an element for the tool.
Returns:
A new xml.dom.Element for the tool.
"""
return ['Tool', self._attrs] | [
"def",
"_GetSpecification",
"(",
"self",
")",
":",
"return",
"[",
"'Tool'",
",",
"self",
".",
"_attrs",
"]"
] | [
25,
2
] | [
31,
32
] | python | en | ['en', 'en', 'en'] | True |
Filter.__init__ | (self, name, contents=None) | Initializes the folder.
Args:
name: Filter (folder) name.
contents: List of filenames and/or Filter objects contained.
| Initializes the folder. | def __init__(self, name, contents=None):
"""Initializes the folder.
Args:
name: Filter (folder) name.
contents: List of filenames and/or Filter objects contained.
"""
self.name = name
self.contents = list(contents or []) | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"contents",
"=",
"None",
")",
":",
"self",
".",
"name",
"=",
"name",
"self",
".",
"contents",
"=",
"list",
"(",
"contents",
"or",
"[",
"]",
")"
] | [
36,
2
] | [
44,
40
] | python | en | ['en', 'zu', 'en'] | True |
Writer.__init__ | (self, project_path, version, name, guid=None, platforms=None) | Initializes the project.
Args:
project_path: Path to the project file.
version: Format version to emit.
name: Name of the project.
guid: GUID to use for project, if not None.
platforms: Array of string, the supported platforms. If null, ['Win32']
| Initializes the project. | def __init__(self, project_path, version, name, guid=None, platforms=None):
"""Initializes the project.
Args:
project_path: Path to the project file.
version: Format version to emit.
name: Name of the project.
guid: GUID to use for project, if not None.
platforms: Array of string,... | [
"def",
"__init__",
"(",
"self",
",",
"project_path",
",",
"version",
",",
"name",
",",
"guid",
"=",
"None",
",",
"platforms",
"=",
"None",
")",
":",
"self",
".",
"project_path",
"=",
"project_path",
"self",
".",
"version",
"=",
"version",
"self",
".",
... | [
53,
2
] | [
81,
28
] | python | en | ['en', 'en', 'en'] | True |
Writer.AddToolFile | (self, path) | Adds a tool file to the project.
Args:
path: Relative path from project to tool file.
| Adds a tool file to the project. | def AddToolFile(self, path):
"""Adds a tool file to the project.
Args:
path: Relative path from project to tool file.
"""
self.tool_files_section.append(['ToolFile', {'RelativePath': path}]) | [
"def",
"AddToolFile",
"(",
"self",
",",
"path",
")",
":",
"self",
".",
"tool_files_section",
".",
"append",
"(",
"[",
"'ToolFile'",
",",
"{",
"'RelativePath'",
":",
"path",
"}",
"]",
")"
] | [
83,
2
] | [
89,
72
] | python | en | ['en', 'en', 'en'] | True |
Writer._GetSpecForConfiguration | (self, config_type, config_name, attrs, tools) | Returns the specification for a configuration.
Args:
config_type: Type of configuration node.
config_name: Configuration name.
attrs: Dict of configuration attributes; may be None.
tools: List of tools (strings or Tool objects); may be None.
Returns:
| Returns the specification for a configuration. | def _GetSpecForConfiguration(self, config_type, config_name, attrs, tools):
"""Returns the specification for a configuration.
Args:
config_type: Type of configuration node.
config_name: Configuration name.
attrs: Dict of configuration attributes; may be None.
tools: List of tools (strin... | [
"def",
"_GetSpecForConfiguration",
"(",
"self",
",",
"config_type",
",",
"config_name",
",",
"attrs",
",",
"tools",
")",
":",
"# Handle defaults",
"if",
"not",
"attrs",
":",
"attrs",
"=",
"{",
"}",
"if",
"not",
"tools",
":",
"tools",
"=",
"[",
"]",
"# Ad... | [
91,
2
] | [
119,
24
] | python | en | ['en', 'en', 'en'] | True |
Writer.AddConfig | (self, name, attrs=None, tools=None) | Adds a configuration to the project.
Args:
name: Configuration name.
attrs: Dict of configuration attributes; may be None.
tools: List of tools (strings or Tool objects); may be None.
| Adds a configuration to the project. | def AddConfig(self, name, attrs=None, tools=None):
"""Adds a configuration to the project.
Args:
name: Configuration name.
attrs: Dict of configuration attributes; may be None.
tools: List of tools (strings or Tool objects); may be None.
"""
spec = self._GetSpecForConfiguration('Confi... | [
"def",
"AddConfig",
"(",
"self",
",",
"name",
",",
"attrs",
"=",
"None",
",",
"tools",
"=",
"None",
")",
":",
"spec",
"=",
"self",
".",
"_GetSpecForConfiguration",
"(",
"'Configuration'",
",",
"name",
",",
"attrs",
",",
"tools",
")",
"self",
".",
"conf... | [
122,
2
] | [
131,
44
] | python | en | ['en', 'en', 'en'] | True |
Writer._AddFilesToNode | (self, parent, files) | Adds files and/or filters to the parent node.
Args:
parent: Destination node
files: A list of Filter objects and/or relative paths to files.
Will call itself recursively, if the files list contains Filter objects.
| Adds files and/or filters to the parent node. | def _AddFilesToNode(self, parent, files):
"""Adds files and/or filters to the parent node.
Args:
parent: Destination node
files: A list of Filter objects and/or relative paths to files.
Will call itself recursively, if the files list contains Filter objects.
"""
for f in files:
i... | [
"def",
"_AddFilesToNode",
"(",
"self",
",",
"parent",
",",
"files",
")",
":",
"for",
"f",
"in",
"files",
":",
"if",
"isinstance",
"(",
"f",
",",
"Filter",
")",
":",
"node",
"=",
"[",
"'Filter'",
",",
"{",
"'Name'",
":",
"f",
".",
"name",
"}",
"]"... | [
133,
2
] | [
149,
25
] | python | en | ['en', 'en', 'en'] | True |
Writer.AddFiles | (self, files) | Adds files to the project.
Args:
files: A list of Filter objects and/or relative paths to files.
This makes a copy of the file/filter tree at the time of this call. If you
later add files to a Filter object which was passed into a previous call
to AddFiles(), it will not be reflected in this pr... | Adds files to the project. | def AddFiles(self, files):
"""Adds files to the project.
Args:
files: A list of Filter objects and/or relative paths to files.
This makes a copy of the file/filter tree at the time of this call. If you
later add files to a Filter object which was passed into a previous call
to AddFiles(), i... | [
"def",
"AddFiles",
"(",
"self",
",",
"files",
")",
":",
"self",
".",
"_AddFilesToNode",
"(",
"self",
".",
"files_section",
",",
"files",
")"
] | [
151,
2
] | [
161,
51
] | python | en | ['en', 'en', 'en'] | True |
Writer.AddFileConfig | (self, path, config, attrs=None, tools=None) | Adds a configuration to a file.
Args:
path: Relative path to the file.
config: Name of configuration to add.
attrs: Dict of configuration attributes; may be None.
tools: List of tools (strings or Tool objects); may be None.
Raises:
ValueError: Relative path does not match any fil... | Adds a configuration to a file. | def AddFileConfig(self, path, config, attrs=None, tools=None):
"""Adds a configuration to a file.
Args:
path: Relative path to the file.
config: Name of configuration to add.
attrs: Dict of configuration attributes; may be None.
tools: List of tools (strings or Tool objects); may be Non... | [
"def",
"AddFileConfig",
"(",
"self",
",",
"path",
",",
"config",
",",
"attrs",
"=",
"None",
",",
"tools",
"=",
"None",
")",
":",
"# Find the file node with the right relative path",
"parent",
"=",
"self",
".",
"files_dict",
".",
"get",
"(",
"path",
")",
"if"... | [
165,
2
] | [
185,
23
] | python | en | ['en', 'en', 'en'] | True |
Writer.WriteIfChanged | (self) | Writes the project file. | Writes the project file. | def WriteIfChanged(self):
"""Writes the project file."""
# First create XML content definition
content = [
'VisualStudioProject',
{'ProjectType': 'Visual C++',
'Version': self.version.ProjectVersion(),
'Name': self.name,
'ProjectGUID': self.guid,
'RootName... | [
"def",
"WriteIfChanged",
"(",
"self",
")",
":",
"# First create XML content definition",
"content",
"=",
"[",
"'VisualStudioProject'",
",",
"{",
"'ProjectType'",
":",
"'Visual C++'",
",",
"'Version'",
":",
"self",
".",
"version",
".",
"ProjectVersion",
"(",
")",
"... | [
187,
2
] | [
207,
55
] | python | en | ['en', 'en', 'en'] | True |
make_uplift_classification | (n_samples=1000,
treatment_name=['control', 'treatment1', 'treatment2', 'treatment3'],
y_name='conversion',
n_classification_features=10,
n_classification_informative=5,
... | Generate a synthetic dataset for classification uplift modeling problem.
Parameters
----------
n_samples : int, optional (default=1000)
The number of samples to be generated for each treatment group.
treatment_name: list, optional (default = ['control','treatment1','treatment2','treatment3'])
... | Generate a synthetic dataset for classification uplift modeling problem. | def make_uplift_classification(n_samples=1000,
treatment_name=['control', 'treatment1', 'treatment2', 'treatment3'],
y_name='conversion',
n_classification_features=10,
n_classification_informative... | [
"def",
"make_uplift_classification",
"(",
"n_samples",
"=",
"1000",
",",
"treatment_name",
"=",
"[",
"'control'",
",",
"'treatment1'",
",",
"'treatment2'",
",",
"'treatment3'",
"]",
",",
"y_name",
"=",
"'conversion'",
",",
"n_classification_features",
"=",
"10",
"... | [
5,
0
] | [
182,
25
] | python | en | ['en', 'en', 'en'] | True |
DiagResult.include_element | (self, key: str) |
Note that a particular key is something relevant to this result -- e.g.
'oh, the key foo-mapping.1 is active here'.
One problem here is that we don't currently cycle over to make sure that
all the requisite higher-level objects are brought in when we mark an
element active. Thi... |
Note that a particular key is something relevant to this result -- e.g.
'oh, the key foo-mapping.1 is active here'. | def include_element(self, key: str) -> None:
"""
Note that a particular key is something relevant to this result -- e.g.
'oh, the key foo-mapping.1 is active here'.
One problem here is that we don't currently cycle over to make sure that
all the requisite higher-level objects ar... | [
"def",
"include_element",
"(",
"self",
",",
"key",
":",
"str",
")",
"->",
"None",
":",
"self",
".",
"element_keys",
"[",
"key",
"]",
"=",
"True"
] | [
144,
4
] | [
155,
37
] | python | en | ['en', 'error', 'th'] | False |
DiagResult.include_referenced_elements | (self, obj: dict) |
Include all of the elements in the given object's _referenced_by
array.
:param obj: object for which to include referencing keys
|
Include all of the elements in the given object's _referenced_by
array. | def include_referenced_elements(self, obj: dict) -> None:
"""
Include all of the elements in the given object's _referenced_by
array.
:param obj: object for which to include referencing keys
"""
for element_key in obj['_referenced_by']:
self.include_element(... | [
"def",
"include_referenced_elements",
"(",
"self",
",",
"obj",
":",
"dict",
")",
"->",
"None",
":",
"for",
"element_key",
"in",
"obj",
"[",
"'_referenced_by'",
"]",
":",
"self",
".",
"include_element",
"(",
"element_key",
")"
] | [
157,
4
] | [
166,
45
] | python | en | ['en', 'error', 'th'] | False |
DiagResult.include_cluster | (self, cluster: dict) |
Note that a particular cluster and everything that references it are
relevant to this result. If the cluster has related health information in
our cstats, fold that in too.
Don't pass an IRCluster here -- turn it into a dict with as_dict()
first.
Returns the DiagCluste... |
Note that a particular cluster and everything that references it are
relevant to this result. If the cluster has related health information in
our cstats, fold that in too. | def include_cluster(self, cluster: dict) -> DiagCluster:
"""
Note that a particular cluster and everything that references it are
relevant to this result. If the cluster has related health information in
our cstats, fold that in too.
Don't pass an IRCluster here -- turn it into ... | [
"def",
"include_cluster",
"(",
"self",
",",
"cluster",
":",
"dict",
")",
"->",
"DiagCluster",
":",
"c_name",
"=",
"cluster",
"[",
"'name'",
"]",
"if",
"c_name",
"not",
"in",
"self",
".",
"clusters",
":",
"self",
".",
"clusters",
"[",
"c_name",
"]",
"="... | [
168,
4
] | [
193,
36
] | python | en | ['en', 'error', 'th'] | False |
DiagResult.include_httpgroup | (self, group: IRHTTPMappingGroup) |
Note that a particular IRHTTPMappingGroup, all of the clusters it uses for upstream
traffic, and everything that references it are relevant to this result.
This method actually does a fair amount of work around handling clusters, shadow
clusters, and host_redirects. It would be a horri... |
Note that a particular IRHTTPMappingGroup, all of the clusters it uses for upstream
traffic, and everything that references it are relevant to this result. | def include_httpgroup(self, group: IRHTTPMappingGroup) -> None:
"""
Note that a particular IRHTTPMappingGroup, all of the clusters it uses for upstream
traffic, and everything that references it are relevant to this result.
This method actually does a fair amount of work around handling... | [
"def",
"include_httpgroup",
"(",
"self",
",",
"group",
":",
"IRHTTPMappingGroup",
")",
"->",
"None",
":",
"# self.logger.debug(\"GROUP %s\" % group.as_json())",
"prefix",
"=",
"group",
"[",
"'prefix'",
"]",
"if",
"'prefix'",
"in",
"group",
"else",
"group",
"[",
"'... | [
195,
4
] | [
297,
47
] | python | en | ['en', 'error', 'th'] | False |
DiagResult.finalize | (self) |
Make sure that all the elements we've marked as included actually appear
in the ambassador_resources and envoy_resources dictionaries, so that the
UI can properly connect all the dots.
|
Make sure that all the elements we've marked as included actually appear
in the ambassador_resources and envoy_resources dictionaries, so that the
UI can properly connect all the dots.
| def finalize(self) -> None:
"""
Make sure that all the elements we've marked as included actually appear
in the ambassador_resources and envoy_resources dictionaries, so that the
UI can properly connect all the dots.
"""
for key in self.element_keys.keys():
a... | [
"def",
"finalize",
"(",
"self",
")",
"->",
"None",
":",
"for",
"key",
"in",
"self",
".",
"element_keys",
".",
"keys",
"(",
")",
":",
"amb_el_info",
"=",
"self",
".",
"diag",
".",
"ambassador_elements",
".",
"get",
"(",
"key",
",",
"None",
")",
"if",
... | [
299,
4
] | [
321,
57
] | python | en | ['en', 'error', 'th'] | False |
Diagnostics.add_ambassador_service | (self, svc, type_name) |
Remember information about a given Ambassador-wide service (Auth, RateLimit, Tracing).
:param svc: service record
:param type_name: what kind of thing is this?
|
Remember information about a given Ambassador-wide service (Auth, RateLimit, Tracing). | def add_ambassador_service(self, svc, type_name) -> None:
"""
Remember information about a given Ambassador-wide service (Auth, RateLimit, Tracing).
:param svc: service record
:param type_name: what kind of thing is this?
"""
cluster = svc.cluster
urls = cluster... | [
"def",
"add_ambassador_service",
"(",
"self",
",",
"svc",
",",
"type_name",
")",
"->",
"None",
":",
"cluster",
"=",
"svc",
".",
"cluster",
"urls",
"=",
"cluster",
".",
"urls",
"svc_weight",
"=",
"100.0",
"/",
"len",
"(",
"urls",
")",
"for",
"url",
"in"... | [
524,
4
] | [
544,
14
] | python | en | ['en', 'error', 'th'] | False |
Diagnostics.add_ambassador_resolver | (self, resolver, group_list) |
Remember information about a given Ambassador-wide resolver.
:param resolver: resolver record
:param group_list: list of groups that use this resolver
|
Remember information about a given Ambassador-wide resolver. | def add_ambassador_resolver(self, resolver, group_list) -> None:
"""
Remember information about a given Ambassador-wide resolver.
:param resolver: resolver record
:param group_list: list of groups that use this resolver
"""
self.ambassador_resolvers.append({
... | [
"def",
"add_ambassador_resolver",
"(",
"self",
",",
"resolver",
",",
"group_list",
")",
"->",
"None",
":",
"self",
".",
"ambassador_resolvers",
".",
"append",
"(",
"{",
"'kind'",
":",
"resolver",
".",
"kind",
",",
"'_source'",
":",
"resolver",
".",
"location... | [
546,
4
] | [
559,
10
] | python | en | ['en', 'error', 'th'] | False |
Diagnostics.split_key | (key) |
Split a key into its components (the base name and the object index).
:param key: possibly-qualified key
:return: tuple of the base and a possible index
|
Split a key into its components (the base name and the object index). | def split_key(key) -> Tuple[str, Optional[str]]:
"""
Split a key into its components (the base name and the object index).
:param key: possibly-qualified key
:return: tuple of the base and a possible index
"""
key_base = key
key_index = None
m = Diagnos... | [
"def",
"split_key",
"(",
"key",
")",
"->",
"Tuple",
"[",
"str",
",",
"Optional",
"[",
"str",
"]",
"]",
":",
"key_base",
"=",
"key",
"key_index",
"=",
"None",
"m",
"=",
"Diagnostics",
".",
"reKeyIndex",
".",
"search",
"(",
"key",
")",
"if",
"m",
":"... | [
562,
4
] | [
579,
34
] | python | en | ['en', 'error', 'th'] | False |
Diagnostics._remember_source | (self, src_key: str, dest_key: str) |
Link keys of active sources together. The source map lets us answer questions
like 'which objects does ambassador.yaml define?' and this is the primitive
that actually populates the map.
The src_key is where you start the lookup; the dest_key is something defined
by the src_key... |
Link keys of active sources together. The source map lets us answer questions
like 'which objects does ambassador.yaml define?' and this is the primitive
that actually populates the map. | def _remember_source(self, src_key: str, dest_key: str) -> None:
"""
Link keys of active sources together. The source map lets us answer questions
like 'which objects does ambassador.yaml define?' and this is the primitive
that actually populates the map.
The src_key is where yo... | [
"def",
"_remember_source",
"(",
"self",
",",
"src_key",
":",
"str",
",",
"dest_key",
":",
"str",
")",
"->",
"None",
":",
"src_map",
"=",
"self",
".",
"source_map",
".",
"setdefault",
"(",
"src_key",
",",
"{",
"}",
")",
"src_map",
"[",
"dest_key",
"]",
... | [
630,
4
] | [
644,
32
] | python | en | ['en', 'error', 'th'] | False |
Diagnostics.remember_source | (self, uqkey: str, fqkey: Optional[str], location: Optional[str],
dest_key: str) |
Populate the source map in various ways. A mapping from uqkey to dest_key is
always added; mappings for fqkey and location are added if they are unique
keys.
:param uqkey: unqualified source key
:param fqkey: qualified source key
:param location: source location
... |
Populate the source map in various ways. A mapping from uqkey to dest_key is
always added; mappings for fqkey and location are added if they are unique
keys. | def remember_source(self, uqkey: str, fqkey: Optional[str], location: Optional[str],
dest_key: str) -> None:
"""
Populate the source map in various ways. A mapping from uqkey to dest_key is
always added; mappings for fqkey and location are added if they are unique
... | [
"def",
"remember_source",
"(",
"self",
",",
"uqkey",
":",
"str",
",",
"fqkey",
":",
"Optional",
"[",
"str",
"]",
",",
"location",
":",
"Optional",
"[",
"str",
"]",
",",
"dest_key",
":",
"str",
")",
"->",
"None",
":",
"self",
".",
"_remember_source",
... | [
646,
4
] | [
664,
53
] | python | en | ['en', 'error', 'th'] | False |
Diagnostics.overview | (self, request, estat: EnvoyStats) |
Generate overview data describing the whole Ambassador setup, most
notably the routing table. Returns the dictionary form of a DiagResult.
:param request: the Flask request being handled
:param estat: current EnvoyStats
:return: the dictionary form of a DiagResult
|
Generate overview data describing the whole Ambassador setup, most
notably the routing table. Returns the dictionary form of a DiagResult. | def overview(self, request, estat: EnvoyStats) -> Dict[str, Any]:
"""
Generate overview data describing the whole Ambassador setup, most
notably the routing table. Returns the dictionary form of a DiagResult.
:param request: the Flask request being handled
:param estat: current ... | [
"def",
"overview",
"(",
"self",
",",
"request",
",",
"estat",
":",
"EnvoyStats",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"result",
"=",
"DiagResult",
"(",
"self",
",",
"estat",
",",
"request",
")",
"for",
"group",
"in",
"self",
".",
"i... | [
666,
4
] | [
683,
31
] | python | en | ['en', 'error', 'th'] | False |
Diagnostics.lookup | (self, request, key: str, estat: EnvoyStats) |
Generate data describing a specific key in the Ambassador setup, and all
the things connected to it. Returns the dictionary form of a DiagResult.
'key' can be a group key that starts with grp-, a cluster key that starts
with cluster_, or a source key.
:param request: the Flask... |
Generate data describing a specific key in the Ambassador setup, and all
the things connected to it. Returns the dictionary form of a DiagResult. | def lookup(self, request, key: str, estat: EnvoyStats) -> Optional[Dict[str, Any]]:
"""
Generate data describing a specific key in the Ambassador setup, and all
the things connected to it. Returns the dictionary form of a DiagResult.
'key' can be a group key that starts with grp-, a clu... | [
"def",
"lookup",
"(",
"self",
",",
"request",
",",
"key",
":",
"str",
",",
"estat",
":",
"EnvoyStats",
")",
"->",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"result",
"=",
"DiagResult",
"(",
"self",
",",
"estat",
",",
"request"... | [
685,
4
] | [
741,
23
] | python | en | ['en', 'error', 'th'] | False |
AbstractDisplay.redirect_display | (self, on) |
on:
* True -> set $DISPLAY to virtual screen
* False -> set $DISPLAY to original screen
:param on: bool
|
on:
* True -> set $DISPLAY to virtual screen
* False -> set $DISPLAY to original screen | def redirect_display(self, on):
'''
on:
* True -> set $DISPLAY to virtual screen
* False -> set $DISPLAY to original screen
:param on: bool
'''
d = self.new_display_var if on else self.old_display_var
if d is None:
del os.environ['DISPLAY']
... | [
"def",
"redirect_display",
"(",
"self",
",",
"on",
")",
":",
"d",
"=",
"self",
".",
"new_display_var",
"if",
"on",
"else",
"self",
".",
"old_display_var",
"if",
"d",
"is",
"None",
":",
"del",
"os",
".",
"environ",
"[",
"'DISPLAY'",
"]",
"else",
":",
... | [
59,
4
] | [
71,
37
] | python | en | ['en', 'error', 'th'] | False |
AbstractDisplay.start | (self) |
start display
:rtype: self
|
start display | def start(self):
'''
start display
:rtype: self
'''
if self.use_xauth:
self._setup_xauth()
EasyProcess.start(self)
# https://github.com/ponty/PyVirtualDisplay/issues/2
# https://github.com/ponty/PyVirtualDisplay/issues/14
self.old_dis... | [
"def",
"start",
"(",
"self",
")",
":",
"if",
"self",
".",
"use_xauth",
":",
"self",
".",
"_setup_xauth",
"(",
")",
"EasyProcess",
".",
"start",
"(",
"self",
")",
"# https://github.com/ponty/PyVirtualDisplay/issues/2",
"# https://github.com/ponty/PyVirtualDisplay/issues/... | [
73,
4
] | [
91,
19
] | python | en | ['en', 'error', 'th'] | False |
AbstractDisplay.stop | (self) |
stop display
:rtype: self
|
stop display | def stop(self):
'''
stop display
:rtype: self
'''
self.redirect_display(False)
EasyProcess.stop(self)
if self.use_xauth:
self._clear_xauth()
return self | [
"def",
"stop",
"(",
"self",
")",
":",
"self",
".",
"redirect_display",
"(",
"False",
")",
"EasyProcess",
".",
"stop",
"(",
"self",
")",
"if",
"self",
".",
"use_xauth",
":",
"self",
".",
"_clear_xauth",
"(",
")",
"return",
"self"
] | [
93,
4
] | [
103,
19
] | python | en | ['en', 'error', 'th'] | False |
AbstractDisplay._setup_xauth | (self) |
Set up the Xauthority file and the XAUTHORITY environment variable.
|
Set up the Xauthority file and the XAUTHORITY environment variable.
| def _setup_xauth(self):
'''
Set up the Xauthority file and the XAUTHORITY environment variable.
'''
handle, filename = tempfile.mkstemp(prefix='PyVirtualDisplay.',
suffix='.Xauthority')
self._xauth_filename = filename
os.close(h... | [
"def",
"_setup_xauth",
"(",
"self",
")",
":",
"handle",
",",
"filename",
"=",
"tempfile",
".",
"mkstemp",
"(",
"prefix",
"=",
"'PyVirtualDisplay.'",
",",
"suffix",
"=",
"'.Xauthority'",
")",
"self",
".",
"_xauth_filename",
"=",
"filename",
"os",
".",
"close"... | [
105,
4
] | [
120,
60
] | python | en | ['en', 'error', 'th'] | False |
AbstractDisplay._clear_xauth | (self) |
Clear the Xauthority file and restore the environment variables.
|
Clear the Xauthority file and restore the environment variables.
| def _clear_xauth(self):
'''
Clear the Xauthority file and restore the environment variables.
'''
os.remove(self._xauth_filename)
for varname in ['AUTHFILE', 'XAUTHORITY']:
if self._old_xauth[varname] is None:
del os.environ[varname]
else:
... | [
"def",
"_clear_xauth",
"(",
"self",
")",
":",
"os",
".",
"remove",
"(",
"self",
".",
"_xauth_filename",
")",
"for",
"varname",
"in",
"[",
"'AUTHFILE'",
",",
"'XAUTHORITY'",
"]",
":",
"if",
"self",
".",
"_old_xauth",
"[",
"varname",
"]",
"is",
"None",
"... | [
122,
4
] | [
132,
30
] | python | en | ['en', 'error', 'th'] | False |
send_opsgenie_alert | (query, suite_name, settings) | Creates an alert in Opsgenie. | Creates an alert in Opsgenie. | def send_opsgenie_alert(query, suite_name, settings):
"""Creates an alert in Opsgenie."""
if settings["region"] != None:
url = "https://api.{region}.opsgenie.com/v2/alerts".format(
region=settings["region"]
) # accommodate for Europeans
else:
url = "https://api.opsgenie.... | [
"def",
"send_opsgenie_alert",
"(",
"query",
",",
"suite_name",
",",
"settings",
")",
":",
"if",
"settings",
"[",
"\"region\"",
"]",
"!=",
"None",
":",
"url",
"=",
"\"https://api.{region}.opsgenie.com/v2/alerts\"",
".",
"format",
"(",
"region",
"=",
"settings",
"... | [
44,
0
] | [
84,
18
] | python | en | ['en', 'de', 'en'] | True |
test_database_evaluation_parameter_store_store_backend_id | (in_memory_param_store) |
What does this test and why?
A Store should be able to report it's store_backend_id
which is set when the StoreBackend is instantiated.
|
What does this test and why?
A Store should be able to report it's store_backend_id
which is set when the StoreBackend is instantiated.
| def test_database_evaluation_parameter_store_store_backend_id(in_memory_param_store):
"""
What does this test and why?
A Store should be able to report it's store_backend_id
which is set when the StoreBackend is instantiated.
"""
# Check that store_backend_id exists can be read
assert in_mem... | [
"def",
"test_database_evaluation_parameter_store_store_backend_id",
"(",
"in_memory_param_store",
")",
":",
"# Check that store_backend_id exists can be read",
"assert",
"in_memory_param_store",
".",
"store_backend_id",
"is",
"not",
"None",
"# Check that store_backend_id is a valid UUID"... | [
186,
0
] | [
195,
76
] | python | en | ['en', 'error', 'th'] | False |
ParameterBuilder.__init__ | (
self,
parameter_name: str,
data_context: Optional[DataContext] = None,
batch_request: Optional[Union[dict, str]] = None,
) |
The ParameterBuilder will build parameters for the active domain from the rule.
Args:
parameter_name: the name of this parameter -- this is user-specified parameter name (from configuration);
it is not the fully-qualified parameter name; a fully-qualified parameter name must st... |
The ParameterBuilder will build parameters for the active domain from the rule. | def __init__(
self,
parameter_name: str,
data_context: Optional[DataContext] = None,
batch_request: Optional[Union[dict, str]] = None,
):
"""
The ParameterBuilder will build parameters for the active domain from the rule.
Args:
parameter_name: the... | [
"def",
"__init__",
"(",
"self",
",",
"parameter_name",
":",
"str",
",",
"data_context",
":",
"Optional",
"[",
"DataContext",
"]",
"=",
"None",
",",
"batch_request",
":",
"Optional",
"[",
"Union",
"[",
"dict",
",",
"str",
"]",
"]",
"=",
"None",
",",
")"... | [
44,
4
] | [
63,
43
] | python | en | ['en', 'error', 'th'] | False |
bygroups | (*args) |
Callback that yields multiple actions for each group in the match.
|
Callback that yields multiple actions for each group in the match.
| def bygroups(*args):
"""
Callback that yields multiple actions for each group in the match.
"""
def callback(lexer, match, ctx=None):
for i, action in enumerate(args):
if action is None:
continue
elif type(action) is _TokenType:
data = matc... | [
"def",
"bygroups",
"(",
"*",
"args",
")",
":",
"def",
"callback",
"(",
"lexer",
",",
"match",
",",
"ctx",
"=",
"None",
")",
":",
"for",
"i",
",",
"action",
"in",
"enumerate",
"(",
"args",
")",
":",
"if",
"action",
"is",
"None",
":",
"continue",
"... | [
304,
0
] | [
327,
19
] | python | en | ['en', 'error', 'th'] | False |
using | (_other, **kwargs) |
Callback that processes the match with a different lexer.
The keyword arguments are forwarded to the lexer, except `state` which
is handled separately.
`state` specifies the state that the new lexer will start in, and can
be an enumerable such as ('root', 'inline', 'string') or a simple
strin... |
Callback that processes the match with a different lexer. | def using(_other, **kwargs):
"""
Callback that processes the match with a different lexer.
The keyword arguments are forwarded to the lexer, except `state` which
is handled separately.
`state` specifies the state that the new lexer will start in, and can
be an enumerable such as ('root', 'inli... | [
"def",
"using",
"(",
"_other",
",",
"*",
"*",
"kwargs",
")",
":",
"gt_kwargs",
"=",
"{",
"}",
"if",
"'state'",
"in",
"kwargs",
":",
"s",
"=",
"kwargs",
".",
"pop",
"(",
"'state'",
")",
"if",
"isinstance",
"(",
"s",
",",
"(",
"list",
",",
"tuple",... | [
338,
0
] | [
385,
19
] | python | en | ['en', 'error', 'th'] | False |
do_insertions | (insertions, tokens) |
Helper for lexers which must combine the results of several
sublexers.
``insertions`` is a list of ``(index, itokens)`` pairs.
Each ``itokens`` iterable should be inserted at position
``index`` into the token stream given by the ``tokens``
argument.
The result is a combined token stream.
... |
Helper for lexers which must combine the results of several
sublexers. | def do_insertions(insertions, tokens):
"""
Helper for lexers which must combine the results of several
sublexers.
``insertions`` is a list of ``(index, itokens)`` pairs.
Each ``itokens`` iterable should be inserted at position
``index`` into the token stream given by the ``tokens``
argument... | [
"def",
"do_insertions",
"(",
"insertions",
",",
"tokens",
")",
":",
"insertions",
"=",
"iter",
"(",
"insertions",
")",
"try",
":",
"index",
",",
"itokens",
"=",
"next",
"(",
"insertions",
")",
"except",
"StopIteration",
":",
"# no insertions",
"for",
"item",... | [
757,
0
] | [
817,
17
] | python | en | ['en', 'error', 'th'] | False |
RegexLexerMeta._process_regex | (cls, regex, rflags, state) | Preprocess the regular expression component of a token definition. | Preprocess the regular expression component of a token definition. | def _process_regex(cls, regex, rflags, state):
"""Preprocess the regular expression component of a token definition."""
if isinstance(regex, Future):
regex = regex.get()
return re.compile(regex, rflags).match | [
"def",
"_process_regex",
"(",
"cls",
",",
"regex",
",",
"rflags",
",",
"state",
")",
":",
"if",
"isinstance",
"(",
"regex",
",",
"Future",
")",
":",
"regex",
"=",
"regex",
".",
"get",
"(",
")",
"return",
"re",
".",
"compile",
"(",
"regex",
",",
"rf... | [
422,
4
] | [
426,
46
] | python | en | ['en', 'en', 'en'] | True |
RegexLexerMeta._process_token | (cls, token) | Preprocess the token component of a token definition. | Preprocess the token component of a token definition. | def _process_token(cls, token):
"""Preprocess the token component of a token definition."""
assert type(token) is _TokenType or callable(token), \
'token type must be simple type or callable, not %r' % (token,)
return token | [
"def",
"_process_token",
"(",
"cls",
",",
"token",
")",
":",
"assert",
"type",
"(",
"token",
")",
"is",
"_TokenType",
"or",
"callable",
"(",
"token",
")",
",",
"'token type must be simple type or callable, not %r'",
"%",
"(",
"token",
",",
")",
"return",
"toke... | [
428,
4
] | [
432,
20
] | python | en | ['en', 'en', 'en'] | True |
RegexLexerMeta._process_new_state | (cls, new_state, unprocessed, processed) | Preprocess the state transition action of a token definition. | Preprocess the state transition action of a token definition. | def _process_new_state(cls, new_state, unprocessed, processed):
"""Preprocess the state transition action of a token definition."""
if isinstance(new_state, str):
# an existing state
if new_state == '#pop':
return -1
elif new_state in unprocessed:
... | [
"def",
"_process_new_state",
"(",
"cls",
",",
"new_state",
",",
"unprocessed",
",",
"processed",
")",
":",
"if",
"isinstance",
"(",
"new_state",
",",
"str",
")",
":",
"# an existing state",
"if",
"new_state",
"==",
"'#pop'",
":",
"return",
"-",
"1",
"elif",
... | [
434,
4
] | [
467,
64
] | python | en | ['en', 'en', 'en'] | True |
RegexLexerMeta._process_state | (cls, unprocessed, processed, state) | Preprocess a single state definition. | Preprocess a single state definition. | def _process_state(cls, unprocessed, processed, state):
"""Preprocess a single state definition."""
assert type(state) is str, "wrong state name %r" % state
assert state[0] != '#', "invalid state name %r" % state
if state in processed:
return processed[state]
tokens =... | [
"def",
"_process_state",
"(",
"cls",
",",
"unprocessed",
",",
"processed",
",",
"state",
")",
":",
"assert",
"type",
"(",
"state",
")",
"is",
"str",
",",
"\"wrong state name %r\"",
"%",
"state",
"assert",
"state",
"[",
"0",
"]",
"!=",
"'#'",
",",
"\"inva... | [
469,
4
] | [
511,
21
] | python | en | ['en', 'en', 'en'] | True |
RegexLexerMeta.process_tokendef | (cls, name, tokendefs=None) | Preprocess a dictionary of token definitions. | Preprocess a dictionary of token definitions. | def process_tokendef(cls, name, tokendefs=None):
"""Preprocess a dictionary of token definitions."""
processed = cls._all_tokens[name] = {}
tokendefs = tokendefs or cls.tokens[name]
for state in list(tokendefs):
cls._process_state(tokendefs, processed, state)
return p... | [
"def",
"process_tokendef",
"(",
"cls",
",",
"name",
",",
"tokendefs",
"=",
"None",
")",
":",
"processed",
"=",
"cls",
".",
"_all_tokens",
"[",
"name",
"]",
"=",
"{",
"}",
"tokendefs",
"=",
"tokendefs",
"or",
"cls",
".",
"tokens",
"[",
"name",
"]",
"f... | [
513,
4
] | [
519,
24
] | python | en | ['en', 'en', 'en'] | True |
RegexLexerMeta.get_tokendefs | (cls) |
Merge tokens from superclasses in MRO order, returning a single tokendef
dictionary.
Any state that is not defined by a subclass will be inherited
automatically. States that *are* defined by subclasses will, by
default, override that state in the superclass. If a subclass wis... |
Merge tokens from superclasses in MRO order, returning a single tokendef
dictionary. | def get_tokendefs(cls):
"""
Merge tokens from superclasses in MRO order, returning a single tokendef
dictionary.
Any state that is not defined by a subclass will be inherited
automatically. States that *are* defined by subclasses will, by
default, override that state in... | [
"def",
"get_tokendefs",
"(",
"cls",
")",
":",
"tokens",
"=",
"{",
"}",
"inheritable",
"=",
"{",
"}",
"for",
"c",
"in",
"cls",
".",
"__mro__",
":",
"toks",
"=",
"c",
".",
"__dict__",
".",
"get",
"(",
"'tokens'",
",",
"{",
"}",
")",
"for",
"state",... | [
521,
4
] | [
568,
21
] | python | en | ['en', 'error', 'th'] | False |
RegexLexerMeta.__call__ | (cls, *args, **kwds) | Instantiate cls after preprocessing its token definitions. | Instantiate cls after preprocessing its token definitions. | def __call__(cls, *args, **kwds):
"""Instantiate cls after preprocessing its token definitions."""
if '_tokens' not in cls.__dict__:
cls._all_tokens = {}
cls._tmpname = 0
if hasattr(cls, 'token_variants') and cls.token_variants:
# don't process yet
... | [
"def",
"__call__",
"(",
"cls",
",",
"*",
"args",
",",
"*",
"*",
"kwds",
")",
":",
"if",
"'_tokens'",
"not",
"in",
"cls",
".",
"__dict__",
":",
"cls",
".",
"_all_tokens",
"=",
"{",
"}",
"cls",
".",
"_tmpname",
"=",
"0",
"if",
"hasattr",
"(",
"cls"... | [
570,
4
] | [
581,
48
] | python | en | ['en', 'en', 'en'] | True |
ExtendedRegexLexer.get_tokens_unprocessed | (self, text=None, context=None) |
Split ``text`` into (tokentype, text) pairs.
If ``context`` is given, use this lexer context instead.
|
Split ``text`` into (tokentype, text) pairs.
If ``context`` is given, use this lexer context instead.
| def get_tokens_unprocessed(self, text=None, context=None):
"""
Split ``text`` into (tokentype, text) pairs.
If ``context`` is given, use this lexer context instead.
"""
tokendefs = self._tokens
if not context:
ctx = LexerContext(text, 0)
statetoken... | [
"def",
"get_tokens_unprocessed",
"(",
"self",
",",
"text",
"=",
"None",
",",
"context",
"=",
"None",
")",
":",
"tokendefs",
"=",
"self",
".",
"_tokens",
"if",
"not",
"context",
":",
"ctx",
"=",
"LexerContext",
"(",
"text",
",",
"0",
")",
"statetokens",
... | [
693,
4
] | [
754,
25
] | python | en | ['en', 'error', 'th'] | False |
GlobReaderBatchKwargsGenerator._get_data_asset_paths | (self, data_asset_name) |
Returns a list of filepaths associated with the given data_asset_name
Args:
data_asset_name:
Returns:
paths (list)
|
Returns a list of filepaths associated with the given data_asset_name | def _get_data_asset_paths(self, data_asset_name):
"""
Returns a list of filepaths associated with the given data_asset_name
Args:
data_asset_name:
Returns:
paths (list)
"""
glob_config = self._get_data_asset_config(data_asset_name)
return... | [
"def",
"_get_data_asset_paths",
"(",
"self",
",",
"data_asset_name",
")",
":",
"glob_config",
"=",
"self",
".",
"_get_data_asset_config",
"(",
"data_asset_name",
")",
"return",
"glob",
".",
"glob",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"base... | [
177,
4
] | [
188,
80
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.