Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
test_optional_dependency_graph_single_page | () | confirms that has_create._optional_dependency_graph(Base) returns a complete dependency tree
including all optional_dependencies
| confirms that has_create._optional_dependency_graph(Base) returns a complete dependency tree
including all optional_dependencies
| def test_optional_dependency_graph_single_page():
"""confirms that has_create._optional_dependency_graph(Base) returns a complete dependency tree
including all optional_dependencies
"""
desired = {}
desired[H] = set([E, A])
desired[E] = set([D, C])
desired[D] = set([A, B])
desired[C] = s... | [
"def",
"test_optional_dependency_graph_single_page",
"(",
")",
":",
"desired",
"=",
"{",
"}",
"desired",
"[",
"H",
"]",
"=",
"set",
"(",
"[",
"E",
",",
"A",
"]",
")",
"desired",
"[",
"E",
"]",
"=",
"set",
"(",
"[",
"D",
",",
"C",
"]",
")",
"desir... | [
151,
0
] | [
162,
61
] | python | en | ['en', 'en', 'en'] | True |
test_optional_dependency_graph_with_additional | () | confirms that has_create._optional_dependency_graph(Base) returns a complete dependency tree
including all optional_dependencies with the AdditionalBases treated as a dependencies
of Base (when they aren't) and their dependencies and optional_dependencies included as well.
| confirms that has_create._optional_dependency_graph(Base) returns a complete dependency tree
including all optional_dependencies with the AdditionalBases treated as a dependencies
of Base (when they aren't) and their dependencies and optional_dependencies included as well.
| def test_optional_dependency_graph_with_additional():
"""confirms that has_create._optional_dependency_graph(Base) returns a complete dependency tree
including all optional_dependencies with the AdditionalBases treated as a dependencies
of Base (when they aren't) and their dependencies and optional_dependen... | [
"def",
"test_optional_dependency_graph_with_additional",
"(",
")",
":",
"desired",
"=",
"{",
"}",
"desired",
"[",
"F",
"]",
"=",
"set",
"(",
"[",
"B",
",",
"E",
"]",
")",
"desired",
"[",
"H",
"]",
"=",
"set",
"(",
"[",
"E",
",",
"A",
"]",
")",
"d... | [
165,
0
] | [
178,
67
] | python | en | ['en', 'en', 'en'] | True |
test_creation_order | () | confirms that `has_create.creation_order()` returns a valid creation order in the desired list of sets format | confirms that `has_create.creation_order()` returns a valid creation order in the desired list of sets format | def test_creation_order():
"""confirms that `has_create.creation_order()` returns a valid creation order in the desired list of sets format"""
dependency_graph = dict(
eight=set(['seven', 'six']),
seven=set(['five']),
six=set(),
five=set(['two', 'one']),
four=set(['one'])... | [
"def",
"test_creation_order",
"(",
")",
":",
"dependency_graph",
"=",
"dict",
"(",
"eight",
"=",
"set",
"(",
"[",
"'seven'",
",",
"'six'",
"]",
")",
",",
"seven",
"=",
"set",
"(",
"[",
"'five'",
"]",
")",
",",
"six",
"=",
"set",
"(",
")",
",",
"f... | [
181,
0
] | [
194,
65
] | python | en | ['en', 'en', 'en'] | True |
test_creation_order_with_loop | () | confirms that `has_create.creation_order()` raises toposort.CircularDependencyError when evaluating
a cyclic dependency graph
| confirms that `has_create.creation_order()` raises toposort.CircularDependencyError when evaluating
a cyclic dependency graph
| def test_creation_order_with_loop():
"""confirms that `has_create.creation_order()` raises toposort.CircularDependencyError when evaluating
a cyclic dependency graph
"""
dependency_graph = dict(
eight=set(['seven', 'six']),
seven=set(['five']),
six=set(),
five=set(['two',... | [
"def",
"test_creation_order_with_loop",
"(",
")",
":",
"dependency_graph",
"=",
"dict",
"(",
"eight",
"=",
"set",
"(",
"[",
"'seven'",
",",
"'six'",
"]",
")",
",",
"seven",
"=",
"set",
"(",
"[",
"'five'",
"]",
")",
",",
"six",
"=",
"set",
"(",
")",
... | [
197,
0
] | [
212,
58
] | python | en | ['en', 'en', 'en'] | True |
test_separate_async_optionals_none_exist | () | confirms that when creation group classes have no async optional dependencies the order is unchanged | confirms that when creation group classes have no async optional dependencies the order is unchanged | def test_separate_async_optionals_none_exist():
"""confirms that when creation group classes have no async optional dependencies the order is unchanged"""
order = has_create.creation_order(has_create.optional_dependency_graph(Three, Two, One))
assert has_create.separate_async_optionals(order) == order | [
"def",
"test_separate_async_optionals_none_exist",
"(",
")",
":",
"order",
"=",
"has_create",
".",
"creation_order",
"(",
"has_create",
".",
"optional_dependency_graph",
"(",
"Three",
",",
"Two",
",",
"One",
")",
")",
"assert",
"has_create",
".",
"separate_async_opt... | [
248,
0
] | [
251,
62
] | python | en | ['en', 'en', 'en'] | True |
test_separate_async_optionals_two_exist | () | confirms that when two creation group classes have async dependencies
the class that has shared item as a dependency occurs first in a separate creation group
| confirms that when two creation group classes have async dependencies
the class that has shared item as a dependency occurs first in a separate creation group
| def test_separate_async_optionals_two_exist():
"""confirms that when two creation group classes have async dependencies
the class that has shared item as a dependency occurs first in a separate creation group
"""
order = has_create.creation_order(has_create.optional_dependency_graph(Four, Three, Two))
... | [
"def",
"test_separate_async_optionals_two_exist",
"(",
")",
":",
"order",
"=",
"has_create",
".",
"creation_order",
"(",
"has_create",
".",
"optional_dependency_graph",
"(",
"Four",
",",
"Three",
",",
"Two",
")",
")",
"assert",
"has_create",
".",
"separate_async_opt... | [
254,
0
] | [
259,
108
] | python | en | ['en', 'en', 'en'] | True |
test_separate_async_optionals_three_exist | () | confirms that when three creation group classes have async dependencies
the class that has shared item as a dependency occurs first in a separate creation group
| confirms that when three creation group classes have async dependencies
the class that has shared item as a dependency occurs first in a separate creation group
| def test_separate_async_optionals_three_exist():
"""confirms that when three creation group classes have async dependencies
the class that has shared item as a dependency occurs first in a separate creation group
"""
order = has_create.creation_order(has_create.optional_dependency_graph(Five, Four, Thre... | [
"def",
"test_separate_async_optionals_three_exist",
"(",
")",
":",
"order",
"=",
"has_create",
".",
"creation_order",
"(",
"has_create",
".",
"optional_dependency_graph",
"(",
"Five",
",",
"Four",
",",
"Three",
")",
")",
"assert",
"has_create",
".",
"separate_async_... | [
262,
0
] | [
267,
121
] | python | en | ['en', 'en', 'en'] | True |
test_separate_async_optionals_not_has_create | () | confirms that when a dependency isn't a HasCreate has_create.separate_aysnc_optionals doesn't
unnecessarily move it from the initial creation group
| confirms that when a dependency isn't a HasCreate has_create.separate_aysnc_optionals doesn't
unnecessarily move it from the initial creation group
| def test_separate_async_optionals_not_has_create():
"""confirms that when a dependency isn't a HasCreate has_create.separate_aysnc_optionals doesn't
unnecessarily move it from the initial creation group
"""
order = has_create.creation_order(has_create.optional_dependency_graph(Seven, Six))
assert ha... | [
"def",
"test_separate_async_optionals_not_has_create",
"(",
")",
":",
"order",
"=",
"has_create",
".",
"creation_order",
"(",
"has_create",
".",
"optional_dependency_graph",
"(",
"Seven",
",",
"Six",
")",
")",
"assert",
"has_create",
".",
"separate_async_optionals",
"... | [
270,
0
] | [
275,
116
] | python | en | ['en', 'en', 'en'] | True |
test_page_creation_order_single_page | () | confirms that `has_create.page_creation_order()` returns a valid creation order | confirms that `has_create.page_creation_order()` returns a valid creation order | def test_page_creation_order_single_page():
"""confirms that `has_create.page_creation_order()` returns a valid creation order"""
desired = [set([A]), set([D]), set([G])]
assert has_create.page_creation_order(G) == desired | [
"def",
"test_page_creation_order_single_page",
"(",
")",
":",
"desired",
"=",
"[",
"set",
"(",
"[",
"A",
"]",
")",
",",
"set",
"(",
"[",
"D",
"]",
")",
",",
"set",
"(",
"[",
"G",
"]",
")",
"]",
"assert",
"has_create",
".",
"page_creation_order",
"(",... | [
278,
0
] | [
281,
55
] | python | en | ['en', 'en', 'en'] | True |
test_page_creation_order_optionals_provided | () | confirms that `has_create.page_creation_order()` returns a valid creation order
when optional_dependencies are included
| confirms that `has_create.page_creation_order()` returns a valid creation order
when optional_dependencies are included
| def test_page_creation_order_optionals_provided():
"""confirms that `has_create.page_creation_order()` returns a valid creation order
when optional_dependencies are included
"""
desired = [set([A]), set([B]), set([C]), set([D]), set([E]), set([H])]
assert has_create.page_creation_order(H, A, E) == d... | [
"def",
"test_page_creation_order_optionals_provided",
"(",
")",
":",
"desired",
"=",
"[",
"set",
"(",
"[",
"A",
"]",
")",
",",
"set",
"(",
"[",
"B",
"]",
")",
",",
"set",
"(",
"[",
"C",
"]",
")",
",",
"set",
"(",
"[",
"D",
"]",
")",
",",
"set",... | [
284,
0
] | [
289,
61
] | python | en | ['en', 'en', 'en'] | True |
test_page_creation_order_additionals_provided | () | confirms that `has_create.page_creation_order()` returns a valid creation order
when additional pages are included
| confirms that `has_create.page_creation_order()` returns a valid creation order
when additional pages are included
| def test_page_creation_order_additionals_provided():
"""confirms that `has_create.page_creation_order()` returns a valid creation order
when additional pages are included
"""
desired = [set([A]), set([B]), set([D]), set([F, H]), set([G])]
assert has_create.page_creation_order(F, H, G) == desired | [
"def",
"test_page_creation_order_additionals_provided",
"(",
")",
":",
"desired",
"=",
"[",
"set",
"(",
"[",
"A",
"]",
")",
",",
"set",
"(",
"[",
"B",
"]",
")",
",",
"set",
"(",
"[",
"D",
"]",
")",
",",
"set",
"(",
"[",
"F",
",",
"H",
"]",
")",... | [
292,
0
] | [
297,
61
] | python | en | ['en', 'en', 'en'] | True |
test_tuple_for_class_arg_causes_unshared_dependencies_when_downstream | () | Confirms that provided arg-tuple for dependency type is applied instead of chained dependency | Confirms that provided arg-tuple for dependency type is applied instead of chained dependency | def test_tuple_for_class_arg_causes_unshared_dependencies_when_downstream():
"""Confirms that provided arg-tuple for dependency type is applied instead of chained dependency"""
three_wa = ThreeWithArgs().create(
two_with_args=(TwoWithArgs, dict(one_with_args=False, make_one_with_args=True, two_with_args... | [
"def",
"test_tuple_for_class_arg_causes_unshared_dependencies_when_downstream",
"(",
")",
":",
"three_wa",
"=",
"ThreeWithArgs",
"(",
")",
".",
"create",
"(",
"two_with_args",
"=",
"(",
"TwoWithArgs",
",",
"dict",
"(",
"one_with_args",
"=",
"False",
",",
"make_one_wit... | [
526,
0
] | [
538,
58
] | python | en | ['en', 'en', 'en'] | True |
test_tuples_for_class_arg_cause_unshared_dependencies_when_downstream | () | Confirms that provided arg-tuple for dependency type is applied instead of chained dependency | Confirms that provided arg-tuple for dependency type is applied instead of chained dependency | def test_tuples_for_class_arg_cause_unshared_dependencies_when_downstream():
"""Confirms that provided arg-tuple for dependency type is applied instead of chained dependency"""
four_wa = FourWithArgs().create(
two_with_args=(TwoWithArgs, dict(one_with_args=False, make_one_with_args=True, two_with_args_k... | [
"def",
"test_tuples_for_class_arg_cause_unshared_dependencies_when_downstream",
"(",
")",
":",
"four_wa",
"=",
"FourWithArgs",
"(",
")",
".",
"create",
"(",
"two_with_args",
"=",
"(",
"TwoWithArgs",
",",
"dict",
"(",
"one_with_args",
"=",
"False",
",",
"make_one_with_... | [
541,
0
] | [
556,
52
] | python | en | ['en', 'en', 'en'] | True |
test_not_has_create_default_dependency | () | Confirms that HasCreates that claim non-HasCreates as dependencies claim them by correct kwarg
class name in _dependency_store
| Confirms that HasCreates that claim non-HasCreates as dependencies claim them by correct kwarg
class name in _dependency_store
| def test_not_has_create_default_dependency():
"""Confirms that HasCreates that claim non-HasCreates as dependencies claim them by correct kwarg
class name in _dependency_store
"""
dep_holder = NotHasCreateDependencyHolder().create()
assert isinstance(dep_holder.ds.not_has_create, MixinUserA) | [
"def",
"test_not_has_create_default_dependency",
"(",
")",
":",
"dep_holder",
"=",
"NotHasCreateDependencyHolder",
"(",
")",
".",
"create",
"(",
")",
"assert",
"isinstance",
"(",
"dep_holder",
".",
"ds",
".",
"not_has_create",
",",
"MixinUserA",
")"
] | [
593,
0
] | [
598,
63
] | python | en | ['en', 'en', 'en'] | True |
test_not_has_create_passed_dependency | () | Confirms that passed non-HasCreate subclasses are sourced as dependency | Confirms that passed non-HasCreate subclasses are sourced as dependency | def test_not_has_create_passed_dependency():
"""Confirms that passed non-HasCreate subclasses are sourced as dependency"""
dep = MixinUserB().create()
assert isinstance(dep, MixinUserB)
dep_holder = NotHasCreateDependencyHolder().create(not_has_create=dep)
assert dep_holder.ds.not_has_create == dep | [
"def",
"test_not_has_create_passed_dependency",
"(",
")",
":",
"dep",
"=",
"MixinUserB",
"(",
")",
".",
"create",
"(",
")",
"assert",
"isinstance",
"(",
"dep",
",",
"MixinUserB",
")",
"dep_holder",
"=",
"NotHasCreateDependencyHolder",
"(",
")",
".",
"create",
... | [
601,
0
] | [
606,
46
] | python | en | ['en', 'en', 'en'] | True |
test_has_create_stored_as_parent_dependency | () | Confirms that HasCreate subclasses are sourced as their parent | Confirms that HasCreate subclasses are sourced as their parent | def test_has_create_stored_as_parent_dependency():
"""Confirms that HasCreate subclasses are sourced as their parent"""
dep = MixinUserC().create()
assert isinstance(dep, MixinUserC)
assert isinstance(dep, MixinUserB)
dep_holder = HasCreateParentDependencyHolder().create(mixin_user_b=dep)
assert... | [
"def",
"test_has_create_stored_as_parent_dependency",
"(",
")",
":",
"dep",
"=",
"MixinUserC",
"(",
")",
".",
"create",
"(",
")",
"assert",
"isinstance",
"(",
"dep",
",",
"MixinUserC",
")",
"assert",
"isinstance",
"(",
"dep",
",",
"MixinUserB",
")",
"dep_holde... | [
618,
0
] | [
624,
44
] | python | en | ['en', 'en', 'en'] | True |
test_subclass_or_parent_dynamic_not_has_create_dependency_declaration | (dependency, dependency_class) | Confirms that dependencies that dynamically declare dependencies subclassed from not HasCreate
are properly linked
| Confirms that dependencies that dynamically declare dependencies subclassed from not HasCreate
are properly linked
| def test_subclass_or_parent_dynamic_not_has_create_dependency_declaration(dependency, dependency_class):
"""Confirms that dependencies that dynamically declare dependencies subclassed from not HasCreate
are properly linked
"""
dep_holder = DynamicallyDeclaresNotHasCreateDependency().create(dependency)
... | [
"def",
"test_subclass_or_parent_dynamic_not_has_create_dependency_declaration",
"(",
"dependency",
",",
"dependency_class",
")",
":",
"dep_holder",
"=",
"DynamicallyDeclaresNotHasCreateDependency",
"(",
")",
".",
"create",
"(",
"dependency",
")",
"assert",
"dep_holder",
".",
... | [
638,
0
] | [
643,
69
] | python | en | ['en', 'en', 'en'] | True |
test_subclass_or_parent_dynamic_has_create_dependency_declaration | (dependency, dependency_class) | Confirms that dependencies that dynamically declare dependencies subclassed from not HasCreate
are properly linked
| Confirms that dependencies that dynamically declare dependencies subclassed from not HasCreate
are properly linked
| def test_subclass_or_parent_dynamic_has_create_dependency_declaration(dependency, dependency_class):
"""Confirms that dependencies that dynamically declare dependencies subclassed from not HasCreate
are properly linked
"""
dep_holder = DynamicallyDeclaresHasCreateDependency().create(dependency)
asse... | [
"def",
"test_subclass_or_parent_dynamic_has_create_dependency_declaration",
"(",
"dependency",
",",
"dependency_class",
")",
":",
"dep_holder",
"=",
"DynamicallyDeclaresHasCreateDependency",
"(",
")",
".",
"create",
"(",
"dependency",
")",
"assert",
"dep_holder",
".",
"ds",... | [
657,
0
] | [
662,
67
] | python | en | ['en', 'en', 'en'] | True |
Timestamp.__init__ | (self, seconds, nanoseconds=0) | Initialize a Timestamp object.
:param int seconds:
Number of seconds since the UNIX epoch (00:00:00 UTC Jan 1 1970, minus leap seconds).
May be negative.
:param int nanoseconds:
Number of nanoseconds to add to `seconds` to get fractional time.
Maximum is... | Initialize a Timestamp object. | def __init__(self, seconds, nanoseconds=0):
"""Initialize a Timestamp object.
:param int seconds:
Number of seconds since the UNIX epoch (00:00:00 UTC Jan 1 1970, minus leap seconds).
May be negative.
:param int nanoseconds:
Number of nanoseconds to add to `... | [
"def",
"__init__",
"(",
"self",
",",
"seconds",
",",
"nanoseconds",
"=",
"0",
")",
":",
"if",
"not",
"isinstance",
"(",
"seconds",
",",
"int_types",
")",
":",
"raise",
"TypeError",
"(",
"\"seconds must be an interger\"",
")",
"if",
"not",
"isinstance",
"(",
... | [
44,
4
] | [
66,
38
] | python | en | ['en', 'en', 'en'] | True |
Timestamp.__repr__ | (self) | String representation of Timestamp. | String representation of Timestamp. | def __repr__(self):
"""String representation of Timestamp."""
return "Timestamp(seconds={0}, nanoseconds={1})".format(
self.seconds, self.nanoseconds
) | [
"def",
"__repr__",
"(",
"self",
")",
":",
"return",
"\"Timestamp(seconds={0}, nanoseconds={1})\"",
".",
"format",
"(",
"self",
".",
"seconds",
",",
"self",
".",
"nanoseconds",
")"
] | [
68,
4
] | [
72,
9
] | python | en | ['en', 'kk', 'en'] | True |
Timestamp.__eq__ | (self, other) | Check for equality with another Timestamp object | Check for equality with another Timestamp object | def __eq__(self, other):
"""Check for equality with another Timestamp object"""
if type(other) is self.__class__:
return (
self.seconds == other.seconds and self.nanoseconds == other.nanoseconds
)
return False | [
"def",
"__eq__",
"(",
"self",
",",
"other",
")",
":",
"if",
"type",
"(",
"other",
")",
"is",
"self",
".",
"__class__",
":",
"return",
"(",
"self",
".",
"seconds",
"==",
"other",
".",
"seconds",
"and",
"self",
".",
"nanoseconds",
"==",
"other",
".",
... | [
74,
4
] | [
80,
20
] | python | en | ['en', 'en', 'en'] | True |
Timestamp.__ne__ | (self, other) | not-equals method (see :func:`__eq__()`) | not-equals method (see :func:`__eq__()`) | def __ne__(self, other):
"""not-equals method (see :func:`__eq__()`)"""
return not self.__eq__(other) | [
"def",
"__ne__",
"(",
"self",
",",
"other",
")",
":",
"return",
"not",
"self",
".",
"__eq__",
"(",
"other",
")"
] | [
82,
4
] | [
84,
37
] | python | en | ['en', 'en', 'en'] | True |
Timestamp.from_bytes | (b) | Unpack bytes into a `Timestamp` object.
Used for pure-Python msgpack unpacking.
:param b: Payload from msgpack ext message with code -1
:type b: bytes
:returns: Timestamp object unpacked from msgpack ext payload
:rtype: Timestamp
| Unpack bytes into a `Timestamp` object. | def from_bytes(b):
"""Unpack bytes into a `Timestamp` object.
Used for pure-Python msgpack unpacking.
:param b: Payload from msgpack ext message with code -1
:type b: bytes
:returns: Timestamp object unpacked from msgpack ext payload
:rtype: Timestamp
"""
... | [
"def",
"from_bytes",
"(",
"b",
")",
":",
"if",
"len",
"(",
"b",
")",
"==",
"4",
":",
"seconds",
"=",
"struct",
".",
"unpack",
"(",
"\"!L\"",
",",
"b",
")",
"[",
"0",
"]",
"nanoseconds",
"=",
"0",
"elif",
"len",
"(",
"b",
")",
"==",
"8",
":",
... | [
90,
4
] | [
114,
46
] | python | en | ['pt', 'en', 'en'] | True |
Timestamp.to_bytes | (self) | Pack this Timestamp object into bytes.
Used for pure-Python msgpack packing.
:returns data: Payload for EXT message with code -1 (timestamp type)
:rtype: bytes
| Pack this Timestamp object into bytes. | def to_bytes(self):
"""Pack this Timestamp object into bytes.
Used for pure-Python msgpack packing.
:returns data: Payload for EXT message with code -1 (timestamp type)
:rtype: bytes
"""
if (self.seconds >> 34) == 0: # seconds is non-negative and fits in 34 bits
... | [
"def",
"to_bytes",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"seconds",
">>",
"34",
")",
"==",
"0",
":",
"# seconds is non-negative and fits in 34 bits",
"data64",
"=",
"self",
".",
"nanoseconds",
"<<",
"34",
"|",
"self",
".",
"seconds",
"if",
"data64... | [
116,
4
] | [
135,
19
] | python | en | ['en', 'en', 'en'] | True |
Timestamp.from_unix | (unix_sec) | Create a Timestamp from posix timestamp in seconds.
:param unix_float: Posix timestamp in seconds.
:type unix_float: int or float.
| Create a Timestamp from posix timestamp in seconds. | def from_unix(unix_sec):
"""Create a Timestamp from posix timestamp in seconds.
:param unix_float: Posix timestamp in seconds.
:type unix_float: int or float.
"""
seconds = int(unix_sec // 1)
nanoseconds = int((unix_sec % 1) * 10 ** 9)
return Timestamp(seconds, n... | [
"def",
"from_unix",
"(",
"unix_sec",
")",
":",
"seconds",
"=",
"int",
"(",
"unix_sec",
"//",
"1",
")",
"nanoseconds",
"=",
"int",
"(",
"(",
"unix_sec",
"%",
"1",
")",
"*",
"10",
"**",
"9",
")",
"return",
"Timestamp",
"(",
"seconds",
",",
"nanoseconds... | [
138,
4
] | [
146,
46
] | python | en | ['en', 'en', 'en'] | True |
Timestamp.to_unix | (self) | Get the timestamp as a floating-point value.
:returns: posix timestamp
:rtype: float
| Get the timestamp as a floating-point value. | def to_unix(self):
"""Get the timestamp as a floating-point value.
:returns: posix timestamp
:rtype: float
"""
return self.seconds + self.nanoseconds / 1e9 | [
"def",
"to_unix",
"(",
"self",
")",
":",
"return",
"self",
".",
"seconds",
"+",
"self",
".",
"nanoseconds",
"/",
"1e9"
] | [
148,
4
] | [
154,
52
] | python | en | ['en', 'en', 'en'] | True |
Timestamp.from_unix_nano | (unix_ns) | Create a Timestamp from posix timestamp in nanoseconds.
:param int unix_ns: Posix timestamp in nanoseconds.
:rtype: Timestamp
| Create a Timestamp from posix timestamp in nanoseconds. | def from_unix_nano(unix_ns):
"""Create a Timestamp from posix timestamp in nanoseconds.
:param int unix_ns: Posix timestamp in nanoseconds.
:rtype: Timestamp
"""
return Timestamp(*divmod(unix_ns, 10 ** 9)) | [
"def",
"from_unix_nano",
"(",
"unix_ns",
")",
":",
"return",
"Timestamp",
"(",
"*",
"divmod",
"(",
"unix_ns",
",",
"10",
"**",
"9",
")",
")"
] | [
157,
4
] | [
163,
51
] | python | en | ['en', 'en', 'en'] | True |
Timestamp.to_unix_nano | (self) | Get the timestamp as a unixtime in nanoseconds.
:returns: posix timestamp in nanoseconds
:rtype: int
| Get the timestamp as a unixtime in nanoseconds. | def to_unix_nano(self):
"""Get the timestamp as a unixtime in nanoseconds.
:returns: posix timestamp in nanoseconds
:rtype: int
"""
return self.seconds * 10 ** 9 + self.nanoseconds | [
"def",
"to_unix_nano",
"(",
"self",
")",
":",
"return",
"self",
".",
"seconds",
"*",
"10",
"**",
"9",
"+",
"self",
".",
"nanoseconds"
] | [
165,
4
] | [
171,
56
] | python | en | ['en', 'en', 'en'] | True |
Timestamp.to_datetime | (self) | Get the timestamp as a UTC datetime.
Python 2 is not supported.
:rtype: datetime.
| Get the timestamp as a UTC datetime. | def to_datetime(self):
"""Get the timestamp as a UTC datetime.
Python 2 is not supported.
:rtype: datetime.
"""
return datetime.datetime.fromtimestamp(self.to_unix(), _utc) | [
"def",
"to_datetime",
"(",
"self",
")",
":",
"return",
"datetime",
".",
"datetime",
".",
"fromtimestamp",
"(",
"self",
".",
"to_unix",
"(",
")",
",",
"_utc",
")"
] | [
173,
4
] | [
180,
68
] | python | en | ['en', 'en', 'en'] | True |
Timestamp.from_datetime | (dt) | Create a Timestamp from datetime with tzinfo.
Python 2 is not supported.
:rtype: Timestamp
| Create a Timestamp from datetime with tzinfo. | def from_datetime(dt):
"""Create a Timestamp from datetime with tzinfo.
Python 2 is not supported.
:rtype: Timestamp
"""
return Timestamp.from_unix(dt.timestamp()) | [
"def",
"from_datetime",
"(",
"dt",
")",
":",
"return",
"Timestamp",
".",
"from_unix",
"(",
"dt",
".",
"timestamp",
"(",
")",
")"
] | [
183,
4
] | [
190,
50
] | python | en | ['en', 'en', 'en'] | True |
get_level_tags | () |
Returns the message level tags.
|
Returns the message level tags.
| def get_level_tags():
"""
Returns the message level tags.
"""
level_tags = constants.DEFAULT_TAGS.copy()
level_tags.update(getattr(settings, 'MESSAGE_TAGS', {}))
return level_tags | [
"def",
"get_level_tags",
"(",
")",
":",
"level_tags",
"=",
"constants",
".",
"DEFAULT_TAGS",
".",
"copy",
"(",
")",
"level_tags",
".",
"update",
"(",
"getattr",
"(",
"settings",
",",
"'MESSAGE_TAGS'",
",",
"{",
"}",
")",
")",
"return",
"level_tags"
] | [
4,
0
] | [
10,
21
] | python | en | ['en', 'error', 'th'] | False |
_GetLargePdbShimCcPath | () | Returns the path of the large_pdb_shim.cc file. | Returns the path of the large_pdb_shim.cc file. | def _GetLargePdbShimCcPath():
"""Returns the path of the large_pdb_shim.cc file."""
this_dir = os.path.abspath(os.path.dirname(__file__))
src_dir = os.path.abspath(os.path.join(this_dir, "..", ".."))
win_data_dir = os.path.join(src_dir, "data", "win")
large_pdb_shim_cc = os.path.join(win_data_dir, "... | [
"def",
"_GetLargePdbShimCcPath",
"(",
")",
":",
"this_dir",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
")",
"src_dir",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"... | [
20,
0
] | [
26,
28
] | python | en | ['en', 'en', 'en'] | True |
_DeepCopySomeKeys | (in_dict, keys) | Performs a partial deep-copy on |in_dict|, only copying the keys in |keys|.
Arguments:
in_dict: The dictionary to copy.
keys: The keys to be copied. If a key is in this list and doesn't exist in
|in_dict| this is not an error.
Returns:
The partially deep-copied dictionary.
| Performs a partial deep-copy on |in_dict|, only copying the keys in |keys|. | def _DeepCopySomeKeys(in_dict, keys):
"""Performs a partial deep-copy on |in_dict|, only copying the keys in |keys|.
Arguments:
in_dict: The dictionary to copy.
keys: The keys to be copied. If a key is in this list and doesn't exist in
|in_dict| this is not an error.
Returns:
The partially ... | [
"def",
"_DeepCopySomeKeys",
"(",
"in_dict",
",",
"keys",
")",
":",
"d",
"=",
"{",
"}",
"for",
"key",
"in",
"keys",
":",
"if",
"key",
"not",
"in",
"in_dict",
":",
"continue",
"d",
"[",
"key",
"]",
"=",
"copy",
".",
"deepcopy",
"(",
"in_dict",
"[",
... | [
29,
0
] | [
44,
12
] | python | en | ['en', 'en', 'en'] | True |
_SuffixName | (name, suffix) | Add a suffix to the end of a target.
Arguments:
name: name of the target (foo#target)
suffix: the suffix to be added
Returns:
Target name with suffix added (foo_suffix#target)
| Add a suffix to the end of a target. | def _SuffixName(name, suffix):
"""Add a suffix to the end of a target.
Arguments:
name: name of the target (foo#target)
suffix: the suffix to be added
Returns:
Target name with suffix added (foo_suffix#target)
"""
parts = name.rsplit("#", 1)
parts[0] = "%s_%s" % (parts[0], suffix)
ret... | [
"def",
"_SuffixName",
"(",
"name",
",",
"suffix",
")",
":",
"parts",
"=",
"name",
".",
"rsplit",
"(",
"\"#\"",
",",
"1",
")",
"parts",
"[",
"0",
"]",
"=",
"\"%s_%s\"",
"%",
"(",
"parts",
"[",
"0",
"]",
",",
"suffix",
")",
"return",
"\"#\"",
".",
... | [
47,
0
] | [
58,
26
] | python | en | ['en', 'en', 'en'] | True |
_ShardName | (name, number) | Add a shard number to the end of a target.
Arguments:
name: name of the target (foo#target)
number: shard number
Returns:
Target name with shard added (foo_1#target)
| Add a shard number to the end of a target. | def _ShardName(name, number):
"""Add a shard number to the end of a target.
Arguments:
name: name of the target (foo#target)
number: shard number
Returns:
Target name with shard added (foo_1#target)
"""
return _SuffixName(name, str(number)) | [
"def",
"_ShardName",
"(",
"name",
",",
"number",
")",
":",
"return",
"_SuffixName",
"(",
"name",
",",
"str",
"(",
"number",
")",
")"
] | [
61,
0
] | [
70,
41
] | python | en | ['en', 'en', 'en'] | True |
ShardTargets | (target_list, target_dicts) | Shard some targets apart to work around the linkers limits.
Arguments:
target_list: List of target pairs: 'base/base.gyp:base'.
target_dicts: Dict of target properties keyed on target pair.
Returns:
Tuple of the new sharded versions of the inputs.
| Shard some targets apart to work around the linkers limits. | def ShardTargets(target_list, target_dicts):
"""Shard some targets apart to work around the linkers limits.
Arguments:
target_list: List of target pairs: 'base/base.gyp:base'.
target_dicts: Dict of target properties keyed on target pair.
Returns:
Tuple of the new sharded versions of the inputs.
"... | [
"def",
"ShardTargets",
"(",
"target_list",
",",
"target_dicts",
")",
":",
"# Gather the targets to shard, and how many pieces.",
"targets_to_shard",
"=",
"{",
"}",
"for",
"t",
"in",
"target_dicts",
":",
"shards",
"=",
"int",
"(",
"target_dicts",
"[",
"t",
"]",
"."... | [
73,
0
] | [
126,
46
] | python | en | ['en', 'en', 'en'] | True |
_GetPdbPath | (target_dict, config_name, vars) | Returns the path to the PDB file that will be generated by a given
configuration.
The lookup proceeds as follows:
- Look for an explicit path in the VCLinkerTool configuration block.
- Look for an 'msvs_large_pdb_path' variable.
- Use '<(PRODUCT_DIR)/<(product_name).(exe|dll).pdb' if 'product_name' is
... | Returns the path to the PDB file that will be generated by a given
configuration. | def _GetPdbPath(target_dict, config_name, vars):
"""Returns the path to the PDB file that will be generated by a given
configuration.
The lookup proceeds as follows:
- Look for an explicit path in the VCLinkerTool configuration block.
- Look for an 'msvs_large_pdb_path' variable.
- Use '<(PRODUCT_D... | [
"def",
"_GetPdbPath",
"(",
"target_dict",
",",
"config_name",
",",
"vars",
")",
":",
"config",
"=",
"target_dict",
"[",
"\"configurations\"",
"]",
"[",
"config_name",
"]",
"msvs",
"=",
"config",
".",
"setdefault",
"(",
"\"msvs_settings\"",
",",
"{",
"}",
")"... | [
129,
0
] | [
165,
19
] | python | en | ['en', 'en', 'en'] | True |
InsertLargePdbShims | (target_list, target_dicts, vars) | Insert a shim target that forces the linker to use 4KB pagesize PDBs.
This is a workaround for targets with PDBs greater than 1GB in size, the
limit for the 1KB pagesize PDBs created by the linker by default.
Arguments:
target_list: List of target pairs: 'base/base.gyp:base'.
target_dicts: Dict of targe... | Insert a shim target that forces the linker to use 4KB pagesize PDBs. | def InsertLargePdbShims(target_list, target_dicts, vars):
"""Insert a shim target that forces the linker to use 4KB pagesize PDBs.
This is a workaround for targets with PDBs greater than 1GB in size, the
limit for the 1KB pagesize PDBs created by the linker by default.
Arguments:
target_list: List of ta... | [
"def",
"InsertLargePdbShims",
"(",
"target_list",
",",
"target_dicts",
",",
"vars",
")",
":",
"# Determine which targets need shimming.",
"targets_to_shim",
"=",
"[",
"]",
"for",
"t",
"in",
"target_dicts",
":",
"target_dict",
"=",
"target_dicts",
"[",
"t",
"]",
"#... | [
168,
0
] | [
270,
38
] | python | en | ['en', 'en', 'en'] | True |
RadarrHookTests.test_radarr_test | (self) |
Tests if radarr test payload is handled correctly
|
Tests if radarr test payload is handled correctly
| def test_radarr_test(self) -> None:
"""
Tests if radarr test payload is handled correctly
"""
expected_topic = "Radarr - Test"
expected_message = "Radarr webhook has been successfully configured."
self.check_webhook("radarr_test", expected_topic, expected_message) | [
"def",
"test_radarr_test",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Radarr - Test\"",
"expected_message",
"=",
"\"Radarr webhook has been successfully configured.\"",
"self",
".",
"check_webhook",
"(",
"\"radarr_test\"",
",",
"expected_topic",
",",
"... | [
8,
4
] | [
14,
75
] | python | en | ['en', 'error', 'th'] | False |
RadarrHookTests.test_radarr_health_check_warning | (self) |
Tests if radarr health check warning payload is handled correctly
|
Tests if radarr health check warning payload is handled correctly
| def test_radarr_health_check_warning(self) -> None:
"""
Tests if radarr health check warning payload is handled correctly
"""
expected_topic = "Health warning"
expected_message = "No download client is available."
self.check_webhook("radarr_health_check_warning", expected... | [
"def",
"test_radarr_health_check_warning",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Health warning\"",
"expected_message",
"=",
"\"No download client is available.\"",
"self",
".",
"check_webhook",
"(",
"\"radarr_health_check_warning\"",
",",
"expected_t... | [
16,
4
] | [
22,
91
] | python | en | ['en', 'error', 'th'] | False |
RadarrHookTests.test_radarr_health_check_error | (self) |
Tests if radarr health check error payload is handled correctly
|
Tests if radarr health check error payload is handled correctly
| def test_radarr_health_check_error(self) -> None:
"""
Tests if radarr health check error payload is handled correctly
"""
expected_topic = "Health error"
expected_message = "Movie Gotham City Sirens (tmdbid 416649) was removed from TMDb."
self.check_webhook("radarr_health... | [
"def",
"test_radarr_health_check_error",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Health error\"",
"expected_message",
"=",
"\"Movie Gotham City Sirens (tmdbid 416649) was removed from TMDb.\"",
"self",
".",
"check_webhook",
"(",
"\"radarr_health_check_error... | [
24,
4
] | [
30,
89
] | python | en | ['en', 'error', 'th'] | False |
RadarrHookTests.test_radarr_movie_renamed | (self) |
Tests if radarr movie renamed payload is handled correctly
|
Tests if radarr movie renamed payload is handled correctly
| def test_radarr_movie_renamed(self) -> None:
"""
Tests if radarr movie renamed payload is handled correctly
"""
expected_topic = "Marley & Me"
expected_message = "The movie Marley & Me has been renamed."
self.check_webhook("radarr_movie_renamed", expected_topic, expected_... | [
"def",
"test_radarr_movie_renamed",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Marley & Me\"",
"expected_message",
"=",
"\"The movie Marley & Me has been renamed.\"",
"self",
".",
"check_webhook",
"(",
"\"radarr_movie_renamed\"",
",",
"expected_topic",
"... | [
32,
4
] | [
38,
84
] | python | en | ['en', 'error', 'th'] | False |
RadarrHookTests.test_radarr_movie_imported | (self) |
Tests if radarr movie imported payload is handled correctly
|
Tests if radarr movie imported payload is handled correctly
| def test_radarr_movie_imported(self) -> None:
"""
Tests if radarr movie imported payload is handled correctly
"""
expected_topic = "Batman v Superman: Dawn of Justice"
expected_message = "The movie Batman v Superman: Dawn of Justice has been imported."
self.check_webhook(... | [
"def",
"test_radarr_movie_imported",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Batman v Superman: Dawn of Justice\"",
"expected_message",
"=",
"\"The movie Batman v Superman: Dawn of Justice has been imported.\"",
"self",
".",
"check_webhook",
"(",
"\"radarr_... | [
40,
4
] | [
46,
85
] | python | en | ['en', 'error', 'th'] | False |
RadarrHookTests.test_radarr_movie_imported_upgrade | (self) |
Tests if radarr movie imported upgrade payload is handled correctly
|
Tests if radarr movie imported upgrade payload is handled correctly
| def test_radarr_movie_imported_upgrade(self) -> None:
"""
Tests if radarr movie imported upgrade payload is handled correctly
"""
expected_topic = "Greenland"
expected_message = "The movie Greenland has been upgraded from WEBRip-720p to WEBRip-1080p."
self.check_webhook("... | [
"def",
"test_radarr_movie_imported_upgrade",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Greenland\"",
"expected_message",
"=",
"\"The movie Greenland has been upgraded from WEBRip-720p to WEBRip-1080p.\"",
"self",
".",
"check_webhook",
"(",
"\"radarr_movie_imp... | [
48,
4
] | [
54,
93
] | python | en | ['en', 'error', 'th'] | False |
RadarrHookTests.test_radarr_movie_grabbed | (self) |
Tests if radarr movie grabbed payload is handled correctly
|
Tests if radarr movie grabbed payload is handled correctly
| def test_radarr_movie_grabbed(self) -> None:
"""
Tests if radarr movie grabbed payload is handled correctly
"""
expected_topic = "Greenland"
expected_message = "The movie Greenland has been grabbed."
self.check_webhook("radarr_movie_grabbed", expected_topic, expected_mess... | [
"def",
"test_radarr_movie_grabbed",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Greenland\"",
"expected_message",
"=",
"\"The movie Greenland has been grabbed.\"",
"self",
".",
"check_webhook",
"(",
"\"radarr_movie_grabbed\"",
",",
"expected_topic",
",",
... | [
56,
4
] | [
62,
84
] | python | en | ['en', 'error', 'th'] | False |
ResultsTree.add_sample | (self, sample) |
:type sample: FunctionalSample
|
:type sample: FunctionalSample
| def add_sample(self, sample):
"""
:type sample: FunctionalSample
"""
test_suite = sample.test_suite
self.get(test_suite, [], force_set=True).append(sample) | [
"def",
"add_sample",
"(",
"self",
",",
"sample",
")",
":",
"test_suite",
"=",
"sample",
".",
"test_suite",
"self",
".",
"get",
"(",
"test_suite",
",",
"[",
"]",
",",
"force_set",
"=",
"True",
")",
".",
"append",
"(",
"sample",
")"
] | [
116,
4
] | [
121,
63
] | python | en | ['en', 'error', 'th'] | False |
FunctionalResultsReader.read | (self, last_pass=False) | Yields functional samples | Yields functional samples | def read(self, last_pass=False):
"""Yields functional samples"""
yield | [
"def",
"read",
"(",
"self",
",",
"last_pass",
"=",
"False",
")",
":",
"yield"
] | [
132,
4
] | [
134,
13
] | python | en | ['en', 'en', 'en'] | True |
FunctionalAggregatorListener.aggregated_results | (self, results, cumulative_results) |
Callback that gets called every time aggregator processes new test results.
:type results: ResultsTree
:type cumulative_results: ResultsTree
|
Callback that gets called every time aggregator processes new test results.
:type results: ResultsTree
:type cumulative_results: ResultsTree
| def aggregated_results(self, results, cumulative_results):
"""
Callback that gets called every time aggregator processes new test results.
:type results: ResultsTree
:type cumulative_results: ResultsTree
"""
pass | [
"def",
"aggregated_results",
"(",
"self",
",",
"results",
",",
"cumulative_results",
")",
":",
"pass"
] | [
139,
4
] | [
145,
12
] | python | en | ['en', 'error', 'th'] | False |
_add_doc | (func, doc) | Add documentation to a function. | Add documentation to a function. | def _add_doc(func, doc):
"""Add documentation to a function."""
func.__doc__ = doc | [
"def",
"_add_doc",
"(",
"func",
",",
"doc",
")",
":",
"func",
".",
"__doc__",
"=",
"doc"
] | [
74,
0
] | [
76,
22
] | python | en | ['en', 'en', 'en'] | True |
_import_module | (name) | Import module, returning the module after the last dot. | Import module, returning the module after the last dot. | def _import_module(name):
"""Import module, returning the module after the last dot."""
__import__(name)
return sys.modules[name] | [
"def",
"_import_module",
"(",
"name",
")",
":",
"__import__",
"(",
"name",
")",
"return",
"sys",
".",
"modules",
"[",
"name",
"]"
] | [
79,
0
] | [
82,
28
] | python | en | ['en', 'en', 'en'] | True |
add_move | (move) | Add an item to six.moves. | Add an item to six.moves. | def add_move(move):
"""Add an item to six.moves."""
setattr(_MovedItems, move.name, move) | [
"def",
"add_move",
"(",
"move",
")",
":",
"setattr",
"(",
"_MovedItems",
",",
"move",
".",
"name",
",",
"move",
")"
] | [
493,
0
] | [
495,
41
] | python | en | ['en', 'en', 'en'] | True |
remove_move | (name) | Remove item from six.moves. | Remove item from six.moves. | def remove_move(name):
"""Remove item from six.moves."""
try:
delattr(_MovedItems, name)
except AttributeError:
try:
del moves.__dict__[name]
except KeyError:
raise AttributeError("no such move, %r" % (name,)) | [
"def",
"remove_move",
"(",
"name",
")",
":",
"try",
":",
"delattr",
"(",
"_MovedItems",
",",
"name",
")",
"except",
"AttributeError",
":",
"try",
":",
"del",
"moves",
".",
"__dict__",
"[",
"name",
"]",
"except",
"KeyError",
":",
"raise",
"AttributeError",
... | [
498,
0
] | [
506,
62
] | python | en | ['en', 'en', 'en'] | True |
with_metaclass | (meta, *bases) | Create a base class with a metaclass. | Create a base class with a metaclass. | def with_metaclass(meta, *bases):
"""Create a base class with a metaclass."""
# This requires a bit of explanation: the basic idea is to make a dummy
# metaclass for one level of class instantiation that replaces itself with
# the actual metaclass.
class metaclass(type):
def __new__(cls, na... | [
"def",
"with_metaclass",
"(",
"meta",
",",
"*",
"bases",
")",
":",
"# This requires a bit of explanation: the basic idea is to make a dummy",
"# metaclass for one level of class instantiation that replaces itself with",
"# the actual metaclass.",
"class",
"metaclass",
"(",
"type",
")... | [
839,
0
] | [
860,
61
] | python | en | ['en', 'en', 'en'] | True |
add_metaclass | (metaclass) | Class decorator for creating a class with a metaclass. | Class decorator for creating a class with a metaclass. | def add_metaclass(metaclass):
"""Class decorator for creating a class with a metaclass."""
def wrapper(cls):
orig_vars = cls.__dict__.copy()
slots = orig_vars.get('__slots__')
if slots is not None:
if isinstance(slots, str):
slots = [slots]
for slo... | [
"def",
"add_metaclass",
"(",
"metaclass",
")",
":",
"def",
"wrapper",
"(",
"cls",
")",
":",
"orig_vars",
"=",
"cls",
".",
"__dict__",
".",
"copy",
"(",
")",
"slots",
"=",
"orig_vars",
".",
"get",
"(",
"'__slots__'",
")",
"if",
"slots",
"is",
"not",
"... | [
863,
0
] | [
878,
18
] | python | en | ['en', 'en', 'en'] | True |
ensure_binary | (s, encoding='utf-8', errors='strict') | Coerce **s** to six.binary_type.
For Python 2:
- `unicode` -> encoded to `str`
- `str` -> `str`
For Python 3:
- `str` -> encoded to `bytes`
- `bytes` -> `bytes`
| Coerce **s** to six.binary_type. | def ensure_binary(s, encoding='utf-8', errors='strict'):
"""Coerce **s** to six.binary_type.
For Python 2:
- `unicode` -> encoded to `str`
- `str` -> `str`
For Python 3:
- `str` -> encoded to `bytes`
- `bytes` -> `bytes`
"""
if isinstance(s, binary_type):
return s
... | [
"def",
"ensure_binary",
"(",
"s",
",",
"encoding",
"=",
"'utf-8'",
",",
"errors",
"=",
"'strict'",
")",
":",
"if",
"isinstance",
"(",
"s",
",",
"binary_type",
")",
":",
"return",
"s",
"if",
"isinstance",
"(",
"s",
",",
"text_type",
")",
":",
"return",
... | [
881,
0
] | [
896,
56
] | python | en | ['en', 'sn', 'en'] | True |
ensure_str | (s, encoding='utf-8', errors='strict') | Coerce *s* to `str`.
For Python 2:
- `unicode` -> encoded to `str`
- `str` -> `str`
For Python 3:
- `str` -> `str`
- `bytes` -> decoded to `str`
| Coerce *s* to `str`. | def ensure_str(s, encoding='utf-8', errors='strict'):
"""Coerce *s* to `str`.
For Python 2:
- `unicode` -> encoded to `str`
- `str` -> `str`
For Python 3:
- `str` -> `str`
- `bytes` -> decoded to `str`
"""
# Optimization: Fast return for the common case.
if type(s) is s... | [
"def",
"ensure_str",
"(",
"s",
",",
"encoding",
"=",
"'utf-8'",
",",
"errors",
"=",
"'strict'",
")",
":",
"# Optimization: Fast return for the common case.",
"if",
"type",
"(",
"s",
")",
"is",
"str",
":",
"return",
"s",
"if",
"PY2",
"and",
"isinstance",
"(",... | [
899,
0
] | [
919,
12
] | python | en | ['en', 'sl', 'en'] | True |
ensure_text | (s, encoding='utf-8', errors='strict') | Coerce *s* to six.text_type.
For Python 2:
- `unicode` -> `unicode`
- `str` -> `unicode`
For Python 3:
- `str` -> `str`
- `bytes` -> decoded to `str`
| Coerce *s* to six.text_type. | def ensure_text(s, encoding='utf-8', errors='strict'):
"""Coerce *s* to six.text_type.
For Python 2:
- `unicode` -> `unicode`
- `str` -> `unicode`
For Python 3:
- `str` -> `str`
- `bytes` -> decoded to `str`
"""
if isinstance(s, binary_type):
return s.decode(encodin... | [
"def",
"ensure_text",
"(",
"s",
",",
"encoding",
"=",
"'utf-8'",
",",
"errors",
"=",
"'strict'",
")",
":",
"if",
"isinstance",
"(",
"s",
",",
"binary_type",
")",
":",
"return",
"s",
".",
"decode",
"(",
"encoding",
",",
"errors",
")",
"elif",
"isinstanc... | [
922,
0
] | [
938,
60
] | python | en | ['en', 'sr', 'en'] | True |
python_2_unicode_compatible | (klass) |
A class decorator that defines __unicode__ and __str__ methods under Python 2.
Under Python 3 it does nothing.
To support Python 2 and 3 with a single code base, define a __str__ method
returning text and apply this decorator to the class.
|
A class decorator that defines __unicode__ and __str__ methods under Python 2.
Under Python 3 it does nothing. | def python_2_unicode_compatible(klass):
"""
A class decorator that defines __unicode__ and __str__ methods under Python 2.
Under Python 3 it does nothing.
To support Python 2 and 3 with a single code base, define a __str__ method
returning text and apply this decorator to the class.
"""
if ... | [
"def",
"python_2_unicode_compatible",
"(",
"klass",
")",
":",
"if",
"PY2",
":",
"if",
"'__str__'",
"not",
"in",
"klass",
".",
"__dict__",
":",
"raise",
"ValueError",
"(",
"\"@python_2_unicode_compatible cannot be applied \"",
"\"to %s because it doesn't define __str__().\""... | [
941,
0
] | [
956,
16
] | python | en | ['en', 'error', 'th'] | False |
_SixMetaPathImporter.is_package | (self, fullname) |
Return true, if the named module is a package.
We need this method to get correct spec objects with
Python 3.4 (see PEP451)
|
Return true, if the named module is a package. | def is_package(self, fullname):
"""
Return true, if the named module is a package.
We need this method to get correct spec objects with
Python 3.4 (see PEP451)
"""
return hasattr(self.__get_module(fullname), "__path__") | [
"def",
"is_package",
"(",
"self",
",",
"fullname",
")",
":",
"return",
"hasattr",
"(",
"self",
".",
"__get_module",
"(",
"fullname",
")",
",",
"\"__path__\"",
")"
] | [
208,
4
] | [
215,
63
] | python | en | ['en', 'error', 'th'] | False |
_SixMetaPathImporter.get_code | (self, fullname) | Return None
Required, if is_package is implemented | Return None | def get_code(self, fullname):
"""Return None
Required, if is_package is implemented"""
self.__get_module(fullname) # eventually raises ImportError
return None | [
"def",
"get_code",
"(",
"self",
",",
"fullname",
")",
":",
"self",
".",
"__get_module",
"(",
"fullname",
")",
"# eventually raises ImportError",
"return",
"None"
] | [
217,
4
] | [
222,
19
] | python | en | ['en', 'co', 'en'] | False |
remove_choose_permission | (apps, _schema_editor) | Reverse the above additions of permissions. | Reverse the above additions of permissions. | def remove_choose_permission(apps, _schema_editor):
"""Reverse the above additions of permissions."""
ContentType = apps.get_model('contenttypes.ContentType')
Permission = apps.get_model('auth.Permission')
image_content_type = ContentType.objects.get(
model='image',
app_label='wagtailima... | [
"def",
"remove_choose_permission",
"(",
"apps",
",",
"_schema_editor",
")",
":",
"ContentType",
"=",
"apps",
".",
"get_model",
"(",
"'contenttypes.ContentType'",
")",
"Permission",
"=",
"apps",
".",
"get_model",
"(",
"'auth.Permission'",
")",
"image_content_type",
"... | [
30,
0
] | [
42,
14
] | python | en | ['en', 'en', 'en'] | True |
tower_auth_config | (module) |
`tower_auth_config` attempts to load the tower-cli.cfg file
specified from the `tower_config_file` parameter. If found,
if returns the contents of the file as a dictionary, else
it will attempt to fetch values from the module params and
only pass those values that have been set.
|
`tower_auth_config` attempts to load the tower-cli.cfg file
specified from the `tower_config_file` parameter. If found,
if returns the contents of the file as a dictionary, else
it will attempt to fetch values from the module params and
only pass those values that have been set.
| def tower_auth_config(module):
"""
`tower_auth_config` attempts to load the tower-cli.cfg file
specified from the `tower_config_file` parameter. If found,
if returns the contents of the file as a dictionary, else
it will attempt to fetch values from the module params and
only pass those values t... | [
"def",
"tower_auth_config",
"(",
"module",
")",
":",
"config_file",
"=",
"module",
".",
"params",
".",
"pop",
"(",
"'tower_config_file'",
",",
"None",
")",
"if",
"config_file",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"config_file",
")",
... | [
49,
0
] | [
81,
26
] | python | en | ['en', 'error', 'th'] | False |
tower_check_mode | (module) | Execute check mode logic for Ansible Tower modules | Execute check mode logic for Ansible Tower modules | def tower_check_mode(module):
'''Execute check mode logic for Ansible Tower modules'''
if module.check_mode:
try:
result = client.get('/ping').json()
module.exit_json(changed=True, tower_version='{0}'.format(result['version']))
except (exc.ServerError, exc.ConnectionError... | [
"def",
"tower_check_mode",
"(",
"module",
")",
":",
"if",
"module",
".",
"check_mode",
":",
"try",
":",
"result",
"=",
"client",
".",
"get",
"(",
"'/ping'",
")",
".",
"json",
"(",
")",
"module",
".",
"exit_json",
"(",
"changed",
"=",
"True",
",",
"to... | [
84,
0
] | [
91,
89
] | python | en | ['en', 'en', 'en'] | True |
UserInterfaceRepository.get_machines_overview | (self) |
TODO refactor this ugly stuff
:return:
|
TODO refactor this ugly stuff
:return:
| def get_machines_overview(self):
"""
TODO refactor this ugly stuff
:return:
"""
with session_commit(sess_maker=self.__sess_maker) as session:
# Fetching data
mis = session.query(MachineInterface).filter(MachineInterface.as_boot == True).all()
m... | [
"def",
"get_machines_overview",
"(",
"self",
")",
":",
"with",
"session_commit",
"(",
"sess_maker",
"=",
"self",
".",
"__sess_maker",
")",
"as",
"session",
":",
"# Fetching data",
"mis",
"=",
"session",
".",
"query",
"(",
"MachineInterface",
")",
".",
"filter"... | [
22,
4
] | [
80,
19
] | python | en | ['en', 'error', 'th'] | False |
deconstructible | (*args, **kwargs) |
Class decorator that allow the decorated class to be serialized
by the migrations subsystem.
Accepts an optional kwarg `path` to specify the import path.
|
Class decorator that allow the decorated class to be serialized
by the migrations subsystem. | def deconstructible(*args, **kwargs):
"""
Class decorator that allow the decorated class to be serialized
by the migrations subsystem.
Accepts an optional kwarg `path` to specify the import path.
"""
path = kwargs.pop('path', None)
def decorator(klass):
def __new__(cls, *args, **kw... | [
"def",
"deconstructible",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"path",
"=",
"kwargs",
".",
"pop",
"(",
"'path'",
",",
"None",
")",
"def",
"decorator",
"(",
"klass",
")",
":",
"def",
"__new__",
"(",
"cls",
",",
"*",
"args",
",",
"*... | [
5,
0
] | [
56,
37
] | python | en | ['en', 'error', 'th'] | False |
CloudProvWidget.__init__ | (self, test) |
:type test: BaseCloudTest
|
:type test: BaseCloudTest
| def __init__(self, test):
"""
:type test: BaseCloudTest
"""
self.test = test
self.text = Text("")
super(CloudProvWidget, self).__init__([self.text])
PrioritizedWidget.__init__(self) | [
"def",
"__init__",
"(",
"self",
",",
"test",
")",
":",
"self",
".",
"test",
"=",
"test",
"self",
".",
"text",
"=",
"Text",
"(",
"\"\"",
")",
"super",
"(",
"CloudProvWidget",
",",
"self",
")",
".",
"__init__",
"(",
"[",
"self",
".",
"text",
"]",
"... | [
808,
4
] | [
815,
40
] | python | en | ['en', 'error', 'th'] | False |
TestUserPasswordReset.test_password_reset_view_disabled | (self) |
This tests that the password reset view responds with a 404
when setting WAGTAIL_PASSWORD_RESET_ENABLED is False
|
This tests that the password reset view responds with a 404
when setting WAGTAIL_PASSWORD_RESET_ENABLED is False
| def test_password_reset_view_disabled(self):
"""
This tests that the password reset view responds with a 404
when setting WAGTAIL_PASSWORD_RESET_ENABLED is False
"""
# Get password reset page
response = self.client.get(reverse('wagtailadmin_password_reset'))
# Ch... | [
"def",
"test_password_reset_view_disabled",
"(",
"self",
")",
":",
"# Get password reset page",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtailadmin_password_reset'",
")",
")",
"# Check that the user received a 404",
"self",
".",
"asse... | [
35,
4
] | [
44,
51
] | python | en | ['en', 'error', 'th'] | False |
remove_initial_data | (apps, schema_editor) | This function does nothing. The below code is commented out together
with an explanation of why we don't need to bother reversing any of the
initial data | This function does nothing. The below code is commented out together
with an explanation of why we don't need to bother reversing any of the
initial data | def remove_initial_data(apps, schema_editor):
"""This function does nothing. The below code is commented out together
with an explanation of why we don't need to bother reversing any of the
initial data"""
pass | [
"def",
"remove_initial_data",
"(",
"apps",
",",
"schema_editor",
")",
":",
"pass"
] | [
90,
0
] | [
94,
8
] | python | en | ['en', 'en', 'en'] | True |
set_page_path_collation | (apps, schema_editor) |
Treebeard's path comparison logic can fail on certain locales such as sk_SK, which
sort numbers after letters. To avoid this, we explicitly set the collation for the
'path' column to the (non-locale-specific) 'C' collation.
See: https://groups.google.com/d/msg/wagtail/q0leyuCnYWI/I9uDvVlyBAAJ
|
Treebeard's path comparison logic can fail on certain locales such as sk_SK, which
sort numbers after letters. To avoid this, we explicitly set the collation for the
'path' column to the (non-locale-specific) 'C' collation. | def set_page_path_collation(apps, schema_editor):
"""
Treebeard's path comparison logic can fail on certain locales such as sk_SK, which
sort numbers after letters. To avoid this, we explicitly set the collation for the
'path' column to the (non-locale-specific) 'C' collation.
See: https://groups.g... | [
"def",
"set_page_path_collation",
"(",
"apps",
",",
"schema_editor",
")",
":",
"if",
"schema_editor",
".",
"connection",
".",
"vendor",
"==",
"'postgresql'",
":",
"schema_editor",
".",
"execute",
"(",
"\"\"\"\n ALTER TABLE wagtailcore_page ALTER COLUMN path TYPE ... | [
115,
0
] | [
126,
12
] | python | en | ['en', 'error', 'th'] | False |
open | (fp, mode="r") |
Load texture from a GD image file.
:param filename: GD file name, or an opened file handle.
:param mode: Optional mode. In this version, if the mode argument
is given, it must be "r".
:returns: An image instance.
:raises OSError: If the image could not be read.
|
Load texture from a GD image file. | def open(fp, mode="r"):
"""
Load texture from a GD image file.
:param filename: GD file name, or an opened file handle.
:param mode: Optional mode. In this version, if the mode argument
is given, it must be "r".
:returns: An image instance.
:raises OSError: If the image could not be re... | [
"def",
"open",
"(",
"fp",
",",
"mode",
"=",
"\"r\"",
")",
":",
"if",
"mode",
"!=",
"\"r\"",
":",
"raise",
"ValueError",
"(",
"\"bad mode\"",
")",
"try",
":",
"return",
"GdImageFile",
"(",
"fp",
")",
"except",
"SyntaxError",
"as",
"e",
":",
"raise",
"... | [
74,
0
] | [
90,
78
] | python | en | ['en', 'error', 'th'] | False |
install_given_reqs | (
requirements, # type: List[InstallRequirement]
install_options, # type: List[str]
global_options, # type: Sequence[str]
root, # type: Optional[str]
home, # type: Optional[str]
prefix, # type: Optional[str]
warn_script_location, # type: bool
use_user_site, # type: bool
pycom... |
Install everything in the given list.
(to be called after having downloaded and unpacked the packages)
|
Install everything in the given list. | def install_given_reqs(
requirements, # type: List[InstallRequirement]
install_options, # type: List[str]
global_options, # type: Sequence[str]
root, # type: Optional[str]
home, # type: Optional[str]
prefix, # type: Optional[str]
warn_script_location, # type: bool
use_user_site, ... | [
"def",
"install_given_reqs",
"(",
"requirements",
",",
"# type: List[InstallRequirement]",
"install_options",
",",
"# type: List[str]",
"global_options",
",",
"# type: Sequence[str]",
"root",
",",
"# type: Optional[str]",
"home",
",",
"# type: Optional[str]",
"prefix",
",",
"... | [
42,
0
] | [
102,
20
] | python | en | ['en', 'error', 'th'] | False |
cluster_node_health_check | (node) |
Used for the health check endpoint, refreshes the status of the instance, but must be ran on target node
|
Used for the health check endpoint, refreshes the status of the instance, but must be ran on target node
| def cluster_node_health_check(node):
'''
Used for the health check endpoint, refreshes the status of the instance, but must be ran on target node
'''
if node == '':
logger.warn('Local health check incorrectly called with blank string')
return
elif node != settings.CLUSTER_HOST_ID:
... | [
"def",
"cluster_node_health_check",
"(",
"node",
")",
":",
"if",
"node",
"==",
"''",
":",
"logger",
".",
"warn",
"(",
"'Local health check incorrectly called with blank string'",
")",
"return",
"elif",
"node",
"!=",
"settings",
".",
"CLUSTER_HOST_ID",
":",
"logger",... | [
411,
0
] | [
426,
34
] | python | en | ['en', 'error', 'th'] | False |
awx_receptor_workunit_reaper | () |
When an AWX job is launched via receptor, files such as status, stdin, and stdout are created
in a specific receptor directory. This directory on disk is a random 8 character string, e.g. qLL2JFNT
This is also called the work Unit ID in receptor, and is used in various receptor commands,
e.g. "work res... |
When an AWX job is launched via receptor, files such as status, stdin, and stdout are created
in a specific receptor directory. This directory on disk is a random 8 character string, e.g. qLL2JFNT
This is also called the work Unit ID in receptor, and is used in various receptor commands,
e.g. "work res... | def awx_receptor_workunit_reaper():
"""
When an AWX job is launched via receptor, files such as status, stdin, and stdout are created
in a specific receptor directory. This directory on disk is a random 8 character string, e.g. qLL2JFNT
This is also called the work Unit ID in receptor, and is used in va... | [
"def",
"awx_receptor_workunit_reaper",
"(",
")",
":",
"if",
"not",
"settings",
".",
"RECEPTOR_RELEASE_WORK",
":",
"return",
"logger",
".",
"debug",
"(",
"\"Checking for unreleased receptor work units\"",
")",
"receptor_ctl",
"=",
"get_receptor_ctl",
"(",
")",
"receptor_... | [
599,
0
] | [
622,
71
] | python | en | ['en', 'error', 'th'] | False |
update_inventory_computed_fields | (inventory_id) |
Signal handler and wrapper around inventory.update_computed_fields to
prevent unnecessary recursive calls.
|
Signal handler and wrapper around inventory.update_computed_fields to
prevent unnecessary recursive calls.
| def update_inventory_computed_fields(inventory_id):
"""
Signal handler and wrapper around inventory.update_computed_fields to
prevent unnecessary recursive calls.
"""
i = Inventory.objects.filter(id=inventory_id)
if not i.exists():
logger.error("Update Inventory Computed Fields failed du... | [
"def",
"update_inventory_computed_fields",
"(",
"inventory_id",
")",
":",
"i",
"=",
"Inventory",
".",
"objects",
".",
"filter",
"(",
"id",
"=",
"inventory_id",
")",
"if",
"not",
"i",
".",
"exists",
"(",
")",
":",
"logger",
".",
"error",
"(",
"\"Update Inve... | [
779,
0
] | [
795,
13
] | python | en | ['en', 'error', 'th'] | False |
build_private_data | (self, project_update, private_data_dir) |
Return SSH private key data needed for this project update.
Returns a dict of the form
{
'credentials': {
<awx.main.models.Credential>: <credential_decrypted_ssh_key_data>,
<awx.main.models.Credential>: <credential_decrypted_ssh_key_data>,
... |
Return SSH private key data needed for this project update. | def build_private_data(self, project_update, private_data_dir):
"""
Return SSH private key data needed for this project update.
Returns a dict of the form
{
'credentials': {
<awx.main.models.Credential>: <credential_decrypted_ssh_key_data>,
<a... | [
"def",
"build_private_data",
"(",
"self",
",",
"project_update",
",",
"private_data_dir",
")",
":",
"private_data",
"=",
"{",
"'credentials'",
":",
"{",
"}",
"}",
"if",
"project_update",
".",
"credential",
":",
"credential",
"=",
"project_update",
".",
"credenti... | [
1999,
4
] | [
2017,
27
] | python | en | ['en', 'error', 'th'] | False |
build_passwords | (self, project_update, runtime_passwords) |
Build a dictionary of passwords for SSH private key unlock and SCM
username/password.
|
Build a dictionary of passwords for SSH private key unlock and SCM
username/password.
| def build_passwords(self, project_update, runtime_passwords):
"""
Build a dictionary of passwords for SSH private key unlock and SCM
username/password.
"""
passwords = super(RunProjectUpdate, self).build_passwords(project_update, runtime_passwords)
if project_update.crede... | [
"def",
"build_passwords",
"(",
"self",
",",
"project_update",
",",
"runtime_passwords",
")",
":",
"passwords",
"=",
"super",
"(",
"RunProjectUpdate",
",",
"self",
")",
".",
"build_passwords",
"(",
"project_update",
",",
"runtime_passwords",
")",
"if",
"project_upd... | [
2019,
4
] | [
2029,
24
] | python | en | ['en', 'error', 'th'] | False |
build_env | (self, project_update, private_data_dir, private_data_files=None) |
Build environment dictionary for ansible-playbook.
|
Build environment dictionary for ansible-playbook.
| def build_env(self, project_update, private_data_dir, private_data_files=None):
"""
Build environment dictionary for ansible-playbook.
"""
env = super(RunProjectUpdate, self).build_env(project_update, private_data_dir, private_data_files=private_data_files)
env['ANSIBLE_RETRY_FIL... | [
"def",
"build_env",
"(",
"self",
",",
"project_update",
",",
"private_data_dir",
",",
"private_data_files",
"=",
"None",
")",
":",
"env",
"=",
"super",
"(",
"RunProjectUpdate",
",",
"self",
")",
".",
"build_env",
"(",
"project_update",
",",
"private_data_dir",
... | [
2031,
4
] | [
2063,
18
] | python | en | ['en', 'error', 'th'] | False |
_build_scm_url_extra_vars | (self, project_update) |
Helper method to build SCM url and extra vars with parameters needed
for authentication.
|
Helper method to build SCM url and extra vars with parameters needed
for authentication.
| def _build_scm_url_extra_vars(self, project_update):
"""
Helper method to build SCM url and extra vars with parameters needed
for authentication.
"""
extra_vars = {}
if project_update.credential:
scm_username = project_update.credential.get_input('username', d... | [
"def",
"_build_scm_url_extra_vars",
"(",
"self",
",",
"project_update",
")",
":",
"extra_vars",
"=",
"{",
"}",
"if",
"project_update",
".",
"credential",
":",
"scm_username",
"=",
"project_update",
".",
"credential",
".",
"get_input",
"(",
"'username'",
",",
"de... | [
2065,
4
] | [
2103,
34
] | python | en | ['en', 'error', 'th'] | False |
build_args | (self, project_update, private_data_dir, passwords) |
Build command line argument list for running ansible-playbook,
optionally using ssh-agent for public/private key authentication.
|
Build command line argument list for running ansible-playbook,
optionally using ssh-agent for public/private key authentication.
| def build_args(self, project_update, private_data_dir, passwords):
"""
Build command line argument list for running ansible-playbook,
optionally using ssh-agent for public/private key authentication.
"""
args = []
if getattr(settings, 'PROJECT_UPDATE_VVV', False):
... | [
"def",
"build_args",
"(",
"self",
",",
"project_update",
",",
"private_data_dir",
",",
"passwords",
")",
":",
"args",
"=",
"[",
"]",
"if",
"getattr",
"(",
"settings",
",",
"'PROJECT_UPDATE_VVV'",
",",
"False",
")",
":",
"args",
".",
"append",
"(",
"'-vvv'"... | [
2108,
4
] | [
2118,
19
] | python | en | ['en', 'error', 'th'] | False |
BaseTask.update_model | (self, pk, _attempt=0, **updates) | Reload the model instance from the database and update the
given fields.
| Reload the model instance from the database and update the
given fields.
| def update_model(self, pk, _attempt=0, **updates):
"""Reload the model instance from the database and update the
given fields.
"""
try:
with transaction.atomic():
# Retrieve the model instance.
instance = self.model.objects.get(pk=pk)
... | [
"def",
"update_model",
"(",
"self",
",",
"pk",
",",
"_attempt",
"=",
"0",
",",
"*",
"*",
"updates",
")",
":",
"try",
":",
"with",
"transaction",
".",
"atomic",
"(",
")",
":",
"# Retrieve the model instance.",
"instance",
"=",
"self",
".",
"model",
".",
... | [
895,
4
] | [
925,
109
] | python | en | ['en', 'en', 'en'] | True |
BaseTask.get_path_to | (self, *args) |
Return absolute path relative to this file.
|
Return absolute path relative to this file.
| def get_path_to(self, *args):
"""
Return absolute path relative to this file.
"""
return os.path.abspath(os.path.join(os.path.dirname(__file__), *args)) | [
"def",
"get_path_to",
"(",
"self",
",",
"*",
"args",
")",
":",
"return",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"*",
"args",
")",
")"
] | [
927,
4
] | [
931,
78
] | python | en | ['en', 'error', 'th'] | False |
BaseTask.build_private_data | (self, instance, private_data_dir) |
Return SSH private key data (only if stored in DB as ssh_key_data).
Return structure is a dict of the form:
|
Return SSH private key data (only if stored in DB as ssh_key_data).
Return structure is a dict of the form:
| def build_private_data(self, instance, private_data_dir):
"""
Return SSH private key data (only if stored in DB as ssh_key_data).
Return structure is a dict of the form:
""" | [
"def",
"build_private_data",
"(",
"self",
",",
"instance",
",",
"private_data_dir",
")",
":"
] | [
973,
4
] | [
977,
11
] | python | en | ['en', 'error', 'th'] | False |
BaseTask.build_private_data_dir | (self, instance) |
Create a temporary directory for job-related files.
|
Create a temporary directory for job-related files.
| def build_private_data_dir(self, instance):
"""
Create a temporary directory for job-related files.
"""
pdd_wrapper_path = tempfile.mkdtemp(prefix=f'pdd_wrapper_{instance.pk}_', dir=settings.AWX_ISOLATION_BASE_PATH)
os.chmod(pdd_wrapper_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_... | [
"def",
"build_private_data_dir",
"(",
"self",
",",
"instance",
")",
":",
"pdd_wrapper_path",
"=",
"tempfile",
".",
"mkdtemp",
"(",
"prefix",
"=",
"f'pdd_wrapper_{instance.pk}_'",
",",
"dir",
"=",
"settings",
".",
"AWX_ISOLATION_BASE_PATH",
")",
"os",
".",
"chmod",... | [
979,
4
] | [
996,
19
] | python | en | ['en', 'error', 'th'] | False |
BaseTask.build_private_data_files | (self, instance, private_data_dir) |
Creates temporary files containing the private data.
Returns a dictionary i.e.,
{
'credentials': {
<awx.main.models.Credential>: '/path/to/decrypted/data',
<awx.main.models.Credential>: '/path/to/decrypted/data',
...
},
... |
Creates temporary files containing the private data.
Returns a dictionary i.e., | def build_private_data_files(self, instance, private_data_dir):
"""
Creates temporary files containing the private data.
Returns a dictionary i.e.,
{
'credentials': {
<awx.main.models.Credential>: '/path/to/decrypted/data',
<awx.main.models.Cr... | [
"def",
"build_private_data_files",
"(",
"self",
",",
"instance",
",",
"private_data_dir",
")",
":",
"private_data",
"=",
"self",
".",
"build_private_data",
"(",
"instance",
",",
"private_data_dir",
")",
"private_data_files",
"=",
"{",
"'credentials'",
":",
"{",
"}... | [
998,
4
] | [
1054,
33
] | python | en | ['en', 'error', 'th'] | False |
BaseTask.build_passwords | (self, instance, runtime_passwords) |
Build a dictionary of passwords for responding to prompts.
|
Build a dictionary of passwords for responding to prompts.
| def build_passwords(self, instance, runtime_passwords):
"""
Build a dictionary of passwords for responding to prompts.
"""
return {
'yes': 'yes',
'no': 'no',
'': '',
} | [
"def",
"build_passwords",
"(",
"self",
",",
"instance",
",",
"runtime_passwords",
")",
":",
"return",
"{",
"'yes'",
":",
"'yes'",
",",
"'no'",
":",
"'no'",
",",
"''",
":",
"''",
",",
"}"
] | [
1056,
4
] | [
1064,
9
] | python | en | ['en', 'error', 'th'] | False |
BaseTask.build_extra_vars_file | (self, instance, private_data_dir) |
Build ansible yaml file filled with extra vars to be passed via -e@file.yml
|
Build ansible yaml file filled with extra vars to be passed via -e | def build_extra_vars_file(self, instance, private_data_dir):
"""
Build ansible yaml file filled with extra vars to be passed via -e@file.yml
""" | [
"def",
"build_extra_vars_file",
"(",
"self",
",",
"instance",
",",
"private_data_dir",
")",
":"
] | [
1066,
4
] | [
1069,
11
] | python | en | ['en', 'error', 'th'] | False |
BaseTask.build_env | (self, instance, private_data_dir, private_data_files=None) |
Build environment dictionary for ansible-playbook.
|
Build environment dictionary for ansible-playbook.
| def build_env(self, instance, private_data_dir, private_data_files=None):
"""
Build environment dictionary for ansible-playbook.
"""
env = {}
# Add ANSIBLE_* settings to the subprocess environment.
for attr in dir(settings):
if attr == attr.upper() and attr.st... | [
"def",
"build_env",
"(",
"self",
",",
"instance",
",",
"private_data_dir",
",",
"private_data_files",
"=",
"None",
")",
":",
"env",
"=",
"{",
"}",
"# Add ANSIBLE_* settings to the subprocess environment.",
"for",
"attr",
"in",
"dir",
"(",
"settings",
")",
":",
"... | [
1097,
4
] | [
1139,
18
] | python | en | ['en', 'error', 'th'] | False |
BaseTask.get_password_prompts | (self, passwords={}) |
Return a dictionary where keys are strings or regular expressions for
prompts, and values are password lookup keys (keys that are returned
from build_passwords).
|
Return a dictionary where keys are strings or regular expressions for
prompts, and values are password lookup keys (keys that are returned
from build_passwords).
| def get_password_prompts(self, passwords={}):
"""
Return a dictionary where keys are strings or regular expressions for
prompts, and values are password lookup keys (keys that are returned
from build_passwords).
"""
return OrderedDict() | [
"def",
"get_password_prompts",
"(",
"self",
",",
"passwords",
"=",
"{",
"}",
")",
":",
"return",
"OrderedDict",
"(",
")"
] | [
1191,
4
] | [
1197,
28
] | python | en | ['en', 'error', 'th'] | False |
BaseTask.pre_run_hook | (self, instance, private_data_dir) |
Hook for any steps to run before the job/task starts
|
Hook for any steps to run before the job/task starts
| def pre_run_hook(self, instance, private_data_dir):
"""
Hook for any steps to run before the job/task starts
"""
instance.log_lifecycle("pre_run") | [
"def",
"pre_run_hook",
"(",
"self",
",",
"instance",
",",
"private_data_dir",
")",
":",
"instance",
".",
"log_lifecycle",
"(",
"\"pre_run\"",
")"
] | [
1205,
4
] | [
1209,
41
] | python | en | ['en', 'error', 'th'] | False |
BaseTask.post_run_hook | (self, instance, status) |
Hook for any steps to run before job/task is marked as complete.
|
Hook for any steps to run before job/task is marked as complete.
| def post_run_hook(self, instance, status):
"""
Hook for any steps to run before job/task is marked as complete.
"""
instance.log_lifecycle("post_run") | [
"def",
"post_run_hook",
"(",
"self",
",",
"instance",
",",
"status",
")",
":",
"instance",
".",
"log_lifecycle",
"(",
"\"post_run\"",
")"
] | [
1211,
4
] | [
1215,
42
] | python | en | ['en', 'error', 'th'] | False |
BaseTask.final_run_hook | (self, instance, status, private_data_dir, fact_modification_times) |
Hook for any steps to run after job/task is marked as complete.
|
Hook for any steps to run after job/task is marked as complete.
| def final_run_hook(self, instance, status, private_data_dir, fact_modification_times):
"""
Hook for any steps to run after job/task is marked as complete.
"""
instance.log_lifecycle("finalize_run")
job_profiling_dir = os.path.join(private_data_dir, 'artifacts/playbook_profiling')... | [
"def",
"final_run_hook",
"(",
"self",
",",
"instance",
",",
"status",
",",
"private_data_dir",
",",
"fact_modification_times",
")",
":",
"instance",
".",
"log_lifecycle",
"(",
"\"finalize_run\"",
")",
"job_profiling_dir",
"=",
"os",
".",
"path",
".",
"join",
"("... | [
1217,
4
] | [
1240,
64
] | python | en | ['en', 'error', 'th'] | False |
BaseTask.event_handler | (self, event_data) |
Ansible runner puts a parent_uuid on each event, no matter what the type.
AWX only saves the parent_uuid if the event is for a Job.
|
Ansible runner puts a parent_uuid on each event, no matter what the type.
AWX only saves the parent_uuid if the event is for a Job.
| def event_handler(self, event_data):
#
# ⚠️ D-D-D-DANGER ZONE ⚠️
# This method is called once for *every event* emitted by Ansible
# Runner as a playbook runs. That means that changes to the code in
# this method are _very_ likely to introduce performance regressions.
#... | [
"def",
"event_handler",
"(",
"self",
",",
"event_data",
")",
":",
"#",
"# ⚠️ D-D-D-DANGER ZONE ⚠️",
"# This method is called once for *every event* emitted by Ansible",
"# Runner as a playbook runs. That means that changes to the code in",
"# this method are _very_ likely to introduce perf... | [
1242,
4
] | [
1347,
20
] | python | en | ['en', 'error', 'th'] | False |
BaseTask.cancel_callback | (self) |
Ansible runner callback to tell the job when/if it is canceled
|
Ansible runner callback to tell the job when/if it is canceled
| def cancel_callback(self):
"""
Ansible runner callback to tell the job when/if it is canceled
"""
unified_job_id = self.instance.pk
self.instance = self.update_model(unified_job_id)
if not self.instance:
logger.error('unified job {} was deleted while running, ... | [
"def",
"cancel_callback",
"(",
"self",
")",
":",
"unified_job_id",
"=",
"self",
".",
"instance",
".",
"pk",
"self",
".",
"instance",
"=",
"self",
".",
"update_model",
"(",
"unified_job_id",
")",
"if",
"not",
"self",
".",
"instance",
":",
"logger",
".",
"... | [
1349,
4
] | [
1363,
20
] | python | en | ['en', 'error', 'th'] | False |
BaseTask.finished_callback | (self, runner_obj) |
Ansible runner callback triggered on finished run
|
Ansible runner callback triggered on finished run
| def finished_callback(self, runner_obj):
"""
Ansible runner callback triggered on finished run
"""
event_data = {
'event': 'EOF',
'final_counter': self.event_ct,
'guid': self.guid,
}
event_data.setdefault(self.event_data_key, self.insta... | [
"def",
"finished_callback",
"(",
"self",
",",
"runner_obj",
")",
":",
"event_data",
"=",
"{",
"'event'",
":",
"'EOF'",
",",
"'final_counter'",
":",
"self",
".",
"event_ct",
",",
"'guid'",
":",
"self",
".",
"guid",
",",
"}",
"event_data",
".",
"setdefault",... | [
1365,
4
] | [
1375,
44
] | python | en | ['en', 'error', 'th'] | False |
BaseTask.status_handler | (self, status_data, runner_config) |
Ansible runner callback triggered on status transition
|
Ansible runner callback triggered on status transition
| def status_handler(self, status_data, runner_config):
"""
Ansible runner callback triggered on status transition
"""
if status_data['status'] == 'starting':
job_env = dict(runner_config.env)
'''
Take the safe environment variables and overwrite
... | [
"def",
"status_handler",
"(",
"self",
",",
"status_data",
",",
"runner_config",
")",
":",
"if",
"status_data",
"[",
"'status'",
"]",
"==",
"'starting'",
":",
"job_env",
"=",
"dict",
"(",
"runner_config",
".",
"env",
")",
"'''\n Take the safe environment... | [
1377,
4
] | [
1399,
106
] | python | en | ['en', 'error', 'th'] | False |
BaseTask.run | (self, pk, **kwargs) |
Run the job/task and capture its output.
|
Run the job/task and capture its output.
| def run(self, pk, **kwargs):
"""
Run the job/task and capture its output.
"""
self.instance = self.model.objects.get(pk=pk)
if self.instance.execution_environment_id is None:
from awx.main.signals import disable_activity_stream
with disable_activity_stre... | [
"def",
"run",
"(",
"self",
",",
"pk",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"instance",
"=",
"self",
".",
"model",
".",
"objects",
".",
"get",
"(",
"pk",
"=",
"pk",
")",
"if",
"self",
".",
"instance",
".",
"execution_environment_id",
"is"... | [
1402,
4
] | [
1576,
63
] | python | en | ['en', 'error', 'th'] | False |
content_state_equal | (v1, v2, match_keys=False) | Test whether two contentState structures are equal, ignoring 'key' properties if match_keys=False | Test whether two contentState structures are equal, ignoring 'key' properties if match_keys=False | def content_state_equal(v1, v2, match_keys=False):
"Test whether two contentState structures are equal, ignoring 'key' properties if match_keys=False"
if type(v1) != type(v2):
return False
if isinstance(v1, dict):
if set(v1.keys()) != set(v2.keys()):
return False
return ... | [
"def",
"content_state_equal",
"(",
"v1",
",",
"v2",
",",
"match_keys",
"=",
"False",
")",
":",
"if",
"type",
"(",
"v1",
")",
"!=",
"type",
"(",
"v2",
")",
":",
"return",
"False",
"if",
"isinstance",
"(",
"v1",
",",
"dict",
")",
":",
"if",
"set",
... | [
13,
0
] | [
32,
23
] | python | en | ['en', 'en', 'en'] | True |
TestHtmlToContentState.assertContentStateEqual | (self, v1, v2, match_keys=False) | Assert that two contentState structures are equal, ignoring 'key' properties if match_keys is False | Assert that two contentState structures are equal, ignoring 'key' properties if match_keys is False | def assertContentStateEqual(self, v1, v2, match_keys=False):
"Assert that two contentState structures are equal, ignoring 'key' properties if match_keys is False"
self.assertTrue(
content_state_equal(v1, v2, match_keys=match_keys),
"%s does not match %s" % (json.dumps(v1, indent=... | [
"def",
"assertContentStateEqual",
"(",
"self",
",",
"v1",
",",
"v2",
",",
"match_keys",
"=",
"False",
")",
":",
"self",
".",
"assertTrue",
"(",
"content_state_equal",
"(",
"v1",
",",
"v2",
",",
"match_keys",
"=",
"match_keys",
")",
",",
"\"%s does not match ... | [
38,
4
] | [
43,
9
] | python | en | ['en', 'en', 'en'] | True |
TestHtmlToContentState.test_image_after_list | (self) |
There should be no spacer paragraph inserted between a list and an image
|
There should be no spacer paragraph inserted between a list and an image
| def test_image_after_list(self):
"""
There should be no spacer paragraph inserted between a list and an image
"""
converter = ContentstateConverter(features=['ul', 'image'])
result = json.loads(converter.from_database_format(
'''
<ul>
<li>M... | [
"def",
"test_image_after_list",
"(",
"self",
")",
":",
"converter",
"=",
"ContentstateConverter",
"(",
"features",
"=",
"[",
"'ul'",
",",
"'image'",
"]",
")",
"result",
"=",
"json",
".",
"loads",
"(",
"converter",
".",
"from_database_format",
"(",
"'''\n ... | [
487,
4
] | [
519,
10
] | python | en | ['en', 'error', 'th'] | False |
TestSimplestCases.test_steady_source | (self) |
Sanity check: Ensure we get no newsource table entries for a steady
source.
|
Sanity check: Ensure we get no newsource table entries for a steady
source.
| def test_steady_source(self):
"""
Sanity check: Ensure we get no newsource table entries for a steady
source.
"""
im_params = self.im_params
steady_src = db_subs.MockSource(
template_extractedsource=db_subs.example_extractedsource_tuple(
ra=i... | [
"def",
"test_steady_source",
"(",
"self",
")",
":",
"im_params",
"=",
"self",
".",
"im_params",
"steady_src",
"=",
"db_subs",
".",
"MockSource",
"(",
"template_extractedsource",
"=",
"db_subs",
".",
"example_extractedsource_tuple",
"(",
"ra",
"=",
"im_params",
"["... | [
68,
4
] | [
97,
48
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.