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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
_BaseNetwork.is_global | (self) | Test if this address is allocated for public networks.
Returns:
A boolean, True if the address is not reserved per
iana-ipv4-special-registry or iana-ipv6-special-registry.
| Test if this address is allocated for public networks. | def is_global(self):
"""Test if this address is allocated for public networks.
Returns:
A boolean, True if the address is not reserved per
iana-ipv4-special-registry or iana-ipv6-special-registry.
"""
return not self.is_private | [
"def",
"is_global",
"(",
"self",
")",
":",
"return",
"not",
"self",
".",
"is_private"
] | [
1157,
4
] | [
1165,
34
] | python | en | ['en', 'en', 'en'] | True |
_BaseNetwork.is_unspecified | (self) | Test if the address is unspecified.
Returns:
A boolean, True if this is the unspecified address as defined in
RFC 2373 2.5.2.
| Test if the address is unspecified. | def is_unspecified(self):
"""Test if the address is unspecified.
Returns:
A boolean, True if this is the unspecified address as defined in
RFC 2373 2.5.2.
"""
return (self.network_address.is_unspecified and
self.broadcast_address.is_unspecified) | [
"def",
"is_unspecified",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"network_address",
".",
"is_unspecified",
"and",
"self",
".",
"broadcast_address",
".",
"is_unspecified",
")"
] | [
1168,
4
] | [
1177,
54
] | python | en | ['en', 'en', 'en'] | True |
_BaseNetwork.is_loopback | (self) | Test if the address is a loopback address.
Returns:
A boolean, True if the address is a loopback address as defined in
RFC 2373 2.5.3.
| Test if the address is a loopback address. | def is_loopback(self):
"""Test if the address is a loopback address.
Returns:
A boolean, True if the address is a loopback address as defined in
RFC 2373 2.5.3.
"""
return (self.network_address.is_loopback and
self.broadcast_address.is_loopback) | [
"def",
"is_loopback",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"network_address",
".",
"is_loopback",
"and",
"self",
".",
"broadcast_address",
".",
"is_loopback",
")"
] | [
1180,
4
] | [
1189,
51
] | python | en | ['en', 'en', 'en'] | True |
_BaseV4._make_netmask | (cls, arg) | Make a (netmask, prefix_len) tuple from the given argument.
Argument can be:
- an integer (the prefix length)
- a string representing the prefix length (e.g. "24")
- a string representing the prefix netmask (e.g. "255.255.255.0")
| Make a (netmask, prefix_len) tuple from the given argument. | def _make_netmask(cls, arg):
"""Make a (netmask, prefix_len) tuple from the given argument.
Argument can be:
- an integer (the prefix length)
- a string representing the prefix length (e.g. "24")
- a string representing the prefix netmask (e.g. "255.255.255.0")
"""
... | [
"def",
"_make_netmask",
"(",
"cls",
",",
"arg",
")",
":",
"if",
"arg",
"not",
"in",
"cls",
".",
"_netmask_cache",
":",
"if",
"isinstance",
"(",
"arg",
",",
"_compat_int_types",
")",
":",
"prefixlen",
"=",
"arg",
"else",
":",
"try",
":",
"# Check for a ne... | [
1219,
4
] | [
1240,
38
] | python | en | ['en', 'en', 'en'] | True |
_BaseV4._ip_int_from_string | (cls, ip_str) | Turn the given IP string into an integer for comparison.
Args:
ip_str: A string, the IP ip_str.
Returns:
The IP ip_str as an integer.
Raises:
AddressValueError: if ip_str isn't a valid IPv4 Address.
| Turn the given IP string into an integer for comparison. | def _ip_int_from_string(cls, ip_str):
"""Turn the given IP string into an integer for comparison.
Args:
ip_str: A string, the IP ip_str.
Returns:
The IP ip_str as an integer.
Raises:
AddressValueError: if ip_str isn't a valid IPv4 Address.
... | [
"def",
"_ip_int_from_string",
"(",
"cls",
",",
"ip_str",
")",
":",
"if",
"not",
"ip_str",
":",
"raise",
"AddressValueError",
"(",
"'Address cannot be empty'",
")",
"octets",
"=",
"ip_str",
".",
"split",
"(",
"'.'",
")",
"if",
"len",
"(",
"octets",
")",
"!=... | [
1243,
4
] | [
1267,
63
] | python | en | ['en', 'en', 'en'] | True |
_BaseV4._parse_octet | (cls, octet_str) | Convert a decimal octet into an integer.
Args:
octet_str: A string, the number to parse.
Returns:
The octet as an integer.
Raises:
ValueError: if the octet isn't strictly a decimal from [0..255].
| Convert a decimal octet into an integer. | def _parse_octet(cls, octet_str):
"""Convert a decimal octet into an integer.
Args:
octet_str: A string, the number to parse.
Returns:
The octet as an integer.
Raises:
ValueError: if the octet isn't strictly a decimal from [0..255].
"""
... | [
"def",
"_parse_octet",
"(",
"cls",
",",
"octet_str",
")",
":",
"if",
"not",
"octet_str",
":",
"raise",
"ValueError",
"(",
"\"Empty octet not permitted\"",
")",
"# Whitelist the characters, since int() allows a lot of bizarre stuff.",
"if",
"not",
"cls",
".",
"_DECIMAL_DIG... | [
1270,
4
] | [
1304,
24
] | python | br | ['br', 'lb', 'it'] | False |
_BaseV4._string_from_ip_int | (cls, ip_int) | Turns a 32-bit integer into dotted decimal notation.
Args:
ip_int: An integer, the IP address.
Returns:
The IP address as a string in dotted decimal notation.
| Turns a 32-bit integer into dotted decimal notation. | def _string_from_ip_int(cls, ip_int):
"""Turns a 32-bit integer into dotted decimal notation.
Args:
ip_int: An integer, the IP address.
Returns:
The IP address as a string in dotted decimal notation.
"""
return '.'.join(_compat_str(struct.unpack(b'!B', ... | [
"def",
"_string_from_ip_int",
"(",
"cls",
",",
"ip_int",
")",
":",
"return",
"'.'",
".",
"join",
"(",
"_compat_str",
"(",
"struct",
".",
"unpack",
"(",
"b'!B'",
",",
"b",
")",
"[",
"0",
"]",
"if",
"isinstance",
"(",
"b",
",",
"bytes",
")",
"else",
... | [
1307,
4
] | [
1320,
68
] | python | en | ['pt', 'en', 'en'] | True |
_BaseV4._is_hostmask | (self, ip_str) | Test if the IP string is a hostmask (rather than a netmask).
Args:
ip_str: A string, the potential hostmask.
Returns:
A boolean, True if the IP string is a hostmask.
| Test if the IP string is a hostmask (rather than a netmask). | def _is_hostmask(self, ip_str):
"""Test if the IP string is a hostmask (rather than a netmask).
Args:
ip_str: A string, the potential hostmask.
Returns:
A boolean, True if the IP string is a hostmask.
"""
bits = ip_str.split('.')
try:
... | [
"def",
"_is_hostmask",
"(",
"self",
",",
"ip_str",
")",
":",
"bits",
"=",
"ip_str",
".",
"split",
"(",
"'.'",
")",
"try",
":",
"parts",
"=",
"[",
"x",
"for",
"x",
"in",
"map",
"(",
"int",
",",
"bits",
")",
"if",
"x",
"in",
"self",
".",
"_valid_... | [
1322,
4
] | [
1341,
20
] | python | en | ['en', 'en', 'en'] | True |
_BaseV4._reverse_pointer | (self) | Return the reverse DNS pointer name for the IPv4 address.
This implements the method described in RFC1035 3.5.
| Return the reverse DNS pointer name for the IPv4 address. | def _reverse_pointer(self):
"""Return the reverse DNS pointer name for the IPv4 address.
This implements the method described in RFC1035 3.5.
"""
reverse_octets = _compat_str(self).split('.')[::-1]
return '.'.join(reverse_octets) + '.in-addr.arpa' | [
"def",
"_reverse_pointer",
"(",
"self",
")",
":",
"reverse_octets",
"=",
"_compat_str",
"(",
"self",
")",
".",
"split",
"(",
"'.'",
")",
"[",
":",
":",
"-",
"1",
"]",
"return",
"'.'",
".",
"join",
"(",
"reverse_octets",
")",
"+",
"'.in-addr.arpa'"
] | [
1343,
4
] | [
1350,
57
] | python | en | ['en', 'no', 'en'] | True |
IPv4Address.__init__ | (self, address) |
Args:
address: A string or integer representing the IP
Additionally, an integer can be passed, so
IPv4Address('192.0.2.1') == IPv4Address(3221225985).
or, more generally
IPv4Address(int(IPv4Address('192.0.2.1'))) ==
IPv4Addres... |
Args:
address: A string or integer representing the IP | def __init__(self, address):
"""
Args:
address: A string or integer representing the IP
Additionally, an integer can be passed, so
IPv4Address('192.0.2.1') == IPv4Address(3221225985).
or, more generally
IPv4Address(int(IPv4Address('19... | [
"def",
"__init__",
"(",
"self",
",",
"address",
")",
":",
"# Efficient constructor from integer.",
"if",
"isinstance",
"(",
"address",
",",
"_compat_int_types",
")",
":",
"self",
".",
"_check_int_address",
"(",
"address",
")",
"self",
".",
"_ip",
"=",
"address",... | [
1367,
4
] | [
1401,
53
] | python | en | ['en', 'error', 'th'] | False |
IPv4Address.packed | (self) | The binary representation of this address. | The binary representation of this address. | def packed(self):
"""The binary representation of this address."""
return v4_int_to_packed(self._ip) | [
"def",
"packed",
"(",
"self",
")",
":",
"return",
"v4_int_to_packed",
"(",
"self",
".",
"_ip",
")"
] | [
1404,
4
] | [
1406,
41
] | python | en | ['en', 'en', 'en'] | True |
IPv4Address.is_reserved | (self) | Test if the address is otherwise IETF reserved.
Returns:
A boolean, True if the address is within the
reserved IPv4 Network range.
| Test if the address is otherwise IETF reserved. | def is_reserved(self):
"""Test if the address is otherwise IETF reserved.
Returns:
A boolean, True if the address is within the
reserved IPv4 Network range.
"""
return self in self._constants._reserved_network | [
"def",
"is_reserved",
"(",
"self",
")",
":",
"return",
"self",
"in",
"self",
".",
"_constants",
".",
"_reserved_network"
] | [
1409,
4
] | [
1417,
56
] | python | en | ['en', 'en', 'en'] | True |
IPv4Address.is_private | (self) | Test if this address is allocated for private networks.
Returns:
A boolean, True if the address is reserved per
iana-ipv4-special-registry.
| Test if this address is allocated for private networks. | def is_private(self):
"""Test if this address is allocated for private networks.
Returns:
A boolean, True if the address is reserved per
iana-ipv4-special-registry.
"""
return any(self in net for net in self._constants._private_networks) | [
"def",
"is_private",
"(",
"self",
")",
":",
"return",
"any",
"(",
"self",
"in",
"net",
"for",
"net",
"in",
"self",
".",
"_constants",
".",
"_private_networks",
")"
] | [
1420,
4
] | [
1428,
76
] | python | en | ['en', 'en', 'en'] | True |
IPv4Address.is_multicast | (self) | Test if the address is reserved for multicast use.
Returns:
A boolean, True if the address is multicast.
See RFC 3171 for details.
| Test if the address is reserved for multicast use. | def is_multicast(self):
"""Test if the address is reserved for multicast use.
Returns:
A boolean, True if the address is multicast.
See RFC 3171 for details.
"""
return self in self._constants._multicast_network | [
"def",
"is_multicast",
"(",
"self",
")",
":",
"return",
"self",
"in",
"self",
".",
"_constants",
".",
"_multicast_network"
] | [
1437,
4
] | [
1445,
57
] | python | en | ['en', 'en', 'en'] | True |
IPv4Address.is_unspecified | (self) | Test if the address is unspecified.
Returns:
A boolean, True if this is the unspecified address as defined in
RFC 5735 3.
| Test if the address is unspecified. | def is_unspecified(self):
"""Test if the address is unspecified.
Returns:
A boolean, True if this is the unspecified address as defined in
RFC 5735 3.
"""
return self == self._constants._unspecified_address | [
"def",
"is_unspecified",
"(",
"self",
")",
":",
"return",
"self",
"==",
"self",
".",
"_constants",
".",
"_unspecified_address"
] | [
1448,
4
] | [
1456,
59
] | python | en | ['en', 'en', 'en'] | True |
IPv4Address.is_loopback | (self) | Test if the address is a loopback address.
Returns:
A boolean, True if the address is a loopback per RFC 3330.
| Test if the address is a loopback address. | def is_loopback(self):
"""Test if the address is a loopback address.
Returns:
A boolean, True if the address is a loopback per RFC 3330.
"""
return self in self._constants._loopback_network | [
"def",
"is_loopback",
"(",
"self",
")",
":",
"return",
"self",
"in",
"self",
".",
"_constants",
".",
"_loopback_network"
] | [
1459,
4
] | [
1466,
56
] | python | en | ['en', 'en', 'en'] | True |
IPv4Address.is_link_local | (self) | Test if the address is reserved for link-local.
Returns:
A boolean, True if the address is link-local per RFC 3927.
| Test if the address is reserved for link-local. | def is_link_local(self):
"""Test if the address is reserved for link-local.
Returns:
A boolean, True if the address is link-local per RFC 3927.
"""
return self in self._constants._linklocal_network | [
"def",
"is_link_local",
"(",
"self",
")",
":",
"return",
"self",
"in",
"self",
".",
"_constants",
".",
"_linklocal_network"
] | [
1469,
4
] | [
1476,
57
] | python | en | ['en', 'en', 'en'] | True |
IPv4Network.__init__ | (self, address, strict=True) | Instantiate a new IPv4 network object.
Args:
address: A string or integer representing the IP [& network].
'192.0.2.0/24'
'192.0.2.0/255.255.255.0'
'192.0.0.2/0.0.0.255'
are all functionally the same in IPv4. Similarly,
'192.0.2.... | Instantiate a new IPv4 network object. | def __init__(self, address, strict=True):
"""Instantiate a new IPv4 network object.
Args:
address: A string or integer representing the IP [& network].
'192.0.2.0/24'
'192.0.2.0/255.255.255.0'
'192.0.0.2/0.0.0.255'
are all functionall... | [
"def",
"__init__",
"(",
"self",
",",
"address",
",",
"strict",
"=",
"True",
")",
":",
"_BaseNetwork",
".",
"__init__",
"(",
"self",
",",
"address",
")",
"# Constructing from a packed address or integer",
"if",
"isinstance",
"(",
"address",
",",
"(",
"_compat_int... | [
1577,
4
] | [
1660,
38
] | python | en | ['en', 'en', 'en'] | True |
IPv4Network.is_global | (self) | Test if this address is allocated for public networks.
Returns:
A boolean, True if the address is not reserved per
iana-ipv4-special-registry.
| Test if this address is allocated for public networks. | def is_global(self):
"""Test if this address is allocated for public networks.
Returns:
A boolean, True if the address is not reserved per
iana-ipv4-special-registry.
"""
return (not (self.network_address in IPv4Network('100.64.0.0/10') and
self.... | [
"def",
"is_global",
"(",
"self",
")",
":",
"return",
"(",
"not",
"(",
"self",
".",
"network_address",
"in",
"IPv4Network",
"(",
"'100.64.0.0/10'",
")",
"and",
"self",
".",
"broadcast_address",
"in",
"IPv4Network",
"(",
"'100.64.0.0/10'",
")",
")",
"and",
"no... | [
1663,
4
] | [
1673,
36
] | python | en | ['en', 'en', 'en'] | True |
_BaseV6._make_netmask | (cls, arg) | Make a (netmask, prefix_len) tuple from the given argument.
Argument can be:
- an integer (the prefix length)
- a string representing the prefix length (e.g. "24")
- a string representing the prefix netmask (e.g. "255.255.255.0")
| Make a (netmask, prefix_len) tuple from the given argument. | def _make_netmask(cls, arg):
"""Make a (netmask, prefix_len) tuple from the given argument.
Argument can be:
- an integer (the prefix length)
- a string representing the prefix length (e.g. "24")
- a string representing the prefix netmask (e.g. "255.255.255.0")
"""
... | [
"def",
"_make_netmask",
"(",
"cls",
",",
"arg",
")",
":",
"if",
"arg",
"not",
"in",
"cls",
".",
"_netmask_cache",
":",
"if",
"isinstance",
"(",
"arg",
",",
"_compat_int_types",
")",
":",
"prefixlen",
"=",
"arg",
"else",
":",
"prefixlen",
"=",
"cls",
".... | [
1732,
4
] | [
1747,
38
] | python | en | ['en', 'en', 'en'] | True |
_BaseV6._ip_int_from_string | (cls, ip_str) | Turn an IPv6 ip_str into an integer.
Args:
ip_str: A string, the IPv6 ip_str.
Returns:
An int, the IPv6 address
Raises:
AddressValueError: if ip_str isn't a valid IPv6 Address.
| Turn an IPv6 ip_str into an integer. | def _ip_int_from_string(cls, ip_str):
"""Turn an IPv6 ip_str into an integer.
Args:
ip_str: A string, the IPv6 ip_str.
Returns:
An int, the IPv6 address
Raises:
AddressValueError: if ip_str isn't a valid IPv6 Address.
"""
if not ip_... | [
"def",
"_ip_int_from_string",
"(",
"cls",
",",
"ip_str",
")",
":",
"if",
"not",
"ip_str",
":",
"raise",
"AddressValueError",
"(",
"'Address cannot be empty'",
")",
"parts",
"=",
"ip_str",
".",
"split",
"(",
"':'",
")",
"# An IPv6 address needs at least 2 colons (3 p... | [
1750,
4
] | [
1852,
63
] | python | en | ['en', 'lb', 'it'] | False |
_BaseV6._parse_hextet | (cls, hextet_str) | Convert an IPv6 hextet string into an integer.
Args:
hextet_str: A string, the number to parse.
Returns:
The hextet as an integer.
Raises:
ValueError: if the input isn't strictly a hex number from
[0..FFFF].
| Convert an IPv6 hextet string into an integer. | def _parse_hextet(cls, hextet_str):
"""Convert an IPv6 hextet string into an integer.
Args:
hextet_str: A string, the number to parse.
Returns:
The hextet as an integer.
Raises:
ValueError: if the input isn't strictly a hex number from
... | [
"def",
"_parse_hextet",
"(",
"cls",
",",
"hextet_str",
")",
":",
"# Whitelist the characters, since int() allows a lot of bizarre stuff.",
"if",
"not",
"cls",
".",
"_HEX_DIGITS",
".",
"issuperset",
"(",
"hextet_str",
")",
":",
"raise",
"ValueError",
"(",
"\"Only hex dig... | [
1855,
4
] | [
1878,
34
] | python | br | ['br', 'lb', 'en'] | False |
_BaseV6._compress_hextets | (cls, hextets) | Compresses a list of hextets.
Compresses a list of strings, replacing the longest continuous
sequence of "0" in the list with "" and adding empty strings at
the beginning or at the end of the string such that subsequently
calling ":".join(hextets) will produce the compressed version of
... | Compresses a list of hextets. | def _compress_hextets(cls, hextets):
"""Compresses a list of hextets.
Compresses a list of strings, replacing the longest continuous
sequence of "0" in the list with "" and adding empty strings at
the beginning or at the end of the string such that subsequently
calling ":".join(... | [
"def",
"_compress_hextets",
"(",
"cls",
",",
"hextets",
")",
":",
"best_doublecolon_start",
"=",
"-",
"1",
"best_doublecolon_len",
"=",
"0",
"doublecolon_start",
"=",
"-",
"1",
"doublecolon_len",
"=",
"0",
"for",
"index",
",",
"hextet",
"in",
"enumerate",
"(",... | [
1881,
4
] | [
1926,
22
] | python | en | ['en', 'ca', 'en'] | True |
_BaseV6._string_from_ip_int | (cls, ip_int=None) | Turns a 128-bit integer into hexadecimal notation.
Args:
ip_int: An integer, the IP address.
Returns:
A string, the hexadecimal representation of the address.
Raises:
ValueError: The address is bigger than 128 bits of all ones.
| Turns a 128-bit integer into hexadecimal notation. | def _string_from_ip_int(cls, ip_int=None):
"""Turns a 128-bit integer into hexadecimal notation.
Args:
ip_int: An integer, the IP address.
Returns:
A string, the hexadecimal representation of the address.
Raises:
ValueError: The address is bigger th... | [
"def",
"_string_from_ip_int",
"(",
"cls",
",",
"ip_int",
"=",
"None",
")",
":",
"if",
"ip_int",
"is",
"None",
":",
"ip_int",
"=",
"int",
"(",
"cls",
".",
"_ip",
")",
"if",
"ip_int",
">",
"cls",
".",
"_ALL_ONES",
":",
"raise",
"ValueError",
"(",
"'IPv... | [
1929,
4
] | [
1952,
32
] | python | en | ['en', 'lb', 'en'] | True |
_BaseV6._explode_shorthand_ip_string | (self) | Expand a shortened IPv6 address.
Args:
ip_str: A string, the IPv6 address.
Returns:
A string, the expanded IPv6 address.
| Expand a shortened IPv6 address. | def _explode_shorthand_ip_string(self):
"""Expand a shortened IPv6 address.
Args:
ip_str: A string, the IPv6 address.
Returns:
A string, the expanded IPv6 address.
"""
if isinstance(self, IPv6Network):
ip_str = _compat_str(self.network_addre... | [
"def",
"_explode_shorthand_ip_string",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"self",
",",
"IPv6Network",
")",
":",
"ip_str",
"=",
"_compat_str",
"(",
"self",
".",
"network_address",
")",
"elif",
"isinstance",
"(",
"self",
",",
"IPv6Interface",
")",
... | [
1954,
4
] | [
1976,
30
] | python | en | ['en', 'ny', 'en'] | True |
_BaseV6._reverse_pointer | (self) | Return the reverse DNS pointer name for the IPv6 address.
This implements the method described in RFC3596 2.5.
| Return the reverse DNS pointer name for the IPv6 address. | def _reverse_pointer(self):
"""Return the reverse DNS pointer name for the IPv6 address.
This implements the method described in RFC3596 2.5.
"""
reverse_chars = self.exploded[::-1].replace(':', '')
return '.'.join(reverse_chars) + '.ip6.arpa' | [
"def",
"_reverse_pointer",
"(",
"self",
")",
":",
"reverse_chars",
"=",
"self",
".",
"exploded",
"[",
":",
":",
"-",
"1",
"]",
".",
"replace",
"(",
"':'",
",",
"''",
")",
"return",
"'.'",
".",
"join",
"(",
"reverse_chars",
")",
"+",
"'.ip6.arpa'"
] | [
1978,
4
] | [
1985,
52
] | python | en | ['en', 'no', 'en'] | True |
IPv6Address.__init__ | (self, address) | Instantiate a new IPv6 address object.
Args:
address: A string or integer representing the IP
Additionally, an integer can be passed, so
IPv6Address('2001:db8::') ==
IPv6Address(42540766411282592856903984951653826560)
or, more generally
... | Instantiate a new IPv6 address object. | def __init__(self, address):
"""Instantiate a new IPv6 address object.
Args:
address: A string or integer representing the IP
Additionally, an integer can be passed, so
IPv6Address('2001:db8::') ==
IPv6Address(425407664112825928569039849516538265... | [
"def",
"__init__",
"(",
"self",
",",
"address",
")",
":",
"# Efficient constructor from integer.",
"if",
"isinstance",
"(",
"address",
",",
"_compat_int_types",
")",
":",
"self",
".",
"_check_int_address",
"(",
"address",
")",
"self",
".",
"_ip",
"=",
"address",... | [
2002,
4
] | [
2037,
53
] | python | en | ['en', 'fy', 'en'] | True |
IPv6Address.packed | (self) | The binary representation of this address. | The binary representation of this address. | def packed(self):
"""The binary representation of this address."""
return v6_int_to_packed(self._ip) | [
"def",
"packed",
"(",
"self",
")",
":",
"return",
"v6_int_to_packed",
"(",
"self",
".",
"_ip",
")"
] | [
2040,
4
] | [
2042,
41
] | python | en | ['en', 'en', 'en'] | True |
IPv6Address.is_multicast | (self) | Test if the address is reserved for multicast use.
Returns:
A boolean, True if the address is a multicast address.
See RFC 2373 2.7 for details.
| Test if the address is reserved for multicast use. | def is_multicast(self):
"""Test if the address is reserved for multicast use.
Returns:
A boolean, True if the address is a multicast address.
See RFC 2373 2.7 for details.
"""
return self in self._constants._multicast_network | [
"def",
"is_multicast",
"(",
"self",
")",
":",
"return",
"self",
"in",
"self",
".",
"_constants",
".",
"_multicast_network"
] | [
2045,
4
] | [
2053,
57
] | python | en | ['en', 'en', 'en'] | True |
IPv6Address.is_reserved | (self) | Test if the address is otherwise IETF reserved.
Returns:
A boolean, True if the address is within one of the
reserved IPv6 Network ranges.
| Test if the address is otherwise IETF reserved. | def is_reserved(self):
"""Test if the address is otherwise IETF reserved.
Returns:
A boolean, True if the address is within one of the
reserved IPv6 Network ranges.
"""
return any(self in x for x in self._constants._reserved_networks) | [
"def",
"is_reserved",
"(",
"self",
")",
":",
"return",
"any",
"(",
"self",
"in",
"x",
"for",
"x",
"in",
"self",
".",
"_constants",
".",
"_reserved_networks",
")"
] | [
2056,
4
] | [
2064,
73
] | python | en | ['en', 'en', 'en'] | True |
IPv6Address.is_link_local | (self) | Test if the address is reserved for link-local.
Returns:
A boolean, True if the address is reserved per RFC 4291.
| Test if the address is reserved for link-local. | def is_link_local(self):
"""Test if the address is reserved for link-local.
Returns:
A boolean, True if the address is reserved per RFC 4291.
"""
return self in self._constants._linklocal_network | [
"def",
"is_link_local",
"(",
"self",
")",
":",
"return",
"self",
"in",
"self",
".",
"_constants",
".",
"_linklocal_network"
] | [
2067,
4
] | [
2074,
57
] | python | en | ['en', 'en', 'en'] | True |
IPv6Address.is_site_local | (self) | Test if the address is reserved for site-local.
Note that the site-local address space has been deprecated by RFC 3879.
Use is_private to test if this address is in the space of unique local
addresses as defined by RFC 4193.
Returns:
A boolean, True if the address is reserv... | Test if the address is reserved for site-local. | def is_site_local(self):
"""Test if the address is reserved for site-local.
Note that the site-local address space has been deprecated by RFC 3879.
Use is_private to test if this address is in the space of unique local
addresses as defined by RFC 4193.
Returns:
A bo... | [
"def",
"is_site_local",
"(",
"self",
")",
":",
"return",
"self",
"in",
"self",
".",
"_constants",
".",
"_sitelocal_network"
] | [
2077,
4
] | [
2088,
57
] | python | en | ['en', 'en', 'en'] | True |
IPv6Address.is_private | (self) | Test if this address is allocated for private networks.
Returns:
A boolean, True if the address is reserved per
iana-ipv6-special-registry.
| Test if this address is allocated for private networks. | def is_private(self):
"""Test if this address is allocated for private networks.
Returns:
A boolean, True if the address is reserved per
iana-ipv6-special-registry.
"""
return any(self in net for net in self._constants._private_networks) | [
"def",
"is_private",
"(",
"self",
")",
":",
"return",
"any",
"(",
"self",
"in",
"net",
"for",
"net",
"in",
"self",
".",
"_constants",
".",
"_private_networks",
")"
] | [
2091,
4
] | [
2099,
76
] | python | en | ['en', 'en', 'en'] | True |
IPv6Address.is_global | (self) | Test if this address is allocated for public networks.
Returns:
A boolean, true if the address is not reserved per
iana-ipv6-special-registry.
| Test if this address is allocated for public networks. | def is_global(self):
"""Test if this address is allocated for public networks.
Returns:
A boolean, true if the address is not reserved per
iana-ipv6-special-registry.
"""
return not self.is_private | [
"def",
"is_global",
"(",
"self",
")",
":",
"return",
"not",
"self",
".",
"is_private"
] | [
2102,
4
] | [
2110,
34
] | python | en | ['en', 'en', 'en'] | True |
IPv6Address.is_unspecified | (self) | Test if the address is unspecified.
Returns:
A boolean, True if this is the unspecified address as defined in
RFC 2373 2.5.2.
| Test if the address is unspecified. | def is_unspecified(self):
"""Test if the address is unspecified.
Returns:
A boolean, True if this is the unspecified address as defined in
RFC 2373 2.5.2.
"""
return self._ip == 0 | [
"def",
"is_unspecified",
"(",
"self",
")",
":",
"return",
"self",
".",
"_ip",
"==",
"0"
] | [
2113,
4
] | [
2121,
28
] | python | en | ['en', 'en', 'en'] | True |
IPv6Address.is_loopback | (self) | Test if the address is a loopback address.
Returns:
A boolean, True if the address is a loopback address as defined in
RFC 2373 2.5.3.
| Test if the address is a loopback address. | def is_loopback(self):
"""Test if the address is a loopback address.
Returns:
A boolean, True if the address is a loopback address as defined in
RFC 2373 2.5.3.
"""
return self._ip == 1 | [
"def",
"is_loopback",
"(",
"self",
")",
":",
"return",
"self",
".",
"_ip",
"==",
"1"
] | [
2124,
4
] | [
2132,
28
] | python | en | ['en', 'en', 'en'] | True |
IPv6Address.ipv4_mapped | (self) | Return the IPv4 mapped address.
Returns:
If the IPv6 address is a v4 mapped address, return the
IPv4 mapped address. Return None otherwise.
| Return the IPv4 mapped address. | def ipv4_mapped(self):
"""Return the IPv4 mapped address.
Returns:
If the IPv6 address is a v4 mapped address, return the
IPv4 mapped address. Return None otherwise.
"""
if (self._ip >> 32) != 0xFFFF:
return None
return IPv4Address(self._ip &... | [
"def",
"ipv4_mapped",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"_ip",
">>",
"32",
")",
"!=",
"0xFFFF",
":",
"return",
"None",
"return",
"IPv4Address",
"(",
"self",
".",
"_ip",
"&",
"0xFFFFFFFF",
")"
] | [
2135,
4
] | [
2145,
49
] | python | en | ['en', 'no', 'en'] | True |
IPv6Address.teredo | (self) | Tuple of embedded teredo IPs.
Returns:
Tuple of the (server, client) IPs or None if the address
doesn't appear to be a teredo address (doesn't start with
2001::/32)
| Tuple of embedded teredo IPs. | def teredo(self):
"""Tuple of embedded teredo IPs.
Returns:
Tuple of the (server, client) IPs or None if the address
doesn't appear to be a teredo address (doesn't start with
2001::/32)
"""
if (self._ip >> 96) != 0x20010000:
return None
... | [
"def",
"teredo",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"_ip",
">>",
"96",
")",
"!=",
"0x20010000",
":",
"return",
"None",
"return",
"(",
"IPv4Address",
"(",
"(",
"self",
".",
"_ip",
">>",
"64",
")",
"&",
"0xFFFFFFFF",
")",
",",
"IPv4Addres... | [
2148,
4
] | [
2160,
52
] | python | en | ['en', 'xh', 'en'] | True |
IPv6Address.sixtofour | (self) | Return the IPv4 6to4 embedded address.
Returns:
The IPv4 6to4-embedded address if present or None if the
address doesn't appear to contain a 6to4 embedded address.
| Return the IPv4 6to4 embedded address. | def sixtofour(self):
"""Return the IPv4 6to4 embedded address.
Returns:
The IPv4 6to4-embedded address if present or None if the
address doesn't appear to contain a 6to4 embedded address.
"""
if (self._ip >> 112) != 0x2002:
return None
return... | [
"def",
"sixtofour",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"_ip",
">>",
"112",
")",
"!=",
"0x2002",
":",
"return",
"None",
"return",
"IPv4Address",
"(",
"(",
"self",
".",
"_ip",
">>",
"80",
")",
"&",
"0xFFFFFFFF",
")"
] | [
2163,
4
] | [
2173,
57
] | python | en | ['en', 'ru-Latn', 'en'] | True |
IPv6Network.__init__ | (self, address, strict=True) | Instantiate a new IPv6 Network object.
Args:
address: A string or integer representing the IPv6 network or the
IP and prefix/netmask.
'2001:db8::/128'
'2001:db8:0000:0000:0000:0000:0000:0000/128'
'2001:db8::'
are all functionally... | Instantiate a new IPv6 Network object. | def __init__(self, address, strict=True):
"""Instantiate a new IPv6 Network object.
Args:
address: A string or integer representing the IPv6 network or the
IP and prefix/netmask.
'2001:db8::/128'
'2001:db8:0000:0000:0000:0000:0000:0000/128'
... | [
"def",
"__init__",
"(",
"self",
",",
"address",
",",
"strict",
"=",
"True",
")",
":",
"_BaseNetwork",
".",
"__init__",
"(",
"self",
",",
"address",
")",
"# Efficient constructor from integer or packed address",
"if",
"isinstance",
"(",
"address",
",",
"(",
"byte... | [
2279,
4
] | [
2356,
38
] | python | en | ['en', 'en', 'en'] | True |
IPv6Network.hosts | (self) | Generate Iterator over usable hosts in a network.
This is like __iter__ except it doesn't return the
Subnet-Router anycast address.
| Generate Iterator over usable hosts in a network. | def hosts(self):
"""Generate Iterator over usable hosts in a network.
This is like __iter__ except it doesn't return the
Subnet-Router anycast address.
"""
network = int(self.network_address)
broadcast = int(self.broadcast_address)
for x in _compat_range(net... | [
"def",
"hosts",
"(",
"self",
")",
":",
"network",
"=",
"int",
"(",
"self",
".",
"network_address",
")",
"broadcast",
"=",
"int",
"(",
"self",
".",
"broadcast_address",
")",
"for",
"x",
"in",
"_compat_range",
"(",
"network",
"+",
"1",
",",
"broadcast",
... | [
2358,
4
] | [
2368,
40
] | python | en | ['en', 'en', 'en'] | True |
IPv6Network.is_site_local | (self) | Test if the address is reserved for site-local.
Note that the site-local address space has been deprecated by RFC 3879.
Use is_private to test if this address is in the space of unique local
addresses as defined by RFC 4193.
Returns:
A boolean, True if the address is reserv... | Test if the address is reserved for site-local. | def is_site_local(self):
"""Test if the address is reserved for site-local.
Note that the site-local address space has been deprecated by RFC 3879.
Use is_private to test if this address is in the space of unique local
addresses as defined by RFC 4193.
Returns:
A bo... | [
"def",
"is_site_local",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"network_address",
".",
"is_site_local",
"and",
"self",
".",
"broadcast_address",
".",
"is_site_local",
")"
] | [
2371,
4
] | [
2383,
53
] | python | en | ['en', 'en', 'en'] | True |
TestAdminDateInput.test_media_inheritance | (self) |
Widgets inheriting from AdminDateInput should have their media definitions merged
with AdminDateInput's
|
Widgets inheriting from AdminDateInput should have their media definitions merged
with AdminDateInput's
| def test_media_inheritance(self):
"""
Widgets inheriting from AdminDateInput should have their media definitions merged
with AdminDateInput's
"""
widget = AdminStarDateInput()
media_html = str(widget.media)
self.assertIn('wagtailadmin/js/date-time-chooser.js', med... | [
"def",
"test_media_inheritance",
"(",
"self",
")",
":",
"widget",
"=",
"AdminStarDateInput",
"(",
")",
"media_html",
"=",
"str",
"(",
"widget",
".",
"media",
")",
"self",
".",
"assertIn",
"(",
"'wagtailadmin/js/date-time-chooser.js'",
",",
"media_html",
")",
"se... | [
172,
4
] | [
180,
56
] | python | en | ['en', 'error', 'th'] | False |
TestAdminTagWidget.get_js_init_params | (self, html) | Returns a list of the params passed in to initTagField from the supplied HTML | Returns a list of the params passed in to initTagField from the supplied HTML | def get_js_init_params(self, html):
"""Returns a list of the params passed in to initTagField from the supplied HTML"""
# Eg. ["test_id", "/admin/tag-autocomplete/", {'allowSpaces': True}]
start = 'initTagField('
end = ');'
items_after_init = html.split(start)[1]
if items... | [
"def",
"get_js_init_params",
"(",
"self",
",",
"html",
")",
":",
"# Eg. [\"test_id\", \"/admin/tag-autocomplete/\", {'allowSpaces': True}]",
"start",
"=",
"'initTagField('",
"end",
"=",
"');'",
"items_after_init",
"=",
"html",
".",
"split",
"(",
"start",
")",
"[",
"1"... | [
307,
4
] | [
318,
17
] | python | en | ['en', 'en', 'en'] | True |
TestAdminTagWidget.test_render_js_init_basic | (self) | Checks that the 'initTagField' is correctly added to the inline script for tag widgets | Checks that the 'initTagField' is correctly added to the inline script for tag widgets | def test_render_js_init_basic(self):
"""Checks that the 'initTagField' is correctly added to the inline script for tag widgets"""
widget = widgets.AdminTagWidget()
html = widget.render('tags', None, attrs={'id': 'alpha'})
params = self.get_js_init_params(html)
self.assertEqual(... | [
"def",
"test_render_js_init_basic",
"(",
"self",
")",
":",
"widget",
"=",
"widgets",
".",
"AdminTagWidget",
"(",
")",
"html",
"=",
"widget",
".",
"render",
"(",
"'tags'",
",",
"None",
",",
"attrs",
"=",
"{",
"'id'",
":",
"'alpha'",
"}",
")",
"params",
... | [
320,
4
] | [
330,
9
] | python | en | ['en', 'en', 'en'] | True |
TestAdminTagWidget.test_render_js_init_no_spaces_allowed | (self) | Checks that the 'initTagField' includes the correct value based on TAG_SPACES_ALLOWED in settings | Checks that the 'initTagField' includes the correct value based on TAG_SPACES_ALLOWED in settings | def test_render_js_init_no_spaces_allowed(self):
"""Checks that the 'initTagField' includes the correct value based on TAG_SPACES_ALLOWED in settings"""
widget = widgets.AdminTagWidget()
html = widget.render('tags', None, attrs={'id': 'alpha'})
params = self.get_js_init_params(html)
... | [
"def",
"test_render_js_init_no_spaces_allowed",
"(",
"self",
")",
":",
"widget",
"=",
"widgets",
".",
"AdminTagWidget",
"(",
")",
"html",
"=",
"widget",
".",
"render",
"(",
"'tags'",
",",
"None",
",",
"attrs",
"=",
"{",
"'id'",
":",
"'alpha'",
"}",
")",
... | [
333,
4
] | [
343,
9
] | python | en | ['en', 'en', 'en'] | True |
TestAdminTagWidget.test_render_js_init_with_tag_limit | (self) | Checks that the 'initTagField' includes the correct value based on TAG_LIMIT in settings | Checks that the 'initTagField' includes the correct value based on TAG_LIMIT in settings | def test_render_js_init_with_tag_limit(self):
"""Checks that the 'initTagField' includes the correct value based on TAG_LIMIT in settings"""
widget = widgets.AdminTagWidget()
html = widget.render('tags', None, attrs={'id': 'alpha'})
params = self.get_js_init_params(html)
self.a... | [
"def",
"test_render_js_init_with_tag_limit",
"(",
"self",
")",
":",
"widget",
"=",
"widgets",
".",
"AdminTagWidget",
"(",
")",
"html",
"=",
"widget",
".",
"render",
"(",
"'tags'",
",",
"None",
",",
"attrs",
"=",
"{",
"'id'",
":",
"'alpha'",
"}",
")",
"pa... | [
346,
4
] | [
356,
9
] | python | en | ['en', 'en', 'en'] | True |
TestAdminTagWidget.test_render_js_init_with_tag_model | (self) |
Checks that 'initTagField' is passed the correct autocomplete URL for the custom model,
and sets autocompleteOnly according to that model's free_tagging attribute
|
Checks that 'initTagField' is passed the correct autocomplete URL for the custom model,
and sets autocompleteOnly according to that model's free_tagging attribute
| def test_render_js_init_with_tag_model(self):
"""
Checks that 'initTagField' is passed the correct autocomplete URL for the custom model,
and sets autocompleteOnly according to that model's free_tagging attribute
"""
widget = widgets.AdminTagWidget(tag_model=RestaurantTag)
... | [
"def",
"test_render_js_init_with_tag_model",
"(",
"self",
")",
":",
"widget",
"=",
"widgets",
".",
"AdminTagWidget",
"(",
"tag_model",
"=",
"RestaurantTag",
")",
"html",
"=",
"widget",
".",
"render",
"(",
"'tags'",
",",
"None",
",",
"attrs",
"=",
"{",
"'id'"... | [
358,
4
] | [
371,
9
] | python | en | ['en', 'error', 'th'] | False |
TestAdminTagWidget.test_render_with_free_tagging_false | (self) | Checks that free_tagging=False is passed to the inline script | Checks that free_tagging=False is passed to the inline script | def test_render_with_free_tagging_false(self):
"""Checks that free_tagging=False is passed to the inline script"""
widget = widgets.AdminTagWidget(free_tagging=False)
html = widget.render('tags', None, attrs={'id': 'alpha'})
params = self.get_js_init_params(html)
self.assertEqu... | [
"def",
"test_render_with_free_tagging_false",
"(",
"self",
")",
":",
"widget",
"=",
"widgets",
".",
"AdminTagWidget",
"(",
"free_tagging",
"=",
"False",
")",
"html",
"=",
"widget",
".",
"render",
"(",
"'tags'",
",",
"None",
",",
"attrs",
"=",
"{",
"'id'",
... | [
373,
4
] | [
383,
9
] | python | en | ['en', 'en', 'en'] | True |
TestAdminTagWidget.test_render_with_free_tagging_true | (self) | free_tagging=True on the widget can also override the tag model setting free_tagging=False | free_tagging=True on the widget can also override the tag model setting free_tagging=False | def test_render_with_free_tagging_true(self):
"""free_tagging=True on the widget can also override the tag model setting free_tagging=False"""
widget = widgets.AdminTagWidget(tag_model=RestaurantTag, free_tagging=True)
html = widget.render('tags', None, attrs={'id': 'alpha'})
params = s... | [
"def",
"test_render_with_free_tagging_true",
"(",
"self",
")",
":",
"widget",
"=",
"widgets",
".",
"AdminTagWidget",
"(",
"tag_model",
"=",
"RestaurantTag",
",",
"free_tagging",
"=",
"True",
")",
"html",
"=",
"widget",
".",
"render",
"(",
"'tags'",
",",
"None"... | [
385,
4
] | [
395,
9
] | python | en | ['en', 'en', 'en'] | True |
NetworkInNetwork.__init__ | (self, args) |
TODO: Write Comment
|
TODO: Write Comment
| def __init__(self, args):
"""
TODO: Write Comment
"""
self.name = 'NIN'
CifarModel.__init__(self, args) | [
"def",
"__init__",
"(",
"self",
",",
"args",
")",
":",
"self",
".",
"name",
"=",
"'NIN'",
"CifarModel",
".",
"__init__",
"(",
"self",
",",
"args",
")"
] | [
10,
4
] | [
17,
39
] | python | en | ['en', 'error', 'th'] | False |
NetworkInNetwork.network | (self, img_input) |
TODO: Write Comment
|
TODO: Write Comment
| def network(self, img_input):
"""
TODO: Write Comment
"""
from tensorflow.keras import initializers, layers, regularizers
weight_decay = 0.0001
dropout = 0.5
x = layers.Conv2D(192, (5, 5), padding='same', kernel_regularizer=regularizers.l2(weight_decay), k... | [
"def",
"network",
"(",
"self",
",",
"img_input",
")",
":",
"from",
"tensorflow",
".",
"keras",
"import",
"initializers",
",",
"layers",
",",
"regularizers",
"weight_decay",
"=",
"0.0001",
"dropout",
"=",
"0.5",
"x",
"=",
"layers",
".",
"Conv2D",
"(",
"192"... | [
19,
4
] | [
77,
16
] | python | en | ['en', 'error', 'th'] | False |
NetworkInNetwork.scheduler | (self, epoch) |
TODO: Write Comment
|
TODO: Write Comment
| def scheduler(self, epoch):
"""
TODO: Write Comment
"""
if epoch <= 60:
return 0.05
if epoch <= 120:
return 0.01
if epoch <= 160:
return 0.002
return 0.0004 | [
"def",
"scheduler",
"(",
"self",
",",
"epoch",
")",
":",
"if",
"epoch",
"<=",
"60",
":",
"return",
"0.05",
"if",
"epoch",
"<=",
"120",
":",
"return",
"0.01",
"if",
"epoch",
"<=",
"160",
":",
"return",
"0.002",
"return",
"0.0004"
] | [
79,
4
] | [
90,
21
] | python | en | ['en', 'error', 'th'] | False |
Node.__init__ | (self, children=None, connector=None, negated=False) |
Constructs a new Node. If no connector is given, the default will be
used.
|
Constructs a new Node. If no connector is given, the default will be
used.
| def __init__(self, children=None, connector=None, negated=False):
"""
Constructs a new Node. If no connector is given, the default will be
used.
"""
self.children = children[:] if children else []
self.connector = connector or self.default
self.negated = negated | [
"def",
"__init__",
"(",
"self",
",",
"children",
"=",
"None",
",",
"connector",
"=",
"None",
",",
"negated",
"=",
"False",
")",
":",
"self",
".",
"children",
"=",
"children",
"[",
":",
"]",
"if",
"children",
"else",
"[",
"]",
"self",
".",
"connector"... | [
20,
4
] | [
27,
30
] | python | en | ['en', 'error', 'th'] | False |
Node._new_instance | (cls, children=None, connector=None, negated=False) |
This is called to create a new instance of this class when we need new
Nodes (or subclasses) in the internal code in this class. Normally, it
just shadows __init__(). However, subclasses with an __init__ signature
that is not an extension of Node.__init__ might need to implement this
... |
This is called to create a new instance of this class when we need new
Nodes (or subclasses) in the internal code in this class. Normally, it
just shadows __init__(). However, subclasses with an __init__ signature
that is not an extension of Node.__init__ might need to implement this
... | def _new_instance(cls, children=None, connector=None, negated=False):
"""
This is called to create a new instance of this class when we need new
Nodes (or subclasses) in the internal code in this class. Normally, it
just shadows __init__(). However, subclasses with an __init__ signature
... | [
"def",
"_new_instance",
"(",
"cls",
",",
"children",
"=",
"None",
",",
"connector",
"=",
"None",
",",
"negated",
"=",
"False",
")",
":",
"obj",
"=",
"Node",
"(",
"children",
",",
"connector",
",",
"negated",
")",
"obj",
".",
"__class__",
"=",
"cls",
... | [
32,
4
] | [
43,
18
] | python | en | ['en', 'error', 'th'] | False |
Node.__deepcopy__ | (self, memodict) |
Utility method used by copy.deepcopy().
|
Utility method used by copy.deepcopy().
| def __deepcopy__(self, memodict):
"""
Utility method used by copy.deepcopy().
"""
obj = Node(connector=self.connector, negated=self.negated)
obj.__class__ = self.__class__
obj.children = copy.deepcopy(self.children, memodict)
return obj | [
"def",
"__deepcopy__",
"(",
"self",
",",
"memodict",
")",
":",
"obj",
"=",
"Node",
"(",
"connector",
"=",
"self",
".",
"connector",
",",
"negated",
"=",
"self",
".",
"negated",
")",
"obj",
".",
"__class__",
"=",
"self",
".",
"__class__",
"obj",
".",
... | [
52,
4
] | [
59,
18
] | python | en | ['en', 'error', 'th'] | False |
Node.__len__ | (self) |
The size of a node if the number of children it has.
|
The size of a node if the number of children it has.
| def __len__(self):
"""
The size of a node if the number of children it has.
"""
return len(self.children) | [
"def",
"__len__",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
".",
"children",
")"
] | [
61,
4
] | [
65,
33
] | python | en | ['en', 'error', 'th'] | False |
Node.__bool__ | (self) |
For truth value testing.
|
For truth value testing.
| def __bool__(self):
"""
For truth value testing.
"""
return bool(self.children) | [
"def",
"__bool__",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"self",
".",
"children",
")"
] | [
67,
4
] | [
71,
34
] | python | en | ['en', 'error', 'th'] | False |
Node.__contains__ | (self, other) |
Returns True is 'other' is a direct child of this instance.
|
Returns True is 'other' is a direct child of this instance.
| def __contains__(self, other):
"""
Returns True is 'other' is a direct child of this instance.
"""
return other in self.children | [
"def",
"__contains__",
"(",
"self",
",",
"other",
")",
":",
"return",
"other",
"in",
"self",
".",
"children"
] | [
76,
4
] | [
80,
37
] | python | en | ['en', 'error', 'th'] | False |
Node.add | (self, data, conn_type, squash=True) |
Combines this tree and the data represented by data using the
connector conn_type. The combine is done by squashing the node other
away if possible.
This tree (self) will never be pushed to a child node of the
combined tree, nor will the connector or negated properties change.
... |
Combines this tree and the data represented by data using the
connector conn_type. The combine is done by squashing the node other
away if possible. | def add(self, data, conn_type, squash=True):
"""
Combines this tree and the data represented by data using the
connector conn_type. The combine is done by squashing the node other
away if possible.
This tree (self) will never be pushed to a child node of the
combined tre... | [
"def",
"add",
"(",
"self",
",",
"data",
",",
"conn_type",
",",
"squash",
"=",
"True",
")",
":",
"if",
"data",
"in",
"self",
".",
"children",
":",
"return",
"data",
"if",
"not",
"squash",
":",
"self",
".",
"children",
".",
"append",
"(",
"data",
")"... | [
82,
4
] | [
124,
23
] | python | en | ['en', 'error', 'th'] | False |
Node.negate | (self) |
Negate the sense of the root connector.
|
Negate the sense of the root connector.
| def negate(self):
"""
Negate the sense of the root connector.
"""
self.negated = not self.negated | [
"def",
"negate",
"(",
"self",
")",
":",
"self",
".",
"negated",
"=",
"not",
"self",
".",
"negated"
] | [
126,
4
] | [
130,
39
] | python | en | ['en', 'error', 'th'] | False |
_suggest_semantic_version | (s) |
Try to suggest a semantic form for a version for which
_suggest_normalized_version couldn't come up with anything.
|
Try to suggest a semantic form for a version for which
_suggest_normalized_version couldn't come up with anything.
| def _suggest_semantic_version(s):
"""
Try to suggest a semantic form for a version for which
_suggest_normalized_version couldn't come up with anything.
"""
result = s.strip().lower()
for pat, repl in _REPLACEMENTS:
result = pat.sub(repl, result)
if not result:
result = '0.0.... | [
"def",
"_suggest_semantic_version",
"(",
"s",
")",
":",
"result",
"=",
"s",
".",
"strip",
"(",
")",
".",
"lower",
"(",
")",
"for",
"pat",
",",
"repl",
"in",
"_REPLACEMENTS",
":",
"result",
"=",
"pat",
".",
"sub",
"(",
"repl",
",",
"result",
")",
"i... | [
405,
0
] | [
448,
17
] | python | en | ['en', 'error', 'th'] | False |
_suggest_normalized_version | (s) | Suggest a normalized version close to the given version string.
If you have a version string that isn't rational (i.e. NormalizedVersion
doesn't like it) then you might be able to get an equivalent (or close)
rational version from this function.
This does a number of simple normalizations to the given... | Suggest a normalized version close to the given version string. | def _suggest_normalized_version(s):
"""Suggest a normalized version close to the given version string.
If you have a version string that isn't rational (i.e. NormalizedVersion
doesn't like it) then you might be able to get an equivalent (or close)
rational version from this function.
This does a n... | [
"def",
"_suggest_normalized_version",
"(",
"s",
")",
":",
"try",
":",
"_normalized_key",
"(",
"s",
")",
"return",
"s",
"# already rational",
"except",
"UnsupportedVersionError",
":",
"pass",
"rs",
"=",
"s",
".",
"lower",
"(",
")",
"# part of this could use maketra... | [
451,
0
] | [
559,
13
] | python | en | ['en', 'en', 'en'] | True |
Matcher.match | (self, version) |
Check if the provided version matches the constraints.
:param version: The version to match against this instance.
:type version: String or :class:`Version` instance.
|
Check if the provided version matches the constraints. | def match(self, version):
"""
Check if the provided version matches the constraints.
:param version: The version to match against this instance.
:type version: String or :class:`Version` instance.
"""
if isinstance(version, string_types):
version = self.versi... | [
"def",
"match",
"(",
"self",
",",
"version",
")",
":",
"if",
"isinstance",
"(",
"version",
",",
"string_types",
")",
":",
"version",
"=",
"self",
".",
"version_class",
"(",
"version",
")",
"for",
"operator",
",",
"constraint",
",",
"prefix",
"in",
"self"... | [
128,
4
] | [
147,
19
] | python | en | ['en', 'error', 'th'] | False |
VersionScheme.is_valid_constraint_list | (self, s) |
Used for processing some metadata fields
|
Used for processing some metadata fields
| def is_valid_constraint_list(self, s):
"""
Used for processing some metadata fields
"""
return self.is_valid_matcher('dummy_name (%s)' % s) | [
"def",
"is_valid_constraint_list",
"(",
"self",
",",
"s",
")",
":",
"return",
"self",
".",
"is_valid_matcher",
"(",
"'dummy_name (%s)'",
"%",
"s",
")"
] | [
708,
4
] | [
712,
59
] | python | en | ['en', 'error', 'th'] | False |
test_check_message_cant_forge_message_as_other_realm_user | (self) |
Verifies that the .can_forge_sender permission doesn't allow
forging another realm's user as sender of a message to a stream
in the forwarder's realm.
|
Verifies that the .can_forge_sender permission doesn't allow
forging another realm's user as sender of a message to a stream
in the forwarder's realm.
| def test_check_message_cant_forge_message_as_other_realm_user(self) -> None:
"""
Verifies that the .can_forge_sender permission doesn't allow
forging another realm's user as sender of a message to a stream
in the forwarder's realm.
"""
forwarder_user_profile = self.exampl... | [
"def",
"test_check_message_cant_forge_message_as_other_realm_user",
"(",
"self",
")",
"->",
"None",
":",
"forwarder_user_profile",
"=",
"self",
".",
"example_user",
"(",
"\"othello\"",
")",
"do_change_can_forge_sender",
"(",
"forwarder_user_profile",
",",
"True",
")",
"mi... | [
2493,
4
] | [
2528,
13
] | python | en | ['en', 'error', 'th'] | False |
test_check_message_cant_forge_message_to_stream_in_different_realm | (self) |
Verifies that the .can_forge_sender permission doesn't allow
forging another realm's user as sender of a message to a stream
in the forged user's realm..
|
Verifies that the .can_forge_sender permission doesn't allow
forging another realm's user as sender of a message to a stream
in the forged user's realm..
| def test_check_message_cant_forge_message_to_stream_in_different_realm(self) -> None:
"""
Verifies that the .can_forge_sender permission doesn't allow
forging another realm's user as sender of a message to a stream
in the forged user's realm..
"""
forwarder_user_profile =... | [
"def",
"test_check_message_cant_forge_message_to_stream_in_different_realm",
"(",
"self",
")",
"->",
"None",
":",
"forwarder_user_profile",
"=",
"self",
".",
"example_user",
"(",
"\"othello\"",
")",
"do_change_can_forge_sender",
"(",
"forwarder_user_profile",
",",
"True",
"... | [
2530,
4
] | [
2582,
13
] | python | en | ['en', 'error', 'th'] | False |
MessagePOSTTest.test_message_to_stream_by_name | (self) |
Sending a message to a stream to which you are subscribed is
successful.
|
Sending a message to a stream to which you are subscribed is
successful.
| def test_message_to_stream_by_name(self) -> None:
"""
Sending a message to a stream to which you are subscribed is
successful.
"""
self.login("hamlet")
result = self.client_post(
"/json/messages",
{
"type": "stream",
... | [
"def",
"test_message_to_stream_by_name",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"result",
"=",
"self",
".",
"client_post",
"(",
"\"/json/messages\"",
",",
"{",
"\"type\"",
":",
"\"stream\"",
",",
"\"to\"",
":",
"\"... | [
82,
4
] | [
98,
40
] | python | en | ['en', 'error', 'th'] | False |
MessagePOSTTest.test_api_message_to_stream_by_name | (self) |
Same as above, but for the API view
|
Same as above, but for the API view
| def test_api_message_to_stream_by_name(self) -> None:
"""
Same as above, but for the API view
"""
user = self.example_user("hamlet")
result = self.api_post(
user,
"/api/v1/messages",
{
"type": "stream",
"to": "Ve... | [
"def",
"test_api_message_to_stream_by_name",
"(",
"self",
")",
"->",
"None",
":",
"user",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"result",
"=",
"self",
".",
"api_post",
"(",
"user",
",",
"\"/api/v1/messages\"",
",",
"{",
"\"type\"",
":",
"... | [
100,
4
] | [
116,
40
] | python | en | ['en', 'error', 'th'] | False |
MessagePOSTTest.test_message_to_stream_by_id | (self) |
Sending a message to a stream (by stream ID) to which you are
subscribed is successful.
|
Sending a message to a stream (by stream ID) to which you are
subscribed is successful.
| def test_message_to_stream_by_id(self) -> None:
"""
Sending a message to a stream (by stream ID) to which you are
subscribed is successful.
"""
self.login("hamlet")
realm = get_realm("zulip")
stream = get_stream("Verona", realm)
result = self.client_post(
... | [
"def",
"test_message_to_stream_by_id",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"stream",
"=",
"get_stream",
"(",
"\"Verona\"",
",",
"realm",
")",
"result",
"=",
"s... | [
144,
4
] | [
164,
71
] | python | en | ['en', 'error', 'th'] | False |
MessagePOSTTest.test_sending_message_as_stream_post_policy_admins | (self) |
Sending messages to streams which only the admins can post to.
|
Sending messages to streams which only the admins can post to.
| def test_sending_message_as_stream_post_policy_admins(self) -> None:
"""
Sending messages to streams which only the admins can post to.
"""
admin_profile = self.example_user("iago")
self.login_user(admin_profile)
stream_name = "Verona"
stream = get_stream(stream_... | [
"def",
"test_sending_message_as_stream_post_policy_admins",
"(",
"self",
")",
"->",
"None",
":",
"admin_profile",
"=",
"self",
".",
"example_user",
"(",
"\"iago\"",
")",
"self",
".",
"login_user",
"(",
"admin_profile",
")",
"stream_name",
"=",
"\"Verona\"",
"stream"... | [
166,
4
] | [
252,
9
] | python | en | ['en', 'error', 'th'] | False |
MessagePOSTTest.test_sending_message_as_stream_post_policy_moderators | (self) |
Sending messages to streams which only the moderators can post to.
|
Sending messages to streams which only the moderators can post to.
| def test_sending_message_as_stream_post_policy_moderators(self) -> None:
"""
Sending messages to streams which only the moderators can post to.
"""
admin_profile = self.example_user("iago")
self.login_user(admin_profile)
stream_name = "Verona"
stream = get_stream... | [
"def",
"test_sending_message_as_stream_post_policy_moderators",
"(",
"self",
")",
"->",
"None",
":",
"admin_profile",
"=",
"self",
".",
"example_user",
"(",
"\"iago\"",
")",
"self",
".",
"login_user",
"(",
"admin_profile",
")",
"stream_name",
"=",
"\"Verona\"",
"str... | [
254,
4
] | [
334,
9
] | python | en | ['en', 'error', 'th'] | False |
MessagePOSTTest.test_sending_message_as_stream_post_policy_restrict_new_members | (self) |
Sending messages to streams which new members cannot post to.
|
Sending messages to streams which new members cannot post to.
| def test_sending_message_as_stream_post_policy_restrict_new_members(self) -> None:
"""
Sending messages to streams which new members cannot post to.
"""
admin_profile = self.example_user("iago")
self.login_user(admin_profile)
do_set_realm_property(admin_profile.realm, "w... | [
"def",
"test_sending_message_as_stream_post_policy_restrict_new_members",
"(",
"self",
")",
"->",
"None",
":",
"admin_profile",
"=",
"self",
".",
"example_user",
"(",
"\"iago\"",
")",
"self",
".",
"login_user",
"(",
"admin_profile",
")",
"do_set_realm_property",
"(",
... | [
336,
4
] | [
438,
9
] | python | en | ['en', 'error', 'th'] | False |
MessagePOSTTest.test_api_message_with_default_to | (self) |
Sending messages without a to field should be sent to the default
stream for the user_profile.
|
Sending messages without a to field should be sent to the default
stream for the user_profile.
| def test_api_message_with_default_to(self) -> None:
"""
Sending messages without a to field should be sent to the default
stream for the user_profile.
"""
user = self.example_user("hamlet")
user.default_sending_stream_id = get_stream("Verona", user.realm).id
user.... | [
"def",
"test_api_message_with_default_to",
"(",
"self",
")",
"->",
"None",
":",
"user",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"user",
".",
"default_sending_stream_id",
"=",
"get_stream",
"(",
"\"Verona\"",
",",
"user",
".",
"realm",
")",
".... | [
440,
4
] | [
463,
68
] | python | en | ['en', 'error', 'th'] | False |
MessagePOSTTest.test_message_to_nonexistent_stream | (self) |
Sending a message to a nonexistent stream fails.
|
Sending a message to a nonexistent stream fails.
| def test_message_to_nonexistent_stream(self) -> None:
"""
Sending a message to a nonexistent stream fails.
"""
self.login("hamlet")
self.assertFalse(Stream.objects.filter(name="nonexistent_stream"))
result = self.client_post(
"/json/messages",
{
... | [
"def",
"test_message_to_nonexistent_stream",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"self",
".",
"assertFalse",
"(",
"Stream",
".",
"objects",
".",
"filter",
"(",
"name",
"=",
"\"nonexistent_stream\"",
")",
")",
"r... | [
465,
4
] | [
481,
84
] | python | en | ['en', 'error', 'th'] | False |
MessagePOSTTest.test_message_to_nonexistent_stream_with_bad_characters | (self) |
Nonexistent stream name with bad characters should be escaped properly.
|
Nonexistent stream name with bad characters should be escaped properly.
| def test_message_to_nonexistent_stream_with_bad_characters(self) -> None:
"""
Nonexistent stream name with bad characters should be escaped properly.
"""
self.login("hamlet")
self.assertFalse(Stream.objects.filter(name="""&<"'><non-existent>"""))
result = self.client_post... | [
"def",
"test_message_to_nonexistent_stream_with_bad_characters",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"self",
".",
"assertFalse",
"(",
"Stream",
".",
"objects",
".",
"filter",
"(",
"name",
"=",
"\"\"\"&<\"'><non-existe... | [
483,
4
] | [
501,
9
] | python | en | ['en', 'error', 'th'] | False |
MessagePOSTTest.test_personal_message | (self) |
Sending a personal message to a valid username is successful.
|
Sending a personal message to a valid username is successful.
| def test_personal_message(self) -> None:
"""
Sending a personal message to a valid username is successful.
"""
user_profile = self.example_user("hamlet")
self.login_user(user_profile)
othello = self.example_user("othello")
result = self.client_post(
"/... | [
"def",
"test_personal_message",
"(",
"self",
")",
"->",
"None",
":",
"user_profile",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"self",
".",
"login_user",
"(",
"user_profile",
")",
"othello",
"=",
"self",
".",
"example_user",
"(",
"\"othello\"",... | [
503,
4
] | [
553,
80
] | python | en | ['en', 'error', 'th'] | False |
MessagePOSTTest.test_personal_message_by_id | (self) |
Sending a personal message to a valid user ID is successful.
|
Sending a personal message to a valid user ID is successful.
| def test_personal_message_by_id(self) -> None:
"""
Sending a personal message to a valid user ID is successful.
"""
self.login("hamlet")
result = self.client_post(
"/json/messages",
{
"type": "private",
"content": "Test mess... | [
"def",
"test_personal_message_by_id",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"result",
"=",
"self",
".",
"client_post",
"(",
"\"/json/messages\"",
",",
"{",
"\"type\"",
":",
"\"private\"",
",",
"\"content\"",
":",
... | [
555,
4
] | [
573,
85
] | python | en | ['en', 'error', 'th'] | False |
MessagePOSTTest.test_group_personal_message_by_id | (self) |
Sending a personal message to a valid user ID is successful.
|
Sending a personal message to a valid user ID is successful.
| def test_group_personal_message_by_id(self) -> None:
"""
Sending a personal message to a valid user ID is successful.
"""
self.login("hamlet")
result = self.client_post(
"/json/messages",
{
"type": "private",
"content": "Tes... | [
"def",
"test_group_personal_message_by_id",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"result",
"=",
"self",
".",
"client_post",
"(",
"\"/json/messages\"",
",",
"{",
"\"type\"",
":",
"\"private\"",
",",
"\"content\"",
"... | [
575,
4
] | [
604,
9
] | python | en | ['en', 'error', 'th'] | False |
MessagePOSTTest.test_personal_message_copying_self | (self) |
Sending a personal message to yourself plus another user is successful,
and counts as a message just to that user.
|
Sending a personal message to yourself plus another user is successful,
and counts as a message just to that user.
| def test_personal_message_copying_self(self) -> None:
"""
Sending a personal message to yourself plus another user is successful,
and counts as a message just to that user.
"""
hamlet = self.example_user("hamlet")
othello = self.example_user("othello")
self.login_... | [
"def",
"test_personal_message_copying_self",
"(",
"self",
")",
"->",
"None",
":",
"hamlet",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"othello",
"=",
"self",
".",
"example_user",
"(",
"\"othello\"",
")",
"self",
".",
"login_user",
"(",
"hamlet"... | [
606,
4
] | [
626,
54
] | python | en | ['en', 'error', 'th'] | False |
MessagePOSTTest.test_personal_message_to_nonexistent_user | (self) |
Sending a personal message to an invalid email returns error JSON.
|
Sending a personal message to an invalid email returns error JSON.
| def test_personal_message_to_nonexistent_user(self) -> None:
"""
Sending a personal message to an invalid email returns error JSON.
"""
self.login("hamlet")
result = self.client_post(
"/json/messages",
{
"type": "private",
"... | [
"def",
"test_personal_message_to_nonexistent_user",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"result",
"=",
"self",
".",
"client_post",
"(",
"\"/json/messages\"",
",",
"{",
"\"type\"",
":",
"\"private\"",
",",
"\"content... | [
628,
4
] | [
642,
69
] | python | en | ['en', 'error', 'th'] | False |
MessagePOSTTest.test_personal_message_to_deactivated_user | (self) |
Sending a personal message to a deactivated user returns error JSON.
|
Sending a personal message to a deactivated user returns error JSON.
| def test_personal_message_to_deactivated_user(self) -> None:
"""
Sending a personal message to a deactivated user returns error JSON.
"""
othello = self.example_user("othello")
cordelia = self.example_user("cordelia")
do_deactivate_user(othello, acting_user=None)
... | [
"def",
"test_personal_message_to_deactivated_user",
"(",
"self",
")",
"->",
"None",
":",
"othello",
"=",
"self",
".",
"example_user",
"(",
"\"othello\"",
")",
"cordelia",
"=",
"self",
".",
"example_user",
"(",
"\"cordelia\"",
")",
"do_deactivate_user",
"(",
"othel... | [
644,
4
] | [
673,
86
] | python | en | ['en', 'error', 'th'] | False |
MessagePOSTTest.test_invalid_type | (self) |
Sending a message of unknown type returns error JSON.
|
Sending a message of unknown type returns error JSON.
| def test_invalid_type(self) -> None:
"""
Sending a message of unknown type returns error JSON.
"""
self.login("hamlet")
othello = self.example_user("othello")
result = self.client_post(
"/json/messages",
{
"type": "invalid type",
... | [
"def",
"test_invalid_type",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"othello",
"=",
"self",
".",
"example_user",
"(",
"\"othello\"",
")",
"result",
"=",
"self",
".",
"client_post",
"(",
"\"/json/messages\"",
",",
... | [
675,
4
] | [
690,
62
] | python | en | ['en', 'error', 'th'] | False |
MessagePOSTTest.test_empty_message | (self) |
Sending a message that is empty or only whitespace should fail
|
Sending a message that is empty or only whitespace should fail
| def test_empty_message(self) -> None:
"""
Sending a message that is empty or only whitespace should fail
"""
self.login("hamlet")
othello = self.example_user("othello")
result = self.client_post(
"/json/messages",
{"type": "private", "content": " "... | [
"def",
"test_empty_message",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"othello",
"=",
"self",
".",
"example_user",
"(",
"\"othello\"",
")",
"result",
"=",
"self",
".",
"client_post",
"(",
"\"/json/messages\"",
",",
... | [
692,
4
] | [
702,
67
] | python | en | ['en', 'error', 'th'] | False |
MessagePOSTTest.test_empty_string_topic | (self) |
Sending a message that has empty string topic should fail
|
Sending a message that has empty string topic should fail
| def test_empty_string_topic(self) -> None:
"""
Sending a message that has empty string topic should fail
"""
self.login("hamlet")
result = self.client_post(
"/json/messages",
{
"type": "stream",
"to": "Verona",
... | [
"def",
"test_empty_string_topic",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"result",
"=",
"self",
".",
"client_post",
"(",
"\"/json/messages\"",
",",
"{",
"\"type\"",
":",
"\"stream\"",
",",
"\"to\"",
":",
"\"Verona\... | [
704,
4
] | [
719,
62
] | python | en | ['en', 'error', 'th'] | False |
MessagePOSTTest.test_missing_topic | (self) |
Sending a message without topic should fail
|
Sending a message without topic should fail
| def test_missing_topic(self) -> None:
"""
Sending a message without topic should fail
"""
self.login("hamlet")
result = self.client_post(
"/json/messages",
{"type": "stream", "to": "Verona", "client": "test suite", "content": "Test message"},
)
... | [
"def",
"test_missing_topic",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"result",
"=",
"self",
".",
"client_post",
"(",
"\"/json/messages\"",
",",
"{",
"\"type\"",
":",
"\"stream\"",
",",
"\"to\"",
":",
"\"Verona\"",
... | [
721,
4
] | [
730,
55
] | python | en | ['en', 'error', 'th'] | False |
MessagePOSTTest.test_invalid_message_type | (self) |
Messages other than the type of "private" or "stream" are considered as invalid
|
Messages other than the type of "private" or "stream" are considered as invalid
| def test_invalid_message_type(self) -> None:
"""
Messages other than the type of "private" or "stream" are considered as invalid
"""
self.login("hamlet")
result = self.client_post(
"/json/messages",
{
"type": "invalid",
"to"... | [
"def",
"test_invalid_message_type",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"result",
"=",
"self",
".",
"client_post",
"(",
"\"/json/messages\"",
",",
"{",
"\"type\"",
":",
"\"invalid\"",
",",
"\"to\"",
":",
"\"Vero... | [
732,
4
] | [
747,
62
] | python | en | ['en', 'error', 'th'] | False |
MessagePOSTTest.test_private_message_without_recipients | (self) |
Sending private message without recipients should fail
|
Sending private message without recipients should fail
| def test_private_message_without_recipients(self) -> None:
"""
Sending private message without recipients should fail
"""
self.login("hamlet")
result = self.client_post(
"/json/messages",
{"type": "private", "content": "Test content", "client": "test suite... | [
"def",
"test_private_message_without_recipients",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"result",
"=",
"self",
".",
"client_post",
"(",
"\"/json/messages\"",
",",
"{",
"\"type\"",
":",
"\"private\"",
",",
"\"content\"... | [
749,
4
] | [
758,
70
] | python | en | ['en', 'error', 'th'] | False |
MessagePOSTTest.test_mirrored_huddle | (self) |
Sending a mirrored huddle message works
|
Sending a mirrored huddle message works
| def test_mirrored_huddle(self) -> None:
"""
Sending a mirrored huddle message works
"""
result = self.api_post(
self.mit_user("starnine"),
"/json/messages",
{
"type": "private",
"sender": self.mit_email("sipbtest"),
... | [
"def",
"test_mirrored_huddle",
"(",
"self",
")",
"->",
"None",
":",
"result",
"=",
"self",
".",
"api_post",
"(",
"self",
".",
"mit_user",
"(",
"\"starnine\"",
")",
",",
"\"/json/messages\"",
",",
"{",
"\"type\"",
":",
"\"private\"",
",",
"\"sender\"",
":",
... | [
760,
4
] | [
778,
40
] | python | en | ['en', 'error', 'th'] | False |
MessagePOSTTest.test_mirrored_personal | (self) |
Sending a mirrored personal message works
|
Sending a mirrored personal message works
| def test_mirrored_personal(self) -> None:
"""
Sending a mirrored personal message works
"""
result = self.api_post(
self.mit_user("starnine"),
"/json/messages",
{
"type": "private",
"sender": self.mit_email("sipbtest"),
... | [
"def",
"test_mirrored_personal",
"(",
"self",
")",
"->",
"None",
":",
"result",
"=",
"self",
".",
"api_post",
"(",
"self",
".",
"mit_user",
"(",
"\"starnine\"",
")",
",",
"\"/json/messages\"",
",",
"{",
"\"type\"",
":",
"\"private\"",
",",
"\"sender\"",
":",... | [
780,
4
] | [
796,
40
] | python | en | ['en', 'error', 'th'] | False |
MessagePOSTTest.test_mirrored_personal_browser | (self) |
Sending a mirrored personal message via the browser should not work.
|
Sending a mirrored personal message via the browser should not work.
| def test_mirrored_personal_browser(self) -> None:
"""
Sending a mirrored personal message via the browser should not work.
"""
user = self.mit_user("starnine")
self.login_user(user)
result = self.client_post(
"/json/messages",
{
"ty... | [
"def",
"test_mirrored_personal_browser",
"(",
"self",
")",
"->",
"None",
":",
"user",
"=",
"self",
".",
"mit_user",
"(",
"\"starnine\"",
")",
"self",
".",
"login_user",
"(",
"user",
")",
"result",
"=",
"self",
".",
"client_post",
"(",
"\"/json/messages\"",
"... | [
798,
4
] | [
815,
66
] | python | en | ['en', 'error', 'th'] | False |
MessagePOSTTest.test_mirrored_personal_to_someone_else | (self) |
Sending a mirrored personal message to someone else is not allowed.
|
Sending a mirrored personal message to someone else is not allowed.
| def test_mirrored_personal_to_someone_else(self) -> None:
"""
Sending a mirrored personal message to someone else is not allowed.
"""
result = self.api_post(
self.mit_user("starnine"),
"/api/v1/messages",
{
"type": "private",
... | [
"def",
"test_mirrored_personal_to_someone_else",
"(",
"self",
")",
"->",
"None",
":",
"result",
"=",
"self",
".",
"api_post",
"(",
"self",
".",
"mit_user",
"(",
"\"starnine\"",
")",
",",
"\"/api/v1/messages\"",
",",
"{",
"\"type\"",
":",
"\"private\"",
",",
"\... | [
817,
4
] | [
833,
76
] | python | en | ['en', 'error', 'th'] | False |
MessagePOSTTest.test_duplicated_mirrored_huddle | (self) |
Sending two mirrored huddles in the row return the same ID
|
Sending two mirrored huddles in the row return the same ID
| def test_duplicated_mirrored_huddle(self) -> None:
"""
Sending two mirrored huddles in the row return the same ID
"""
msg = {
"type": "private",
"sender": self.mit_email("sipbtest"),
"content": "Test message",
"client": "zephyr_mirror",
... | [
"def",
"test_duplicated_mirrored_huddle",
"(",
"self",
")",
"->",
"None",
":",
"msg",
"=",
"{",
"\"type\"",
":",
"\"private\"",
",",
"\"sender\"",
":",
"self",
".",
"mit_email",
"(",
"\"sipbtest\"",
")",
",",
"\"content\"",
":",
"\"Test message\"",
",",
"\"cli... | [
835,
4
] | [
867,
98
] | python | en | ['en', 'error', 'th'] | False |
MessagePOSTTest.test_message_with_null_bytes | (self) |
A message with null bytes in it is handled.
|
A message with null bytes in it is handled.
| def test_message_with_null_bytes(self) -> None:
"""
A message with null bytes in it is handled.
"""
self.login("hamlet")
post_data = {
"type": "stream",
"to": "Verona",
"client": "test suite",
"content": " I like null bytes \x00 in... | [
"def",
"test_message_with_null_bytes",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"post_data",
"=",
"{",
"\"type\"",
":",
"\"stream\"",
",",
"\"to\"",
":",
"\"Verona\"",
",",
"\"client\"",
":",
"\"test suite\"",
",",
"... | [
869,
4
] | [
882,
77
] | python | en | ['en', 'error', 'th'] | False |
MessagePOSTTest.test_strip_message | (self) |
A message with mixed whitespace at the end is cleaned up.
|
A message with mixed whitespace at the end is cleaned up.
| def test_strip_message(self) -> None:
"""
A message with mixed whitespace at the end is cleaned up.
"""
self.login("hamlet")
post_data = {
"type": "stream",
"to": "Verona",
"client": "test suite",
"content": " I like whitespace at ... | [
"def",
"test_strip_message",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"post_data",
"=",
"{",
"\"type\"",
":",
"\"stream\"",
",",
"\"to\"",
":",
"\"Verona\"",
",",
"\"client\"",
":",
"\"test suite\"",
",",
"\"content\... | [
884,
4
] | [
899,
81
] | python | en | ['en', 'error', 'th'] | False |
MessagePOSTTest.test_long_message | (self) |
Sending a message longer than the maximum message length succeeds but is
truncated.
|
Sending a message longer than the maximum message length succeeds but is
truncated.
| def test_long_message(self) -> None:
"""
Sending a message longer than the maximum message length succeeds but is
truncated.
"""
self.login("hamlet")
MAX_MESSAGE_LENGTH = settings.MAX_MESSAGE_LENGTH
long_message = "A" * (MAX_MESSAGE_LENGTH + 1)
post_data =... | [
"def",
"test_long_message",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"MAX_MESSAGE_LENGTH",
"=",
"settings",
".",
"MAX_MESSAGE_LENGTH",
"long_message",
"=",
"\"A\"",
"*",
"(",
"MAX_MESSAGE_LENGTH",
"+",
"1",
")",
"post_... | [
902,
4
] | [
923,
9
] | python | en | ['en', 'error', 'th'] | False |
MessagePOSTTest.test_long_topic | (self) |
Sending a message with a topic longer than the maximum topic length
succeeds, but the topic is truncated.
|
Sending a message with a topic longer than the maximum topic length
succeeds, but the topic is truncated.
| def test_long_topic(self) -> None:
"""
Sending a message with a topic longer than the maximum topic length
succeeds, but the topic is truncated.
"""
self.login("hamlet")
long_topic = "A" * (MAX_TOPIC_NAME_LENGTH + 1)
post_data = {
"type": "stream",
... | [
"def",
"test_long_topic",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"long_topic",
"=",
"\"A\"",
"*",
"(",
"MAX_TOPIC_NAME_LENGTH",
"+",
"1",
")",
"post_data",
"=",
"{",
"\"type\"",
":",
"\"stream\"",
",",
"\"to\"",
... | [
925,
4
] | [
943,
94
] | python | en | ['en', 'error', 'th'] | False |
MessagePOSTTest.test_send_message_forging_message_to_another_realm | (self) |
Test for a specific vulnerability that allowed a .can_forge_sender
user to forge a message as a cross-realm bot to a stream in another realm,
by setting up an appropriate RealmDomain and specifying JabberMirror as client
to cause the vulnerable codepath to be executed.
|
Test for a specific vulnerability that allowed a .can_forge_sender
user to forge a message as a cross-realm bot to a stream in another realm,
by setting up an appropriate RealmDomain and specifying JabberMirror as client
to cause the vulnerable codepath to be executed.
| def test_send_message_forging_message_to_another_realm(self) -> None:
"""
Test for a specific vulnerability that allowed a .can_forge_sender
user to forge a message as a cross-realm bot to a stream in another realm,
by setting up an appropriate RealmDomain and specifying JabberMirror as ... | [
"def",
"test_send_message_forging_message_to_another_realm",
"(",
"self",
")",
"->",
"None",
":",
"user",
"=",
"self",
".",
"example_user",
"(",
"\"default_bot\"",
")",
"do_change_can_forge_sender",
"(",
"user",
",",
"True",
")",
"zephyr_realm",
"=",
"get_realm",
"(... | [
1009,
4
] | [
1036,
76
] | python | en | ['en', 'error', 'th'] | False |
StreamMessagesTest.assert_stream_message | (
self, stream_name: str, topic_name: str = "test topic", content: str = "test content"
) |
Check that messages sent to a stream reach all subscribers to that stream.
|
Check that messages sent to a stream reach all subscribers to that stream.
| def assert_stream_message(
self, stream_name: str, topic_name: str = "test topic", content: str = "test content"
) -> None:
"""
Check that messages sent to a stream reach all subscribers to that stream.
"""
realm = get_realm("zulip")
subscribers = self.users_subscribe... | [
"def",
"assert_stream_message",
"(",
"self",
",",
"stream_name",
":",
"str",
",",
"topic_name",
":",
"str",
"=",
"\"test topic\"",
",",
"content",
":",
"str",
"=",
"\"test content\"",
")",
"->",
"None",
":",
"realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
... | [
1460,
4
] | [
1507,
95
] | python | en | ['en', 'error', 'th'] | False |
StreamMessagesTest.test_performance | (self) |
This test is part of the automated test suite, but
it is more intended as an aid to measuring the
performance of do_send_messages() with consistent
data setup across different commits. You can modify
the values below and run just this test, and then
comment out the prin... |
This test is part of the automated test suite, but
it is more intended as an aid to measuring the
performance of do_send_messages() with consistent
data setup across different commits. You can modify
the values below and run just this test, and then
comment out the prin... | def test_performance(self) -> None:
"""
This test is part of the automated test suite, but
it is more intended as an aid to measuring the
performance of do_send_messages() with consistent
data setup across different commits. You can modify
the values below and run just t... | [
"def",
"test_performance",
"(",
"self",
")",
"->",
"None",
":",
"num_messages",
"=",
"2",
"num_extra_users",
"=",
"10",
"sender",
"=",
"self",
".",
"example_user",
"(",
"\"cordelia\"",
")",
"realm",
"=",
"sender",
".",
"realm",
"message_content",
"=",
"\"wha... | [
1509,
4
] | [
1567,
72
] | 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.