MCPcopy Index your code
hub / github.com/RustPython/RustPython / _prefix_from_prefix_string

Method _prefix_from_prefix_string

Lib/ipaddress.py:470–492  ·  view source on GitHub ↗

Return prefix length from a numeric string Args: prefixlen_str: The string to be converted Returns: An integer, the prefix length. Raises: NetmaskValueError: If the input is not a valid netmask

(cls, prefixlen_str)

Source from the content-addressed store, hash-verified

468
469 @classmethod
470 def _prefix_from_prefix_string(cls, prefixlen_str):
471 """Return prefix length from a numeric string
472
473 Args:
474 prefixlen_str: The string to be converted
475
476 Returns:
477 An integer, the prefix length.
478
479 Raises:
480 NetmaskValueError: If the input is not a valid netmask
481 """
482 # int allows a leading +/- as well as surrounding whitespace,
483 # so we ensure that isn't the case
484 if not (prefixlen_str.isascii() and prefixlen_str.isdigit()):
485 cls._report_invalid_netmask(prefixlen_str)
486 try:
487 prefixlen = int(prefixlen_str)
488 except ValueError:
489 cls._report_invalid_netmask(prefixlen_str)
490 if not (0 <= prefixlen <= cls.max_prefixlen):
491 cls._report_invalid_netmask(prefixlen_str)
492 return prefixlen
493
494 @classmethod
495 def _prefix_from_ip_string(cls, ip_str):

Callers 3

_make_netmaskMethod · 0.80
_make_netmaskMethod · 0.80
testZeroNetmaskMethod · 0.80

Calls 3

isasciiMethod · 0.45
isdigitMethod · 0.45

Tested by 1

testZeroNetmaskMethod · 0.64