/usr/lib/python2.6/site-packages/netaddr/strategy
Edit: /usr/lib/python2.6/site-packages/netaddr/strategy/__init__.pyc (7945B)
Ñò
}DVc @ s˜ d Z d d k Z d d k l Z l Z d „ Z e ƒ Z d „ Z d „ Z d „ Z
d d „ Z d d
„ Z d d „ Z
d „ Z d
„ Z d „ Z d S( s)
Shared logic for various address types.
iÿÿÿÿN( t _ranget _is_strc C sƒ g } t d d d ƒ } xd t d ƒ D]V } d d g } x* | D]" } d | d @| | <| d L} q? W| i d i | ƒ ƒ q% W| S( s
:return: A 256 element list containing 8-bit binary digit strings. The
list index value is equivalent to its bit string value.
i iÿÿÿÿi i t 01i t N( R t ranget Nonet appendt join( t lookupt
bits_per_bytet numt bitst i( ( s: /tmp/pip-build-lt8jXN/netaddr/netaddr/strategy/__init__.pyt
bytes_to_bits s
c C ss t | d ƒ p t St | ƒ | j o t Sd | d } x1 | D]) } d | j o
| j n p t SqB Wt S( s6
:param words: A sequence of unsigned integer word values.
:param word_size: Width (in bits) of each unsigned integer word value.
:param num_words: Number of unsigned integer words expected.
:return: ``True`` if word sequence is valid for this address type,
``False`` otherwise.
t __iter__i i i ( t hasattrt Falset lent True( t wordst word_sizet num_wordst max_wordR ( ( s: /tmp/pip-build-lt8jXN/netaddr/netaddr/strategy/__init__.pyt valid_words! s c C s¬ d | | d } d | j o
| j n p t d t | ƒ ƒ ‚ n d | d } g } x; t | ƒ D]- } | | @} | i t | ƒ ƒ | | L} qk Wt t | ƒ ƒ S( sJ
:param int_val: Unsigned integer to be divided into words of equal size.
:param word_size: Width (in bits) of each unsigned integer word value.
:param num_words: Number of unsigned integer words expected.
:return: A tuple contain unsigned integer word values split according
to provided arguments.
i i i s integer out of bounds: %r!( t
IndexErrort hexR R t intt tuplet reversed( t int_valR R t max_intR R t _t word( ( s: /tmp/pip-build-lt8jXN/netaddr/netaddr/strategy/__init__.pyt int_to_words; s
c C sr t | | | ƒ p t d | ƒ ‚ n d } x> t t | ƒ ƒ D]* \ } } | } | | | >} | | B} q@ W| S( s5
:param words: A sequence of unsigned integer word values.
:param word_size: Width (in bits) of each unsigned integer word value.
:param num_words: Number of unsigned integer words expected.
:return: An unsigned integer that is equivalent to value represented
by word sequence.
s" invalid integer word sequence: %r!i ( R t
ValueErrort enumerateR ( R R R R R R
R ( ( s: /tmp/pip-build-lt8jXN/netaddr/netaddr/strategy/__init__.pyt words_to_intV s R c C s¥ t | ƒ p t S| d j o | i | d ƒ } n t | ƒ | j o t Sd | d } y0 d t | d ƒ j o
| j n o t SWn t j
o n Xt S( sl
:param bits: A network address in a delimited binary string format.
:param width: Maximum width (in bits) of a network address (excluding
delimiters).
:param word_sep: (optional) character or string used to delimit word
groups (default: '', no separator).
:return: ``True`` if network address is valid, ``False`` otherwise.
R i i i ( R R t replaceR R R R" ( R t widtht word_sepR ( ( s: /tmp/pip-build-lt8jXN/netaddr/netaddr/strategy/__init__.pyt
valid_bitsm s
' c C sW t | | | ƒ p t d | ƒ ‚ n | d j o | i | d ƒ } n t | d ƒ S( s¡
:param bits: A network address in a delimited binary string format.
:param width: Maximum width (in bits) of a network address (excluding
delimiters).
:param word_sep: (optional) character or string used to delimit word
groups (default: '', no separator).
:return: An unsigned integer that is equivalent to value represented
by network address in readable binary form.
s# invalid readable binary string: %r!R i ( R( R" R% R ( R R&