Changeset - 75e886b91cc0
[Not reviewed]
default
0 1 0
Dennis Fink - 10 years ago 2015-07-07 19:19:52
dennis.fink@c3l.lu
Fixed line endings in utils.py
1 file changed with 27 insertions and 25 deletions:
0 comments (0 inline, 0 general)
spaceapi/utils.py
Show inline comments
 
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 el in keys:
 
		if el in iterable:
 
			return el
 
 
	raise ValueError
 
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 el in keys:
 
        if el in iterable:
 
            return el
 

	
 
    raise ValueError
0 comments (0 inline, 0 general)