def handle(client, request):
    """
    Handle format request

    request struct:

        {
            'data': 'data_need_format',
            'formaters': [
                {
                    'name': 'formater_name',
                    'config': {}  # None or dict
                },
                ... # formaters
            ]
        }

    if no formaters, use autopep8 formater and it's default config
    """
    formaters = request.get('formaters', None)
    if not formaters:
        formaters = [{'name': 'autopep8'}]
    logging.debug('formaters: ' + json.dumps(formaters, indent=4))
    data = request.get('data', None)
    if not isinstance(data, str):
        return send(client, 'invalid data', None)

    max_line_length = None
    for formater in formaters:
        max_line_length = formater.get('config', {}).get('max_line_length')
        if max_line_length:
            break

    for formater in formaters:
        name = formater.get('name', None)
        config = formater.get('config', {})
        if name not in FORMATERS:
            return send(client, 'formater {} not support'.format(name), None)
        formater = FORMATERS[name]
        if formater is None:
            return send(client, 'formater {} not installed'.format(name), None)
        if name == 'isort' and max_line_length:
            config.setdefault('line_length', max_line_length)
        data = formater(data, **config)
    return send(client, None, data)
Handle format request

    request struct:

        {
            'data': 'data_need_format',
            'formaters': [
                {
                    'name': 'formater_name',
                    'config': {}  # None or dict
                },
                ... # formaters
            ]
        }

    if no formaters, use autopep8 formater and it's default config