<s> import base64 <EOL> import sys <EOL> from . _common_models import ( <EOL> _unicode_type , <EOL> ) <EOL> def _encode_base64 ( data ) : <EOL> if isinstance ( data , _unicode_type ) : <EOL> data = data . encode ( '<STR_LIT:utf-8>' ) <EOL> encoded = base64 . b64encode ( data ) <EOL> return encoded . decode ( '<STR_LIT:utf-8>' ) <EOL> def _decode_base64_to_bytes ( data ) : <EOL> if isinstance ( data , _unicode_type ) : <EOL> data = data . encode ( '<STR_LIT:utf-8>' ) <EOL> return base64 . b64decode ( data ) <EOL> def _decode_base64_to_text ( data ) : <EOL> decoded_bytes = _decode_base64_to_bytes ( data ) <EOL> return decoded_bytes . decode ( '<STR_LIT:utf-8>' ) <EOL> if sys . version_info < ( <NUM_LIT:3> , ) : <EOL> def _str ( value ) : <EOL> if isinstance ( value , unicode ) : <EOL> return value . encode ( '<STR_LIT:utf-8>' ) <EOL> return str ( value ) <EOL> else : <EOL> _str = str <EOL> def _str_or_none ( value ) : <EOL> if value is None : <EOL> return None <EOL> return _str ( value ) <EOL> def _int_or_none ( value ) : <EOL> if value is None : <EOL> return None <EOL> return str ( int ( value ) ) <EOL> def _bool_or_none ( value ) : <EOL> if value is None : <EOL> return None <EOL> if isinstance ( value , bool ) : <EOL> if value : <EOL> return '<STR_LIT:true>' <EOL> else : <EOL> return '<STR_LIT:false>' <EOL> return str ( value ) <EOL> def _lower ( text ) : <EOL> return text . lower ( ) </s>
