Files @ c447e51fad04
Branch filter:

Location: C3L-NOC/spaceapi/spaceapi/utils.py

Dennis Fink
use key a name instead of el in first function
from flask import request


def request_wants_json():
    best = request.accept_mimetypes.best_match(
        ['application/json', 'text/html']
    )
    return best == 'application/json' and \
        request.accept_mimetypes[best] > \
        request.accept_mimetypes['text/html']


def fuzzy_list_find(lst, key, value):

    for i, dic in enumerate(lst):
        if dic[key] == value:
            return i

    raise ValueError


def first(iterable, keys):
    for key in keys:
        if key in iterable:
            return key

    raise ValueError