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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ActionSimulator.sample | (self, valid_only=True, rng=None) | Sample a random (valid) action from the action space. | Sample a random (valid) action from the action space. | def sample(self, valid_only=True, rng=None) -> ActionLike:
"""Sample a random (valid) action from the action space."""
return self._action_mapper.sample(valid_only=valid_only, rng=rng) | [
"def",
"sample",
"(",
"self",
",",
"valid_only",
"=",
"True",
",",
"rng",
"=",
"None",
")",
"->",
"ActionLike",
":",
"return",
"self",
".",
"_action_mapper",
".",
"sample",
"(",
"valid_only",
"=",
"valid_only",
",",
"rng",
"=",
"rng",
")"
] | [
116,
4
] | [
118,
73
] | python | en | ['en', 'en', 'en'] | True |
ActionSimulator.action_space_dim | (self) | Return dimension of the actions space. | Return dimension of the actions space. | def action_space_dim(self) -> int:
"""Return dimension of the actions space."""
return len(self._action_mapper.DIMENSION_TYPES) | [
"def",
"action_space_dim",
"(",
"self",
")",
"->",
"int",
":",
"return",
"len",
"(",
"self",
".",
"_action_mapper",
".",
"DIMENSION_TYPES",
")"
] | [
121,
4
] | [
123,
55
] | python | en | ['en', 'en', 'en'] | True |
ActionSimulator.build_discrete_action_space | (self, max_actions,
seed=1) | Build a mapping from the given number of action to the action space.
Args:
max_actions: int, maximum number of discrete actions.
seed: int, random seed to generate the subspace.
Returns:
discrete_actions: tuple of actions of length max_actions.
| Build a mapping from the given number of action to the action space. | def build_discrete_action_space(self, max_actions,
seed=1) -> Sequence[ActionLike]:
"""Build a mapping from the given number of action to the action space.
Args:
max_actions: int, maximum number of discrete actions.
seed: int, random seed to g... | [
"def",
"build_discrete_action_space",
"(",
"self",
",",
"max_actions",
",",
"seed",
"=",
"1",
")",
"->",
"Sequence",
"[",
"ActionLike",
"]",
":",
"rng",
"=",
"np",
".",
"random",
".",
"RandomState",
"(",
"seed",
"=",
"seed",
")",
"return",
"[",
"self",
... | [
125,
4
] | [
137,
65
] | python | en | ['en', 'en', 'en'] | True |
ActionSimulator.initial_scenes | (self) | Represents intial scene for each task before agent input.
uint8 array with shape (task, height, width).
| Represents intial scene for each task before agent input. | def initial_scenes(self) -> np.ndarray:
"""Represents intial scene for each task before agent input.
uint8 array with shape (task, height, width).
"""
return self._initial_scenes | [
"def",
"initial_scenes",
"(",
"self",
")",
"->",
"np",
".",
"ndarray",
":",
"return",
"self",
".",
"_initial_scenes"
] | [
140,
4
] | [
145,
35
] | python | en | ['en', 'en', 'en'] | True |
ActionSimulator.initial_featurized_objects | (self) | Inital scene objects featurized for each task before agent input.
List (length tasks) of FeaturizedObjects containing float arrays of size
(number scene objects, OBJECT_FEATURE_SIZE).
| Inital scene objects featurized for each task before agent input.
List (length tasks) of FeaturizedObjects containing float arrays of size
(number scene objects, OBJECT_FEATURE_SIZE).
| def initial_featurized_objects(self) -> np.ndarray:
"""Inital scene objects featurized for each task before agent input.
List (length tasks) of FeaturizedObjects containing float arrays of size
(number scene objects, OBJECT_FEATURE_SIZE).
"""
return self._initial_featuri... | [
"def",
"initial_featurized_objects",
"(",
"self",
")",
"->",
"np",
".",
"ndarray",
":",
"return",
"self",
".",
"_initial_featurized_objects"
] | [
148,
4
] | [
154,
47
] | python | en | ['en', 'en', 'en'] | True |
ActionSimulator.goals | (self) | Represents goals for each task.
uint8 array with shape (task, 3). Each goal is encoded with
three numbers: (obj_type1, obj_type2, rel). All three are less than
MAX_GOAL. To be more precise, obj_types are less than MAX_OBJECT_TYPE
and rel is less than MAX_RELATION.
| Represents goals for each task. | def goals(self) -> Optional[np.ndarray]:
"""Represents goals for each task.
uint8 array with shape (task, 3). Each goal is encoded with
three numbers: (obj_type1, obj_type2, rel). All three are less than
MAX_GOAL. To be more precise, obj_types are less than MAX_OBJECT_TYPE
and r... | [
"def",
"goals",
"(",
"self",
")",
"->",
"Optional",
"[",
"np",
".",
"ndarray",
"]",
":",
"return",
"self",
".",
"_goals"
] | [
157,
4
] | [
165,
26
] | python | en | ['en', 'en', 'en'] | True |
ActionSimulator.task_ids | (self) | Tuple of task ids in simulator.
| Tuple of task ids in simulator.
| def task_ids(self) -> Tuple[str, ...]:
"""Tuple of task ids in simulator.
"""
return self._task_ids | [
"def",
"task_ids",
"(",
"self",
")",
"->",
"Tuple",
"[",
"str",
",",
"...",
"]",
":",
"return",
"self",
".",
"_task_ids"
] | [
168,
4
] | [
171,
29
] | python | en | ['en', 'it', 'en'] | True |
ActionSimulator.simulate_single | (self,
task_index: int,
action: ActionLike,
need_images: bool = True,
stride: int = phyre.simulator.DEFAULT_STRIDE,
stable: bool = False
) | Deprecated in version 0.2.0 in favor of simulate_action.
Runs simluation for the action.
Args:
task_index: index of the task.
action: numpy array or list of self.action_space_dim floats in
[0, 1].
need_images: whether simulation images are needed.
... | Deprecated in version 0.2.0 in favor of simulate_action.
Runs simluation for the action. | def simulate_single(self,
task_index: int,
action: ActionLike,
need_images: bool = True,
stride: int = phyre.simulator.DEFAULT_STRIDE,
stable: bool = False
) -> Tuple[Simulation... | [
"def",
"simulate_single",
"(",
"self",
",",
"task_index",
":",
"int",
",",
"action",
":",
"ActionLike",
",",
"need_images",
":",
"bool",
"=",
"True",
",",
"stride",
":",
"int",
"=",
"phyre",
".",
"simulator",
".",
"DEFAULT_STRIDE",
",",
"stable",
":",
"b... | [
218,
4
] | [
255,
51
] | python | en | ['en', 'en', 'en'] | True |
ActionSimulator.simulate_action | (self,
task_index: int,
action: ActionLike,
*,
need_images: bool = True,
need_featurized_objects: bool = False,
stride: int = phyre.simulator.DEFAULT_STRIDE,
... | Runs simluation for the action.
Args:
task_index: index of the task.
action: numpy array or list of self.action_space_dim floats in
[0, 1].
need_images: whether simulation images are needed.
need_featurized_objects: whether simulation featurized_o... | Runs simluation for the action. | def simulate_action(self,
task_index: int,
action: ActionLike,
*,
need_images: bool = True,
need_featurized_objects: bool = False,
stride: int = phyre.simulator.DEFAULT_STRIDE,... | [
"def",
"simulate_action",
"(",
"self",
",",
"task_index",
":",
"int",
",",
"action",
":",
"ActionLike",
",",
"*",
",",
"need_images",
":",
"bool",
"=",
"True",
",",
"need_featurized_objects",
":",
"bool",
"=",
"False",
",",
"stride",
":",
"int",
"=",
"ph... | [
257,
4
] | [
333,
39
] | python | en | ['en', 'en', 'en'] | True |
read_configuration | (
filepath, find_others=False, ignore_option_errors=False) | Read given configuration file and returns options from it as a dict.
:param str|unicode filepath: Path to configuration file
to get options from.
:param bool find_others: Whether to search for other configuration files
which could be on in various places.
:param bool ignore_option_errors:... | Read given configuration file and returns options from it as a dict. | def read_configuration(
filepath, find_others=False, ignore_option_errors=False):
"""Read given configuration file and returns options from it as a dict.
:param str|unicode filepath: Path to configuration file
to get options from.
:param bool find_others: Whether to search for other config... | [
"def",
"read_configuration",
"(",
"filepath",
",",
"find_others",
"=",
"False",
",",
"ignore_option_errors",
"=",
"False",
")",
":",
"from",
"setuptools",
".",
"dist",
"import",
"Distribution",
",",
"_Distribution",
"filepath",
"=",
"os",
".",
"path",
".",
"ab... | [
12,
0
] | [
56,
42
] | python | en | ['en', 'en', 'en'] | True |
configuration_to_dict | (handlers) | Returns configuration data gathered by given handlers as a dict.
:param list[ConfigHandler] handlers: Handlers list,
usually from parse_configuration()
:rtype: dict
| Returns configuration data gathered by given handlers as a dict. | def configuration_to_dict(handlers):
"""Returns configuration data gathered by given handlers as a dict.
:param list[ConfigHandler] handlers: Handlers list,
usually from parse_configuration()
:rtype: dict
"""
config_dict = defaultdict(dict)
for handler in handlers:
obj_alias ... | [
"def",
"configuration_to_dict",
"(",
"handlers",
")",
":",
"config_dict",
"=",
"defaultdict",
"(",
"dict",
")",
"for",
"handler",
"in",
"handlers",
":",
"obj_alias",
"=",
"handler",
".",
"section_prefix",
"target_obj",
"=",
"handler",
".",
"target_obj",
"for",
... | [
59,
0
] | [
85,
22
] | python | en | ['en', 'en', 'en'] | True |
parse_configuration | (
distribution, command_options, ignore_option_errors=False) | Performs additional parsing of configuration options
for a distribution.
Returns a list of used option handlers.
:param Distribution distribution:
:param dict command_options:
:param bool ignore_option_errors: Whether to silently ignore
options, values of which could not be resolved (e.g. ... | Performs additional parsing of configuration options
for a distribution. | def parse_configuration(
distribution, command_options, ignore_option_errors=False):
"""Performs additional parsing of configuration options
for a distribution.
Returns a list of used option handlers.
:param Distribution distribution:
:param dict command_options:
:param bool ignore_opt... | [
"def",
"parse_configuration",
"(",
"distribution",
",",
"command_options",
",",
"ignore_option_errors",
"=",
"False",
")",
":",
"meta",
"=",
"ConfigMetadataHandler",
"(",
"distribution",
".",
"metadata",
",",
"command_options",
",",
"ignore_option_errors",
")",
"meta"... | [
88,
0
] | [
111,
24
] | python | en | ['en', 'en', 'en'] | True |
ConfigHandler.parsers | (self) | Metadata item name to parser function mapping. | Metadata item name to parser function mapping. | def parsers(self):
"""Metadata item name to parser function mapping."""
raise NotImplementedError(
'%s must provide .parsers property' % self.__class__.__name__) | [
"def",
"parsers",
"(",
"self",
")",
":",
"raise",
"NotImplementedError",
"(",
"'%s must provide .parsers property'",
"%",
"self",
".",
"__class__",
".",
"__name__",
")"
] | [
147,
4
] | [
150,
74
] | python | en | ['en', 'jv', 'en'] | True |
ConfigHandler._parse_list | (cls, value, separator=',') | Represents value as a list.
Value is split either by separator (defaults to comma) or by lines.
:param value:
:param separator: List items separator character.
:rtype: list
| Represents value as a list. | def _parse_list(cls, value, separator=','):
"""Represents value as a list.
Value is split either by separator (defaults to comma) or by lines.
:param value:
:param separator: List items separator character.
:rtype: list
"""
if isinstance(value, list): # _get_pa... | [
"def",
"_parse_list",
"(",
"cls",
",",
"value",
",",
"separator",
"=",
"','",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"list",
")",
":",
"# _get_parser_compound case",
"return",
"value",
"if",
"'\\n'",
"in",
"value",
":",
"value",
"=",
"value",
"... | [
191,
4
] | [
208,
66
] | python | en | ['en', 'en', 'en'] | True |
ConfigHandler._parse_dict | (cls, value) | Represents value as a dict.
:param value:
:rtype: dict
| Represents value as a dict. | def _parse_dict(cls, value):
"""Represents value as a dict.
:param value:
:rtype: dict
"""
separator = '='
result = {}
for line in cls._parse_list(value):
key, sep, val = line.partition(separator)
if sep != separator:
raise... | [
"def",
"_parse_dict",
"(",
"cls",
",",
"value",
")",
":",
"separator",
"=",
"'='",
"result",
"=",
"{",
"}",
"for",
"line",
"in",
"cls",
".",
"_parse_list",
"(",
"value",
")",
":",
"key",
",",
"sep",
",",
"val",
"=",
"line",
".",
"partition",
"(",
... | [
211,
4
] | [
226,
21
] | python | en | ['en', 'ca', 'en'] | True |
ConfigHandler._parse_bool | (cls, value) | Represents value as boolean.
:param value:
:rtype: bool
| Represents value as boolean. | def _parse_bool(cls, value):
"""Represents value as boolean.
:param value:
:rtype: bool
"""
value = value.lower()
return value in ('1', 'true', 'yes') | [
"def",
"_parse_bool",
"(",
"cls",
",",
"value",
")",
":",
"value",
"=",
"value",
".",
"lower",
"(",
")",
"return",
"value",
"in",
"(",
"'1'",
",",
"'true'",
",",
"'yes'",
")"
] | [
229,
4
] | [
236,
44
] | python | en | ['en', 'en', 'en'] | True |
ConfigHandler._parse_file | (cls, value) | Represents value as a string, allowing including text
from nearest files using `file:` directive.
Directive is sandboxed and won't reach anything outside
directory with setup.py.
Examples:
file: LICENSE
file: README.rst, CHANGELOG.md, src/file.txt
:para... | Represents value as a string, allowing including text
from nearest files using `file:` directive. | def _parse_file(cls, value):
"""Represents value as a string, allowing including text
from nearest files using `file:` directive.
Directive is sandboxed and won't reach anything outside
directory with setup.py.
Examples:
file: LICENSE
file: README.rst, C... | [
"def",
"_parse_file",
"(",
"cls",
",",
"value",
")",
":",
"include_directive",
"=",
"'file:'",
"if",
"not",
"isinstance",
"(",
"value",
",",
"string_types",
")",
":",
"return",
"value",
"if",
"not",
"value",
".",
"startswith",
"(",
"include_directive",
")",
... | [
239,
4
] | [
268,
9
] | python | en | ['en', 'en', 'en'] | True |
ConfigHandler._parse_attr | (cls, value) | Represents value as a module attribute.
Examples:
attr: package.attr
attr: package.module.attr
:param str value:
:rtype: str
| Represents value as a module attribute. | def _parse_attr(cls, value):
"""Represents value as a module attribute.
Examples:
attr: package.attr
attr: package.module.attr
:param str value:
:rtype: str
"""
attr_directive = 'attr:'
if not value.startswith(attr_directive):
... | [
"def",
"_parse_attr",
"(",
"cls",
",",
"value",
")",
":",
"attr_directive",
"=",
"'attr:'",
"if",
"not",
"value",
".",
"startswith",
"(",
"attr_directive",
")",
":",
"return",
"value",
"attrs_path",
"=",
"value",
".",
"replace",
"(",
"attr_directive",
",",
... | [
282,
4
] | [
310,
20
] | python | en | ['en', 'en', 'en'] | True |
ConfigHandler._get_parser_compound | (cls, *parse_methods) | Returns parser function to represents value as a list.
Parses a value applying given methods one after another.
:param parse_methods:
:rtype: callable
| Returns parser function to represents value as a list. | def _get_parser_compound(cls, *parse_methods):
"""Returns parser function to represents value as a list.
Parses a value applying given methods one after another.
:param parse_methods:
:rtype: callable
"""
def parse(value):
parsed = value
for met... | [
"def",
"_get_parser_compound",
"(",
"cls",
",",
"*",
"parse_methods",
")",
":",
"def",
"parse",
"(",
"value",
")",
":",
"parsed",
"=",
"value",
"for",
"method",
"in",
"parse_methods",
":",
"parsed",
"=",
"method",
"(",
"parsed",
")",
"return",
"parsed",
... | [
313,
4
] | [
329,
20
] | python | en | ['en', 'en', 'en'] | True |
ConfigHandler._parse_section_to_dict | (cls, section_options, values_parser=None) | Parses section options into a dictionary.
Optionally applies a given parser to values.
:param dict section_options:
:param callable values_parser:
:rtype: dict
| Parses section options into a dictionary. | def _parse_section_to_dict(cls, section_options, values_parser=None):
"""Parses section options into a dictionary.
Optionally applies a given parser to values.
:param dict section_options:
:param callable values_parser:
:rtype: dict
"""
value = {}
values... | [
"def",
"_parse_section_to_dict",
"(",
"cls",
",",
"section_options",
",",
"values_parser",
"=",
"None",
")",
":",
"value",
"=",
"{",
"}",
"values_parser",
"=",
"values_parser",
"or",
"(",
"lambda",
"val",
":",
"val",
")",
"for",
"key",
",",
"(",
"_",
","... | [
332,
4
] | [
345,
20
] | python | en | ['en', 'en', 'en'] | True |
ConfigHandler.parse_section | (self, section_options) | Parses configuration file section.
:param dict section_options:
| Parses configuration file section. | def parse_section(self, section_options):
"""Parses configuration file section.
:param dict section_options:
"""
for (name, (_, value)) in section_options.items():
try:
self[name] = value
except KeyError:
pass | [
"def",
"parse_section",
"(",
"self",
",",
"section_options",
")",
":",
"for",
"(",
"name",
",",
"(",
"_",
",",
"value",
")",
")",
"in",
"section_options",
".",
"items",
"(",
")",
":",
"try",
":",
"self",
"[",
"name",
"]",
"=",
"value",
"except",
"K... | [
347,
4
] | [
357,
20
] | python | en | ['en', 'en', 'en'] | True |
ConfigHandler.parse | (self) | Parses configuration file items from one
or more related sections.
| Parses configuration file items from one
or more related sections. | def parse(self):
"""Parses configuration file items from one
or more related sections.
"""
for section_name, section_options in self.sections.items():
method_postfix = ''
if section_name: # [section.option] variant
method_postfix = '_%s' % secti... | [
"def",
"parse",
"(",
"self",
")",
":",
"for",
"section_name",
",",
"section_options",
"in",
"self",
".",
"sections",
".",
"items",
"(",
")",
":",
"method_postfix",
"=",
"''",
"if",
"section_name",
":",
"# [section.option] variant",
"method_postfix",
"=",
"'_%s... | [
359,
4
] | [
381,
50
] | python | en | ['en', 'en', 'en'] | True |
ConfigMetadataHandler.parsers | (self) | Metadata item name to parser function mapping. | Metadata item name to parser function mapping. | def parsers(self):
"""Metadata item name to parser function mapping."""
parse_list = self._parse_list
parse_file = self._parse_file
parse_dict = self._parse_dict
return {
'platforms': parse_list,
'keywords': parse_list,
'provides': parse_list,... | [
"def",
"parsers",
"(",
"self",
")",
":",
"parse_list",
"=",
"self",
".",
"_parse_list",
"parse_file",
"=",
"self",
".",
"_parse_file",
"parse_dict",
"=",
"self",
".",
"_parse_dict",
"return",
"{",
"'platforms'",
":",
"parse_list",
",",
"'keywords'",
":",
"pa... | [
402,
4
] | [
420,
9
] | python | en | ['en', 'jv', 'en'] | True |
ConfigMetadataHandler._parse_version | (self, value) | Parses `version` option value.
:param value:
:rtype: str
| Parses `version` option value. | def _parse_version(self, value):
"""Parses `version` option value.
:param value:
:rtype: str
"""
version = self._parse_attr(value)
if callable(version):
version = version()
if not isinstance(version, string_types):
if hasattr(version, '... | [
"def",
"_parse_version",
"(",
"self",
",",
"value",
")",
":",
"version",
"=",
"self",
".",
"_parse_attr",
"(",
"value",
")",
"if",
"callable",
"(",
"version",
")",
":",
"version",
"=",
"version",
"(",
")",
"if",
"not",
"isinstance",
"(",
"version",
","... | [
422,
4
] | [
440,
22
] | python | en | ['en', 'fr', 'en'] | True |
ConfigOptionsHandler.parsers | (self) | Metadata item name to parser function mapping. | Metadata item name to parser function mapping. | def parsers(self):
"""Metadata item name to parser function mapping."""
parse_list = self._parse_list
parse_list_semicolon = partial(self._parse_list, separator=';')
parse_bool = self._parse_bool
parse_dict = self._parse_dict
return {
'zip_safe': parse_bool,
... | [
"def",
"parsers",
"(",
"self",
")",
":",
"parse_list",
"=",
"self",
".",
"_parse_list",
"parse_list_semicolon",
"=",
"partial",
"(",
"self",
".",
"_parse_list",
",",
"separator",
"=",
"';'",
")",
"parse_bool",
"=",
"self",
".",
"_parse_bool",
"parse_dict",
"... | [
448,
4
] | [
473,
9
] | python | en | ['en', 'jv', 'en'] | True |
ConfigOptionsHandler._parse_packages | (self, value) | Parses `packages` option value.
:param value:
:rtype: list
| Parses `packages` option value. | def _parse_packages(self, value):
"""Parses `packages` option value.
:param value:
:rtype: list
"""
find_directive = 'find:'
if not value.startswith(find_directive):
return self._parse_list(value)
# Read function arguments from a dedicated section.
... | [
"def",
"_parse_packages",
"(",
"self",
",",
"value",
")",
":",
"find_directive",
"=",
"'find:'",
"if",
"not",
"value",
".",
"startswith",
"(",
"find_directive",
")",
":",
"return",
"self",
".",
"_parse_list",
"(",
"value",
")",
"# Read function arguments from a ... | [
475,
4
] | [
492,
43
] | python | en | ['en', 'en', 'en'] | True |
ConfigOptionsHandler.parse_section_packages__find | (self, section_options) | Parses `packages.find` configuration file section.
To be used in conjunction with _parse_packages().
:param dict section_options:
| Parses `packages.find` configuration file section. | def parse_section_packages__find(self, section_options):
"""Parses `packages.find` configuration file section.
To be used in conjunction with _parse_packages().
:param dict section_options:
"""
section_data = self._parse_section_to_dict(
section_options, self._parse... | [
"def",
"parse_section_packages__find",
"(",
"self",
",",
"section_options",
")",
":",
"section_data",
"=",
"self",
".",
"_parse_section_to_dict",
"(",
"section_options",
",",
"self",
".",
"_parse_list",
")",
"valid_keys",
"=",
"[",
"'where'",
",",
"'include'",
","... | [
494,
4
] | [
513,
26
] | python | en | ['en', 'en', 'en'] | True |
ConfigOptionsHandler.parse_section_entry_points | (self, section_options) | Parses `entry_points` configuration file section.
:param dict section_options:
| Parses `entry_points` configuration file section. | def parse_section_entry_points(self, section_options):
"""Parses `entry_points` configuration file section.
:param dict section_options:
"""
parsed = self._parse_section_to_dict(section_options, self._parse_list)
self['entry_points'] = parsed | [
"def",
"parse_section_entry_points",
"(",
"self",
",",
"section_options",
")",
":",
"parsed",
"=",
"self",
".",
"_parse_section_to_dict",
"(",
"section_options",
",",
"self",
".",
"_parse_list",
")",
"self",
"[",
"'entry_points'",
"]",
"=",
"parsed"
] | [
515,
4
] | [
521,
37
] | python | en | ['en', 'en', 'en'] | True |
ConfigOptionsHandler.parse_section_package_data | (self, section_options) | Parses `package_data` configuration file section.
:param dict section_options:
| Parses `package_data` configuration file section. | def parse_section_package_data(self, section_options):
"""Parses `package_data` configuration file section.
:param dict section_options:
"""
self['package_data'] = self._parse_package_data(section_options) | [
"def",
"parse_section_package_data",
"(",
"self",
",",
"section_options",
")",
":",
"self",
"[",
"'package_data'",
"]",
"=",
"self",
".",
"_parse_package_data",
"(",
"section_options",
")"
] | [
533,
4
] | [
538,
72
] | python | en | ['en', 'en', 'en'] | True |
ConfigOptionsHandler.parse_section_exclude_package_data | (self, section_options) | Parses `exclude_package_data` configuration file section.
:param dict section_options:
| Parses `exclude_package_data` configuration file section. | def parse_section_exclude_package_data(self, section_options):
"""Parses `exclude_package_data` configuration file section.
:param dict section_options:
"""
self['exclude_package_data'] = self._parse_package_data(
section_options) | [
"def",
"parse_section_exclude_package_data",
"(",
"self",
",",
"section_options",
")",
":",
"self",
"[",
"'exclude_package_data'",
"]",
"=",
"self",
".",
"_parse_package_data",
"(",
"section_options",
")"
] | [
540,
4
] | [
546,
28
] | python | en | ['en', 'en', 'en'] | True |
ConfigOptionsHandler.parse_section_extras_require | (self, section_options) | Parses `extras_require` configuration file section.
:param dict section_options:
| Parses `extras_require` configuration file section. | def parse_section_extras_require(self, section_options):
"""Parses `extras_require` configuration file section.
:param dict section_options:
"""
parse_list = partial(self._parse_list, separator=';')
self['extras_require'] = self._parse_section_to_dict(
section_option... | [
"def",
"parse_section_extras_require",
"(",
"self",
",",
"section_options",
")",
":",
"parse_list",
"=",
"partial",
"(",
"self",
".",
"_parse_list",
",",
"separator",
"=",
"';'",
")",
"self",
"[",
"'extras_require'",
"]",
"=",
"self",
".",
"_parse_section_to_dic... | [
548,
4
] | [
555,
40
] | python | en | ['es', 'en', 'en'] | True |
CaseInsensitiveDict.lower_items | (self) | Like iteritems(), but with all lowercase keys. | Like iteritems(), but with all lowercase keys. | def lower_items(self):
"""Like iteritems(), but with all lowercase keys."""
return (
(lowerkey, keyval[1])
for (lowerkey, keyval)
in self._store.items()
) | [
"def",
"lower_items",
"(",
"self",
")",
":",
"return",
"(",
"(",
"lowerkey",
",",
"keyval",
"[",
"1",
"]",
")",
"for",
"(",
"lowerkey",
",",
"keyval",
")",
"in",
"self",
".",
"_store",
".",
"items",
"(",
")",
")"
] | [
64,
4
] | [
70,
9
] | python | en | ['en', 'en', 'en'] | True |
fix_shape_and_type_for_serving | (placeholder) | Fixes the shape and type of serving input strings.
Given placeholder tensor, return parsed and processed feature tensor.
Args:
placeholder: Placeholder tensor holding raw data from serving input
function.
Returns:
Parsed and processed feature tensor.
| Fixes the shape and type of serving input strings. | def fix_shape_and_type_for_serving(placeholder):
"""Fixes the shape and type of serving input strings.
Given placeholder tensor, return parsed and processed feature tensor.
Args:
placeholder: Placeholder tensor holding raw data from serving input
function.
Returns:
Parsed and processed feature ... | [
"def",
"fix_shape_and_type_for_serving",
"(",
"placeholder",
")",
":",
"cur_batch_size",
"=",
"tf",
".",
"shape",
"(",
"input",
"=",
"placeholder",
",",
"out_type",
"=",
"tf",
".",
"int64",
")",
"[",
"0",
"]",
"# String split each string in batch and output values f... | [
4,
0
] | [
33,
23
] | python | en | ['en', 'en', 'en'] | True |
get_shape_and_set_modified_shape_2D | (tensor, additional_dimension_sizes) | Fixes the shape and type of serving input strings.
Given feature tensor and additional dimension size, sequence length,
fixes dynamic shape ambiguity of last dimension so that we will be able to
use it in our DNN (since tf.layers.dense require the last dimension to be
known).
Args:
tensor: tf.float64 ve... | Fixes the shape and type of serving input strings. | def get_shape_and_set_modified_shape_2D(tensor, additional_dimension_sizes):
"""Fixes the shape and type of serving input strings.
Given feature tensor and additional dimension size, sequence length,
fixes dynamic shape ambiguity of last dimension so that we will be able to
use it in our DNN (since tf.layers.d... | [
"def",
"get_shape_and_set_modified_shape_2D",
"(",
"tensor",
",",
"additional_dimension_sizes",
")",
":",
"# Get static shape for tensor and convert it to list",
"shape",
"=",
"tensor",
".",
"get_shape",
"(",
")",
".",
"as_list",
"(",
")",
"# Set outer shape to additional_dim... | [
36,
0
] | [
61,
15
] | python | en | ['en', 'en', 'en'] | True |
serving_input_fn | (feat_names, seq_len) | Serving input function.
Given the sequence length, return ServingInputReceiver object.
Args:
feat_names: List of string names of features.
seq_len: Number of timesteps in sequence.
Returns:
ServingInputReceiver object containing features and receiver tensors.
| Serving input function. | def serving_input_fn(feat_names, seq_len):
"""Serving input function.
Given the sequence length, return ServingInputReceiver object.
Args:
feat_names: List of string names of features.
seq_len: Number of timesteps in sequence.
Returns:
ServingInputReceiver object containing features and receiver ... | [
"def",
"serving_input_fn",
"(",
"feat_names",
",",
"seq_len",
")",
":",
"# Create placeholders to accept the data sent to the model at serving time",
"# All features come in as a batch of strings, shape = (batch_size,),",
"# this was so because of passing the arrays to online ml-engine predictio... | [
64,
0
] | [
95,
63
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceAsyncClient.from_service_account_info | (cls, info: dict, *args, **kwargs) | Creates an instance of this client using the provided credentials
info.
Args:
info (dict): The service account private key info.
args: Additional arguments to pass to the constructor.
kwargs: Additional arguments to pass to the constructor.
Returns:
... | Creates an instance of this client using the provided credentials
info. | def from_service_account_info(cls, info: dict, *args, **kwargs):
"""Creates an instance of this client using the provided credentials
info.
Args:
info (dict): The service account private key info.
args: Additional arguments to pass to the constructor.
kwa... | [
"def",
"from_service_account_info",
"(",
"cls",
",",
"info",
":",
"dict",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"DashboardsServiceClient",
".",
"from_service_account_info",
".",
"__func__",
"(",
"DashboardsServiceAsyncClient",
",",
"info",... | [
84,
4
] | [
96,
126
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceAsyncClient.from_service_account_file | (cls, filename: str, *args, **kwargs) | Creates an instance of this client using the provided credentials
file.
Args:
filename (str): The path to the service account private key json
file.
args: Additional arguments to pass to the constructor.
kwargs: Additional arguments to pass to the... | Creates an instance of this client using the provided credentials
file. | def from_service_account_file(cls, filename: str, *args, **kwargs):
"""Creates an instance of this client using the provided credentials
file.
Args:
filename (str): The path to the service account private key json
file.
args: Additional arguments to p... | [
"def",
"from_service_account_file",
"(",
"cls",
",",
"filename",
":",
"str",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"DashboardsServiceClient",
".",
"from_service_account_file",
".",
"__func__",
"(",
"DashboardsServiceAsyncClient",
",",
"fil... | [
99,
4
] | [
112,
130
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceAsyncClient.transport | (self) | Returns the transport used by the client instance.
Returns:
DashboardsServiceTransport: The transport used by the client instance.
| Returns the transport used by the client instance. | def transport(self) -> DashboardsServiceTransport:
"""Returns the transport used by the client instance.
Returns:
DashboardsServiceTransport: The transport used by the client instance.
"""
return self._client.transport | [
"def",
"transport",
"(",
"self",
")",
"->",
"DashboardsServiceTransport",
":",
"return",
"self",
".",
"_client",
".",
"transport"
] | [
117,
4
] | [
123,
37
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceAsyncClient.__init__ | (
self,
*,
credentials: ga_credentials.Credentials = None,
transport: Union[str, DashboardsServiceTransport] = "grpc_asyncio",
client_options: ClientOptions = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
) | Instantiates the dashboards service client.
Args:
credentials (Optional[google.auth.credentials.Credentials]): The
authorization credentials to attach to requests. These
credentials identify the application to the service; if none
are specified, the c... | Instantiates the dashboards service client. | def __init__(
self,
*,
credentials: ga_credentials.Credentials = None,
transport: Union[str, DashboardsServiceTransport] = "grpc_asyncio",
client_options: ClientOptions = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
) -> None:
"""I... | [
"def",
"__init__",
"(",
"self",
",",
"*",
",",
"credentials",
":",
"ga_credentials",
".",
"Credentials",
"=",
"None",
",",
"transport",
":",
"Union",
"[",
"str",
",",
"DashboardsServiceTransport",
"]",
"=",
"\"grpc_asyncio\"",
",",
"client_options",
":",
"Clie... | [
129,
4
] | [
174,
9
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceAsyncClient.create_dashboard | (
self,
request: Union[dashboards_service.CreateDashboardRequest, dict] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) | r"""Creates a new custom dashboard. For examples on how you can use
this API to create dashboards, see `Managing dashboards by
API <https://cloud.google.com/monitoring/dashboards/api-dashboard>`__.
This method requires the ``monitoring.dashboards.create``
permission on the specified proj... | r"""Creates a new custom dashboard. For examples on how you can use
this API to create dashboards, see `Managing dashboards by
API <https://cloud.google.com/monitoring/dashboards/api-dashboard>`__.
This method requires the ``monitoring.dashboards.create``
permission on the specified proj... | async def create_dashboard(
self,
request: Union[dashboards_service.CreateDashboardRequest, dict] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> dashboard.Dashboard:
r"""Creates ... | [
"async",
"def",
"create_dashboard",
"(",
"self",
",",
"request",
":",
"Union",
"[",
"dashboards_service",
".",
"CreateDashboardRequest",
",",
"dict",
"]",
"=",
"None",
",",
"*",
",",
"retry",
":",
"OptionalRetry",
"=",
"gapic_v1",
".",
"method",
".",
"DEFAUL... | [
176,
4
] | [
230,
23
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceAsyncClient.list_dashboards | (
self,
request: Union[dashboards_service.ListDashboardsRequest, dict] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) | r"""Lists the existing dashboards.
This method requires the ``monitoring.dashboards.list``
permission on the specified project. For more information, see
`Cloud Identity and Access
Management <https://cloud.google.com/iam>`__.
Args:
request (Union[google.cloud.monit... | r"""Lists the existing dashboards. | async def list_dashboards(
self,
request: Union[dashboards_service.ListDashboardsRequest, dict] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListDashboardsAsyncPager:
r"... | [
"async",
"def",
"list_dashboards",
"(",
"self",
",",
"request",
":",
"Union",
"[",
"dashboards_service",
".",
"ListDashboardsRequest",
",",
"dict",
"]",
"=",
"None",
",",
"*",
",",
"retry",
":",
"OptionalRetry",
"=",
"gapic_v1",
".",
"method",
".",
"DEFAULT"... | [
232,
4
] | [
291,
23
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceAsyncClient.get_dashboard | (
self,
request: Union[dashboards_service.GetDashboardRequest, dict] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) | r"""Fetches a specific dashboard.
This method requires the ``monitoring.dashboards.get``
permission on the specified dashboard. For more information, see
`Cloud Identity and Access
Management <https://cloud.google.com/iam>`__.
Args:
request (Union[google.cloud.monit... | r"""Fetches a specific dashboard. | async def get_dashboard(
self,
request: Union[dashboards_service.GetDashboardRequest, dict] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> dashboard.Dashboard:
r"""Fetches a spec... | [
"async",
"def",
"get_dashboard",
"(",
"self",
",",
"request",
":",
"Union",
"[",
"dashboards_service",
".",
"GetDashboardRequest",
",",
"dict",
"]",
"=",
"None",
",",
"*",
",",
"retry",
":",
"OptionalRetry",
"=",
"gapic_v1",
".",
"method",
".",
"DEFAULT",
... | [
293,
4
] | [
346,
23
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceAsyncClient.delete_dashboard | (
self,
request: Union[dashboards_service.DeleteDashboardRequest, dict] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) | r"""Deletes an existing custom dashboard.
This method requires the ``monitoring.dashboards.delete``
permission on the specified dashboard. For more information, see
`Cloud Identity and Access
Management <https://cloud.google.com/iam>`__.
Args:
request (Union[google.... | r"""Deletes an existing custom dashboard. | async def delete_dashboard(
self,
request: Union[dashboards_service.DeleteDashboardRequest, dict] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> None:
r"""Deletes an existing cus... | [
"async",
"def",
"delete_dashboard",
"(",
"self",
",",
"request",
":",
"Union",
"[",
"dashboards_service",
".",
"DeleteDashboardRequest",
",",
"dict",
"]",
"=",
"None",
",",
"*",
",",
"retry",
":",
"OptionalRetry",
"=",
"gapic_v1",
".",
"method",
".",
"DEFAUL... | [
348,
4
] | [
392,
9
] | python | en | ['en', 'cy', 'en'] | True |
DashboardsServiceAsyncClient.update_dashboard | (
self,
request: Union[dashboards_service.UpdateDashboardRequest, dict] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) | r"""Replaces an existing custom dashboard with a new definition.
This method requires the ``monitoring.dashboards.update``
permission on the specified dashboard. For more information, see
`Cloud Identity and Access
Management <https://cloud.google.com/iam>`__.
Args:
... | r"""Replaces an existing custom dashboard with a new definition. | async def update_dashboard(
self,
request: Union[dashboards_service.UpdateDashboardRequest, dict] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> dashboard.Dashboard:
r"""Replaces... | [
"async",
"def",
"update_dashboard",
"(",
"self",
",",
"request",
":",
"Union",
"[",
"dashboards_service",
".",
"UpdateDashboardRequest",
",",
"dict",
"]",
"=",
"None",
",",
"*",
",",
"retry",
":",
"OptionalRetry",
"=",
"gapic_v1",
".",
"method",
".",
"DEFAUL... | [
394,
4
] | [
449,
23
] | python | en | ['en', 'en', 'en'] | True |
_const_compare_digest_backport | (a, b) |
Compare two digests of equal length in constant time.
The digests must be of type str/bytes.
Returns True if the digests match, and False otherwise.
|
Compare two digests of equal length in constant time. | def _const_compare_digest_backport(a, b):
"""
Compare two digests of equal length in constant time.
The digests must be of type str/bytes.
Returns True if the digests match, and False otherwise.
"""
result = abs(len(a) - len(b))
for left, right in zip(bytearray(a), bytearray(b)):
re... | [
"def",
"_const_compare_digest_backport",
"(",
"a",
",",
"b",
")",
":",
"result",
"=",
"abs",
"(",
"len",
"(",
"a",
")",
"-",
"len",
"(",
"b",
")",
")",
"for",
"left",
",",
"right",
"in",
"zip",
"(",
"bytearray",
"(",
"a",
")",
",",
"bytearray",
"... | [
29,
0
] | [
39,
22
] | python | en | ['en', 'error', 'th'] | False |
assert_fingerprint | (cert, fingerprint) |
Checks if given fingerprint matches the supplied certificate.
:param cert:
Certificate as bytes object.
:param fingerprint:
Fingerprint as string of hexdigits, can be interspersed by colons.
|
Checks if given fingerprint matches the supplied certificate. | def assert_fingerprint(cert, fingerprint):
"""
Checks if given fingerprint matches the supplied certificate.
:param cert:
Certificate as bytes object.
:param fingerprint:
Fingerprint as string of hexdigits, can be interspersed by colons.
"""
fingerprint = fingerprint.replace(":... | [
"def",
"assert_fingerprint",
"(",
"cert",
",",
"fingerprint",
")",
":",
"fingerprint",
"=",
"fingerprint",
".",
"replace",
"(",
"\":\"",
",",
"\"\"",
")",
".",
"lower",
"(",
")",
"digest_length",
"=",
"len",
"(",
"fingerprint",
")",
"hashfunc",
"=",
"HASHF... | [
181,
0
] | [
207,
9
] | python | en | ['en', 'error', 'th'] | False |
resolve_cert_reqs | (candidate) |
Resolves the argument to a numeric constant, which can be passed to
the wrap_socket function/method from the ssl module.
Defaults to :data:`ssl.CERT_REQUIRED`.
If given a string it is assumed to be the name of the constant in the
:mod:`ssl` module or its abbreviation.
(So you can specify `REQUI... |
Resolves the argument to a numeric constant, which can be passed to
the wrap_socket function/method from the ssl module.
Defaults to :data:`ssl.CERT_REQUIRED`.
If given a string it is assumed to be the name of the constant in the
:mod:`ssl` module or its abbreviation.
(So you can specify `REQUI... | def resolve_cert_reqs(candidate):
"""
Resolves the argument to a numeric constant, which can be passed to
the wrap_socket function/method from the ssl module.
Defaults to :data:`ssl.CERT_REQUIRED`.
If given a string it is assumed to be the name of the constant in the
:mod:`ssl` module or its abb... | [
"def",
"resolve_cert_reqs",
"(",
"candidate",
")",
":",
"if",
"candidate",
"is",
"None",
":",
"return",
"CERT_REQUIRED",
"if",
"isinstance",
"(",
"candidate",
",",
"str",
")",
":",
"res",
"=",
"getattr",
"(",
"ssl",
",",
"candidate",
",",
"None",
")",
"i... | [
210,
0
] | [
230,
20
] | python | en | ['en', 'error', 'th'] | False |
resolve_ssl_version | (candidate) |
like resolve_cert_reqs
|
like resolve_cert_reqs
| def resolve_ssl_version(candidate):
"""
like resolve_cert_reqs
"""
if candidate is None:
return PROTOCOL_TLS
if isinstance(candidate, str):
res = getattr(ssl, candidate, None)
if res is None:
res = getattr(ssl, "PROTOCOL_" + candidate)
return res
ret... | [
"def",
"resolve_ssl_version",
"(",
"candidate",
")",
":",
"if",
"candidate",
"is",
"None",
":",
"return",
"PROTOCOL_TLS",
"if",
"isinstance",
"(",
"candidate",
",",
"str",
")",
":",
"res",
"=",
"getattr",
"(",
"ssl",
",",
"candidate",
",",
"None",
")",
"... | [
233,
0
] | [
246,
20
] | python | en | ['en', 'error', 'th'] | False |
create_urllib3_context | (
ssl_version=None, cert_reqs=None, options=None, ciphers=None
) | All arguments have the same meaning as ``ssl_wrap_socket``.
By default, this function does a lot of the same work that
``ssl.create_default_context`` does on Python 3.4+. It:
- Disables SSLv2, SSLv3, and compression
- Sets a restricted set of server ciphers
If you wish to enable SSLv3, you can do... | All arguments have the same meaning as ``ssl_wrap_socket``. | def create_urllib3_context(
ssl_version=None, cert_reqs=None, options=None, ciphers=None
):
"""All arguments have the same meaning as ``ssl_wrap_socket``.
By default, this function does a lot of the same work that
``ssl.create_default_context`` does on Python 3.4+. It:
- Disables SSLv2, SSLv3, and... | [
"def",
"create_urllib3_context",
"(",
"ssl_version",
"=",
"None",
",",
"cert_reqs",
"=",
"None",
",",
"options",
"=",
"None",
",",
"ciphers",
"=",
"None",
")",
":",
"# PROTOCOL_TLS is deprecated in Python 3.10",
"if",
"not",
"ssl_version",
"or",
"ssl_version",
"==... | [
249,
0
] | [
351,
18
] | python | en | ['en', 'en', 'en'] | True |
ssl_wrap_socket | (
sock,
keyfile=None,
certfile=None,
cert_reqs=None,
ca_certs=None,
server_hostname=None,
ssl_version=None,
ciphers=None,
ssl_context=None,
ca_cert_dir=None,
key_password=None,
ca_cert_data=None,
tls_in_tls=False,
) |
All arguments except for server_hostname, ssl_context, and ca_cert_dir have
the same meaning as they do when using :func:`ssl.wrap_socket`.
:param server_hostname:
When SNI is supported, the expected hostname of the certificate
:param ssl_context:
A pre-made :class:`SSLContext` object.... |
All arguments except for server_hostname, ssl_context, and ca_cert_dir have
the same meaning as they do when using :func:`ssl.wrap_socket`. | def ssl_wrap_socket(
sock,
keyfile=None,
certfile=None,
cert_reqs=None,
ca_certs=None,
server_hostname=None,
ssl_version=None,
ciphers=None,
ssl_context=None,
ca_cert_dir=None,
key_password=None,
ca_cert_data=None,
tls_in_tls=False,
):
"""
All arguments except... | [
"def",
"ssl_wrap_socket",
"(",
"sock",
",",
"keyfile",
"=",
"None",
",",
"certfile",
"=",
"None",
",",
"cert_reqs",
"=",
"None",
",",
"ca_certs",
"=",
"None",
",",
"server_hostname",
"=",
"None",
",",
"ssl_version",
"=",
"None",
",",
"ciphers",
"=",
"Non... | [
354,
0
] | [
453,
19
] | python | en | ['en', 'error', 'th'] | False |
is_ipaddress | (hostname) | Detects whether the hostname given is an IPv4 or IPv6 address.
Also detects IPv6 addresses with Zone IDs.
:param str hostname: Hostname to examine.
:return: True if the hostname is an IP address, False otherwise.
| Detects whether the hostname given is an IPv4 or IPv6 address.
Also detects IPv6 addresses with Zone IDs. | def is_ipaddress(hostname):
"""Detects whether the hostname given is an IPv4 or IPv6 address.
Also detects IPv6 addresses with Zone IDs.
:param str hostname: Hostname to examine.
:return: True if the hostname is an IP address, False otherwise.
"""
if not six.PY2 and isinstance(hostname, bytes):... | [
"def",
"is_ipaddress",
"(",
"hostname",
")",
":",
"if",
"not",
"six",
".",
"PY2",
"and",
"isinstance",
"(",
"hostname",
",",
"bytes",
")",
":",
"# IDN A-label bytes are ASCII compatible.",
"hostname",
"=",
"hostname",
".",
"decode",
"(",
"\"ascii\"",
")",
"ret... | [
456,
0
] | [
466,
83
] | python | en | ['en', 'en', 'en'] | True |
_is_key_file_encrypted | (key_file) | Detects if a key file is encrypted or not. | Detects if a key file is encrypted or not. | def _is_key_file_encrypted(key_file):
"""Detects if a key file is encrypted or not."""
with open(key_file, "r") as f:
for line in f:
# Look for Proc-Type: 4,ENCRYPTED
if "ENCRYPTED" in line:
return True
return False | [
"def",
"_is_key_file_encrypted",
"(",
"key_file",
")",
":",
"with",
"open",
"(",
"key_file",
",",
"\"r\"",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
":",
"# Look for Proc-Type: 4,ENCRYPTED",
"if",
"\"ENCRYPTED\"",
"in",
"line",
":",
"return",
"True",
"r... | [
469,
0
] | [
477,
16
] | python | en | ['en', 'en', 'en'] | True |
Mercurial.get_revision | (cls, location) |
Return the repository-local changeset revision number, as an integer.
|
Return the repository-local changeset revision number, as an integer.
| def get_revision(cls, location):
# type: (str) -> str
"""
Return the repository-local changeset revision number, as an integer.
"""
current_revision = cls.run_command(
['parents', '--template={rev}'],
show_stdout=False,
stdout_only=True,
... | [
"def",
"get_revision",
"(",
"cls",
",",
"location",
")",
":",
"# type: (str) -> str",
"current_revision",
"=",
"cls",
".",
"run_command",
"(",
"[",
"'parents'",
",",
"'--template={rev}'",
"]",
",",
"show_stdout",
"=",
"False",
",",
"stdout_only",
"=",
"True",
... | [
84,
4
] | [
95,
31
] | python | en | ['en', 'error', 'th'] | False |
Mercurial.get_requirement_revision | (cls, location) |
Return the changeset identification hash, as a 40-character
hexadecimal string
|
Return the changeset identification hash, as a 40-character
hexadecimal string
| def get_requirement_revision(cls, location):
# type: (str) -> str
"""
Return the changeset identification hash, as a 40-character
hexadecimal string
"""
current_rev_hash = cls.run_command(
['parents', '--template={node}'],
show_stdout=False,
... | [
"def",
"get_requirement_revision",
"(",
"cls",
",",
"location",
")",
":",
"# type: (str) -> str",
"current_rev_hash",
"=",
"cls",
".",
"run_command",
"(",
"[",
"'parents'",
",",
"'--template={node}'",
"]",
",",
"show_stdout",
"=",
"False",
",",
"stdout_only",
"=",... | [
98,
4
] | [
110,
31
] | python | en | ['en', 'error', 'th'] | False |
Mercurial.is_commit_id_equal | (cls, dest, name) | Always assume the versions don't match | Always assume the versions don't match | def is_commit_id_equal(cls, dest, name):
# type: (str, Optional[str]) -> bool
"""Always assume the versions don't match"""
return False | [
"def",
"is_commit_id_equal",
"(",
"cls",
",",
"dest",
",",
"name",
")",
":",
"# type: (str, Optional[str]) -> bool",
"return",
"False"
] | [
113,
4
] | [
116,
20
] | python | en | ['en', 'en', 'en'] | True |
Mercurial.get_subdirectory | (cls, location) |
Return the path to Python project root, relative to the repo root.
Return None if the project root is in the repo root.
|
Return the path to Python project root, relative to the repo root.
Return None if the project root is in the repo root.
| def get_subdirectory(cls, location):
# type: (str) -> Optional[str]
"""
Return the path to Python project root, relative to the repo root.
Return None if the project root is in the repo root.
"""
# find the repo root
repo_root = cls.run_command(
['root... | [
"def",
"get_subdirectory",
"(",
"cls",
",",
"location",
")",
":",
"# type: (str) -> Optional[str]",
"# find the repo root",
"repo_root",
"=",
"cls",
".",
"run_command",
"(",
"[",
"'root'",
"]",
",",
"show_stdout",
"=",
"False",
",",
"stdout_only",
"=",
"True",
"... | [
119,
4
] | [
131,
76
] | python | en | ['en', 'error', 'th'] | False |
create_dataset | (file_pattern, batch_size, mode) | Creates tf.data Dataset Object to feed into model.
Args:
file_pattern: str, file patterns to TFRecord data.
batch_size: int, batch size for training.
mode: tf.estimator.ModeKeys (TRAIN/EVAL).
Returns:
tf.data Dataset object.
| Creates tf.data Dataset Object to feed into model. | def create_dataset(file_pattern, batch_size, mode):
"""Creates tf.data Dataset Object to feed into model.
Args:
file_pattern: str, file patterns to TFRecord data.
batch_size: int, batch size for training.
mode: tf.estimator.ModeKeys (TRAIN/EVAL).
Returns:
tf.data Dataset ob... | [
"def",
"create_dataset",
"(",
"file_pattern",
",",
"batch_size",
",",
"mode",
")",
":",
"def",
"_parse",
"(",
"serialized_example",
")",
":",
"\"\"\"Parse serialized example and return feature_dict and label.\n\n Args:\n serialized_example: tf.example to parse.\n\n ... | [
8,
0
] | [
69,
18
] | python | en | ['en', 'en', 'en'] | True |
add_engineered | (features) | Add engineered features to features dict.
Args:
features: dict, dictionary of input features.
Returns:
features: dict, dictionary with engineered features added.
| Add engineered features to features dict. | def add_engineered(features):
"""Add engineered features to features dict.
Args:
features: dict, dictionary of input features.
Returns:
features: dict, dictionary with engineered features added.
"""
features["londiff"] = features["dropofflon"] - features["pickuplon"]
features["... | [
"def",
"add_engineered",
"(",
"features",
")",
":",
"features",
"[",
"\"londiff\"",
"]",
"=",
"features",
"[",
"\"dropofflon\"",
"]",
"-",
"features",
"[",
"\"pickuplon\"",
"]",
"features",
"[",
"\"latdiff\"",
"]",
"=",
"features",
"[",
"\"dropofflat\"",
"]",
... | [
72,
0
] | [
85,
19
] | python | en | ['en', 'en', 'en'] | True |
serving_input_fn | () | Creates serving input receiver for EvalSpec.
Returns:
tf.estimator.export.ServingInputReceiver object containing
placeholders and features.
| Creates serving input receiver for EvalSpec. | def serving_input_fn():
"""Creates serving input receiver for EvalSpec.
Returns:
tf.estimator.export.ServingInputReceiver object containing
placeholders and features.
"""
inputs = {
"dayofweek": tf.compat.v1.placeholder(
dtype=tf.dtypes.int64, shape=[None], name=... | [
"def",
"serving_input_fn",
"(",
")",
":",
"inputs",
"=",
"{",
"\"dayofweek\"",
":",
"tf",
".",
"compat",
".",
"v1",
".",
"placeholder",
"(",
"dtype",
"=",
"tf",
".",
"dtypes",
".",
"int64",
",",
"shape",
"=",
"[",
"None",
"]",
",",
"name",
"=",
"\"... | [
88,
0
] | [
115,
51
] | python | en | ['en', 'pt', 'en'] | True |
train_and_evaluate | (args) | Build tf.estimator.DNNRegressor and call train_and_evaluate loop.
Args:
args: dict, dictionary of command line arguments from task.py.
| Build tf.estimator.DNNRegressor and call train_and_evaluate loop. | def train_and_evaluate(args):
"""Build tf.estimator.DNNRegressor and call train_and_evaluate loop.
Args:
args: dict, dictionary of command line arguments from task.py.
"""
feat_cols = [
tf.feature_column.numeric_column('dayofweek'),
tf.feature_column.numeric_column('hourofday'),... | [
"def",
"train_and_evaluate",
"(",
"args",
")",
":",
"feat_cols",
"=",
"[",
"tf",
".",
"feature_column",
".",
"numeric_column",
"(",
"'dayofweek'",
")",
",",
"tf",
".",
"feature_column",
".",
"numeric_column",
"(",
"'hourofday'",
")",
",",
"tf",
".",
"feature... | [
118,
0
] | [
164,
69
] | python | en | ['en', 'it', 'en'] | True |
client | () | Yields a test client, AND creates and later cleans up a
dummy collection for sessions.
| Yields a test client, AND creates and later cleans up a
dummy collection for sessions.
| def client():
""" Yields a test client, AND creates and later cleans up a
dummy collection for sessions.
"""
main.app.testing = True
# Override the Firestore collection used for sessions in main
main.sessions = main.db.collection(str(uuid.uuid4()))
client = main.app.test_client()
y... | [
"def",
"client",
"(",
")",
":",
"main",
".",
"app",
".",
"testing",
"=",
"True",
"# Override the Firestore collection used for sessions in main",
"main",
".",
"sessions",
"=",
"main",
".",
"db",
".",
"collection",
"(",
"str",
"(",
"uuid",
".",
"uuid4",
"(",
... | [
22,
0
] | [
36,
24
] | python | en | ['en', 'en', 'en'] | True |
command_bmi | (bot, user, channel, args) | Calculates your body mass index. Usage: bmi height(cm)/weight(kg) | Calculates your body mass index. Usage: bmi height(cm)/weight(kg) | def command_bmi(bot, user, channel, args):
"Calculates your body mass index. Usage: bmi height(cm)/weight(kg)"
data = args.split("/")
if len(data) != 2:
return bot.say(channel, "Usage: bmi height(cm)/weight(kg)")
else:
bmi = print_bmi(calc_bmi(int(data[0]), int(data[1])))
return ... | [
"def",
"command_bmi",
"(",
"bot",
",",
"user",
",",
"channel",
",",
"args",
")",
":",
"data",
"=",
"args",
".",
"split",
"(",
"\"/\"",
")",
"if",
"len",
"(",
"data",
")",
"!=",
"2",
":",
"return",
"bot",
".",
"say",
"(",
"channel",
",",
"\"Usage:... | [
30,
0
] | [
37,
69
] | python | en | ['es', 'en', 'en'] | True |
Field.__init__ | (self, feat, index) |
Initialize on the feature object and the integer index of
the field within the feature.
|
Initialize on the feature object and the integer index of
the field within the feature.
| def __init__(self, feat, index):
"""
Initialize on the feature object and the integer index of
the field within the feature.
"""
# Setting the feature pointer and index.
self._feat = feat
self._index = index
# Getting the pointer for this field.
f... | [
"def",
"__init__",
"(",
"self",
",",
"feat",
",",
"index",
")",
":",
"# Setting the feature pointer and index.",
"self",
".",
"_feat",
"=",
"feat",
"self",
".",
"_index",
"=",
"index",
"# Getting the pointer for this field.",
"fld_ptr",
"=",
"capi",
".",
"get_feat... | [
18,
4
] | [
34,
49
] | python | en | ['en', 'error', 'th'] | False |
Field.__str__ | (self) | Return the string representation of the Field. | Return the string representation of the Field. | def __str__(self):
"Return the string representation of the Field."
return str(self.value).strip() | [
"def",
"__str__",
"(",
"self",
")",
":",
"return",
"str",
"(",
"self",
".",
"value",
")",
".",
"strip",
"(",
")"
] | [
36,
4
] | [
38,
38
] | python | en | ['en', 'en', 'en'] | True |
Field.as_double | (self) | Retrieve the Field's value as a double (float). | Retrieve the Field's value as a double (float). | def as_double(self):
"Retrieve the Field's value as a double (float)."
return capi.get_field_as_double(self._feat.ptr, self._index) if self.is_set else None | [
"def",
"as_double",
"(",
"self",
")",
":",
"return",
"capi",
".",
"get_field_as_double",
"(",
"self",
".",
"_feat",
".",
"ptr",
",",
"self",
".",
"_index",
")",
"if",
"self",
".",
"is_set",
"else",
"None"
] | [
41,
4
] | [
43,
93
] | python | en | ['en', 'ga', 'en'] | True |
Field.as_int | (self, is_64=False) | Retrieve the Field's value as an integer. | Retrieve the Field's value as an integer. | def as_int(self, is_64=False):
"Retrieve the Field's value as an integer."
if is_64:
return capi.get_field_as_integer64(self._feat.ptr, self._index) if self.is_set else None
else:
return capi.get_field_as_integer(self._feat.ptr, self._index) if self.is_set else None | [
"def",
"as_int",
"(",
"self",
",",
"is_64",
"=",
"False",
")",
":",
"if",
"is_64",
":",
"return",
"capi",
".",
"get_field_as_integer64",
"(",
"self",
".",
"_feat",
".",
"ptr",
",",
"self",
".",
"_index",
")",
"if",
"self",
".",
"is_set",
"else",
"Non... | [
45,
4
] | [
50,
98
] | python | en | ['en', 'ga', 'en'] | True |
Field.as_string | (self) | Retrieve the Field's value as a string. | Retrieve the Field's value as a string. | def as_string(self):
"Retrieve the Field's value as a string."
if not self.is_set:
return None
string = capi.get_field_as_string(self._feat.ptr, self._index)
return force_str(string, encoding=self._feat.encoding, strings_only=True) | [
"def",
"as_string",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_set",
":",
"return",
"None",
"string",
"=",
"capi",
".",
"get_field_as_string",
"(",
"self",
".",
"_feat",
".",
"ptr",
",",
"self",
".",
"_index",
")",
"return",
"force_str",
"(",... | [
52,
4
] | [
57,
81
] | python | en | ['en', 'sk', 'en'] | True |
Field.as_datetime | (self) | Retrieve the Field's value as a tuple of date & time components. | Retrieve the Field's value as a tuple of date & time components. | def as_datetime(self):
"Retrieve the Field's value as a tuple of date & time components."
if not self.is_set:
return None
yy, mm, dd, hh, mn, ss, tz = [c_int() for i in range(7)]
status = capi.get_field_as_datetime(
self._feat.ptr, self._index, byref(yy), byref(mm... | [
"def",
"as_datetime",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_set",
":",
"return",
"None",
"yy",
",",
"mm",
",",
"dd",
",",
"hh",
",",
"mn",
",",
"ss",
",",
"tz",
"=",
"[",
"c_int",
"(",
")",
"for",
"i",
"in",
"range",
"(",
"7",
... | [
59,
4
] | [
70,
93
] | python | en | ['en', 'en', 'en'] | True |
Field.is_set | (self) | Return True if the value of this field isn't null, False otherwise. | Return True if the value of this field isn't null, False otherwise. | def is_set(self):
"Return True if the value of this field isn't null, False otherwise."
return capi.is_field_set(self._feat.ptr, self._index) | [
"def",
"is_set",
"(",
"self",
")",
":",
"return",
"capi",
".",
"is_field_set",
"(",
"self",
".",
"_feat",
".",
"ptr",
",",
"self",
".",
"_index",
")"
] | [
74,
4
] | [
76,
61
] | python | en | ['en', 'en', 'en'] | True |
Field.name | (self) | Return the name of this Field. | Return the name of this Field. | def name(self):
"Return the name of this Field."
name = capi.get_field_name(self.ptr)
return force_str(name, encoding=self._feat.encoding, strings_only=True) | [
"def",
"name",
"(",
"self",
")",
":",
"name",
"=",
"capi",
".",
"get_field_name",
"(",
"self",
".",
"ptr",
")",
"return",
"force_str",
"(",
"name",
",",
"encoding",
"=",
"self",
".",
"_feat",
".",
"encoding",
",",
"strings_only",
"=",
"True",
")"
] | [
79,
4
] | [
82,
79
] | python | en | ['en', 'en', 'en'] | True |
Field.precision | (self) | Return the precision of this Field. | Return the precision of this Field. | def precision(self):
"Return the precision of this Field."
return capi.get_field_precision(self.ptr) | [
"def",
"precision",
"(",
"self",
")",
":",
"return",
"capi",
".",
"get_field_precision",
"(",
"self",
".",
"ptr",
")"
] | [
85,
4
] | [
87,
49
] | python | en | ['en', 'en', 'en'] | True |
Field.type | (self) | Return the OGR type of this Field. | Return the OGR type of this Field. | def type(self):
"Return the OGR type of this Field."
return capi.get_field_type(self.ptr) | [
"def",
"type",
"(",
"self",
")",
":",
"return",
"capi",
".",
"get_field_type",
"(",
"self",
".",
"ptr",
")"
] | [
90,
4
] | [
92,
44
] | python | en | ['en', 'en', 'en'] | True |
Field.type_name | (self) | Return the OGR field type name for this Field. | Return the OGR field type name for this Field. | def type_name(self):
"Return the OGR field type name for this Field."
return capi.get_field_type_name(self.type) | [
"def",
"type_name",
"(",
"self",
")",
":",
"return",
"capi",
".",
"get_field_type_name",
"(",
"self",
".",
"type",
")"
] | [
95,
4
] | [
97,
50
] | python | en | ['en', 'en', 'en'] | True |
Field.value | (self) | Return the value of this Field. | Return the value of this Field. | def value(self):
"Return the value of this Field."
# Default is to get the field as a string.
return self.as_string() | [
"def",
"value",
"(",
"self",
")",
":",
"# Default is to get the field as a string.",
"return",
"self",
".",
"as_string",
"(",
")"
] | [
100,
4
] | [
103,
31
] | python | en | ['en', 'en', 'en'] | True |
Field.width | (self) | Return the width of this Field. | Return the width of this Field. | def width(self):
"Return the width of this Field."
return capi.get_field_width(self.ptr) | [
"def",
"width",
"(",
"self",
")",
":",
"return",
"capi",
".",
"get_field_width",
"(",
"self",
".",
"ptr",
")"
] | [
106,
4
] | [
108,
45
] | python | en | ['en', 'en', 'en'] | True |
OFTInteger.value | (self) | Return an integer contained in this field. | Return an integer contained in this field. | def value(self):
"Return an integer contained in this field."
return self.as_int(self._bit64) | [
"def",
"value",
"(",
"self",
")",
":",
"return",
"self",
".",
"as_int",
"(",
"self",
".",
"_bit64",
")"
] | [
116,
4
] | [
118,
39
] | python | en | ['en', 'en', 'en'] | True |
OFTInteger.type | (self) |
GDAL uses OFTReals to represent OFTIntegers in created
shapefiles -- forcing the type here since the underlying field
type may actually be OFTReal.
|
GDAL uses OFTReals to represent OFTIntegers in created
shapefiles -- forcing the type here since the underlying field
type may actually be OFTReal.
| def type(self):
"""
GDAL uses OFTReals to represent OFTIntegers in created
shapefiles -- forcing the type here since the underlying field
type may actually be OFTReal.
"""
return 0 | [
"def",
"type",
"(",
"self",
")",
":",
"return",
"0"
] | [
121,
4
] | [
127,
16
] | python | en | ['en', 'error', 'th'] | False |
OFTReal.value | (self) | Return a float contained in this field. | Return a float contained in this field. | def value(self):
"Return a float contained in this field."
return self.as_double() | [
"def",
"value",
"(",
"self",
")",
":",
"return",
"self",
".",
"as_double",
"(",
")"
] | [
132,
4
] | [
134,
31
] | python | en | ['en', 'en', 'en'] | True |
OFTDate.value | (self) | Return a Python `date` object for the OFTDate field. | Return a Python `date` object for the OFTDate field. | def value(self):
"Return a Python `date` object for the OFTDate field."
try:
yy, mm, dd, hh, mn, ss, tz = self.as_datetime()
return date(yy.value, mm.value, dd.value)
except (TypeError, ValueError, GDALException):
return None | [
"def",
"value",
"(",
"self",
")",
":",
"try",
":",
"yy",
",",
"mm",
",",
"dd",
",",
"hh",
",",
"mn",
",",
"ss",
",",
"tz",
"=",
"self",
".",
"as_datetime",
"(",
")",
"return",
"date",
"(",
"yy",
".",
"value",
",",
"mm",
".",
"value",
",",
"... | [
153,
4
] | [
159,
23
] | python | en | ['en', 'en', 'en'] | True |
OFTDateTime.value | (self) | Return a Python `datetime` object for this OFTDateTime field. | Return a Python `datetime` object for this OFTDateTime field. | def value(self):
"Return a Python `datetime` object for this OFTDateTime field."
# TODO: Adapt timezone information.
# See https://lists.osgeo.org/pipermail/gdal-dev/2006-February/007990.html
# The `tz` variable has values of: 0=unknown, 1=localtime (ambiguous),
# 100=GMT, 104... | [
"def",
"value",
"(",
"self",
")",
":",
"# TODO: Adapt timezone information.",
"# See https://lists.osgeo.org/pipermail/gdal-dev/2006-February/007990.html",
"# The `tz` variable has values of: 0=unknown, 1=localtime (ambiguous),",
"# 100=GMT, 104=GMT+1, 80=GMT-5, etc.",
"try",
":",
"yy",
... | [
164,
4
] | [
174,
23
] | python | en | ['en', 'en', 'en'] | True |
OFTTime.value | (self) | Return a Python `time` object for this OFTTime field. | Return a Python `time` object for this OFTTime field. | def value(self):
"Return a Python `time` object for this OFTTime field."
try:
yy, mm, dd, hh, mn, ss, tz = self.as_datetime()
return time(hh.value, mn.value, ss.value)
except (ValueError, GDALException):
return None | [
"def",
"value",
"(",
"self",
")",
":",
"try",
":",
"yy",
",",
"mm",
",",
"dd",
",",
"hh",
",",
"mn",
",",
"ss",
",",
"tz",
"=",
"self",
".",
"as_datetime",
"(",
")",
"return",
"time",
"(",
"hh",
".",
"value",
",",
"mn",
".",
"value",
",",
"... | [
179,
4
] | [
185,
23
] | python | en | ['en', 'en', 'en'] | True |
parse_rule | (rule) | Parse a rule and return it as generator. Each iteration yields tuples
in the form ``(converter, arguments, variable)``. If the converter is
`None` it's a static url part, otherwise it's a dynamic one.
:internal:
| Parse a rule and return it as generator. Each iteration yields tuples
in the form ``(converter, arguments, variable)``. If the converter is
`None` it's a static url part, otherwise it's a dynamic one. | def parse_rule(rule):
"""Parse a rule and return it as generator. Each iteration yields tuples
in the form ``(converter, arguments, variable)``. If the converter is
`None` it's a static url part, otherwise it's a dynamic one.
:internal:
"""
pos = 0
end = len(rule)
do_match = _rule_re.ma... | [
"def",
"parse_rule",
"(",
"rule",
")",
":",
"pos",
"=",
"0",
"end",
"=",
"len",
"(",
"rule",
")",
"do_match",
"=",
"_rule_re",
".",
"match",
"used_names",
"=",
"set",
"(",
")",
"while",
"pos",
"<",
"end",
":",
"m",
"=",
"do_match",
"(",
"rule",
"... | [
197,
0
] | [
226,
35
] | python | en | ['en', 'en', 'en'] | True |
_prefix_names | (src) | ast parse and prefix names with `.` to avoid collision with user vars | ast parse and prefix names with `.` to avoid collision with user vars | def _prefix_names(src):
"""ast parse and prefix names with `.` to avoid collision with user vars"""
tree = ast.parse(src).body[0]
if isinstance(tree, ast.Expr):
tree = tree.value
for node in ast.walk(tree):
if isinstance(node, ast.Name):
node.id = "." + node.id
return tre... | [
"def",
"_prefix_names",
"(",
"src",
")",
":",
"tree",
"=",
"ast",
".",
"parse",
"(",
"src",
")",
".",
"body",
"[",
"0",
"]",
"if",
"isinstance",
"(",
"tree",
",",
"ast",
".",
"Expr",
")",
":",
"tree",
"=",
"tree",
".",
"value",
"for",
"node",
"... | [
488,
0
] | [
496,
15
] | python | en | ['en', 'en', 'en'] | True |
RuleFactory.get_rules | (self, map) | Subclasses of `RuleFactory` have to override this method and return
an iterable of rules. | Subclasses of `RuleFactory` have to override this method and return
an iterable of rules. | def get_rules(self, map):
"""Subclasses of `RuleFactory` have to override this method and return
an iterable of rules."""
raise NotImplementedError() | [
"def",
"get_rules",
"(",
"self",
",",
"map",
")",
":",
"raise",
"NotImplementedError",
"(",
")"
] | [
337,
4
] | [
340,
35
] | python | en | ['en', 'en', 'en'] | True |
Map.is_endpoint_expecting | (self, endpoint, *arguments) | Iterate over all rules and check if the endpoint expects
the arguments provided. This is for example useful if you have
some URLs that expect a language code and others that do not and
you want to wrap the builder a bit so that the current language
code is automatically added if not pro... | Iterate over all rules and check if the endpoint expects
the arguments provided. This is for example useful if you have
some URLs that expect a language code and others that do not and
you want to wrap the builder a bit so that the current language
code is automatically added if not pro... | def is_endpoint_expecting(self, endpoint, *arguments):
"""Iterate over all rules and check if the endpoint expects
the arguments provided. This is for example useful if you have
some URLs that expect a language code and others that do not and
you want to wrap the builder a bit so that t... | [
"def",
"is_endpoint_expecting",
"(",
"self",
",",
"endpoint",
",",
"*",
"arguments",
")",
":",
"self",
".",
"update",
"(",
")",
"arguments",
"=",
"set",
"(",
"arguments",
")",
"for",
"rule",
"in",
"self",
".",
"_rules_by_endpoint",
"[",
"endpoint",
"]",
... | [
1361,
4
] | [
1379,
20
] | python | en | ['en', 'en', 'en'] | True |
Map.iter_rules | (self, endpoint=None) | Iterate over all rules or the rules of an endpoint.
:param endpoint: if provided only the rules for that endpoint
are returned.
:return: an iterator
| Iterate over all rules or the rules of an endpoint. | def iter_rules(self, endpoint=None):
"""Iterate over all rules or the rules of an endpoint.
:param endpoint: if provided only the rules for that endpoint
are returned.
:return: an iterator
"""
self.update()
if endpoint is not None:
re... | [
"def",
"iter_rules",
"(",
"self",
",",
"endpoint",
"=",
"None",
")",
":",
"self",
".",
"update",
"(",
")",
"if",
"endpoint",
"is",
"not",
"None",
":",
"return",
"iter",
"(",
"self",
".",
"_rules_by_endpoint",
"[",
"endpoint",
"]",
")",
"return",
"iter"... | [
1381,
4
] | [
1391,
32
] | python | en | ['en', 'en', 'en'] | True |
Map.add | (self, rulefactory) | Add a new rule or factory to the map and bind it. Requires that the
rule is not bound to another map.
:param rulefactory: a :class:`Rule` or :class:`RuleFactory`
| Add a new rule or factory to the map and bind it. Requires that the
rule is not bound to another map. | def add(self, rulefactory):
"""Add a new rule or factory to the map and bind it. Requires that the
rule is not bound to another map.
:param rulefactory: a :class:`Rule` or :class:`RuleFactory`
"""
for rule in rulefactory.get_rules(self):
rule.bind(self)
... | [
"def",
"add",
"(",
"self",
",",
"rulefactory",
")",
":",
"for",
"rule",
"in",
"rulefactory",
".",
"get_rules",
"(",
"self",
")",
":",
"rule",
".",
"bind",
"(",
"self",
")",
"self",
".",
"_rules",
".",
"append",
"(",
"rule",
")",
"self",
".",
"_rule... | [
1393,
4
] | [
1403,
26
] | python | en | ['en', 'en', 'en'] | True |
Map.bind | (
self,
server_name,
script_name=None,
subdomain=None,
url_scheme="http",
default_method="GET",
path_info=None,
query_args=None,
) | Return a new :class:`MapAdapter` with the details specified to the
call. Note that `script_name` will default to ``'/'`` if not further
specified or `None`. The `server_name` at least is a requirement
because the HTTP RFC requires absolute URLs for redirects and so all
redirect excepti... | Return a new :class:`MapAdapter` with the details specified to the
call. Note that `script_name` will default to ``'/'`` if not further
specified or `None`. The `server_name` at least is a requirement
because the HTTP RFC requires absolute URLs for redirects and so all
redirect excepti... | def bind(
self,
server_name,
script_name=None,
subdomain=None,
url_scheme="http",
default_method="GET",
path_info=None,
query_args=None,
):
"""Return a new :class:`MapAdapter` with the details specified to the
call. Note that `script_n... | [
"def",
"bind",
"(",
"self",
",",
"server_name",
",",
"script_name",
"=",
"None",
",",
"subdomain",
"=",
"None",
",",
"url_scheme",
"=",
"\"http\"",
",",
"default_method",
"=",
"\"GET\"",
",",
"path_info",
"=",
"None",
",",
"query_args",
"=",
"None",
",",
... | [
1405,
4
] | [
1463,
9
] | python | en | ['en', 'en', 'en'] | True |
Map.bind_to_environ | (self, environ, server_name=None, subdomain=None) | Like :meth:`bind` but you can pass it an WSGI environment and it
will fetch the information from that dictionary. Note that because of
limitations in the protocol there is no way to get the current
subdomain and real `server_name` from the environment. If you don't
provide it, Werkzeug... | Like :meth:`bind` but you can pass it an WSGI environment and it
will fetch the information from that dictionary. Note that because of
limitations in the protocol there is no way to get the current
subdomain and real `server_name` from the environment. If you don't
provide it, Werkzeug... | def bind_to_environ(self, environ, server_name=None, subdomain=None):
"""Like :meth:`bind` but you can pass it an WSGI environment and it
will fetch the information from that dictionary. Note that because of
limitations in the protocol there is no way to get the current
subdomain and re... | [
"def",
"bind_to_environ",
"(",
"self",
",",
"environ",
",",
"server_name",
"=",
"None",
",",
"subdomain",
"=",
"None",
")",
":",
"environ",
"=",
"_get_environ",
"(",
"environ",
")",
"wsgi_server_name",
"=",
"get_host",
"(",
"environ",
")",
".",
"lower",
"(... | [
1465,
4
] | [
1539,
9
] | python | en | ['en', 'en', 'en'] | True |
Map.update | (self) | Called before matching and building to keep the compiled rules
in the correct order after things changed.
| Called before matching and building to keep the compiled rules
in the correct order after things changed.
| def update(self):
"""Called before matching and building to keep the compiled rules
in the correct order after things changed.
"""
if not self._remap:
return
with self._remap_lock:
if not self._remap:
return
self._rules.sort(k... | [
"def",
"update",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_remap",
":",
"return",
"with",
"self",
".",
"_remap_lock",
":",
"if",
"not",
"self",
".",
"_remap",
":",
"return",
"self",
".",
"_rules",
".",
"sort",
"(",
"key",
"=",
"lambda",
"x... | [
1541,
4
] | [
1555,
31
] | python | en | ['en', 'en', 'en'] | True |
MapAdapter.dispatch | (
self, view_func, path_info=None, method=None, catch_http_exceptions=False
) | Does the complete dispatching process. `view_func` is called with
the endpoint and a dict with the values for the view. It should
look up the view function, call it, and return a response object
or WSGI application. http exceptions are not caught by default
so that applications can di... | Does the complete dispatching process. `view_func` is called with
the endpoint and a dict with the values for the view. It should
look up the view function, call it, and return a response object
or WSGI application. http exceptions are not caught by default
so that applications can di... | def dispatch(
self, view_func, path_info=None, method=None, catch_http_exceptions=False
):
"""Does the complete dispatching process. `view_func` is called with
the endpoint and a dict with the values for the view. It should
look up the view function, call it, and return a response ... | [
"def",
"dispatch",
"(",
"self",
",",
"view_func",
",",
"path_info",
"=",
"None",
",",
"method",
"=",
"None",
",",
"catch_http_exceptions",
"=",
"False",
")",
":",
"try",
":",
"try",
":",
"endpoint",
",",
"args",
"=",
"self",
".",
"match",
"(",
"path_in... | [
1591,
4
] | [
1645,
17
] | python | en | ['en', 'en', 'en'] | True |
MapAdapter.match | (self, path_info=None, method=None, return_rule=False, query_args=None) | The usage is simple: you just pass the match method the current
path info as well as the method (which defaults to `GET`). The
following things can then happen:
- you receive a `NotFound` exception that indicates that no URL is
matching. A `NotFound` exception is also a WSGI applica... | The usage is simple: you just pass the match method the current
path info as well as the method (which defaults to `GET`). The
following things can then happen: | def match(self, path_info=None, method=None, return_rule=False, query_args=None):
"""The usage is simple: you just pass the match method the current
path info as well as the method (which defaults to `GET`). The
following things can then happen:
- you receive a `NotFound` exception tha... | [
"def",
"match",
"(",
"self",
",",
"path_info",
"=",
"None",
",",
"method",
"=",
"None",
",",
"return_rule",
"=",
"False",
",",
"query_args",
"=",
"None",
")",
":",
"self",
".",
"map",
".",
"update",
"(",
")",
"if",
"path_info",
"is",
"None",
":",
"... | [
1647,
4
] | [
1798,
24
] | python | en | ['en', 'en', 'en'] | True |
MapAdapter.test | (self, path_info=None, method=None) | Test if a rule would match. Works like `match` but returns `True`
if the URL matches, or `False` if it does not exist.
:param path_info: the path info to use for matching. Overrides the
path info specified on binding.
:param method: the HTTP method used for matching.... | Test if a rule would match. Works like `match` but returns `True`
if the URL matches, or `False` if it does not exist. | def test(self, path_info=None, method=None):
"""Test if a rule would match. Works like `match` but returns `True`
if the URL matches, or `False` if it does not exist.
:param path_info: the path info to use for matching. Overrides the
path info specified on binding.
... | [
"def",
"test",
"(",
"self",
",",
"path_info",
"=",
"None",
",",
"method",
"=",
"None",
")",
":",
"try",
":",
"self",
".",
"match",
"(",
"path_info",
",",
"method",
")",
"except",
"RequestRedirect",
":",
"pass",
"except",
"HTTPException",
":",
"return",
... | [
1800,
4
] | [
1815,
19
] | python | en | ['en', 'en', 'en'] | True |
MapAdapter.allowed_methods | (self, path_info=None) | Returns the valid methods that match for a given path.
.. versionadded:: 0.7
| Returns the valid methods that match for a given path. | def allowed_methods(self, path_info=None):
"""Returns the valid methods that match for a given path.
.. versionadded:: 0.7
"""
try:
self.match(path_info, method="--")
except MethodNotAllowed as e:
return e.valid_methods
except HTTPException:
... | [
"def",
"allowed_methods",
"(",
"self",
",",
"path_info",
"=",
"None",
")",
":",
"try",
":",
"self",
".",
"match",
"(",
"path_info",
",",
"method",
"=",
"\"--\"",
")",
"except",
"MethodNotAllowed",
"as",
"e",
":",
"return",
"e",
".",
"valid_methods",
"exc... | [
1817,
4
] | [
1828,
17
] | python | en | ['en', 'en', 'en'] | True |
MapAdapter.get_host | (self, domain_part) | Figures out the full host name for the given domain part. The
domain part is a subdomain in case host matching is disabled or
a full host name.
| Figures out the full host name for the given domain part. The
domain part is a subdomain in case host matching is disabled or
a full host name.
| def get_host(self, domain_part):
"""Figures out the full host name for the given domain part. The
domain part is a subdomain in case host matching is disabled or
a full host name.
"""
if self.map.host_matching:
if domain_part is None:
return self.serv... | [
"def",
"get_host",
"(",
"self",
",",
"domain_part",
")",
":",
"if",
"self",
".",
"map",
".",
"host_matching",
":",
"if",
"domain_part",
"is",
"None",
":",
"return",
"self",
".",
"server_name",
"return",
"to_unicode",
"(",
"domain_part",
",",
"\"ascii\"",
"... | [
1830,
4
] | [
1844,
74
] | python | en | ['en', 'en', 'en'] | True |
MapAdapter.get_default_redirect | (self, rule, method, values, query_args) | A helper that returns the URL to redirect to if it finds one.
This is used for default redirecting only.
:internal:
| A helper that returns the URL to redirect to if it finds one.
This is used for default redirecting only. | def get_default_redirect(self, rule, method, values, query_args):
"""A helper that returns the URL to redirect to if it finds one.
This is used for default redirecting only.
:internal:
"""
assert self.map.redirect_defaults
for r in self.map._rules_by_endpoint[rule.endpoi... | [
"def",
"get_default_redirect",
"(",
"self",
",",
"rule",
",",
"method",
",",
"values",
",",
"query_args",
")",
":",
"assert",
"self",
".",
"map",
".",
"redirect_defaults",
"for",
"r",
"in",
"self",
".",
"map",
".",
"_rules_by_endpoint",
"[",
"rule",
".",
... | [
1846,
4
] | [
1862,
88
] | python | en | ['en', 'en', 'en'] | True |
MapAdapter.make_redirect_url | (self, path_info, query_args=None, domain_part=None) | Creates a redirect URL.
:internal:
| Creates a redirect URL. | def make_redirect_url(self, path_info, query_args=None, domain_part=None):
"""Creates a redirect URL.
:internal:
"""
suffix = ""
if query_args:
suffix = "?" + self.encode_query_args(query_args)
return str(
"%s://%s/%s%s"
% (
... | [
"def",
"make_redirect_url",
"(",
"self",
",",
"path_info",
",",
"query_args",
"=",
"None",
",",
"domain_part",
"=",
"None",
")",
":",
"suffix",
"=",
"\"\"",
"if",
"query_args",
":",
"suffix",
"=",
"\"?\"",
"+",
"self",
".",
"encode_query_args",
"(",
"query... | [
1869,
4
] | [
1887,
9
] | python | en | ['en', 'zh', 'en'] | True |
MapAdapter.make_alias_redirect_url | (self, path, endpoint, values, method, query_args) | Internally called to make an alias redirect URL. | Internally called to make an alias redirect URL. | def make_alias_redirect_url(self, path, endpoint, values, method, query_args):
"""Internally called to make an alias redirect URL."""
url = self.build(
endpoint, values, method, append_unknown=False, force_external=True
)
if query_args:
url += "?" + self.encode_qu... | [
"def",
"make_alias_redirect_url",
"(",
"self",
",",
"path",
",",
"endpoint",
",",
"values",
",",
"method",
",",
"query_args",
")",
":",
"url",
"=",
"self",
".",
"build",
"(",
"endpoint",
",",
"values",
",",
"method",
",",
"append_unknown",
"=",
"False",
... | [
1889,
4
] | [
1897,
18
] | python | en | ['en', 'en', 'en'] | True |
MapAdapter._partial_build | (self, endpoint, values, method, append_unknown) | Helper for :meth:`build`. Returns subdomain and path for the
rule that accepts this endpoint, values and method.
:internal:
| Helper for :meth:`build`. Returns subdomain and path for the
rule that accepts this endpoint, values and method. | def _partial_build(self, endpoint, values, method, append_unknown):
"""Helper for :meth:`build`. Returns subdomain and path for the
rule that accepts this endpoint, values and method.
:internal:
"""
# in case the method is none, try with the default method first
if meth... | [
"def",
"_partial_build",
"(",
"self",
",",
"endpoint",
",",
"values",
",",
"method",
",",
"append_unknown",
")",
":",
"# in case the method is none, try with the default method first",
"if",
"method",
"is",
"None",
":",
"rv",
"=",
"self",
".",
"_partial_build",
"(",... | [
1899,
4
] | [
1919,
29
] | python | en | ['en', 'en', 'en'] | True |
MapAdapter.build | (
self,
endpoint,
values=None,
method=None,
force_external=False,
append_unknown=True,
) | Building URLs works pretty much the other way round. Instead of
`match` you call `build` and pass it the endpoint and a dict of
arguments for the placeholders.
The `build` function also accepts an argument called `force_external`
which, if you set it to `True` will force external URLs.... | Building URLs works pretty much the other way round. Instead of
`match` you call `build` and pass it the endpoint and a dict of
arguments for the placeholders. | def build(
self,
endpoint,
values=None,
method=None,
force_external=False,
append_unknown=True,
):
"""Building URLs works pretty much the other way round. Instead of
`match` you call `build` and pass it the endpoint and a dict of
arguments for... | [
"def",
"build",
"(",
"self",
",",
"endpoint",
",",
"values",
"=",
"None",
",",
"method",
"=",
"None",
",",
"force_external",
"=",
"False",
",",
"append_unknown",
"=",
"True",
",",
")",
":",
"self",
".",
"map",
".",
"update",
"(",
")",
"if",
"values",... | [
1921,
4
] | [
2038,
9
] | 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.