MCPcopy
hub / github.com/psf/requests / dotted_netmask

Function dotted_netmask

src/requests/utils.py:741–749  ·  view source on GitHub ↗

Converts mask from /xx format to xxx.xxx.xxx.xxx Example: if mask is 24 function returns 255.255.255.0 :rtype: str

(mask: int)

Source from the content-addressed store, hash-verified

739
740
741def dotted_netmask(mask: int) -> str:
742 """Converts mask from /xx format to xxx.xxx.xxx.xxx
743
744 Example: if mask is 24 function returns 255.255.255.0
745
746 :rtype: str
747 """
748 bits = 0xFFFFFFFF ^ (1 << 32 - mask) - 1
749 return socket.inet_ntoa(struct.pack(">I", bits))
750
751
752def is_ipv4_address(string_ip: str) -> bool:

Callers 2

test_dotted_netmaskFunction · 0.90
address_in_networkFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_dotted_netmaskFunction · 0.72