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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
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",
"... | [
238,
4
] | [
255,
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",
"(",
... | [
258,
4
] | [
273,
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'",
")"
] | [
276,
4
] | [
283,
44
] | python | en | ['en', 'en', 'en'] | True |
ConfigHandler._exclude_files_parser | (cls, key) | Returns a parser function to make sure field inputs
are not files.
Parses a value after getting the key so error messages are
more informative.
:param key:
:rtype: callable
| Returns a parser function to make sure field inputs
are not files. | def _exclude_files_parser(cls, key):
"""Returns a parser function to make sure field inputs
are not files.
Parses a value after getting the key so error messages are
more informative.
:param key:
:rtype: callable
"""
def parser(value):
exclud... | [
"def",
"_exclude_files_parser",
"(",
"cls",
",",
"key",
")",
":",
"def",
"parser",
"(",
"value",
")",
":",
"exclude_directive",
"=",
"'file:'",
"if",
"value",
".",
"startswith",
"(",
"exclude_directive",
")",
":",
"raise",
"ValueError",
"(",
"'Only strings are... | [
286,
4
] | [
303,
21
] | 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: README.rst, CHANGELOG.md, src/file.txt
:param str value:
:rtyp... | 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: README.rst, CHANGELOG.md, src/file.txt
... | [
"def",
"_parse_file",
"(",
"cls",
",",
"value",
")",
":",
"include_directive",
"=",
"'file:'",
"if",
"not",
"isinstance",
"(",
"value",
",",
"str",
")",
":",
"return",
"value",
"if",
"not",
"value",
".",
"startswith",
"(",
"include_directive",
")",
":",
... | [
306,
4
] | [
334,
9
] | python | en | ['en', 'en', 'en'] | True |
ConfigHandler._parse_attr | (cls, value, package_dir=None) | 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, package_dir=None):
"""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_direc... | [
"def",
"_parse_attr",
"(",
"cls",
",",
"value",
",",
"package_dir",
"=",
"None",
")",
":",
"attr_directive",
"=",
"'attr:'",
"if",
"not",
"value",
".",
"startswith",
"(",
"attr_directive",
")",
":",
"return",
"value",
"attrs_path",
"=",
"value",
".",
"repl... | [
348,
4
] | [
391,
41
] | 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",
... | [
394,
4
] | [
410,
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",
",",
"(",
"_",
","... | [
413,
4
] | [
426,
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... | [
428,
4
] | [
438,
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... | [
440,
4
] | [
462,
50
] | python | en | ['en', 'en', 'en'] | True |
ConfigHandler._deprecated_config_handler | (self, func, msg, warning_class) | this function will wrap around parameters that are deprecated
:param msg: deprecation message
:param warning_class: class of warning exception to be raised
:param func: function to be wrapped around
| this function will wrap around parameters that are deprecated | def _deprecated_config_handler(self, func, msg, warning_class):
""" this function will wrap around parameters that are deprecated
:param msg: deprecation message
:param warning_class: class of warning exception to be raised
:param func: function to be wrapped around
"""
... | [
"def",
"_deprecated_config_handler",
"(",
"self",
",",
"func",
",",
"msg",
",",
"warning_class",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"config_handler",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"warnings",
".",
"warn",
"(",
"msg"... | [
464,
4
] | [
476,
29
] | 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
exclude_files_parser = self._exclude_files_parser
return {
'platforms': parse_list,
'... | [
"def",
"parsers",
"(",
"self",
")",
":",
"parse_list",
"=",
"self",
".",
"_parse_list",
"parse_file",
"=",
"self",
".",
"_parse_file",
"parse_dict",
"=",
"self",
".",
"_parse_dict",
"exclude_files_parser",
"=",
"self",
".",
"_exclude_files_parser",
"return",
"{"... | [
503,
4
] | [
527,
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_file(value)
if version != value:
version = version.strip()
# Be strict about versions loaded from file because it's easy to
... | [
"def",
"_parse_version",
"(",
"self",
",",
"value",
")",
":",
"version",
"=",
"self",
".",
"_parse_file",
"(",
"value",
")",
"if",
"version",
"!=",
"value",
":",
"version",
"=",
"version",
".",
"strip",
"(",
")",
"# Be strict about versions loaded from file be... | [
529,
4
] | [
562,
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",
"... | [
570,
4
] | [
596,
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_directives = ['find:', 'find_namespace:']
trimmed_value = value.strip()
if trimmed_value not in find_directives:
return self._parse_list(value)
... | [
"def",
"_parse_packages",
"(",
"self",
",",
"value",
")",
":",
"find_directives",
"=",
"[",
"'find:'",
",",
"'find_namespace:'",
"]",
"trimmed_value",
"=",
"value",
".",
"strip",
"(",
")",
"if",
"trimmed_value",
"not",
"in",
"find_directives",
":",
"return",
... | [
598,
4
] | [
621,
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'",
","... | [
623,
4
] | [
642,
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"
] | [
644,
4
] | [
650,
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",
")"
] | [
662,
4
] | [
667,
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",
")"
] | [
669,
4
] | [
675,
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... | [
677,
4
] | [
684,
40
] | python | en | ['es', 'en', 'en'] | True |
ConfigOptionsHandler.parse_section_data_files | (self, section_options) | Parses `data_files` configuration file section.
:param dict section_options:
| Parses `data_files` configuration file section. | def parse_section_data_files(self, section_options):
"""Parses `data_files` configuration file section.
:param dict section_options:
"""
parsed = self._parse_section_to_dict(section_options, self._parse_list)
self['data_files'] = [(k, v) for k, v in parsed.items()] | [
"def",
"parse_section_data_files",
"(",
"self",
",",
"section_options",
")",
":",
"parsed",
"=",
"self",
".",
"_parse_section_to_dict",
"(",
"section_options",
",",
"self",
".",
"_parse_list",
")",
"self",
"[",
"'data_files'",
"]",
"=",
"[",
"(",
"k",
",",
"... | [
686,
4
] | [
692,
64
] | python | en | ['en', 'en', 'en'] | True |
get_display_recipient_remote_cache | (
recipient_id: int, recipient_type: int, recipient_type_id: Optional[int]
) |
returns: an appropriate object describing the recipient. For a
stream this will be the stream name as a string. For a huddle or
personal, it will be an array of dicts about each recipient.
|
returns: an appropriate object describing the recipient. For a
stream this will be the stream name as a string. For a huddle or
personal, it will be an array of dicts about each recipient.
| def get_display_recipient_remote_cache(
recipient_id: int, recipient_type: int, recipient_type_id: Optional[int]
) -> DisplayRecipientT:
"""
returns: an appropriate object describing the recipient. For a
stream this will be the stream name as a string. For a huddle or
personal, it will be an array... | [
"def",
"get_display_recipient_remote_cache",
"(",
"recipient_id",
":",
"int",
",",
"recipient_type",
":",
"int",
",",
"recipient_type_id",
":",
"Optional",
"[",
"int",
"]",
")",
"->",
"DisplayRecipientT",
":",
"if",
"recipient_type",
"==",
"Recipient",
".",
"STREA... | [
28,
0
] | [
51,
34
] | python | en | ['en', 'error', 'th'] | False |
bulk_fetch_display_recipients | (
recipient_tuples: Set[Tuple[int, int, int]],
) |
Takes set of tuples of the form (recipient_id, recipient_type, recipient_type_id)
Returns dict mapping recipient_id to corresponding display_recipient
|
Takes set of tuples of the form (recipient_id, recipient_type, recipient_type_id)
Returns dict mapping recipient_id to corresponding display_recipient
| def bulk_fetch_display_recipients(
recipient_tuples: Set[Tuple[int, int, int]],
) -> Dict[int, DisplayRecipientT]:
"""
Takes set of tuples of the form (recipient_id, recipient_type, recipient_type_id)
Returns dict mapping recipient_id to corresponding display_recipient
"""
# Build dict mapping ... | [
"def",
"bulk_fetch_display_recipients",
"(",
"recipient_tuples",
":",
"Set",
"[",
"Tuple",
"[",
"int",
",",
"int",
",",
"int",
"]",
"]",
",",
")",
"->",
"Dict",
"[",
"int",
",",
"DisplayRecipientT",
"]",
":",
"# Build dict mapping recipient id to (type, type_id) o... | [
72,
0
] | [
201,
82
] | python | en | ['en', 'error', 'th'] | False |
back_plane | () |
The plane of the back of the case
Origin is lower right corner
|
The plane of the back of the case
Origin is lower right corner
| def back_plane():
"""
The plane of the back of the case
Origin is lower right corner
"""
left_corner = left_back_corner()
right_corner = right_back_corner()
return CoordPlane(
(left_corner.x, left_corner.y, left_corner.z),
(right_corner.x, right_corner.y, right_corner.z),
... | [
"def",
"back_plane",
"(",
")",
":",
"left_corner",
"=",
"left_back_corner",
"(",
")",
"right_corner",
"=",
"right_back_corner",
"(",
")",
"return",
"CoordPlane",
"(",
"(",
"left_corner",
".",
"x",
",",
"left_corner",
".",
"y",
",",
"left_corner",
".",
"z",
... | [
254,
0
] | [
267,
5
] | python | en | ['en', 'error', 'th'] | False |
unit_vector | (vector) | Returns the unit vector of the vector. | Returns the unit vector of the vector. | def unit_vector(vector):
""" Returns the unit vector of the vector. """
return vector / np.linalg.norm(vector) | [
"def",
"unit_vector",
"(",
"vector",
")",
":",
"return",
"vector",
"/",
"np",
".",
"linalg",
".",
"norm",
"(",
"vector",
")"
] | [
270,
0
] | [
272,
42
] | python | en | ['en', 'en', 'en'] | True |
back_plane_height | (x) |
height of the back plane at x
|
height of the back plane at x
| def back_plane_height(x):
"""
height of the back plane at x
"""
return (math.tan(math.radians(back_angle())) * x) + min_depth | [
"def",
"back_plane_height",
"(",
"x",
")",
":",
"return",
"(",
"math",
".",
"tan",
"(",
"math",
".",
"radians",
"(",
"back_angle",
"(",
")",
")",
")",
"*",
"x",
")",
"+",
"min_depth"
] | [
295,
0
] | [
299,
65
] | python | en | ['en', 'error', 'th'] | False |
spine_slice | () |
flatten the center spine to make room for the center PCB
provide step down for deep pockets
|
flatten the center spine to make room for the center PCB
provide step down for deep pockets
| def spine_slice():
"""
flatten the center spine to make room for the center PCB
provide step down for deep pockets
"""
gap = 20
fillet = 35
return cq.Workplane("XY") \
.moveTo(40, -40) \
.lineTo(right_big_corner_bottom().x - gap, right_big_corner_bottom().y + gap + (fillet *... | [
"def",
"spine_slice",
"(",
")",
":",
"gap",
"=",
"20",
"fillet",
"=",
"35",
"return",
"cq",
".",
"Workplane",
"(",
"\"XY\"",
")",
".",
"moveTo",
"(",
"40",
",",
"-",
"40",
")",
".",
"lineTo",
"(",
"right_big_corner_bottom",
"(",
")",
".",
"x",
"-",... | [
439,
0
] | [
456,
35
] | python | en | ['en', 'error', 'th'] | False |
pcb_mount | () |
drill holes for PCB mount
|
drill holes for PCB mount
| def pcb_mount():
"""
drill holes for PCB mount
"""
wp = cq.Workplane("XY") \
.transformed(rotate=cq.Vector(-slope, 0, 0))
right_gap = wp.plane.toLocalCoords(transformed_right_wp().plane.toWorldCoords((0, -y)))
offset = right_gap.y + 30
depth = 10
return cq.Workplane("XY") \
... | [
"def",
"pcb_mount",
"(",
")",
":",
"wp",
"=",
"cq",
".",
"Workplane",
"(",
"\"XY\"",
")",
".",
"transformed",
"(",
"rotate",
"=",
"cq",
".",
"Vector",
"(",
"-",
"slope",
",",
"0",
",",
"0",
")",
")",
"right_gap",
"=",
"wp",
".",
"plane",
".",
"... | [
459,
0
] | [
475,
23
] | python | en | ['en', 'error', 'th'] | False |
svg | (svg_file, workplane, extrude_length, shapes=None, invert=True, fillet=None, expand=None) |
extrude shapes in the svg file on the workplane
:param svg_file: file name of svg file
:param workplane: workplane to add svg to
:param extrude_length: amount to extrude by
:param shapes: list of shapes in the svg file to extrude (null extrudes all)
:param invert: invert (y * -1) the svg?
:... |
extrude shapes in the svg file on the workplane
:param svg_file: file name of svg file
:param workplane: workplane to add svg to
:param extrude_length: amount to extrude by
:param shapes: list of shapes in the svg file to extrude (null extrudes all)
:param invert: invert (y * -1) the svg?
:... | def svg(svg_file, workplane, extrude_length, shapes=None, invert=True, fillet=None, expand=None):
"""
extrude shapes in the svg file on the workplane
:param svg_file: file name of svg file
:param workplane: workplane to add svg to
:param extrude_length: amount to extrude by
:param shapes: list o... | [
"def",
"svg",
"(",
"svg_file",
",",
"workplane",
",",
"extrude_length",
",",
"shapes",
"=",
"None",
",",
"invert",
"=",
"True",
",",
"fillet",
"=",
"None",
",",
"expand",
"=",
"None",
")",
":",
"polys",
",",
"min_x",
",",
"max_y",
"=",
"svg_load",
"(... | [
478,
0
] | [
515,
20
] | python | en | ['en', 'error', 'th'] | False |
fillet_shape | (poly, radius, convex = True) |
fillet a polygon
:param poly: list of point tuples describing the polygon
:param radius: radius to fillet by
:param convex: if true fillet the convex corners, if false fillet the concave corners
:return: list of points representing the filleted polygon
|
fillet a polygon
:param poly: list of point tuples describing the polygon
:param radius: radius to fillet by
:param convex: if true fillet the convex corners, if false fillet the concave corners
:return: list of points representing the filleted polygon
| def fillet_shape(poly, radius, convex = True):
"""
fillet a polygon
:param poly: list of point tuples describing the polygon
:param radius: radius to fillet by
:param convex: if true fillet the convex corners, if false fillet the concave corners
:return: list of points representing the filleted ... | [
"def",
"fillet_shape",
"(",
"poly",
",",
"radius",
",",
"convex",
"=",
"True",
")",
":",
"scaled_radius",
"=",
"radius",
"*",
"2",
"**",
"31",
"pco",
"=",
"pyclipper",
".",
"PyclipperOffset",
"(",
")",
"pco",
".",
"ArcTolerance",
"=",
"arc_tolerance",
"#... | [
527,
0
] | [
549,
61
] | python | en | ['en', 'error', 'th'] | False |
expand_shape | (poly, expansion) |
make a polygon larger
:param poly: list of point tuples describing the polygon
:param expansion: mm to expand (1 will make the entire poly 2mm wider and taller)
:return: list of points representing the expanded polygon
|
make a polygon larger
:param poly: list of point tuples describing the polygon
:param expansion: mm to expand (1 will make the entire poly 2mm wider and taller)
:return: list of points representing the expanded polygon
| def expand_shape(poly, expansion):
"""
make a polygon larger
:param poly: list of point tuples describing the polygon
:param expansion: mm to expand (1 will make the entire poly 2mm wider and taller)
:return: list of points representing the expanded polygon
"""
scaled_exp = expansion * 2 ** ... | [
"def",
"expand_shape",
"(",
"poly",
",",
"expansion",
")",
":",
"scaled_exp",
"=",
"expansion",
"*",
"2",
"**",
"31",
"pco",
"=",
"pyclipper",
".",
"PyclipperOffset",
"(",
")",
"pco",
".",
"ArcTolerance",
"=",
"arc_tolerance",
"pco",
".",
"AddPath",
"(",
... | [
552,
0
] | [
565,
63
] | python | en | ['en', 'error', 'th'] | False |
PingdomHookTests.test_pingdom_from_up_to_down_http_check_message | (self) |
Tests if pingdom http check from up to down is handled correctly
|
Tests if pingdom http check from up to down is handled correctly
| def test_pingdom_from_up_to_down_http_check_message(self) -> None:
"""
Tests if pingdom http check from up to down is handled correctly
"""
expected_message = "Service someurl.com changed its HTTP status from UP to DOWN:\n\n``` quote\nNon-recoverable failure in name resolution\n```"
... | [
"def",
"test_pingdom_from_up_to_down_http_check_message",
"(",
"self",
")",
"->",
"None",
":",
"expected_message",
"=",
"\"Service someurl.com changed its HTTP status from UP to DOWN:\\n\\n``` quote\\nNon-recoverable failure in name resolution\\n```\"",
"self",
".",
"check_webhook",
"(",... | [
8,
4
] | [
13,
85
] | python | en | ['en', 'error', 'th'] | False |
PingdomHookTests.test_pingdom_from_up_to_down_smtp_check_message | (self) |
Tests if pingdom smtp check from up to down is handled correctly
|
Tests if pingdom smtp check from up to down is handled correctly
| def test_pingdom_from_up_to_down_smtp_check_message(self) -> None:
"""
Tests if pingdom smtp check from up to down is handled correctly
"""
expected_message = "Service smtp.someurl.com changed its SMTP status from UP to DOWN:\n\n``` quote\nConnection refused\n```"
self.check_webh... | [
"def",
"test_pingdom_from_up_to_down_smtp_check_message",
"(",
"self",
")",
"->",
"None",
":",
"expected_message",
"=",
"\"Service smtp.someurl.com changed its SMTP status from UP to DOWN:\\n\\n``` quote\\nConnection refused\\n```\"",
"self",
".",
"check_webhook",
"(",
"\"smtp_up_to_do... | [
15,
4
] | [
20,
85
] | python | en | ['en', 'error', 'th'] | False |
PingdomHookTests.test_pingdom_from_up_to_down_imap_check_message | (self) |
Tests if pingdom imap check from up to down is handled correctly
|
Tests if pingdom imap check from up to down is handled correctly
| def test_pingdom_from_up_to_down_imap_check_message(self) -> None:
"""
Tests if pingdom imap check from up to down is handled correctly
"""
expected_message = "Service imap.someurl.com changed its IMAP status from UP to DOWN:\n\n``` quote\nInvalid hostname, address or socket\n```"
... | [
"def",
"test_pingdom_from_up_to_down_imap_check_message",
"(",
"self",
")",
"->",
"None",
":",
"expected_message",
"=",
"\"Service imap.someurl.com changed its IMAP status from UP to DOWN:\\n\\n``` quote\\nInvalid hostname, address or socket\\n```\"",
"self",
".",
"check_webhook",
"(",
... | [
22,
4
] | [
27,
85
] | python | en | ['en', 'error', 'th'] | False |
PingdomHookTests.test_pingdom_from_down_to_up_imap_check_message | (self) |
Tests if pingdom imap check from down to up is handled correctly
|
Tests if pingdom imap check from down to up is handled correctly
| def test_pingdom_from_down_to_up_imap_check_message(self) -> None:
"""
Tests if pingdom imap check from down to up is handled correctly
"""
expected_message = "Service imap.someurl.com changed its IMAP status from DOWN to UP."
self.check_webhook("imap_down_to_up", "IMAP check sta... | [
"def",
"test_pingdom_from_down_to_up_imap_check_message",
"(",
"self",
")",
"->",
"None",
":",
"expected_message",
"=",
"\"Service imap.someurl.com changed its IMAP status from DOWN to UP.\"",
"self",
".",
"check_webhook",
"(",
"\"imap_down_to_up\"",
",",
"\"IMAP check status.\"",
... | [
29,
4
] | [
34,
85
] | python | en | ['en', 'error', 'th'] | False |
Encoded.setaty | (self, content) |
Grab the (aty) soap-enc:arrayType and attach it to the
content for proper array processing later in end().
@param content: The current content being unmarshalled.
@type content: L{Content}
@return: self
@rtype: L{Encoded}
|
Grab the (aty) soap-enc:arrayType and attach it to the
content for proper array processing later in end().
| def setaty(self, content):
"""
Grab the (aty) soap-enc:arrayType and attach it to the
content for proper array processing later in end().
@param content: The current content being unmarshalled.
@type content: L{Content}
@return: self
@rtype: L{Encoded}
"""... | [
"def",
"setaty",
"(",
"self",
",",
"content",
")",
":",
"name",
"=",
"'arrayType'",
"ns",
"=",
"(",
"None",
",",
"'http://schemas.xmlsoap.org/soap/encoding/'",
")",
"aty",
"=",
"content",
".",
"node",
".",
"get",
"(",
"name",
",",
"ns",
")",
"if",
"aty",... | [
68,
4
] | [
88,
19
] | python | en | ['en', 'error', 'th'] | False |
Encoded.applyaty | (self, content, xty) |
Apply the type referenced in the I{arrayType} to the content
(child nodes) of the array. Each element (node) in the array
that does not have an explicit xsi:type attribute is given one
based on the I{arrayType}.
@param content: An array content.
@type content: L{Conten... |
Apply the type referenced in the I{arrayType} to the content
(child nodes) of the array. Each element (node) in the array
that does not have an explicit xsi:type attribute is given one
based on the I{arrayType}.
| def applyaty(self, content, xty):
"""
Apply the type referenced in the I{arrayType} to the content
(child nodes) of the array. Each element (node) in the array
that does not have an explicit xsi:type attribute is given one
based on the I{arrayType}.
@param content: An a... | [
"def",
"applyaty",
"(",
"self",
",",
"content",
",",
"xty",
")",
":",
"name",
"=",
"'type'",
"ns",
"=",
"Namespace",
".",
"xsins",
"parent",
"=",
"content",
".",
"node",
"for",
"child",
"in",
"parent",
".",
"getChildren",
"(",
")",
":",
"ref",
"=",
... | [
90,
4
] | [
112,
19
] | python | en | ['en', 'error', 'th'] | False |
Encoded.promote | (self, content) |
Promote (replace) the content.data with the first attribute
of the current content.data that is a I{list}. Note: the
content.data may be empty or contain only _x attributes.
In either case, the content.data is assigned an empty list.
@param content: An array content.
@... |
Promote (replace) the content.data with the first attribute
of the current content.data that is a I{list}. Note: the
content.data may be empty or contain only _x attributes.
In either case, the content.data is assigned an empty list.
| def promote(self, content):
"""
Promote (replace) the content.data with the first attribute
of the current content.data that is a I{list}. Note: the
content.data may be empty or contain only _x attributes.
In either case, the content.data is assigned an empty list.
@par... | [
"def",
"promote",
"(",
"self",
",",
"content",
")",
":",
"for",
"n",
",",
"v",
"in",
"content",
".",
"data",
":",
"if",
"isinstance",
"(",
"v",
",",
"list",
")",
":",
"content",
".",
"data",
"=",
"v",
"return",
"content",
".",
"data",
"=",
"[",
... | [
114,
4
] | [
127,
25
] | python | en | ['en', 'error', 'th'] | False |
get_dict_config | (name, key) | Get a config value from a dict-type setting.
If a specified key does not exist in a requested setting,
the default value defined in openstack_dashboard.defaults
is considered.
.. warning::
This function should not be used from horizon plugins
as it only checks openstack_dashboard.defaul... | Get a config value from a dict-type setting. | def get_dict_config(name, key):
"""Get a config value from a dict-type setting.
If a specified key does not exist in a requested setting,
the default value defined in openstack_dashboard.defaults
is considered.
.. warning::
This function should not be used from horizon plugins
as it... | [
"def",
"get_dict_config",
"(",
"name",
",",
"key",
")",
":",
"config",
"=",
"getattr",
"(",
"settings",
",",
"name",
")",
"if",
"key",
"in",
"config",
":",
"return",
"config",
"[",
"key",
"]",
"return",
"getattr",
"(",
"defaults",
",",
"name",
")",
"... | [
27,
0
] | [
48,
39
] | python | en | ['en', 'en', 'en'] | True |
import_submodules | (module) | Import all submodules and make them available in a dict. | Import all submodules and make them available in a dict. | def import_submodules(module):
"""Import all submodules and make them available in a dict."""
submodules = {}
for loader, name, ispkg in pkgutil.iter_modules(module.__path__,
module.__name__ + '.'):
try:
submodule = import_module(name)
... | [
"def",
"import_submodules",
"(",
"module",
")",
":",
"submodules",
"=",
"{",
"}",
"for",
"loader",
",",
"name",
",",
"ispkg",
"in",
"pkgutil",
".",
"iter_modules",
"(",
"module",
".",
"__path__",
",",
"module",
".",
"__name__",
"+",
"'.'",
")",
":",
"t... | [
51,
0
] | [
65,
21
] | python | en | ['en', 'en', 'en'] | True |
import_dashboard_config | (modules) | Imports configuration from all the modules and merges it. | Imports configuration from all the modules and merges it. | def import_dashboard_config(modules):
"""Imports configuration from all the modules and merges it."""
config = collections.defaultdict(dict)
for module in modules:
for submodule in import_submodules(module).values():
if hasattr(submodule, 'DASHBOARD'):
dashboard = submodu... | [
"def",
"import_dashboard_config",
"(",
"modules",
")",
":",
"config",
"=",
"collections",
".",
"defaultdict",
"(",
"dict",
")",
"for",
"module",
"in",
"modules",
":",
"for",
"submodule",
"in",
"import_submodules",
"(",
"module",
")",
".",
"values",
"(",
")",... | [
68,
0
] | [
88,
67
] | python | en | ['en', 'en', 'en'] | True |
update_dashboards | (modules, horizon_config, installed_apps) | Imports dashboard and panel configuration from modules and applies it.
The submodules from specified modules are imported, and the configuration
for the specific dashboards is merged, with the later modules overriding
settings from the former. Then the configuration is applied to
horizon_config and ins... | Imports dashboard and panel configuration from modules and applies it. | def update_dashboards(modules, horizon_config, installed_apps):
"""Imports dashboard and panel configuration from modules and applies it.
The submodules from specified modules are imported, and the configuration
for the specific dashboards is merged, with the later modules overriding
settings from the ... | [
"def",
"update_dashboards",
"(",
"modules",
",",
"horizon_config",
",",
"installed_apps",
")",
":",
"config_dashboards",
"=",
"horizon_config",
".",
"get",
"(",
"'dashboards'",
",",
"[",
"]",
")",
"if",
"config_dashboards",
"or",
"horizon_config",
".",
"get",
"(... | [
91,
0
] | [
220,
30
] | python | en | ['en', 'en', 'en'] | True |
get_xstatic_dirs | (XSTATIC_MODULES, HORIZON_CONFIG) | Discover static file configuration of the xstatic modules.
For each entry in the XSTATIC_MODULES list we determine the entry
point files (which may come from the xstatic MAIN var) and then
determine where in the Django static tree the xstatic package's contents
should be placed.
For jquery.bootstr... | Discover static file configuration of the xstatic modules. | def get_xstatic_dirs(XSTATIC_MODULES, HORIZON_CONFIG):
"""Discover static file configuration of the xstatic modules.
For each entry in the XSTATIC_MODULES list we determine the entry
point files (which may come from the xstatic MAIN var) and then
determine where in the Django static tree the xstatic pa... | [
"def",
"get_xstatic_dirs",
"(",
"XSTATIC_MODULES",
",",
"HORIZON_CONFIG",
")",
":",
"STATICFILES_DIRS",
"=",
"[",
"]",
"HORIZON_CONFIG",
".",
"setdefault",
"(",
"'xstatic_lib_files'",
",",
"[",
"]",
")",
"for",
"module_name",
",",
"files",
"in",
"XSTATIC_MODULES",... | [
269,
0
] | [
320,
27
] | python | en | ['en', 'en', 'en'] | True |
AlertWordTests.test_default_no_words | (self) |
Users start out with no alert words.
|
Users start out with no alert words.
| def test_default_no_words(self) -> None:
"""
Users start out with no alert words.
"""
user = self.get_user()
words = user_alert_words(user)
self.assertEqual(words, []) | [
"def",
"test_default_no_words",
"(",
"self",
")",
"->",
"None",
":",
"user",
"=",
"self",
".",
"get_user",
"(",
")",
"words",
"=",
"user_alert_words",
"(",
"user",
")",
"self",
".",
"assertEqual",
"(",
"words",
",",
"[",
"]",
")"
] | [
34,
4
] | [
40,
35
] | python | en | ['en', 'error', 'th'] | False |
AlertWordTests.test_basics | (self) |
Verifies the basic behavior of modifying alert words.
Also verifies the cache-flushing behavior.
|
Verifies the basic behavior of modifying alert words. | def test_basics(self) -> None:
"""
Verifies the basic behavior of modifying alert words.
Also verifies the cache-flushing behavior.
"""
user = self.get_user()
realm_alert_words = alert_words_in_realm(user.realm)
self.assert_length(realm_alert_words.get(user.id, [... | [
"def",
"test_basics",
"(",
"self",
")",
"->",
"None",
":",
"user",
"=",
"self",
".",
"get_user",
"(",
")",
"realm_alert_words",
"=",
"alert_words_in_realm",
"(",
"user",
".",
"realm",
")",
"self",
".",
"assert_length",
"(",
"realm_alert_words",
".",
"get",
... | [
42,
4
] | [
72,
57
] | python | en | ['en', 'error', 'th'] | False |
AlertWordTests.test_remove_word | (self) |
Removing alert words works via do_remove_alert_words, even
for multi-word and non-ascii words.
|
Removing alert words works via do_remove_alert_words, even
for multi-word and non-ascii words.
| def test_remove_word(self) -> None:
"""
Removing alert words works via do_remove_alert_words, even
for multi-word and non-ascii words.
"""
user = self.get_user()
expected_remaining_alerts = set(self.interesting_alert_word_list)
do_add_alert_words(user, self.inter... | [
"def",
"test_remove_word",
"(",
"self",
")",
"->",
"None",
":",
"user",
"=",
"self",
".",
"get_user",
"(",
")",
"expected_remaining_alerts",
"=",
"set",
"(",
"self",
".",
"interesting_alert_word_list",
")",
"do_add_alert_words",
"(",
"user",
",",
"self",
".",
... | [
74,
4
] | [
88,
85
] | python | en | ['en', 'error', 'th'] | False |
AlertWordTests.test_realm_words | (self) |
We can gather alert words for an entire realm via
alert_words_in_realm. Alerts added for one user do not impact other
users.
|
We can gather alert words for an entire realm via
alert_words_in_realm. Alerts added for one user do not impact other
users.
| def test_realm_words(self) -> None:
"""
We can gather alert words for an entire realm via
alert_words_in_realm. Alerts added for one user do not impact other
users.
"""
# Clear all the words that we got from populate_db.
AlertWord.objects.all().delete()
... | [
"def",
"test_realm_words",
"(",
"self",
")",
"->",
"None",
":",
"# Clear all the words that we got from populate_db.",
"AlertWord",
".",
"objects",
".",
"all",
"(",
")",
".",
"delete",
"(",
")",
"user1",
"=",
"self",
".",
"get_user",
"(",
")",
"do_add_alert_word... | [
90,
4
] | [
111,
65
] | python | en | ['en', 'error', 'th'] | False |
AlertWordTests.message_does_alert | (self, user: UserProfile, message: str) | Send a bunch of messages as othello, so our user is notified | Send a bunch of messages as othello, so our user is notified | def message_does_alert(self, user: UserProfile, message: str) -> bool:
"""Send a bunch of messages as othello, so our user is notified"""
self.send_stream_message(self.example_user("othello"), "Denmark", message)
user_message = most_recent_usermessage(user)
return "has_alert_word" in use... | [
"def",
"message_does_alert",
"(",
"self",
",",
"user",
":",
"UserProfile",
",",
"message",
":",
"str",
")",
"->",
"bool",
":",
"self",
".",
"send_stream_message",
"(",
"self",
".",
"example_user",
"(",
"\"othello\"",
")",
",",
"\"Denmark\"",
",",
"message",
... | [
158,
4
] | [
162,
60
] | python | en | ['en', 'en', 'en'] | True |
get_topic_from_message_info | (message_info: Dict[str, Any]) |
Use this where you are getting dicts that are based off of messages
that may come from the outside world, especially from third party
APIs and bots.
We prefer 'topic' to 'subject' here. We expect at least one field
to be present (or the caller must know how to handle KeyError).
|
Use this where you are getting dicts that are based off of messages
that may come from the outside world, especially from third party
APIs and bots. | def get_topic_from_message_info(message_info: Dict[str, Any]) -> str:
"""
Use this where you are getting dicts that are based off of messages
that may come from the outside world, especially from third party
APIs and bots.
We prefer 'topic' to 'subject' here. We expect at least one field
to be... | [
"def",
"get_topic_from_message_info",
"(",
"message_info",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"str",
":",
"if",
"\"topic\"",
"in",
"message_info",
":",
"return",
"message_info",
"[",
"\"topic\"",
"]",
"return",
"message_info",
"[",
"\"subject... | [
34,
0
] | [
46,
34
] | python | en | ['en', 'error', 'th'] | False |
su_to_zulip | (save_suid: bool = False) | Warning: su_to_zulip assumes that the zulip checkout is owned by
the zulip user (or whatever normal user is running the Zulip
installation). It should never be run from the installer or other
production contexts before /home/zulip/deployments/current is
created. | Warning: su_to_zulip assumes that the zulip checkout is owned by
the zulip user (or whatever normal user is running the Zulip
installation). It should never be run from the installer or other
production contexts before /home/zulip/deployments/current is
created. | def su_to_zulip(save_suid: bool = False) -> None:
"""Warning: su_to_zulip assumes that the zulip checkout is owned by
the zulip user (or whatever normal user is running the Zulip
installation). It should never be run from the installer or other
production contexts before /home/zulip/deployments/current... | [
"def",
"su_to_zulip",
"(",
"save_suid",
":",
"bool",
"=",
"False",
")",
"->",
"None",
":",
"pwent",
"=",
"get_zulip_pwent",
"(",
")",
"os",
".",
"setgid",
"(",
"pwent",
".",
"pw_gid",
")",
"if",
"save_suid",
":",
"os",
".",
"setresuid",
"(",
"pwent",
... | [
144,
0
] | [
156,
37
] | python | en | ['en', 'en', 'en'] | True |
parse_os_release | () |
Example of the useful subset of the data:
{
'ID': 'ubuntu',
'VERSION_ID': '18.04',
'NAME': 'Ubuntu',
'VERSION': '18.04.3 LTS (Bionic Beaver)',
'PRETTY_NAME': 'Ubuntu 18.04.3 LTS',
}
VERSION_CODENAME (e.g. 'bionic') is nice and human-readable, but
we avoid using it, as it i... |
Example of the useful subset of the data:
{
'ID': 'ubuntu',
'VERSION_ID': '18.04',
'NAME': 'Ubuntu',
'VERSION': '18.04.3 LTS (Bionic Beaver)',
'PRETTY_NAME': 'Ubuntu 18.04.3 LTS',
} | def parse_os_release() -> Dict[str, str]:
"""
Example of the useful subset of the data:
{
'ID': 'ubuntu',
'VERSION_ID': '18.04',
'NAME': 'Ubuntu',
'VERSION': '18.04.3 LTS (Bionic Beaver)',
'PRETTY_NAME': 'Ubuntu 18.04.3 LTS',
}
VERSION_CODENAME (e.g. 'bionic') is nice and h... | [
"def",
"parse_os_release",
"(",
")",
"->",
"Dict",
"[",
"str",
",",
"str",
"]",
":",
"distro_info",
"=",
"{",
"}",
"# type: Dict[str, str]",
"with",
"open",
"(",
"\"/etc/os-release\"",
")",
"as",
"fp",
":",
"for",
"line",
"in",
"fp",
":",
"line",
"=",
... | [
403,
0
] | [
432,
22
] | python | en | ['en', 'error', 'th'] | False |
os_families | () |
Known families:
debian (includes: debian, ubuntu)
ubuntu (includes: ubuntu)
fedora (includes: fedora, rhel, centos)
rhel (includes: rhel, centos)
centos (includes: centos)
|
Known families:
debian (includes: debian, ubuntu)
ubuntu (includes: ubuntu)
fedora (includes: fedora, rhel, centos)
rhel (includes: rhel, centos)
centos (includes: centos)
| def os_families() -> Set[str]:
"""
Known families:
debian (includes: debian, ubuntu)
ubuntu (includes: ubuntu)
fedora (includes: fedora, rhel, centos)
rhel (includes: rhel, centos)
centos (includes: centos)
"""
distro_info = parse_os_release()
return {distro_info["ID"], *distro_i... | [
"def",
"os_families",
"(",
")",
"->",
"Set",
"[",
"str",
"]",
":",
"distro_info",
"=",
"parse_os_release",
"(",
")",
"return",
"{",
"distro_info",
"[",
"\"ID\"",
"]",
",",
"*",
"distro_info",
".",
"get",
"(",
"\"ID_LIKE\"",
",",
"\"\"",
")",
".",
"spli... | [
436,
0
] | [
446,
71
] | python | en | ['en', 'error', 'th'] | False |
is_digest_obsolete | (
hash_name: str, filenames: Sequence[str], extra_strings: Sequence[str] = []
) |
In order to determine if we need to run some
process, we calculate a digest of the important
files and strings whose respective contents
or values may indicate such a need.
filenames = files we should hash the contents of
extra_strings = strings we should hash directly
Grep for ca... |
In order to determine if we need to run some
process, we calculate a digest of the important
files and strings whose respective contents
or values may indicate such a need. | def is_digest_obsolete(
hash_name: str, filenames: Sequence[str], extra_strings: Sequence[str] = []
) -> bool:
"""
In order to determine if we need to run some
process, we calculate a digest of the important
files and strings whose respective contents
or values may indicate such a need.
... | [
"def",
"is_digest_obsolete",
"(",
"hash_name",
":",
"str",
",",
"filenames",
":",
"Sequence",
"[",
"str",
"]",
",",
"extra_strings",
":",
"Sequence",
"[",
"str",
"]",
"=",
"[",
"]",
")",
"->",
"bool",
":",
"last_hash_path",
"=",
"os",
".",
"path",
".",... | [
462,
0
] | [
494,
31
] | python | en | ['en', 'error', 'th'] | False |
deport | (netloc: str) | Remove the port from a hostname:port string. Brackets on a literal
IPv6 address are included. | Remove the port from a hostname:port string. Brackets on a literal
IPv6 address are included. | def deport(netloc: str) -> str:
"""Remove the port from a hostname:port string. Brackets on a literal
IPv6 address are included."""
r = SplitResult("", netloc, "", "", "")
assert r.hostname is not None
return "[" + r.hostname + "]" if ":" in r.hostname else r.hostname | [
"def",
"deport",
"(",
"netloc",
":",
"str",
")",
"->",
"str",
":",
"r",
"=",
"SplitResult",
"(",
"\"\"",
",",
"netloc",
",",
"\"\"",
",",
"\"\"",
",",
"\"\"",
")",
"assert",
"r",
".",
"hostname",
"is",
"not",
"None",
"return",
"\"[\"",
"+",
"r",
... | [
619,
0
] | [
624,
70
] | python | en | ['en', 'en', 'en'] | True |
TestDoctests.test_multiple_patterns | (self, testdir) | Test support for multiple --doctest-glob arguments (#1255).
| Test support for multiple --doctest-glob arguments (#1255).
| def test_multiple_patterns(self, testdir):
"""Test support for multiple --doctest-glob arguments (#1255).
"""
testdir.maketxtfile(xdoc="""
>>> 1
1
""")
testdir.makefile('.foo', test="""
>>> 1
1
""")
testdir.maketxtfi... | [
"def",
"test_multiple_patterns",
"(",
"self",
",",
"testdir",
")",
":",
"testdir",
".",
"maketxtfile",
"(",
"xdoc",
"=",
"\"\"\"\n >>> 1\n 1\n \"\"\"",
")",
"testdir",
".",
"makefile",
"(",
"'.foo'",
",",
"test",
"=",
"\"\"\"\n ... | [
104,
4
] | [
132,
10
] | python | en | ['en', 'da', 'en'] | True |
TestDoctests.test_encoding | (self, testdir, test_string, encoding) | Test support for doctest_encoding ini option.
| Test support for doctest_encoding ini option.
| def test_encoding(self, testdir, test_string, encoding):
"""Test support for doctest_encoding ini option.
"""
testdir.makeini("""
[pytest]
doctest_encoding={0}
""".format(encoding))
doctest = u"""
>>> u"{0}"
{1}
""".format(t... | [
"def",
"test_encoding",
"(",
"self",
",",
"testdir",
",",
"test_string",
",",
"encoding",
")",
":",
"testdir",
".",
"makeini",
"(",
"\"\"\"\n [pytest]\n doctest_encoding={0}\n \"\"\"",
".",
"format",
"(",
"encoding",
")",
")",
"doctest",
"... | [
142,
4
] | [
159,
10
] | python | en | ['en', 'en', 'pt'] | True |
TestDoctests.test_docstring_partial_context_around_error | (self, testdir) | Test that we show some context before the actual line of a failing
doctest.
| Test that we show some context before the actual line of a failing
doctest.
| def test_docstring_partial_context_around_error(self, testdir):
"""Test that we show some context before the actual line of a failing
doctest.
"""
testdir.makepyfile('''
def foo():
"""
text-line-1
text-line-2
tex... | [
"def",
"test_docstring_partial_context_around_error",
"(",
"self",
",",
"testdir",
")",
":",
"testdir",
".",
"makepyfile",
"(",
"'''\n def foo():\n \"\"\"\n text-line-1\n text-line-2\n text-line-3\n text-li... | [
175,
4
] | [
213,
59
] | python | en | ['en', 'en', 'en'] | True |
TestDoctests.test_docstring_full_context_around_error | (self, testdir) | Test that we show the whole context before the actual line of a failing
doctest, provided that the context is up to 10 lines long.
| Test that we show the whole context before the actual line of a failing
doctest, provided that the context is up to 10 lines long.
| def test_docstring_full_context_around_error(self, testdir):
"""Test that we show the whole context before the actual line of a failing
doctest, provided that the context is up to 10 lines long.
"""
testdir.makepyfile('''
def foo():
"""
text-li... | [
"def",
"test_docstring_full_context_around_error",
"(",
"self",
",",
"testdir",
")",
":",
"testdir",
".",
"makepyfile",
"(",
"'''\n def foo():\n \"\"\"\n text-line-1\n text-line-2\n\n >>> 1 + 1\n 3\n ... | [
215,
4
] | [
239,
10
] | python | en | ['en', 'en', 'en'] | True |
TestDoctests.test_contains_unicode | (self, testdir) | Fix internal error with docstrings containing non-ascii characters.
| Fix internal error with docstrings containing non-ascii characters.
| def test_contains_unicode(self, testdir):
"""Fix internal error with docstrings containing non-ascii characters.
"""
testdir.makepyfile(u'''
# encoding: utf-8
def foo():
"""
>>> name = 'с' # not letter 'c' but instead Cyrillic 's'.
... | [
"def",
"test_contains_unicode",
"(",
"self",
",",
"testdir",
")",
":",
"testdir",
".",
"makepyfile",
"(",
"u'''\n # encoding: utf-8\n def foo():\n \"\"\"\n >>> name = 'с' # not letter 'c' but instead Cyrillic 's'.\n 'anything... | [
483,
4
] | [
498,
10
] | python | en | ['en', 'en', 'en'] | True |
TestDoctests.test_junit_report_for_doctest | (self, testdir) |
#713: Fix --junit-xml option when used with --doctest-modules.
|
#713: Fix --junit-xml option when used with --doctest-modules.
| def test_junit_report_for_doctest(self, testdir):
"""
#713: Fix --junit-xml option when used with --doctest-modules.
"""
p = testdir.makepyfile("""
def foo():
'''
>>> 1 + 1
3
'''
pass
""")... | [
"def",
"test_junit_report_for_doctest",
"(",
"self",
",",
"testdir",
")",
":",
"p",
"=",
"testdir",
".",
"makepyfile",
"(",
"\"\"\"\n def foo():\n '''\n >>> 1 + 1\n 3\n '''\n pass\n \"\"\"",
")... | [
516,
4
] | [
530,
38
] | python | en | ['en', 'error', 'th'] | False |
TestDoctests.test_unicode_doctest | (self, testdir) |
Test case for issue 2434: DecodeError on Python 2 when doctest contains non-ascii
characters.
|
Test case for issue 2434: DecodeError on Python 2 when doctest contains non-ascii
characters.
| def test_unicode_doctest(self, testdir):
"""
Test case for issue 2434: DecodeError on Python 2 when doctest contains non-ascii
characters.
"""
p = testdir.maketxtfile(test_unicode_doctest="""
.. doctest::
>>> print(
... "Hi\\n\\nByé... | [
"def",
"test_unicode_doctest",
"(",
"self",
",",
"testdir",
")",
":",
"p",
"=",
"testdir",
".",
"maketxtfile",
"(",
"test_unicode_doctest",
"=",
"\"\"\"\n .. doctest::\n\n >>> print(\n ... \"Hi\\\\n\\\\nByé\")\n Hi\n ... | [
532,
4
] | [
552,
10
] | python | en | ['en', 'error', 'th'] | False |
TestDoctests.test_unicode_doctest_module | (self, testdir) |
Test case for issue 2434: DecodeError on Python 2 when doctest docstring
contains non-ascii characters.
|
Test case for issue 2434: DecodeError on Python 2 when doctest docstring
contains non-ascii characters.
| def test_unicode_doctest_module(self, testdir):
"""
Test case for issue 2434: DecodeError on Python 2 when doctest docstring
contains non-ascii characters.
"""
p = testdir.makepyfile(test_unicode_doctest_module="""
# -*- encoding: utf-8 -*-
from __future__... | [
"def",
"test_unicode_doctest_module",
"(",
"self",
",",
"testdir",
")",
":",
"p",
"=",
"testdir",
".",
"makepyfile",
"(",
"test_unicode_doctest_module",
"=",
"\"\"\"\n # -*- encoding: utf-8 -*-\n from __future__ import unicode_literals\n\n def fix_bad... | [
554,
4
] | [
571,
53
] | python | en | ['en', 'error', 'th'] | False |
TestDoctests.test_reportinfo | (self, testdir) |
Test case to make sure that DoctestItem.reportinfo() returns lineno.
|
Test case to make sure that DoctestItem.reportinfo() returns lineno.
| def test_reportinfo(self, testdir):
'''
Test case to make sure that DoctestItem.reportinfo() returns lineno.
'''
p = testdir.makepyfile(test_reportinfo="""
def foo(x):
'''
>>> foo('a')
'b'
'''
... | [
"def",
"test_reportinfo",
"(",
"self",
",",
"testdir",
")",
":",
"p",
"=",
"testdir",
".",
"makepyfile",
"(",
"test_reportinfo",
"=",
"\"\"\"\n def foo(x):\n '''\n >>> foo('a')\n 'b'\n '''\n ... | [
573,
4
] | [
587,
33
] | python | en | ['en', 'error', 'th'] | False |
TestDoctests.test_valid_setup_py | (self, testdir) |
Test to make sure that pytest ignores valid setup.py files when ran
with --doctest-modules
|
Test to make sure that pytest ignores valid setup.py files when ran
with --doctest-modules
| def test_valid_setup_py(self, testdir):
'''
Test to make sure that pytest ignores valid setup.py files when ran
with --doctest-modules
'''
p = testdir.makepyfile(setup="""
from setuptools import setup, find_packages
setup(name='sample',
v... | [
"def",
"test_valid_setup_py",
"(",
"self",
",",
"testdir",
")",
":",
"p",
"=",
"testdir",
".",
"makepyfile",
"(",
"setup",
"=",
"\"\"\"\n from setuptools import setup, find_packages\n setup(name='sample',\n version='0.0',\n desc... | [
589,
4
] | [
603,
60
] | python | en | ['en', 'error', 'th'] | False |
TestDoctests.test_invalid_setup_py | (self, testdir) |
Test to make sure that pytest reads setup.py files that are not used
for python packages when ran with --doctest-modules
|
Test to make sure that pytest reads setup.py files that are not used
for python packages when ran with --doctest-modules
| def test_invalid_setup_py(self, testdir):
'''
Test to make sure that pytest reads setup.py files that are not used
for python packages when ran with --doctest-modules
'''
p = testdir.makepyfile(setup="""
def test_foo():
return 'bar'
""")
... | [
"def",
"test_invalid_setup_py",
"(",
"self",
",",
"testdir",
")",
":",
"p",
"=",
"testdir",
".",
"makepyfile",
"(",
"setup",
"=",
"\"\"\"\n def test_foo():\n return 'bar'\n \"\"\"",
")",
"result",
"=",
"testdir",
".",
"runpytest",
"(",
... | [
605,
4
] | [
615,
59
] | python | en | ['en', 'error', 'th'] | False |
TestLiterals.test_allow_unicode | (self, testdir, config_mode) | Test that doctests which output unicode work in all python versions
tested by pytest when the ALLOW_UNICODE option is used (either in
the ini file or by an inline comment).
| Test that doctests which output unicode work in all python versions
tested by pytest when the ALLOW_UNICODE option is used (either in
the ini file or by an inline comment).
| def test_allow_unicode(self, testdir, config_mode):
"""Test that doctests which output unicode work in all python versions
tested by pytest when the ALLOW_UNICODE option is used (either in
the ini file or by an inline comment).
"""
if config_mode == 'ini':
testdir.mak... | [
"def",
"test_allow_unicode",
"(",
"self",
",",
"testdir",
",",
"config_mode",
")",
":",
"if",
"config_mode",
"==",
"'ini'",
":",
"testdir",
".",
"makeini",
"(",
"'''\n [pytest]\n doctest_optionflags = ALLOW_UNICODE\n '''",
")",
"comment",
... | [
621,
4
] | [
647,
38
] | python | en | ['en', 'en', 'en'] | True |
TestLiterals.test_allow_bytes | (self, testdir, config_mode) | Test that doctests which output bytes work in all python versions
tested by pytest when the ALLOW_BYTES option is used (either in
the ini file or by an inline comment)(#1287).
| Test that doctests which output bytes work in all python versions
tested by pytest when the ALLOW_BYTES option is used (either in
the ini file or by an inline comment)(#1287).
| def test_allow_bytes(self, testdir, config_mode):
"""Test that doctests which output bytes work in all python versions
tested by pytest when the ALLOW_BYTES option is used (either in
the ini file or by an inline comment)(#1287).
"""
if config_mode == 'ini':
testdir.ma... | [
"def",
"test_allow_bytes",
"(",
"self",
",",
"testdir",
",",
"config_mode",
")",
":",
"if",
"config_mode",
"==",
"'ini'",
":",
"testdir",
".",
"makeini",
"(",
"'''\n [pytest]\n doctest_optionflags = ALLOW_BYTES\n '''",
")",
"comment",
"=",... | [
650,
4
] | [
676,
38
] | python | en | ['en', 'en', 'en'] | True |
TestLiterals.test_unicode_string | (self, testdir) | Test that doctests which output unicode fail in Python 2 when
the ALLOW_UNICODE option is not used. The same test should pass
in Python 3.
| Test that doctests which output unicode fail in Python 2 when
the ALLOW_UNICODE option is not used. The same test should pass
in Python 3.
| def test_unicode_string(self, testdir):
"""Test that doctests which output unicode fail in Python 2 when
the ALLOW_UNICODE option is not used. The same test should pass
in Python 3.
"""
testdir.maketxtfile(test_doc="""
>>> b'12'.decode('ascii')
'12'
... | [
"def",
"test_unicode_string",
"(",
"self",
",",
"testdir",
")",
":",
"testdir",
".",
"maketxtfile",
"(",
"test_doc",
"=",
"\"\"\"\n >>> b'12'.decode('ascii')\n '12'\n \"\"\"",
")",
"reprec",
"=",
"testdir",
".",
"inline_run",
"(",
")",
"pass... | [
678,
4
] | [
689,
67
] | python | en | ['en', 'en', 'en'] | True |
TestLiterals.test_bytes_literal | (self, testdir) | Test that doctests which output bytes fail in Python 3 when
the ALLOW_BYTES option is not used. The same test should pass
in Python 2 (#1287).
| Test that doctests which output bytes fail in Python 3 when
the ALLOW_BYTES option is not used. The same test should pass
in Python 2 (#1287).
| def test_bytes_literal(self, testdir):
"""Test that doctests which output bytes fail in Python 3 when
the ALLOW_BYTES option is not used. The same test should pass
in Python 2 (#1287).
"""
testdir.maketxtfile(test_doc="""
>>> b'foo'
'foo'
""")
... | [
"def",
"test_bytes_literal",
"(",
"self",
",",
"testdir",
")",
":",
"testdir",
".",
"maketxtfile",
"(",
"test_doc",
"=",
"\"\"\"\n >>> b'foo'\n 'foo'\n \"\"\"",
")",
"reprec",
"=",
"testdir",
".",
"inline_run",
"(",
")",
"passed",
"=",
"... | [
691,
4
] | [
702,
67
] | python | en | ['en', 'en', 'en'] | True |
TestDoctestAutoUseFixtures.test_doctest_module_session_fixture | (self, testdir) | Test that session fixtures are initialized for doctest modules (#768)
| Test that session fixtures are initialized for doctest modules (#768)
| def test_doctest_module_session_fixture(self, testdir):
"""Test that session fixtures are initialized for doctest modules (#768)
"""
# session fixture which changes some global data, which will
# be accessed by doctests in a module
testdir.makeconftest("""
import pyte... | [
"def",
"test_doctest_module_session_fixture",
"(",
"self",
",",
"testdir",
")",
":",
"# session fixture which changes some global data, which will",
"# be accessed by doctests in a module",
"testdir",
".",
"makeconftest",
"(",
"\"\"\"\n import pytest\n import sys\n\... | [
763,
4
] | [
793,
49
] | python | en | ['en', 'en', 'en'] | True |
TestDoctestAutoUseFixtures.test_fixture_scopes | (self, testdir, scope, enable_doctest) | Test that auto-use fixtures work properly with doctest modules.
See #1057 and #1100.
| Test that auto-use fixtures work properly with doctest modules.
See #1057 and #1100.
| def test_fixture_scopes(self, testdir, scope, enable_doctest):
"""Test that auto-use fixtures work properly with doctest modules.
See #1057 and #1100.
"""
testdir.makeconftest('''
import pytest
@pytest.fixture(autouse=True, scope="{scope}")
def auto(r... | [
"def",
"test_fixture_scopes",
"(",
"self",
",",
"testdir",
",",
"scope",
",",
"enable_doctest",
")",
":",
"testdir",
".",
"makeconftest",
"(",
"'''\n import pytest\n\n @pytest.fixture(autouse=True, scope=\"{scope}\")\n def auto(request):\n ... | [
797,
4
] | [
820,
69
] | python | en | ['en', 'en', 'en'] | True |
TestDoctestAutoUseFixtures.test_fixture_module_doctest_scopes | (self, testdir, scope, autouse,
use_fixture_in_doctest) | Test that auto-use fixtures work properly with doctest files.
See #1057 and #1100.
| Test that auto-use fixtures work properly with doctest files.
See #1057 and #1100.
| def test_fixture_module_doctest_scopes(self, testdir, scope, autouse,
use_fixture_in_doctest):
"""Test that auto-use fixtures work properly with doctest files.
See #1057 and #1100.
"""
testdir.makeconftest('''
import pytest
... | [
"def",
"test_fixture_module_doctest_scopes",
"(",
"self",
",",
"testdir",
",",
"scope",
",",
"autouse",
",",
"use_fixture_in_doctest",
")",
":",
"testdir",
".",
"makeconftest",
"(",
"'''\n import pytest\n\n @pytest.fixture(autouse={autouse}, scope=\"{scope}\... | [
825,
4
] | [
849,
59
] | python | en | ['en', 'en', 'en'] | True |
TestDoctestAutoUseFixtures.test_auto_use_request_attributes | (self, testdir, scope) | Check that all attributes of a request in an autouse fixture
behave as expected when requested for a doctest item.
| Check that all attributes of a request in an autouse fixture
behave as expected when requested for a doctest item.
| def test_auto_use_request_attributes(self, testdir, scope):
"""Check that all attributes of a request in an autouse fixture
behave as expected when requested for a doctest item.
"""
testdir.makeconftest('''
import pytest
@pytest.fixture(autouse=True, scope="{scop... | [
"def",
"test_auto_use_request_attributes",
"(",
"self",
",",
"testdir",
",",
"scope",
")",
":",
"testdir",
".",
"makeconftest",
"(",
"'''\n import pytest\n\n @pytest.fixture(autouse=True, scope=\"{scope}\")\n def auto(request):\n if \"{scop... | [
852,
4
] | [
875,
59
] | python | en | ['en', 'en', 'en'] | True |
TestDoctestNamespaceFixture.test_namespace_doctestfile | (self, testdir, scope) |
Check that inserting something into the namespace works in a
simple text file doctest
|
Check that inserting something into the namespace works in a
simple text file doctest
| def test_namespace_doctestfile(self, testdir, scope):
"""
Check that inserting something into the namespace works in a
simple text file doctest
"""
testdir.makeconftest("""
import pytest
import contextlib
@pytest.fixture(autouse=True, scope="{... | [
"def",
"test_namespace_doctestfile",
"(",
"self",
",",
"testdir",
",",
"scope",
")",
":",
"testdir",
".",
"makeconftest",
"(",
"\"\"\"\n import pytest\n import contextlib\n\n @pytest.fixture(autouse=True, scope=\"{scope}\")\n def add_contextlib... | [
883,
4
] | [
901,
38
] | python | en | ['en', 'error', 'th'] | False |
TestDoctestNamespaceFixture.test_namespace_pyfile | (self, testdir, scope) |
Check that inserting something into the namespace works in a
simple Python file docstring doctest
|
Check that inserting something into the namespace works in a
simple Python file docstring doctest
| def test_namespace_pyfile(self, testdir, scope):
"""
Check that inserting something into the namespace works in a
simple Python file docstring doctest
"""
testdir.makeconftest("""
import pytest
import contextlib
@pytest.fixture(autouse=True, s... | [
"def",
"test_namespace_pyfile",
"(",
"self",
",",
"testdir",
",",
"scope",
")",
":",
"testdir",
".",
"makeconftest",
"(",
"\"\"\"\n import pytest\n import contextlib\n\n @pytest.fixture(autouse=True, scope=\"{scope}\")\n def add_contextlib(doct... | [
904,
4
] | [
925,
38
] | python | en | ['en', 'error', 'th'] | False |
standardize_headers | (input_headers: Union[None, Dict[str, Any]]) | This method can be used to standardize a dictionary of headers with
the standard format that Django expects. For reference, refer to:
https://docs.djangoproject.com/en/2.2/ref/request-response/#django.http.HttpRequest.headers
NOTE: Historically, Django's headers were not case-insensitive. We're still
c... | This method can be used to standardize a dictionary of headers with
the standard format that Django expects. For reference, refer to:
https://docs.djangoproject.com/en/2.2/ref/request-response/#django.http.HttpRequest.headers | def standardize_headers(input_headers: Union[None, Dict[str, Any]]) -> Dict[str, str]:
"""This method can be used to standardize a dictionary of headers with
the standard format that Django expects. For reference, refer to:
https://docs.djangoproject.com/en/2.2/ref/request-response/#django.http.HttpRequest.... | [
"def",
"standardize_headers",
"(",
"input_headers",
":",
"Union",
"[",
"None",
",",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
")",
"->",
"Dict",
"[",
"str",
",",
"str",
"]",
":",
"canonical_headers",
"=",
"{",
"}",
"if",
"not",
"input_headers",
":",
... | [
108,
0
] | [
128,
28
] | python | en | ['en', 'en', 'en'] | True |
get_fixture_http_headers | (integration_name: str, fixture_name: str) | For integrations that require custom HTTP headers for some (or all)
of their test fixtures, this method will call a specially named
function from the target integration module to determine what set
of HTTP headers goes with the given test fixture.
| For integrations that require custom HTTP headers for some (or all)
of their test fixtures, this method will call a specially named
function from the target integration module to determine what set
of HTTP headers goes with the given test fixture.
| def get_fixture_http_headers(integration_name: str, fixture_name: str) -> Dict["str", "str"]:
"""For integrations that require custom HTTP headers for some (or all)
of their test fixtures, this method will call a specially named
function from the target integration module to determine what set
of HTTP h... | [
"def",
"get_fixture_http_headers",
"(",
"integration_name",
":",
"str",
",",
"fixture_name",
":",
"str",
")",
"->",
"Dict",
"[",
"\"str\"",
",",
"\"str\"",
"]",
":",
"view_module_name",
"=",
"f\"zerver.webhooks.{integration_name}.view\"",
"try",
":",
"# TODO: We may w... | [
152,
0
] | [
166,
43
] | python | en | ['en', 'en', 'en'] | True |
get_http_headers_from_filename | (http_header_key: str) | If an integration requires an event type kind of HTTP header which can
be easily (statically) determined, then name the fixtures in the format
of "header_value__other_details" or even "header_value" and the use this
method in the headers.py file for the integration. | If an integration requires an event type kind of HTTP header which can
be easily (statically) determined, then name the fixtures in the format
of "header_value__other_details" or even "header_value" and the use this
method in the headers.py file for the integration. | def get_http_headers_from_filename(http_header_key: str) -> Callable[[str], Dict[str, str]]:
"""If an integration requires an event type kind of HTTP header which can
be easily (statically) determined, then name the fixtures in the format
of "header_value__other_details" or even "header_value" and the use t... | [
"def",
"get_http_headers_from_filename",
"(",
"http_header_key",
":",
"str",
")",
"->",
"Callable",
"[",
"[",
"str",
"]",
",",
"Dict",
"[",
"str",
",",
"str",
"]",
"]",
":",
"def",
"fixture_to_headers",
"(",
"filename",
":",
"str",
")",
"->",
"Dict",
"["... | [
169,
0
] | [
182,
29
] | python | en | ['en', 'en', 'en'] | True |
unix_milliseconds_to_timestamp | (milliseconds: Any, webhook: str) | If an integration requires time input in unix milliseconds, this helper
checks to ensure correct type and will catch any errors related to type or
value and raise a JsonableError.
Returns a datetime representing the time. | If an integration requires time input in unix milliseconds, this helper
checks to ensure correct type and will catch any errors related to type or
value and raise a JsonableError.
Returns a datetime representing the time. | def unix_milliseconds_to_timestamp(milliseconds: Any, webhook: str) -> datetime:
"""If an integration requires time input in unix milliseconds, this helper
checks to ensure correct type and will catch any errors related to type or
value and raise a JsonableError.
Returns a datetime representing the time... | [
"def",
"unix_milliseconds_to_timestamp",
"(",
"milliseconds",
":",
"Any",
",",
"webhook",
":",
"str",
")",
"->",
"datetime",
":",
"try",
":",
"# timestamps are in milliseconds so divide by 1000",
"seconds",
"=",
"milliseconds",
"/",
"1000",
"return",
"timestamp_to_datet... | [
185,
0
] | [
195,
94
] | python | en | ['en', 'en', 'en'] | True |
IdPFilterAction.filter | (self, table, idps, filter_string) | Naive case-insensitive search. | Naive case-insensitive search. | def filter(self, table, idps, filter_string):
"""Naive case-insensitive search."""
q = filter_string.lower()
return [idp for idp in idps
if q in idp.ud.lower()] | [
"def",
"filter",
"(",
"self",
",",
"table",
",",
"idps",
",",
"filter_string",
")",
":",
"q",
"=",
"filter_string",
".",
"lower",
"(",
")",
"return",
"[",
"idp",
"for",
"idp",
"in",
"idps",
"if",
"q",
"in",
"idp",
".",
"ud",
".",
"lower",
"(",
")... | [
72,
4
] | [
76,
39
] | python | en | ['en', 'it', 'en'] | True |
UsersTab._update_user_roles_names_from_roles_id | (self, user, users_roles,
roles_list) | Add roles names to user.roles, based on users_roles.
:param user: user to update
:param users_roles: list of roles ID
:param roles_list: list of roles obtained with keystone
| Add roles names to user.roles, based on users_roles. | def _update_user_roles_names_from_roles_id(self, user, users_roles,
roles_list):
"""Add roles names to user.roles, based on users_roles.
:param user: user to update
:param users_roles: list of roles ID
:param roles_list: list of roles obtai... | [
"def",
"_update_user_roles_names_from_roles_id",
"(",
"self",
",",
"user",
",",
"users_roles",
",",
"roles_list",
")",
":",
"user_roles_names",
"=",
"[",
"role",
".",
"name",
"for",
"role",
"in",
"roles_list",
"if",
"role",
".",
"id",
"in",
"users_roles",
"]",... | [
75,
4
] | [
86,
75
] | python | en | ['en', 'en', 'en'] | True |
UsersTab._get_users_from_project | (self, project_id, roles, project_users) | Update with users which have role on project NOT through a group.
:param project_id: ID of the project
:param roles: list of roles from keystone
:param project_users: list to be updated with the users found
| Update with users which have role on project NOT through a group. | def _get_users_from_project(self, project_id, roles, project_users):
"""Update with users which have role on project NOT through a group.
:param project_id: ID of the project
:param roles: list of roles from keystone
:param project_users: list to be updated with the users found
... | [
"def",
"_get_users_from_project",
"(",
"self",
",",
"project_id",
",",
"roles",
",",
"project_users",
")",
":",
"# For keystone.user_list project_id is not passed as argument because",
"# it is ignored when using admin credentials",
"# Get all users (to be able to find user name)",
"us... | [
88,
4
] | [
121,
13
] | python | en | ['en', 'en', 'en'] | True |
UsersTab._get_users_from_groups | (self, project_id, roles, project_users) | Update with users which have role on project through a group.
:param project_id: ID of the project
:param roles: list of roles from keystone
:param project_users: list to be updated with the users found
| Update with users which have role on project through a group. | def _get_users_from_groups(self, project_id, roles, project_users):
"""Update with users which have role on project through a group.
:param project_id: ID of the project
:param roles: list of roles from keystone
:param project_users: list to be updated with the users found
"""
... | [
"def",
"_get_users_from_groups",
"(",
"self",
",",
"project_id",
",",
"roles",
",",
"project_users",
")",
":",
"# For keystone.group_list project_id is not passed as argument because",
"# it is ignored when using admin credentials",
"# Get all groups (to be able to find group name)",
"... | [
123,
4
] | [
161,
37
] | python | en | ['en', 'en', 'en'] | True |
UsersTab.get_userstable_data | (self) | Get users with roles on the project.
Roles can be applied directly on the project or through a group.
| Get users with roles on the project. | def get_userstable_data(self):
"""Get users with roles on the project.
Roles can be applied directly on the project or through a group.
"""
project_users = {}
project = self.tab_group.kwargs['project']
try:
# Get all global roles once to avoid multiple reque... | [
"def",
"get_userstable_data",
"(",
"self",
")",
":",
"project_users",
"=",
"{",
"}",
"project",
"=",
"self",
".",
"tab_group",
".",
"kwargs",
"[",
"'project'",
"]",
"try",
":",
"# Get all global roles once to avoid multiple requests.",
"roles",
"=",
"api",
".",
... | [
163,
4
] | [
192,
37
] | python | en | ['en', 'en', 'en'] | True |
load_PT | (data, args) |
Load the Flash copy of the Partition Table from the first segment of the IROM0
segment, that is at 0x10000. If nececessary the LFS partition is then correctly
positioned and adjusted according to the optional start and len arguments.
The (possibly) updated PT is then returned with the LFS sizing.
... |
Load the Flash copy of the Partition Table from the first segment of the IROM0
segment, that is at 0x10000. If nececessary the LFS partition is then correctly
positioned and adjusted according to the optional start and len arguments. | def load_PT(data, args):
"""
Load the Flash copy of the Partition Table from the first segment of the IROM0
segment, that is at 0x10000. If nececessary the LFS partition is then correctly
positioned and adjusted according to the optional start and len arguments.
The (possibly) updated PT is then r... | [
"def",
"load_PT",
"(",
"data",
",",
"args",
")",
":",
"PTrec",
",",
"recs",
"=",
"unpack_RCR",
"(",
"data",
")",
"flash_size",
"=",
"args",
".",
"fs",
"if",
"args",
".",
"fs",
"is",
"not",
"None",
"else",
"DEFAULT_FLASH_SIZE",
"# The partition table format... | [
119,
0
] | [
232,
20
] | python | en | ['en', 'error', 'th'] | False |
relocate_lfs | (data, addr, size) |
The unpacked LFS image comprises the relocatable image itself, followed by a bit
map (one bit per word) flagging if the corresponding word of the image needs
relocating. The image and bitmap are enumerated with any addresses being
relocated by the LFS base address. (Note that the PIC format of addres... |
The unpacked LFS image comprises the relocatable image itself, followed by a bit
map (one bit per word) flagging if the corresponding word of the image needs
relocating. The image and bitmap are enumerated with any addresses being
relocated by the LFS base address. (Note that the PIC format of addres... | def relocate_lfs(data, addr, size):
"""
The unpacked LFS image comprises the relocatable image itself, followed by a bit
map (one bit per word) flagging if the corresponding word of the image needs
relocating. The image and bitmap are enumerated with any addresses being
relocated by the LFS base ad... | [
"def",
"relocate_lfs",
"(",
"data",
",",
"addr",
",",
"size",
")",
":",
"addr",
"+=",
"FLASH_BASE_ADDR",
"w",
"=",
"[",
"PACK_INT",
".",
"unpack_from",
"(",
"data",
",",
"i",
")",
"[",
"0",
"]",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(... | [
234,
0
] | [
268,
53
] | python | en | ['en', 'error', 'th'] | False |
getTreeWalker | (treeType, implementation=None, **kwargs) | Get a TreeWalker class for various types of tree with built-in support
:arg str treeType: the name of the tree type required (case-insensitive).
Supported values are:
* "dom": The xml.dom.minidom DOM implementation
* "etree": A generic walker for tree implementations exposing an
... | Get a TreeWalker class for various types of tree with built-in support | def getTreeWalker(treeType, implementation=None, **kwargs):
"""Get a TreeWalker class for various types of tree with built-in support
:arg str treeType: the name of the tree type required (case-insensitive).
Supported values are:
* "dom": The xml.dom.minidom DOM implementation
* "etree... | [
"def",
"getTreeWalker",
"(",
"treeType",
",",
"implementation",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"treeType",
"=",
"treeType",
".",
"lower",
"(",
")",
"if",
"treeType",
"not",
"in",
"treeWalkerCache",
":",
"if",
"treeType",
"==",
"\"dom\"",
... | [
20,
0
] | [
61,
40
] | python | en | ['en', 'en', 'en'] | True |
pprint | (walker) | Pretty printer for tree walkers
Takes a TreeWalker instance and pretty prints the output of walking the tree.
:arg walker: a TreeWalker instance
| Pretty printer for tree walkers | def pprint(walker):
"""Pretty printer for tree walkers
Takes a TreeWalker instance and pretty prints the output of walking the tree.
:arg walker: a TreeWalker instance
"""
output = []
indent = 0
for token in concatenateCharacterTokens(walker):
type = token["type"]
if type ... | [
"def",
"pprint",
"(",
"walker",
")",
":",
"output",
"=",
"[",
"]",
"indent",
"=",
"0",
"for",
"token",
"in",
"concatenateCharacterTokens",
"(",
"walker",
")",
":",
"type",
"=",
"token",
"[",
"\"type\"",
"]",
"if",
"type",
"in",
"(",
"\"StartTag\"",
","... | [
79,
0
] | [
153,
28
] | python | en | ['en', 'en', 'en'] | True |
Output.__init__ | (self,
output_directory,
package_name,
pre_transformed_columns,
features,
analyzer,
transformer,
model_finder,
X_train,
X_test,
y_train,
... | Create Output object.
Set jinja2 Environment to load HTML templates. Create View objects and Plot objects that are needed for
creating HTML output.
Args:
output_directory (str): directory where HTML output will be placed
package_name (str): name of the data_dashboard pa... | Create Output object. | def __init__(self,
output_directory,
package_name,
pre_transformed_columns,
features,
analyzer,
transformer,
model_finder,
X_train,
X_test,
y_train,
... | [
"def",
"__init__",
"(",
"self",
",",
"output_directory",
",",
"package_name",
",",
"pre_transformed_columns",
",",
"features",
",",
"analyzer",
",",
"transformer",
",",
"model_finder",
",",
"X_train",
",",
"X_test",
",",
"y_train",
",",
"y_test",
",",
"transform... | [
113,
4
] | [
236,
9
] | python | en | ['en', 'en', 'en'] | True |
Output.create_html | (self, do_pairplots, do_logs) | Create HTML output.
HTML output is put into output_directory attribute directory. HTML and static files are copied to the output
directory in a predefined structure and relative paths are used as hyperlinks to join them across HTML pages.
Necessary data for View objects and Plot objects is take... | Create HTML output. | def create_html(self, do_pairplots, do_logs):
"""Create HTML output.
HTML output is put into output_directory attribute directory. HTML and static files are copied to the output
directory in a predefined structure and relative paths are used as hyperlinks to join them across HTML pages.
... | [
"def",
"create_html",
"(",
"self",
",",
"do_pairplots",
",",
"do_logs",
")",
":",
"###################################################",
"# =============== Base Parameters =============== #",
"###################################################",
"# base variables needed by every view",
... | [
238,
4
] | [
418,
42
] | python | en | ['en', 'sm', 'en'] | True |
Output.static_path | (self) | Return absolute path to the static folder in the output directory.
Returns:
str: static directory path in output directory
| Return absolute path to the static folder in the output directory. | def static_path(self):
"""Return absolute path to the static folder in the output directory.
Returns:
str: static directory path in output directory
"""
return os.path.join(self.output_directory, self._created_static_directory) | [
"def",
"static_path",
"(",
"self",
")",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"output_directory",
",",
"self",
".",
"_created_static_directory",
")"
] | [
420,
4
] | [
426,
82
] | python | en | ['en', 'en', 'en'] | True |
Output.assets_path | (self) | Return absolute path to the assets folder in the output directory.
Returns:
str: assets directory path in output directory
| Return absolute path to the assets folder in the output directory. | def assets_path(self):
"""Return absolute path to the assets folder in the output directory.
Returns:
str: assets directory path in output directory
"""
return os.path.join(self.output_directory, self._created_assets_directory) | [
"def",
"assets_path",
"(",
"self",
")",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"output_directory",
",",
"self",
".",
"_created_assets_directory",
")"
] | [
428,
4
] | [
434,
82
] | python | en | ['en', 'en', 'en'] | True |
Output.logs_path | (self) | Return absolute path to the logs folder in the output directory.
Returns:
str: logs directory path in output directory
| Return absolute path to the logs folder in the output directory. | def logs_path(self):
"""Return absolute path to the logs folder in the output directory.
Returns:
str: logs directory path in output directory
"""
return os.path.join(self.output_directory, self._created_logs_directory) | [
"def",
"logs_path",
"(",
"self",
")",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"output_directory",
",",
"self",
".",
"_created_logs_directory",
")"
] | [
436,
4
] | [
442,
80
] | python | en | ['en', 'en', 'en'] | True |
Output.overview_file | (self) | Return absolute path to the Overview HTML file in the output directory.
Returns:
str: Overview HTML file path
| Return absolute path to the Overview HTML file in the output directory. | def overview_file(self):
"""Return absolute path to the Overview HTML file in the output directory.
Returns:
str: Overview HTML file path
"""
return os.path.join(self.output_directory, self._view_overview_html) | [
"def",
"overview_file",
"(",
"self",
")",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"output_directory",
",",
"self",
".",
"_view_overview_html",
")"
] | [
444,
4
] | [
450,
76
] | python | en | ['en', 'en', 'en'] | True |
Output.features_file | (self) | Return absolute path to the FeatureView HTML file in the output directory.
Returns:
str: FeatureView HTML file path
| Return absolute path to the FeatureView HTML file in the output directory. | def features_file(self):
"""Return absolute path to the FeatureView HTML file in the output directory.
Returns:
str: FeatureView HTML file path
"""
return os.path.join(self.output_directory, self._view_features_html) | [
"def",
"features_file",
"(",
"self",
")",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"output_directory",
",",
"self",
".",
"_view_features_html",
")"
] | [
452,
4
] | [
458,
76
] | python | en | ['en', 'en', 'en'] | True |
Output.models_file | (self) | Return absolute path to the ModelsView HTML file in the output directory.
Returns:
str: ModelsView HTML file path
| Return absolute path to the ModelsView HTML file in the output directory. | def models_file(self):
"""Return absolute path to the ModelsView HTML file in the output directory.
Returns:
str: ModelsView HTML file path
"""
return os.path.join(self.output_directory, self._view_models_html) | [
"def",
"models_file",
"(",
"self",
")",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"output_directory",
",",
"self",
".",
"_view_models_html",
")"
] | [
460,
4
] | [
466,
74
] | python | en | ['en', 'en', 'en'] | True |
Output._create_output_directory | (self) | Create output directory in case it doesn't exist.
Include creation of parents directories if they don't exist as well.
| Create output directory in case it doesn't exist. | def _create_output_directory(self):
"""Create output directory in case it doesn't exist.
Include creation of parents directories if they don't exist as well.
"""
pathlib.Path(self.output_directory).mkdir(exist_ok=True, parents=True) | [
"def",
"_create_output_directory",
"(",
"self",
")",
":",
"pathlib",
".",
"Path",
"(",
"self",
".",
"output_directory",
")",
".",
"mkdir",
"(",
"exist_ok",
"=",
"True",
",",
"parents",
"=",
"True",
")"
] | [
468,
4
] | [
473,
78
] | python | en | ['en', 'en', 'en'] | True |
Output._create_subdirectories | (self) | Create directories for static and assets in case they don't exist.
Logs directory is not included as it might not be needed based on flags provided to 'create_html' method.
| Create directories for static and assets in case they don't exist. | def _create_subdirectories(self):
"""Create directories for static and assets in case they don't exist.
Logs directory is not included as it might not be needed based on flags provided to 'create_html' method.
"""
# creating directories for static and assets files
for directory_... | [
"def",
"_create_subdirectories",
"(",
"self",
")",
":",
"# creating directories for static and assets files",
"for",
"directory_path",
"in",
"[",
"self",
".",
"static_path",
"(",
")",
",",
"self",
".",
"assets_path",
"(",
")",
"]",
":",
"pathlib",
".",
"Path",
"... | [
475,
4
] | [
482,
61
] | python | en | ['en', 'en', 'en'] | True |
Output._write_html | (self, template_filename, template) | Write template HTML content into HTML file in output directory based on template filename.
template_filename is used to dynamically create HTML file path in output directory.
Args:
template_filename (str): HTML file name
template (str): rendered HTML content
| Write template HTML content into HTML file in output directory based on template filename. | def _write_html(self, template_filename, template):
"""Write template HTML content into HTML file in output directory based on template filename.
template_filename is used to dynamically create HTML file path in output directory.
Args:
template_filename (str): HTML file name
... | [
"def",
"_write_html",
"(",
"self",
",",
"template_filename",
",",
"template",
")",
":",
"template_filepath",
"=",
"self",
".",
"_path_to_file",
"(",
"template_filename",
")",
"with",
"open",
"(",
"template_filepath",
",",
"\"w\"",
")",
"as",
"f",
":",
"f",
"... | [
484,
4
] | [
495,
29
] | python | en | ['en', 'en', 'en'] | True |
Output._write_logs | (self, time_started) | Write down .csv files of model_finder search results into logs directory in output directory.
3 different search results are available in model_finder object:
- search results
- quicksearch results
- gridsearch results
Log .csv files are created in the new subdirect... | Write down .csv files of model_finder search results into logs directory in output directory. | def _write_logs(self, time_started):
"""Write down .csv files of model_finder search results into logs directory in output directory.
3 different search results are available in model_finder object:
- search results
- quicksearch results
- gridsearch results
... | [
"def",
"_write_logs",
"(",
"self",
",",
"time_started",
")",
":",
"directory",
"=",
"self",
".",
"_create_logs_directory",
"(",
"time_started",
")",
"mf",
"=",
"self",
".",
"model_finder",
"dfs",
"=",
"[",
"mf",
".",
"search_results",
"(",
"model_limit",
"="... | [
497,
4
] | [
517,
60
] | 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.