Package netaddr :: Module strategy :: Class AddrStrategy
[frames] | no frames]

Class AddrStrategy

source code

object --+
         |
        AddrStrategy
Known Subclasses:

Very basic support for all common operations performed on each network type.

There are usually subclasses for each address type that over-ride methods implemented here to optimise their performance and add additional features.

Instance Methods
 
__init__(self, width, word_size, delimiter, word_fmt='%x', addr_type=0, hex_words=True, to_upper=False)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
__repr__(self)
Returns: An executable Python statement that can recreate an object with an equivalent state.
source code
 
valid_bits(self, bits)
Returns: True if network address is valid for this address type, False otherwise.
source code
 
bits_to_int(self, bits)
Returns: A network byte order integer that is equivalent to value represented by network address in readable binary form.
source code
 
bits_to_str(self, bits)
Returns: A network address in string form that is equivalent to value represented by network address in readable binary form.
source code
 
bits_to_words(self, bits)
Returns: An integer word sequence that is equivalent to value represented by network address in readable binary form.
source code
 
valid_int(self, int_val)
Returns: True if network byte order integer falls within the boundaries of this address type, False otherwise.
source code
 
int_to_str(self, int_val)
Returns: A network address in string form that is equivalent to value represented by a network byte order integer.
source code
 
int_to_bits(self, int_val)
Returns: A network address in readable binary form that is equivalent to value represented by a network byte order integer.
source code
 
int_to_words(self, int_val)
Returns: An integer word sequence that is equivalent to value represented by a network byte order integer.
source code
 
valid_str(self, addr)
Returns: True if network address in string form is valid for this address type, False otherwise.
source code
 
str_to_int(self, addr)
Returns: A network byte order integer that is equivalent to value represented by network address in string form.
source code
 
str_to_bits(self, addr)
Returns: A network address in readable binary form that is equivalent to value represented by network address in string form.
source code
 
str_to_words(self, addr)
Returns: An integer word sequence that is equivalent in value to the network address in string form.
source code
 
valid_words(self, words)
Returns: True if word sequence is valid for this address type, False otherwise.
source code
 
words_to_int(self, words)
Returns: A network byte order integer that is equivalent to value represented by word sequence.
source code
 
words_to_str(self, words)
Returns: A network address in string form that is equivalent to value represented by word sequence.
source code
 
words_to_bits(self, words)
Returns: A network address in readable binary form that is equivalent to value represented by word sequence.
source code
 
word_to_bits(self, int_val)
Returns: An integer word value for this address type in a fixed width readable binary form.
source code
 
description(self)
Returns: String detailing setup of this AddrStrategy instance.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __str__

Properties

Inherited from object: __class__

Method Details

__init__(self, width, word_size, delimiter, word_fmt='%x', addr_type=0, hex_words=True, to_upper=False)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 

repr(x)

Returns:
An executable Python statement that can recreate an object with an equivalent state.
Overrides: object.__repr__

valid_bits(self, bits)

source code 
Parameters:
  • bits - A network address in readable binary form.
Returns:
True if network address is valid for this address type, False otherwise.

bits_to_int(self, bits)

source code 
Parameters:
  • bits - A network address in readable binary form.
Returns:
A network byte order integer that is equivalent to value represented by network address in readable binary form.

bits_to_str(self, bits)

source code 
Parameters:
  • bits - A network address in readable binary form.
Returns:
A network address in string form that is equivalent to value represented by network address in readable binary form.

bits_to_words(self, bits)

source code 
Parameters:
  • bits - A network address in readable binary form.
Returns:
An integer word sequence that is equivalent to value represented by network address in readable binary form.

valid_int(self, int_val)

source code 
Parameters:
  • int_val - A network byte order integer.
Returns:
True if network byte order integer falls within the boundaries of this address type, False otherwise.

int_to_str(self, int_val)

source code 
Parameters:
  • int_val - A network byte order integer.
Returns:
A network address in string form that is equivalent to value represented by a network byte order integer.

int_to_bits(self, int_val)

source code 
Parameters:
  • int_val - A network byte order integer.
Returns:
A network address in readable binary form that is equivalent to value represented by a network byte order integer.

int_to_words(self, int_val)

source code 
Parameters:
  • int_val - A network byte order integer.
Returns:
An integer word sequence that is equivalent to value represented by a network byte order integer.

valid_str(self, addr)

source code 
Parameters:
  • addr - A network address in string form.
Returns:
True if network address in string form is valid for this address type, False otherwise.

str_to_int(self, addr)

source code 
Parameters:
  • addr - A network address in string form.
Returns:
A network byte order integer that is equivalent to value represented by network address in string form.

str_to_bits(self, addr)

source code 
Parameters:
  • addr - A network address in string form.
Returns:
A network address in readable binary form that is equivalent to value represented by network address in string form.

str_to_words(self, addr)

source code 
Parameters:
  • addr - A network address in string form.
Returns:
An integer word sequence that is equivalent in value to the network address in string form.

valid_words(self, words)

source code 
Parameters:
  • words - A list or tuple containing integer word values.
Returns:
True if word sequence is valid for this address type, False otherwise.

words_to_int(self, words)

source code 
Parameters:
  • words - A list or tuple containing integer word values.
Returns:
A network byte order integer that is equivalent to value represented by word sequence.

words_to_str(self, words)

source code 
Parameters:
  • words - A list or tuple containing integer word values.
Returns:
A network address in string form that is equivalent to value represented by word sequence.

words_to_bits(self, words)

source code 
Parameters:
  • words - A list or tuple containing integer word values.
Returns:
A network address in readable binary form that is equivalent to value represented by word sequence.

word_to_bits(self, int_val)

source code 
Parameters:
  • int_val - An individual integer word value.
Returns:
An integer word value for this address type in a fixed width readable binary form.

description(self)

source code 
Returns:
String detailing setup of this AddrStrategy instance. Useful for debugging.