<s> """<STR_LIT>""" <EOL> __version__ = '<STR_LIT>' <EOL> from _bitarray import _bitarray , bits2bytes , _sysinfo <EOL> def _btree_insert ( tree , sym , ba ) : <EOL> """<STR_LIT>""" <EOL> v = ba [ <NUM_LIT:0> ] <EOL> if len ( ba ) > <NUM_LIT:1> : <EOL> if tree [ v ] == [ ] : <EOL> tree [ v ] = [ [ ] , [ ] ] <EOL> _btree_insert ( tree [ v ] , sym , ba [ <NUM_LIT:1> : ] ) <EOL> else : <EOL> if tree [ v ] != [ ] : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> tree [ v ] = sym <EOL> def _mk_tree ( codedict ) : <EOL> tree = [ [ ] , [ ] ] <EOL> for sym , ba in codedict . iteritems ( ) : <EOL> _btree_insert ( tree , sym , ba ) <EOL> return tree <EOL> def _check_codedict ( codedict ) : <EOL> if not isinstance ( codedict , dict ) : <EOL> raise TypeError ( "<STR_LIT>" ) <EOL> if len ( codedict ) == <NUM_LIT:0> : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> for k , v in codedict . iteritems ( ) : <EOL> if not isinstance ( v , bitarray ) : <EOL> raise TypeError ( "<STR_LIT>" ) <EOL> if v . length ( ) == <NUM_LIT:0> : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> class bitarray ( _bitarray ) : <EOL> """<STR_LIT>""" <EOL> def decode ( self , codedict ) : <EOL> """<STR_LIT>""" <EOL> _check_codedict ( codedict ) <EOL> return self . _decode ( _mk_tree ( codedict ) ) <EOL> def encode ( self , codedict , iterable ) : <EOL> """<STR_LIT>""" <EOL> _check_codedict ( codedict ) <EOL> return self . _encode ( codedict , iterable ) <EOL> def search ( self , x , limit = - <NUM_LIT:1> ) : <EOL> """<STR_LIT>""" <EOL> return self . _search ( bitarray ( x ) , limit ) <EOL> def __contains__ ( self , other ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( other , int ) : <EOL> try : <EOL> self . index ( other ) <EOL> return True <EOL> except ValueError : <EOL> return False <EOL> else : <EOL> return bool ( self . _search ( bitarray ( other ) , <NUM_LIT:1> ) ) <EOL> def test ( verbosity = <NUM_LIT:1> ) : <EOL> """<STR_LIT>""" <EOL> import test_bitarray <EOL> return test_bitarray . run ( verbosity = verbosity ) </s>
