#NEWLINE# def _is_valid_netmask( self , netmask ) : #NEWLINE# #INDENT# 'Verify that the netmask is valid.\n\n        Args:\n            netmask: A string, either a prefix or dotted decimal\n              netmask.\n\n        Returns:\n            A boolean, True if the prefix represents a valid IPv4\n            netmask.\n\n        ' #NEWLINE# mask = netmask . split ( '.' ) #NEWLINE# if ( len ( mask ) == 4 ) : #NEWLINE# #INDENT# if [ x for x in mask if ( int ( x ) not in self . _valid_mask_octets ) ] : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# if [ y for ( idx , y ) in enumerate ( mask ) if ( ( idx > 0 ) and ( y > mask [ ( idx - 1 ) ] ) ) ] : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# return True #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# netmask = int ( netmask ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# return ( 0 <= netmask <= self . _max_prefixlen )