<s> from six import string_types <EOL> from importlib import import_module <EOL> def import_callable ( path_or_callable ) : <EOL> if hasattr ( path_or_callable , '<STR_LIT>' ) : <EOL> return path_or_callable <EOL> else : <EOL> assert isinstance ( path_or_callable , string_types ) <EOL> package , attr = path_or_callable . rsplit ( '<STR_LIT:.>' , <NUM_LIT:1> ) <EOL> return getattr ( import_module ( package ) , attr ) <EOL> def default_create_token ( token_model , user , serializer ) : <EOL> token , _ = token_model . objects . get_or_create ( user = user ) <EOL> return token <EOL> def jwt_encode ( user ) : <EOL> try : <EOL> from rest_framework_jwt . settings import api_settings <EOL> except ImportError : <EOL> raise ImportError ( '<STR_LIT>' ) <EOL> jwt_payload_handler = api_settings . JWT_PAYLOAD_HANDLER <EOL> jwt_encode_handler = api_settings . JWT_ENCODE_HANDLER <EOL> payload = jwt_payload_handler ( user ) <EOL> return jwt_encode_handler ( payload ) </s>
