def convert_config(config, exporter_class, allow_other):
    """convert config into required exporter format"""
    filters = {}
    preprocs = {}
    other = {}
    for key, val in config.items():
        if key in ['Exporter.filters', 'TemplateExporter.filters']:
            filters.update(config[key])
        if key in ['Exporter.preprocessors', 'TemplateExporter.preprocessors']:
            if preprocs:
                raise ValueError(
                    "'config' contains both Exporter.preprocessors and TemplateExporter.preprocessors"
                    )
            for p in val:
                pname = p.split('.')[-1]
                preprocs[pname] = {'class': p, 'args': {}}
                if pname in ['LatexDocLinks', 'LatexDocHTML']:
                    preprocs[pname]['args']['metapath'] = '${meta_path}'
                    preprocs[pname]['args']['filesfolder'] = '${files_path}'
    for key, val in config.items():
        if key in ['Exporter.filters', 'TemplateExporter.filters',
            'Exporter.preprocessors', 'TemplateExporter.preprocessors']:
            continue
        if key.split('.')[0] in preprocs:
            preprocs[key.split('.')[0]]['args']['.'.join(key.split('.')[1:])
                ] = val
        else:
            other[key] = val
    if other and not allow_other:
        print('Warning: ignoring other args: {}'.format(other))
        other = {}
    output = {'class': exporter_class, 'filters': filters, 'preprocessors':
        list(preprocs.values()), 'other_args': other}
    return output
