+
    4i                     h    R t ^ RItR t]! 4       tR tR tR tRR ltRR lt	RR lt
R	 tR
 tR tR# )z)
Shared logic for various address types.
Nc                     . p \        ^RR4      p\        R4       FQ  p^R.,          pV F  pRV^,          ,          W4&   V^,          pK   	  V P                  RP                  V4      4       KS  	  V # )z
:return: A 256 element list containing 8-bit binary digit strings. The
    list index value is equivalent to its bit string value.
   N01 )rangeappendjoin)lookupbits_per_bytenumbitsis        ;/usr/lib/python3/dist-packages/netaddr/strategy/__init__.pybytes_to_bitsr      so    
 F!R$MSzD6zA37mDGAIC  	bggdm$  M    c                    \        V R4      '       g   R# \        V 4      V8w  d   R# ^V,          ^,
          pV  F  p^ Tu;8:  d   V8:  d   K    R#   R# 	  R# )a  
: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.
__iter__FT)hasattrlen)words	word_size	num_wordsmax_wordr   s   &&&  r   valid_wordsr       sX     5*%%
5zY)|aHA!! "  r   c                J   ^W!,          ,          ^,
          p^ T u;8:  d   V8:  g   M \        R\        V 4      ,          4      h^V,          ^,
          p. p\        V4       F-  pW,          pVP                  \	        V4      4       W,          p K/  	  \        \        V4      4      # )a2  
: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.
zinteger out of bounds: %r!)
IndexErrorhexr   r   inttuplereversed)int_valr   r   max_intr   r   _words   &&&     r   int_to_wordsr%   :   s     I)*Q.G"7"5GDEE)|aHE9!SY 
 %!!r   c                    \        WV4      '       g   \        RV : R24      h^ p\        \        V 4      4       F  w  rETpWaV,          ,          pW6,          pK   	  V# )a  
: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.
zinvalid integer word sequence: !)r   
ValueError	enumerater    )r   r   r   r!   r   r   r$   s   &&&    r   words_to_intr*   U   sX     u33HIIGHUO,1}$. -
 Nr   c                   \        V \        4      '       g   R# VR8w  d   V P                  VR4      p \        V 4      V8w  d   R# ^V,          ^,
          p ^ \	        V ^4      u;8:  d
   V8:  d    R#  R#  R#   \
         d     R# i ; i)aP  
: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.
Fr   T)
isinstancestrreplacer   r   r(   )r   widthword_sepr"   s   &&& r   
valid_bitsr1   l   s     dC  2~||Hb)
4yEhlGD!'' (
  (
   s   A7 1A7 7BBc                    \        WV4      '       g   \        RV : R24      hVR8w  d   V P                  VR4      p \        V ^4      # )a  
: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.
z invalid readable binary string: r'   r   )r1   r(   r.   r   )r   r/   r0   s   &&&r   bits_to_intr3      sB     d8,,$HII2~||Hb)tQ<r   c                   . p\        WV4       F  p. pV'       d/   VP                  \        V^,          ,          4       V^,          pK6  VP                  4        RP	                  V4      ;'       g
    RV,          pRV,          V,           V) R pVP                  V4       K  	  VR8w  d'   \        V\        4      '       g   \        RV: R24      hVP	                  V4      # )a  
:param int_val: An unsigned integer.

:param word_size: Width (in bits) of each unsigned integer word value.

:param num_words: Number of unsigned integer words expected.

:param word_sep: (optional) character or string used to delimit word
    groups (default: '', no separator).

:return: A network address in a delimited binary string format that is
    equivalent in value to unsigned integer.
r   0Nz word separator is not a string: r'   )r%   r   BYTES_TO_BITSreverser	   r,   r-   r(   )r!   r   r   r0   	bit_wordsr$   r   bit_strs   &&&&    r   int_to_bitsr:      s     IW;KKdSj12QJD''$-223?i')I:;7 < 2~(C((hPQQ==##r   c                6   \        V \        4      '       g   R# V P                  R4      '       g   R# V P                  RR4      p \	        V 4      V8  d   R# ^V,          ^,
          p ^ \        V ^4      u;8:  d
   V8:  d    R#  R#  R#   \         d     R# i ; i)z
:param bin_val: A network address in Python's binary representation format
    ('0bxxx').

:param width: Maximum width (in bits) of a network address (excluding
    delimiters).

:return: ``True`` if network address is valid, ``False`` otherwise.
F0br   T)r,   r-   
startswithr.   r   r   r(   )bin_valr/   r"   s   && r   	valid_binr?      s     gs##d##oodB'G
7|ehlGGQ*7* +
  +
   s   'B	 B	 	BBc           	        . p \        V 4      p\        VR,          4      V8  d   \        RV: R24      hV#   \         d{    T pT^ 8  d1   T^,          pTP                  \        T,          4       T^,          pK7  TP	                  4        R\
        P                  ! RRRP                  T4      4      ,           p Li ; i)z
:param int_val: An unsigned integer.

:param width: Maximum allowed width (in bits) of a unsigned integer.

:return: Equivalent string value in Python's binary representation format
    ('0bxxx').
r<   z^[0]+([01]+)$z\1r   :   NNzbinary string out of bounds: r'   )
bin	NameErrorr   r6   r7   _resubr	   r   r   )r!   r/   
bin_tokensr>   r   r$   s   &&    r   
int_to_binrG      s     JOg, 72;%wHIIN  	O!et8DmD12!GA!15"''*:MNN	Os   8 BB=<B=c                |    \        W4      '       g   \        RV : R24      h\        V P                  RR4      ^4      # )a!  
:param bin_val: A string containing an unsigned integer in Python's binary
    representation format ('0bxxx').

:param width: Maximum allowed width (in bits) of a unsigned integer.

:return: An unsigned integer that is equivalent to value represented
    by Python binary string format.
z"not a valid Python binary string: r'   r<   r   )r?   r(   r   r.   )r>   r/   s   &&r   
bin_to_intrI     s5     W$$GMNNwtR(!,,r   )r   )__doc__rerD   r   r6   r   r%   r*   r1   r3   r:   r?   rG   rI    r   r   <module>rM      sM    " 4"6.@,$D@>-r   