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.num_addresses
(self)
Number of hosts in the current subnet.
Number of hosts in the current subnet.
def num_addresses(self): """Number of hosts in the current subnet.""" return int(self.broadcast_address) - int(self.network_address) + 1
[ "def", "num_addresses", "(", "self", ")", ":", "return", "int", "(", "self", ".", "broadcast_address", ")", "-", "int", "(", "self", ".", "network_address", ")", "+", "1" ]
[ 846, 4 ]
[ 848, 74 ]
python
en
['en', 'en', 'en']
True
_BaseNetwork.address_exclude
(self, other)
Remove an address from a larger block. For example: addr1 = ip_network('192.0.2.0/28') addr2 = ip_network('192.0.2.1/32') list(addr1.address_exclude(addr2)) = [IPv4Network('192.0.2.0/32'), IPv4Network('192.0.2.2/31'), IPv4Network('192.0.2.4/...
Remove an address from a larger block.
def address_exclude(self, other): """Remove an address from a larger block. For example: addr1 = ip_network('192.0.2.0/28') addr2 = ip_network('192.0.2.1/32') list(addr1.address_exclude(addr2)) = [IPv4Network('192.0.2.0/32'), IPv4Network('192.0.2.2/3...
[ "def", "address_exclude", "(", "self", ",", "other", ")", ":", "if", "not", "self", ".", "_version", "==", "other", ".", "_version", ":", "raise", "TypeError", "(", "\"%s and %s are not of the same version\"", "%", "(", "self", ",", "other", ")", ")", "if", ...
[ 862, 4 ]
[ 935, 49 ]
python
en
['en', 'en', 'en']
True
_BaseNetwork.compare_networks
(self, other)
Compare two IP objects. This is only concerned about the comparison of the integer representation of the network addresses. This means that the host bits aren't considered at all in this method. If you want to compare host bits, you can easily enough do a 'HostA._ip < HostB._i...
Compare two IP objects.
def compare_networks(self, other): """Compare two IP objects. This is only concerned about the comparison of the integer representation of the network addresses. This means that the host bits aren't considered at all in this method. If you want to compare host bits, you can ea...
[ "def", "compare_networks", "(", "self", ",", "other", ")", ":", "# does this need to raise a ValueError?", "if", "self", ".", "_version", "!=", "other", ".", "_version", ":", "raise", "TypeError", "(", "'%s and %s are not of the same type'", "%", "(", "self", ",", ...
[ 937, 4 ]
[ 983, 16 ]
python
en
['en', 'en', 'en']
True
_BaseNetwork._get_networks_key
(self)
Network-only key function. Returns an object that identifies this address' network and netmask. This function is a suitable "key" argument for sorted() and list.sort().
Network-only key function.
def _get_networks_key(self): """Network-only key function. Returns an object that identifies this address' network and netmask. This function is a suitable "key" argument for sorted() and list.sort(). """ return (self._version, self.network_address, self.netmask)
[ "def", "_get_networks_key", "(", "self", ")", ":", "return", "(", "self", ".", "_version", ",", "self", ".", "network_address", ",", "self", ".", "netmask", ")" ]
[ 985, 4 ]
[ 993, 66 ]
python
en
['en', 'en', 'en']
True
_BaseNetwork.subnets
(self, prefixlen_diff=1, new_prefix=None)
The subnets which join to make the current subnet. In the case that self contains only one IP (self._prefixlen == 32 for IPv4 or self._prefixlen == 128 for IPv6), yield an iterator with just ourself. Args: prefixlen_diff: An integer, the amount the prefix length ...
The subnets which join to make the current subnet.
def subnets(self, prefixlen_diff=1, new_prefix=None): """The subnets which join to make the current subnet. In the case that self contains only one IP (self._prefixlen == 32 for IPv4 or self._prefixlen == 128 for IPv6), yield an iterator with just ourself. Args: pre...
[ "def", "subnets", "(", "self", ",", "prefixlen_diff", "=", "1", ",", "new_prefix", "=", "None", ")", ":", "if", "self", ".", "_prefixlen", "==", "self", ".", "_max_prefixlen", ":", "yield", "self", "return", "if", "new_prefix", "is", "not", "None", ":", ...
[ 995, 4 ]
[ 1046, 25 ]
python
en
['en', 'en', 'en']
True
_BaseNetwork.supernet
(self, prefixlen_diff=1, new_prefix=None)
The supernet containing the current network. Args: prefixlen_diff: An integer, the amount the prefix length of the network should be decreased by. For example, given a /24 network and a prefixlen_diff of 3, a supernet with a /21 netmask is returned. ...
The supernet containing the current network.
def supernet(self, prefixlen_diff=1, new_prefix=None): """The supernet containing the current network. Args: prefixlen_diff: An integer, the amount the prefix length of the network should be decreased by. For example, given a /24 network and a prefixlen_diff of ...
[ "def", "supernet", "(", "self", ",", "prefixlen_diff", "=", "1", ",", "new_prefix", "=", "None", ")", ":", "if", "self", ".", "_prefixlen", "==", "0", ":", "return", "self", "if", "new_prefix", "is", "not", "None", ":", "if", "new_prefix", ">", "self",...
[ 1048, 4 ]
[ 1086, 27 ]
python
en
['en', 'en', 'en']
True
_BaseNetwork.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.network_address.is_multicast and self.broadcast_address.i...
[ "def", "is_multicast", "(", "self", ")", ":", "return", "(", "self", ".", "network_address", ".", "is_multicast", "and", "self", ".", "broadcast_address", ".", "is_multicast", ")" ]
[ 1089, 4 ]
[ 1098, 52 ]
python
en
['en', 'en', 'en']
True
_BaseNetwork.subnet_of
(self, other)
Return True if this network is a subnet of other.
Return True if this network is a subnet of other.
def subnet_of(self, other): """Return True if this network is a subnet of other.""" return self._is_subnet_of(self, other)
[ "def", "subnet_of", "(", "self", ",", "other", ")", ":", "return", "self", ".", "_is_subnet_of", "(", "self", ",", "other", ")" ]
[ 1113, 4 ]
[ 1115, 46 ]
python
en
['en', 'en', 'en']
True
_BaseNetwork.supernet_of
(self, other)
Return True if this network is a supernet of other.
Return True if this network is a supernet of other.
def supernet_of(self, other): """Return True if this network is a supernet of other.""" return self._is_subnet_of(other, self)
[ "def", "supernet_of", "(", "self", ",", "other", ")", ":", "return", "self", ".", "_is_subnet_of", "(", "other", ",", "self", ")" ]
[ 1117, 4 ]
[ 1119, 46 ]
python
en
['en', 'en', 'en']
True
_BaseNetwork.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 (self.network_address.is_reserved and self.broadcast_address.is_reserv...
[ "def", "is_reserved", "(", "self", ")", ":", "return", "(", "self", ".", "network_address", ".", "is_reserved", "and", "self", ".", "broadcast_address", ".", "is_reserved", ")" ]
[ 1122, 4 ]
[ 1131, 51 ]
python
en
['en', 'en', 'en']
True
_BaseNetwork.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.network_address.is_link_local and self.broadcast_address.is_link_local)
[ "def", "is_link_local", "(", "self", ")", ":", "return", "(", "self", ".", "network_address", ".", "is_link_local", "and", "self", ".", "broadcast_address", ".", "is_link_local", ")" ]
[ 1134, 4 ]
[ 1142, 53 ]
python
en
['en', 'en', 'en']
True
_BaseNetwork.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 or 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-ipv4-special-registry or iana-ipv6-special-registry. """ return (self.network_address.is_private and sel...
[ "def", "is_private", "(", "self", ")", ":", "return", "(", "self", ".", "network_address", ".", "is_private", "and", "self", ".", "broadcast_address", ".", "is_private", ")" ]
[ 1145, 4 ]
[ 1154, 50 ]
python
en
['en', 'en', 'en']
True
_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
LBFGS.generate
(self, x, **kwargs)
Return a tensor that constructs adversarial examples for the given input. Generate uses tf.py_func in order to operate over tensors. :param x: (required) A tensor with the inputs. :param kwargs: See `parse_params`
Return a tensor that constructs adversarial examples for the given input. Generate uses tf.py_func in order to operate over tensors. :param x: (required) A tensor with the inputs. :param kwargs: See `parse_params`
def generate(self, x, **kwargs): """ Return a tensor that constructs adversarial examples for the given input. Generate uses tf.py_func in order to operate over tensors. :param x: (required) A tensor with the inputs. :param kwargs: See `parse_params` """ assert ( ...
[ "def", "generate", "(", "self", ",", "x", ",", "*", "*", "kwargs", ")", ":", "assert", "(", "self", ".", "sess", "is", "not", "None", ")", ",", "\"Cannot use `generate` when no `sess` was provided\"", "self", ".", "parse_params", "(", "*", "*", "kwargs", "...
[ 44, 4 ]
[ 87, 19 ]
python
en
['en', 'error', 'th']
False
LBFGS.parse_params
( self, y_target=None, batch_size=1, binary_search_steps=5, max_iterations=1000, initial_const=1e-2, clip_min=0, clip_max=1, )
:param y_target: (optional) A tensor with the one-hot target labels. :param batch_size: The number of inputs to include in a batch and process simultaneously. :param binary_search_steps: The number of times we perform binary search ...
:param y_target: (optional) A tensor with the one-hot target labels. :param batch_size: The number of inputs to include in a batch and process simultaneously. :param binary_search_steps: The number of times we perform binary search ...
def parse_params( self, y_target=None, batch_size=1, binary_search_steps=5, max_iterations=1000, initial_const=1e-2, clip_min=0, clip_max=1, ): """ :param y_target: (optional) A tensor with the one-hot target labels. :param batc...
[ "def", "parse_params", "(", "self", ",", "y_target", "=", "None", ",", "batch_size", "=", "1", ",", "binary_search_steps", "=", "5", ",", "max_iterations", "=", "1000", ",", "initial_const", "=", "1e-2", ",", "clip_min", "=", "0", ",", "clip_max", "=", "...
[ 89, 4 ]
[ 120, 32 ]
python
en
['en', 'error', 'th']
False
LBFGS_impl.attack
(self, x_val, targets)
Perform the attack on the given instance for the given targets.
Perform the attack on the given instance for the given targets.
def attack(self, x_val, targets): """ Perform the attack on the given instance for the given targets. """ def lbfgs_objective(adv_x, self, targets, oimgs, CONST): """ returns the function value and the gradient for fmin_l_bfgs_b """ loss = self.sess.run( ...
[ "def", "attack", "(", "self", ",", "x_val", ",", "targets", ")", ":", "def", "lbfgs_objective", "(", "adv_x", ",", "self", ",", "targets", ",", "oimgs", ",", "CONST", ")", ":", "\"\"\" returns the function value and the gradient for fmin_l_bfgs_b \"\"\"", "loss", ...
[ 193, 4 ]
[ 318, 27 ]
python
en
['en', 'error', 'th']
False
Validator._load_json
(self, path)
Loads json data from file. Args: path (str): path to file Returns: Loaded JSON data as an array or dict
Loads json data from file.
def _load_json(self, path): """Loads json data from file. Args: path (str): path to file Returns: Loaded JSON data as an array or dict """ file = Path(path).resolve() data = json.load(file.open()) return data
[ "def", "_load_json", "(", "self", ",", "path", ")", ":", "file", "=", "Path", "(", "path", ")", ".", "resolve", "(", ")", "data", "=", "json", ".", "load", "(", "file", ".", "open", "(", ")", ")", "return", "data" ]
[ 28, 4 ]
[ 40, 19 ]
python
en
['en', 'en', 'en']
True
Validator.validate
(self, path)
Validates json file against a schema. Args: path (str): path to json file to validate Returns: jsonschema.validate
Validates json file against a schema.
def validate(self, path): """Validates json file against a schema. Args: path (str): path to json file to validate Returns: jsonschema.validate """ data = self._load_json(path) return self.schema.validate(data)
[ "def", "validate", "(", "self", ",", "path", ")", ":", "data", "=", "self", ".", "_load_json", "(", "path", ")", "return", "self", ".", "schema", ".", "validate", "(", "data", ")" ]
[ 42, 4 ]
[ 53, 41 ]
python
de
['de', 'de', 'en']
True
get_realm_email_validator
(realm: Realm)
RESTRICTIVE REALMS: Some realms only allow emails within a set of domains that are configured in RealmDomain. We get the set of domains up front so that folks can validate multiple emails without multiple round trips to the database.
RESTRICTIVE REALMS:
def get_realm_email_validator(realm: Realm) -> Callable[[str], None]: if not realm.emails_restricted_to_domains: # Should we also do '+' check for non-resticted realms? if realm.disallow_disposable_email_addresses: return validate_disposable # allow any email through ret...
[ "def", "get_realm_email_validator", "(", "realm", ":", "Realm", ")", "->", "Callable", "[", "[", "str", "]", ",", "None", "]", ":", "if", "not", "realm", ".", "emails_restricted_to_domains", ":", "# Should we also do '+' check for non-resticted realms?", "if", "real...
[ 27, 0 ]
[ 76, 19 ]
python
en
['en', 'error', 'th']
False
email_allowed_for_realm
(email: str, realm: Realm)
Avoid calling this in a loop! Instead, call get_realm_email_validator() outside of the loop.
Avoid calling this in a loop! Instead, call get_realm_email_validator() outside of the loop.
def email_allowed_for_realm(email: str, realm: Realm) -> None: """ Avoid calling this in a loop! Instead, call get_realm_email_validator() outside of the loop. """ get_realm_email_validator(realm)(email)
[ "def", "email_allowed_for_realm", "(", "email", ":", "str", ",", "realm", ":", "Realm", ")", "->", "None", ":", "get_realm_email_validator", "(", "realm", ")", "(", "email", ")" ]
[ 83, 0 ]
[ 89, 43 ]
python
en
['en', 'error', 'th']
False
get_existing_user_errors
( target_realm: Realm, emails: Set[str], verbose: bool = False, )
We use this function even for a list of one emails. It checks "new" emails to make sure that they don't already exist. There's a bit of fiddly logic related to cross-realm bots and mirror dummies too.
We use this function even for a list of one emails.
def get_existing_user_errors( target_realm: Realm, emails: Set[str], verbose: bool = False, ) -> Dict[str, Tuple[str, bool]]: """ We use this function even for a list of one emails. It checks "new" emails to make sure that they don't already exist. There's a bit of fiddly logic related ...
[ "def", "get_existing_user_errors", "(", "target_realm", ":", "Realm", ",", "emails", ":", "Set", "[", "str", "]", ",", "verbose", ":", "bool", "=", "False", ",", ")", "->", "Dict", "[", "str", ",", "Tuple", "[", "str", ",", "bool", "]", "]", ":", "...
[ 118, 0 ]
[ 188, 17 ]
python
en
['en', 'error', 'th']
False
validate_email_not_already_in_realm
( target_realm: Realm, email: str, verbose: bool = True )
NOTE: Only use this to validate that a single email is not already used in the realm. We should start using bulk_check_new_emails() for any endpoint that takes multiple emails, such as the "invite" interface.
NOTE: Only use this to validate that a single email is not already used in the realm.
def validate_email_not_already_in_realm( target_realm: Realm, email: str, verbose: bool = True ) -> None: """ NOTE: Only use this to validate that a single email is not already used in the realm. We should start using bulk_check_new_emails() for any endpoint that takes multi...
[ "def", "validate_email_not_already_in_realm", "(", "target_realm", ":", "Realm", ",", "email", ":", "str", ",", "verbose", ":", "bool", "=", "True", ")", "->", "None", ":", "error_dict", "=", "get_existing_user_errors", "(", "target_realm", ",", "{", "email", ...
[ 191, 0 ]
[ 209, 34 ]
python
en
['en', 'error', 'th']
False
pkg_resources_distribution_for_wheel
(wheel_zip, name, location)
Get a pkg_resources distribution given a wheel. :raises UnsupportedWheel: on any errors
Get a pkg_resources distribution given a wheel.
def pkg_resources_distribution_for_wheel(wheel_zip, name, location): # type: (ZipFile, str, str) -> Distribution """Get a pkg_resources distribution given a wheel. :raises UnsupportedWheel: on any errors """ info_dir, _ = parse_wheel(wheel_zip, name) metadata_files = [ p for p in wheel...
[ "def", "pkg_resources_distribution_for_wheel", "(", "wheel_zip", ",", "name", ",", "location", ")", ":", "# type: (ZipFile, str, str) -> Distribution", "info_dir", ",", "_", "=", "parse_wheel", "(", "wheel_zip", ",", "name", ")", "metadata_files", "=", "[", "p", "fo...
[ 57, 0 ]
[ 91, 5 ]
python
en
['en', 'en', 'en']
True
parse_wheel
(wheel_zip, name)
Extract information from the provided wheel, ensuring it meets basic standards. Returns the name of the .dist-info directory and the parsed WHEEL metadata.
Extract information from the provided wheel, ensuring it meets basic standards.
def parse_wheel(wheel_zip, name): # type: (ZipFile, str) -> Tuple[str, Message] """Extract information from the provided wheel, ensuring it meets basic standards. Returns the name of the .dist-info directory and the parsed WHEEL metadata. """ try: info_dir = wheel_dist_info_dir(wheel_zi...
[ "def", "parse_wheel", "(", "wheel_zip", ",", "name", ")", ":", "# type: (ZipFile, str) -> Tuple[str, Message]", "try", ":", "info_dir", "=", "wheel_dist_info_dir", "(", "wheel_zip", ",", "name", ")", "metadata", "=", "wheel_metadata", "(", "wheel_zip", ",", "info_di...
[ 94, 0 ]
[ 112, 29 ]
python
en
['en', 'en', 'en']
True
wheel_dist_info_dir
(source, name)
Returns the name of the contained .dist-info directory. Raises AssertionError or UnsupportedWheel if not found, >1 found, or it doesn't match the provided name.
Returns the name of the contained .dist-info directory.
def wheel_dist_info_dir(source, name): # type: (ZipFile, str) -> str """Returns the name of the contained .dist-info directory. Raises AssertionError or UnsupportedWheel if not found, >1 found, or it doesn't match the provided name. """ # Zip file path separators must be / subdirs = list(se...
[ "def", "wheel_dist_info_dir", "(", "source", ",", "name", ")", ":", "# type: (ZipFile, str) -> str", "# Zip file path separators must be /", "subdirs", "=", "list", "(", "set", "(", "p", ".", "split", "(", "\"/\"", ")", "[", "0", "]", "for", "p", "in", "source...
[ 115, 0 ]
[ 150, 31 ]
python
en
['en', 'en', 'en']
True
wheel_metadata
(source, dist_info_dir)
Return the WHEEL metadata of an extracted wheel, if possible. Otherwise, raise UnsupportedWheel.
Return the WHEEL metadata of an extracted wheel, if possible. Otherwise, raise UnsupportedWheel.
def wheel_metadata(source, dist_info_dir): # type: (ZipFile, str) -> Message """Return the WHEEL metadata of an extracted wheel, if possible. Otherwise, raise UnsupportedWheel. """ path = "{}/WHEEL".format(dist_info_dir) # Zip file path separators must be / wheel_contents = read_wheel_metada...
[ "def", "wheel_metadata", "(", "source", ",", "dist_info_dir", ")", ":", "# type: (ZipFile, str) -> Message", "path", "=", "\"{}/WHEEL\"", ".", "format", "(", "dist_info_dir", ")", "# Zip file path separators must be /", "wheel_contents", "=", "read_wheel_metadata_file", "("...
[ 165, 0 ]
[ 182, 40 ]
python
en
['en', 'en', 'en']
True
wheel_version
(wheel_data)
Given WHEEL metadata, return the parsed Wheel-Version. Otherwise, raise UnsupportedWheel.
Given WHEEL metadata, return the parsed Wheel-Version. Otherwise, raise UnsupportedWheel.
def wheel_version(wheel_data): # type: (Message) -> Tuple[int, ...] """Given WHEEL metadata, return the parsed Wheel-Version. Otherwise, raise UnsupportedWheel. """ version_text = wheel_data["Wheel-Version"] if version_text is None: raise UnsupportedWheel("WHEEL is missing Wheel-Version"...
[ "def", "wheel_version", "(", "wheel_data", ")", ":", "# type: (Message) -> Tuple[int, ...]", "version_text", "=", "wheel_data", "[", "\"Wheel-Version\"", "]", "if", "version_text", "is", "None", ":", "raise", "UnsupportedWheel", "(", "\"WHEEL is missing Wheel-Version\"", ...
[ 185, 0 ]
[ 199, 77 ]
python
en
['en', 'de', 'en']
True
check_compatibility
(version, name)
Raises errors or warns if called with an incompatible Wheel-Version. pip should refuse to install a Wheel-Version that's a major series ahead of what it's compatible with (e.g 2.0 > 1.1); and warn when installing a version only minor version ahead (e.g 1.2 > 1.1). version: a 2-tuple representing a Whe...
Raises errors or warns if called with an incompatible Wheel-Version.
def check_compatibility(version, name): # type: (Tuple[int, ...], str) -> None """Raises errors or warns if called with an incompatible Wheel-Version. pip should refuse to install a Wheel-Version that's a major series ahead of what it's compatible with (e.g 2.0 > 1.1); and warn when installing a ve...
[ "def", "check_compatibility", "(", "version", ",", "name", ")", ":", "# type: (Tuple[int, ...], str) -> None", "if", "version", "[", "0", "]", ">", "VERSION_COMPATIBLE", "[", "0", "]", ":", "raise", "UnsupportedWheel", "(", "\"{}'s Wheel-Version ({}) is not compatible w...
[ 202, 0 ]
[ 224, 9 ]
python
en
['en', 'en', 'en']
True
puti16
(fp, values)
Write network order (big-endian) 16-bit sequence
Write network order (big-endian) 16-bit sequence
def puti16(fp, values): """Write network order (big-endian) 16-bit sequence""" for v in values: if v < 0: v += 65536 fp.write(_binary.o16be(v))
[ "def", "puti16", "(", "fp", ",", "values", ")", ":", "for", "v", "in", "values", ":", "if", "v", "<", "0", ":", "v", "+=", "65536", "fp", ".", "write", "(", "_binary", ".", "o16be", "(", "v", ")", ")" ]
[ 24, 0 ]
[ 29, 34 ]
python
en
['en', 'en', 'en']
True
FontFile.compile
(self)
Create metrics and bitmap
Create metrics and bitmap
def compile(self): """Create metrics and bitmap""" if self.bitmap: return # create bitmap large enough to hold all data h = w = maxwidth = 0 lines = 1 for glyph in self: if glyph: d, dst, src, im = glyph h = max(h,...
[ "def", "compile", "(", "self", ")", ":", "if", "self", ".", "bitmap", ":", "return", "# create bitmap large enough to hold all data", "h", "=", "w", "=", "maxwidth", "=", "0", "lines", "=", "1", "for", "glyph", "in", "self", ":", "if", "glyph", ":", "d",...
[ 45, 4 ]
[ 90, 43 ]
python
en
['en', 'mi', 'en']
True
load
(f, _dict=dict, decoder=None)
Parses named file or files as toml and returns a dictionary Args: f: Path to the file to open, array of files to read into single dict or a file descriptor _dict: (optional) Specifies the class of the returned toml dictionary decoder: The decoder to use Returns: Pars...
Parses named file or files as toml and returns a dictionary
def load(f, _dict=dict, decoder=None): """Parses named file or files as toml and returns a dictionary Args: f: Path to the file to open, array of files to read into single dict or a file descriptor _dict: (optional) Specifies the class of the returned toml dictionary decoder:...
[ "def", "load", "(", "f", ",", "_dict", "=", "dict", ",", "decoder", "=", "None", ")", ":", "if", "_ispath", "(", "f", ")", ":", "with", "io", ".", "open", "(", "_getpath", "(", "f", ")", ",", "encoding", "=", "'utf-8'", ")", "as", "ffile", ":",...
[ 112, 0 ]
[ 158, 35 ]
python
en
['en', 'en', 'en']
True
loads
(s, _dict=dict, decoder=None)
Parses string as toml Args: s: String to be parsed _dict: (optional) Specifies the class of the returned toml dictionary Returns: Parsed toml file represented as a dictionary Raises: TypeError: When a non-string is passed TomlDecodeError: Error while decoding toml ...
Parses string as toml
def loads(s, _dict=dict, decoder=None): """Parses string as toml Args: s: String to be parsed _dict: (optional) Specifies the class of the returned toml dictionary Returns: Parsed toml file represented as a dictionary Raises: TypeError: When a non-string is passed ...
[ "def", "loads", "(", "s", ",", "_dict", "=", "dict", ",", "decoder", "=", "None", ")", ":", "implicitgroups", "=", "[", "]", "if", "decoder", "is", "None", ":", "decoder", "=", "TomlDecoder", "(", "_dict", ")", "retval", "=", "decoder", ".", "get_emp...
[ 164, 0 ]
[ 515, 17 ]
python
en
['en', 'en', 'en']
True
_unescape
(v)
Unescape characters in a TOML string.
Unescape characters in a TOML string.
def _unescape(v): """Unescape characters in a TOML string.""" i = 0 backslash = False while i < len(v): if backslash: backslash = False if v[i] in _escapes: v = v[:i - 1] + _escape_to_escapedchars[v[i]] + v[i + 1:] elif v[i] == '\\': ...
[ "def", "_unescape", "(", "v", ")", ":", "i", "=", "0", "backslash", "=", "False", "while", "i", "<", "len", "(", "v", ")", ":", "if", "backslash", ":", "backslash", "=", "False", "if", "v", "[", "i", "]", "in", "_escapes", ":", "v", "=", "v", ...
[ 607, 0 ]
[ 626, 12 ]
python
en
['en', 'en', 'en']
True
_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
check_model_signals
(app_configs=None, **kwargs)
Ensure lazily referenced model signals senders are installed.
Ensure lazily referenced model signals senders are installed.
def check_model_signals(app_configs=None, **kwargs): """Ensure lazily referenced model signals senders are installed.""" from django.db import models errors = [] for name in dir(models.signals): obj = getattr(models.signals, name) if isinstance(obj, models.signals.ModelSignal): ...
[ "def", "check_model_signals", "(", "app_configs", "=", "None", ",", "*", "*", "kwargs", ")", ":", "from", "django", ".", "db", "import", "models", "errors", "=", "[", "]", "for", "name", "in", "dir", "(", "models", ".", "signals", ")", ":", "obj", "=...
[ 20, 0 ]
[ 48, 17 ]
python
en
['en', 'en', 'en']
True
pretty_name
(name)
Converts 'first_name' to 'First name
Converts 'first_name' to 'First name
def pretty_name(name): """Converts 'first_name' to 'First name'""" if not name: return '' return name.replace('_', ' ').capitalize()
[ "def", "pretty_name", "(", "name", ")", ":", "if", "not", "name", ":", "return", "''", "return", "name", ".", "replace", "(", "'_'", ",", "' '", ")", ".", "capitalize", "(", ")" ]
[ 26, 0 ]
[ 30, 46 ]
python
en
['en', 'en', 'en']
True
get_declared_fields
(bases, attrs, with_base_fields=True)
Create a list of form field instances from the passed in 'attrs', plus any similar fields on the base classes (in 'bases'). This is used by both the Form and ModelForm metaclasses. If 'with_base_fields' is True, all fields from the bases are used. Otherwise, only fields in the 'declared_fields' at...
Create a list of form field instances from the passed in 'attrs', plus any similar fields on the base classes (in 'bases'). This is used by both the Form and ModelForm metaclasses.
def get_declared_fields(bases, attrs, with_base_fields=True): """ Create a list of form field instances from the passed in 'attrs', plus any similar fields on the base classes (in 'bases'). This is used by both the Form and ModelForm metaclasses. If 'with_base_fields' is True, all fields from the b...
[ "def", "get_declared_fields", "(", "bases", ",", "attrs", ",", "with_base_fields", "=", "True", ")", ":", "warnings", ".", "warn", "(", "\"get_declared_fields is deprecated and will be removed in Django 1.9.\"", ",", "RemovedInDjango19Warning", ",", "stacklevel", "=", "2"...
[ 33, 0 ]
[ 69, 30 ]
python
en
['en', 'error', 'th']
False
_const_compare_digest_backport
(a, b)
Compare two digests of equal length in constant time. The digests must be of type str/bytes. Returns True if the digests match, and False otherwise.
Compare two digests of equal length in constant time.
def _const_compare_digest_backport(a, b): """ Compare two digests of equal length in constant time. The digests must be of type str/bytes. Returns True if the digests match, and False otherwise. """ result = abs(len(a) - len(b)) for l, r in zip(bytearray(a), bytearray(b)): result |=...
[ "def", "_const_compare_digest_backport", "(", "a", ",", "b", ")", ":", "result", "=", "abs", "(", "len", "(", "a", ")", "-", "len", "(", "b", ")", ")", "for", "l", ",", "r", "in", "zip", "(", "bytearray", "(", "a", ")", ",", "bytearray", "(", "...
[ 23, 0 ]
[ 33, 22 ]
python
en
['en', 'error', 'th']
False
assert_fingerprint
(cert, fingerprint)
Checks if given fingerprint matches the supplied certificate. :param cert: Certificate as bytes object. :param fingerprint: Fingerprint as string of hexdigits, can be interspersed by colons.
Checks if given fingerprint matches the supplied certificate.
def assert_fingerprint(cert, fingerprint): """ Checks if given fingerprint matches the supplied certificate. :param cert: Certificate as bytes object. :param fingerprint: Fingerprint as string of hexdigits, can be interspersed by colons. """ fingerprint = fingerprint.replace(":...
[ "def", "assert_fingerprint", "(", "cert", ",", "fingerprint", ")", ":", "fingerprint", "=", "fingerprint", ".", "replace", "(", "\":\"", ",", "\"\"", ")", ".", "lower", "(", ")", "digest_length", "=", "len", "(", "fingerprint", ")", "hashfunc", "=", "HASHF...
[ 151, 0 ]
[ 177, 9 ]
python
en
['en', 'error', 'th']
False
resolve_cert_reqs
(candidate)
Resolves the argument to a numeric constant, which can be passed to the wrap_socket function/method from the ssl module. Defaults to :data:`ssl.CERT_REQUIRED`. If given a string it is assumed to be the name of the constant in the :mod:`ssl` module or its abbreviation. (So you can specify `REQUI...
Resolves the argument to a numeric constant, which can be passed to the wrap_socket function/method from the ssl module. Defaults to :data:`ssl.CERT_REQUIRED`. If given a string it is assumed to be the name of the constant in the :mod:`ssl` module or its abbreviation. (So you can specify `REQUI...
def resolve_cert_reqs(candidate): """ Resolves the argument to a numeric constant, which can be passed to the wrap_socket function/method from the ssl module. Defaults to :data:`ssl.CERT_REQUIRED`. If given a string it is assumed to be the name of the constant in the :mod:`ssl` module or its abb...
[ "def", "resolve_cert_reqs", "(", "candidate", ")", ":", "if", "candidate", "is", "None", ":", "return", "CERT_REQUIRED", "if", "isinstance", "(", "candidate", ",", "str", ")", ":", "res", "=", "getattr", "(", "ssl", ",", "candidate", ",", "None", ")", "i...
[ 180, 0 ]
[ 200, 20 ]
python
en
['en', 'error', 'th']
False
resolve_ssl_version
(candidate)
like resolve_cert_reqs
like resolve_cert_reqs
def resolve_ssl_version(candidate): """ like resolve_cert_reqs """ if candidate is None: return PROTOCOL_TLS if isinstance(candidate, str): res = getattr(ssl, candidate, None) if res is None: res = getattr(ssl, "PROTOCOL_" + candidate) return res ret...
[ "def", "resolve_ssl_version", "(", "candidate", ")", ":", "if", "candidate", "is", "None", ":", "return", "PROTOCOL_TLS", "if", "isinstance", "(", "candidate", ",", "str", ")", ":", "res", "=", "getattr", "(", "ssl", ",", "candidate", ",", "None", ")", "...
[ 203, 0 ]
[ 216, 20 ]
python
en
['en', 'error', 'th']
False
create_urllib3_context
( ssl_version=None, cert_reqs=None, options=None, ciphers=None )
All arguments have the same meaning as ``ssl_wrap_socket``. By default, this function does a lot of the same work that ``ssl.create_default_context`` does on Python 3.4+. It: - Disables SSLv2, SSLv3, and compression - Sets a restricted set of server ciphers If you wish to enable SSLv3, you can do...
All arguments have the same meaning as ``ssl_wrap_socket``.
def create_urllib3_context( ssl_version=None, cert_reqs=None, options=None, ciphers=None ): """All arguments have the same meaning as ``ssl_wrap_socket``. By default, this function does a lot of the same work that ``ssl.create_default_context`` does on Python 3.4+. It: - Disables SSLv2, SSLv3, and...
[ "def", "create_urllib3_context", "(", "ssl_version", "=", "None", ",", "cert_reqs", "=", "None", ",", "options", "=", "None", ",", "ciphers", "=", "None", ")", ":", "context", "=", "SSLContext", "(", "ssl_version", "or", "PROTOCOL_TLS", ")", "context", ".", ...
[ 219, 0 ]
[ 292, 18 ]
python
en
['en', 'en', 'en']
True
ssl_wrap_socket
( sock, keyfile=None, certfile=None, cert_reqs=None, ca_certs=None, server_hostname=None, ssl_version=None, ciphers=None, ssl_context=None, ca_cert_dir=None, key_password=None, )
All arguments except for server_hostname, ssl_context, and ca_cert_dir have the same meaning as they do when using :func:`ssl.wrap_socket`. :param server_hostname: When SNI is supported, the expected hostname of the certificate :param ssl_context: A pre-made :class:`SSLContext` object....
All arguments except for server_hostname, ssl_context, and ca_cert_dir have the same meaning as they do when using :func:`ssl.wrap_socket`.
def ssl_wrap_socket( sock, keyfile=None, certfile=None, cert_reqs=None, ca_certs=None, server_hostname=None, ssl_version=None, ciphers=None, ssl_context=None, ca_cert_dir=None, key_password=None, ): """ All arguments except for server_hostname, ssl_context, and ca_cer...
[ "def", "ssl_wrap_socket", "(", "sock", ",", "keyfile", "=", "None", ",", "certfile", "=", "None", ",", "cert_reqs", "=", "None", ",", "ca_certs", "=", "None", ",", "server_hostname", "=", "None", ",", "ssl_version", "=", "None", ",", "ciphers", "=", "Non...
[ 295, 0 ]
[ 382, 36 ]
python
en
['en', 'error', 'th']
False
is_ipaddress
(hostname)
Detects whether the hostname given is an IPv4 or IPv6 address. Also detects IPv6 addresses with Zone IDs. :param str hostname: Hostname to examine. :return: True if the hostname is an IP address, False otherwise.
Detects whether the hostname given is an IPv4 or IPv6 address. Also detects IPv6 addresses with Zone IDs.
def is_ipaddress(hostname): """Detects whether the hostname given is an IPv4 or IPv6 address. Also detects IPv6 addresses with Zone IDs. :param str hostname: Hostname to examine. :return: True if the hostname is an IP address, False otherwise. """ if not six.PY2 and isinstance(hostname, bytes):...
[ "def", "is_ipaddress", "(", "hostname", ")", ":", "if", "not", "six", ".", "PY2", "and", "isinstance", "(", "hostname", ",", "bytes", ")", ":", "# IDN A-label bytes are ASCII compatible.", "hostname", "=", "hostname", ".", "decode", "(", "\"ascii\"", ")", "ret...
[ 385, 0 ]
[ 395, 83 ]
python
en
['en', 'en', 'en']
True
_is_key_file_encrypted
(key_file)
Detects if a key file is encrypted or not.
Detects if a key file is encrypted or not.
def _is_key_file_encrypted(key_file): """Detects if a key file is encrypted or not.""" with open(key_file, "r") as f: for line in f: # Look for Proc-Type: 4,ENCRYPTED if "ENCRYPTED" in line: return True return False
[ "def", "_is_key_file_encrypted", "(", "key_file", ")", ":", "with", "open", "(", "key_file", ",", "\"r\"", ")", "as", "f", ":", "for", "line", "in", "f", ":", "# Look for Proc-Type: 4,ENCRYPTED", "if", "\"ENCRYPTED\"", "in", "line", ":", "return", "True", "r...
[ 398, 0 ]
[ 406, 16 ]
python
en
['en', 'en', 'en']
True
GraphTests.test_simple_graph
(self)
Tests a basic dependency graph: app_a: 0001 <-- 0002 <--- 0003 <-- 0004 / app_b: 0001 <-- 0002 <-/
Tests a basic dependency graph:
def test_simple_graph(self): """ Tests a basic dependency graph: app_a: 0001 <-- 0002 <--- 0003 <-- 0004 / app_b: 0001 <-- 0002 <-/ """ # Build graph graph = MigrationGraph() graph.add_node(("app_a", "0001"), None) ...
[ "def", "test_simple_graph", "(", "self", ")", ":", "# Build graph", "graph", "=", "MigrationGraph", "(", ")", "graph", ".", "add_node", "(", "(", "\"app_a\"", ",", "\"0001\"", ")", ",", "None", ")", "graph", ".", "add_node", "(", "(", "\"app_a\"", ",", "...
[ 9, 4 ]
[ 58, 9 ]
python
en
['en', 'error', 'th']
False
GraphTests.test_complex_graph
(self)
Tests a complex dependency graph: app_a: 0001 <-- 0002 <--- 0003 <-- 0004 \ \ / / app_b: 0001 <-\ 0002 <-X / \ \ / app_c: \ 0001 <-- 0002 <-
Tests a complex dependency graph:
def test_complex_graph(self): """ Tests a complex dependency graph: app_a: 0001 <-- 0002 <--- 0003 <-- 0004 \ \ / / app_b: 0001 <-\ 0002 <-X / \ \ / app_c: \ 0001 <-- 0002 <- """ ...
[ "def", "test_complex_graph", "(", "self", ")", ":", "# Build graph", "graph", "=", "MigrationGraph", "(", ")", "graph", ".", "add_node", "(", "(", "\"app_a\"", ",", "\"0001\"", ")", ",", "None", ")", "graph", ".", "add_node", "(", "(", "\"app_a\"", ",", ...
[ 60, 4 ]
[ 112, 9 ]
python
en
['en', 'error', 'th']
False
GraphTests.test_circular_graph
(self)
Tests a circular dependency graph.
Tests a circular dependency graph.
def test_circular_graph(self): """ Tests a circular dependency graph. """ # Build graph graph = MigrationGraph() graph.add_node(("app_a", "0001"), None) graph.add_node(("app_a", "0002"), None) graph.add_node(("app_a", "0003"), None) graph.add_node(...
[ "def", "test_circular_graph", "(", "self", ")", ":", "# Build graph", "graph", "=", "MigrationGraph", "(", ")", "graph", ".", "add_node", "(", "(", "\"app_a\"", ",", "\"0001\"", ")", ",", "None", ")", "graph", ".", "add_node", "(", "(", "\"app_a\"", ",", ...
[ 114, 4 ]
[ 134, 9 ]
python
en
['en', 'error', 'th']
False
GraphTests.test_plan_invalid_node
(self)
Tests for forwards/backwards_plan of nonexistent node.
Tests for forwards/backwards_plan of nonexistent node.
def test_plan_invalid_node(self): """ Tests for forwards/backwards_plan of nonexistent node. """ graph = MigrationGraph() message = "Node ('app_b', '0001') not a valid node" with self.assertRaisesMessage(ValueError, message): graph.forwards_plan(("app_b", "00...
[ "def", "test_plan_invalid_node", "(", "self", ")", ":", "graph", "=", "MigrationGraph", "(", ")", "message", "=", "\"Node ('app_b', '0001') not a valid node\"", "with", "self", ".", "assertRaisesMessage", "(", "ValueError", ",", "message", ")", ":", "graph", ".", ...
[ 151, 4 ]
[ 162, 51 ]
python
en
['en', 'error', 'th']
False
GraphTests.test_missing_parent_nodes
(self)
Tests for missing parent nodes.
Tests for missing parent nodes.
def test_missing_parent_nodes(self): """ Tests for missing parent nodes. """ # Build graph graph = MigrationGraph() graph.add_node(("app_a", "0001"), None) graph.add_node(("app_a", "0002"), None) graph.add_node(("app_a", "0003"), None) graph.add_no...
[ "def", "test_missing_parent_nodes", "(", "self", ")", ":", "# Build graph", "graph", "=", "MigrationGraph", "(", ")", "graph", ".", "add_node", "(", "(", "\"app_a\"", ",", "\"0001\"", ")", ",", "None", ")", "graph", ".", "add_node", "(", "(", "\"app_a\"", ...
[ 164, 4 ]
[ 178, 84 ]
python
en
['en', 'error', 'th']
False
GraphTests.test_missing_child_nodes
(self)
Tests for missing child nodes.
Tests for missing child nodes.
def test_missing_child_nodes(self): """ Tests for missing child nodes. """ # Build graph graph = MigrationGraph() graph.add_node(("app_a", "0001"), None) msg = "Migration app_a.0002 dependencies reference nonexistent child node ('app_a', '0002')" with self...
[ "def", "test_missing_child_nodes", "(", "self", ")", ":", "# Build graph", "graph", "=", "MigrationGraph", "(", ")", "graph", ".", "add_node", "(", "(", "\"app_a\"", ",", "\"0001\"", ")", ",", "None", ")", "msg", "=", "\"Migration app_a.0002 dependencies reference...
[ 180, 4 ]
[ 189, 84 ]
python
en
['en', 'error', 'th']
False
DatabaseCreation.test_db_signature
(self)
Return a tuple that uniquely identifies a test database. This takes into account the special cases of ":memory:" and "" for SQLite since the databases will be distinct despite having the same TEST NAME. See https://www.sqlite.org/inmemorydb.html
Return a tuple that uniquely identifies a test database.
def test_db_signature(self): """ Return a tuple that uniquely identifies a test database. This takes into account the special cases of ":memory:" and "" for SQLite since the databases will be distinct despite having the same TEST NAME. See https://www.sqlite.org/inmemorydb.html ...
[ "def", "test_db_signature", "(", "self", ")", ":", "test_database_name", "=", "self", ".", "_get_test_db_name", "(", ")", "sig", "=", "[", "self", ".", "connection", ".", "settings_dict", "[", "'NAME'", "]", "]", "if", "self", ".", "is_in_memory_db", "(", ...
[ 85, 4 ]
[ 97, 25 ]
python
en
['en', 'error', 'th']
False
register
(viewer, order=1)
The :py:func:`register` function is used to register additional viewers. :param viewer: The viewer to be registered. :param order: Zero or a negative integer to prepend this viewer to the list, a positive integer to append it.
The :py:func:`register` function is used to register additional viewers.
def register(viewer, order=1): """ The :py:func:`register` function is used to register additional viewers. :param viewer: The viewer to be registered. :param order: Zero or a negative integer to prepend this viewer to the list, a positive integer to append it. """ try: ...
[ "def", "register", "(", "viewer", ",", "order", "=", "1", ")", ":", "try", ":", "if", "issubclass", "(", "viewer", ",", "Viewer", ")", ":", "viewer", "=", "viewer", "(", ")", "except", "TypeError", ":", "pass", "# raised if viewer wasn't a class", "if", ...
[ 25, 0 ]
[ 42, 34 ]
python
en
['en', 'error', 'th']
False
show
(image, title=None, **options)
r""" Display a given image. :param image: An image object. :param title: Optional title. Not all viewers can display the title. :param \**options: Additional viewer options. :returns: ``True`` if a suitable viewer was found, ``False`` otherwise.
r""" Display a given image.
def show(image, title=None, **options): r""" Display a given image. :param image: An image object. :param title: Optional title. Not all viewers can display the title. :param \**options: Additional viewer options. :returns: ``True`` if a suitable viewer was found, ``False`` otherwise. """ ...
[ "def", "show", "(", "image", ",", "title", "=", "None", ",", "*", "*", "options", ")", ":", "for", "viewer", "in", "_viewers", ":", "if", "viewer", ".", "show", "(", "image", ",", "title", "=", "title", ",", "*", "*", "options", ")", ":", "return...
[ 45, 0 ]
[ 57, 12 ]
python
cy
['en', 'cy', 'hi']
False
Viewer.show
(self, image, **options)
The main function for displaying an image. Converts the given image to the target format and displays it.
The main function for displaying an image. Converts the given image to the target format and displays it.
def show(self, image, **options): """ The main function for displaying an image. Converts the given image to the target format and displays it. """ # save temporary image to disk if not ( image.mode in ("1", "RGBA") or (self.format == "PNG" and im...
[ "def", "show", "(", "self", ",", "image", ",", "*", "*", "options", ")", ":", "# save temporary image to disk", "if", "not", "(", "image", ".", "mode", "in", "(", "\"1\"", ",", "\"RGBA\"", ")", "or", "(", "self", ".", "format", "==", "\"PNG\"", "and", ...
[ 65, 4 ]
[ 80, 48 ]
python
en
['en', 'error', 'th']
False
Viewer.get_format
(self, image)
Return format name, or ``None`` to save as PGM/PPM.
Return format name, or ``None`` to save as PGM/PPM.
def get_format(self, image): """Return format name, or ``None`` to save as PGM/PPM.""" return self.format
[ "def", "get_format", "(", "self", ",", "image", ")", ":", "return", "self", ".", "format" ]
[ 89, 4 ]
[ 91, 26 ]
python
en
['en', 'en', 'en']
True