pex.type.casting

Module Contents

class pex.type.casting.Casting

Bases: object

Subclass of pex.type module.

This subclass of pex.type module is intended for providing implementations of some type casting methods.

static is_mac(mac: str) bool

Check if string is a MAC address.

Parameters:

mac (str) – string to check

Return bool:

True if string is a MAC address

static is_ipv4(ipv4: str) bool

Check if string is an IPv4 address.

Parameters:

ipv4 (str) – string to check

Return bool:

True if string is an IPv4 address

static is_ipv6(ipv6: str) bool

Check if string is an IPv6 address.

Parameters:

ipv6 (str) – string to check

Return bool:

True if string is an IPv6 address

is_ip(ip: str) bool

Check if string is an IPv4 or an IPv6 address.

Parameters:

ip (str) – string to check

Return bool:

True if string is an IPv4 or an IPv6 address

is_ipv4_cidr(ipv4_cidr: str) bool

Check if string is an IPv4 cidr.

Parameters:

ipv4_cidr (str) – string to check

Return bool:

True if string is an IPv4 cidr

is_ipv6_cidr(ipv6_cidr: str) bool

Check if string is an IPv6 cidr.

Parameters:

ipv6_cidr (str) – string to check

Return bool:

True if string is an IPv6 cidr

is_port(port: int) bool

Check if integer is a port.

Parameters:

port (int) – integer to check

Return bool:

True if integer is a port

is_port_range(port_range: str) bool

Check if string is a port range.

Parameters:

port_range (str) – string to check

Return bool:

True if string is a port range

static is_integer(value: str) bool

Check if string is an integer.

Parameters:

value (str) – string to check

Return bool:

True if string is an integer else False

static is_float(value: str) bool

Check if string is a float.

Parameters:

value (str) – string to check

Return bool:

True if string is a float else False

is_number(value: str) bool

Check if string is a number (float/int).

Parameters:

value (str) – string to check

Return bool:

True if string is a number else False

static is_boolean(value: str) bool

Check if string is a boolean (yes/no/y/n).

Parameters:

value (str) – string to check

Return bool:

True if string is a boolean else False