mirror of
https://github.com/morpheus65535/bazarr
synced 2024-12-28 02:27:28 +00:00
35 lines
719 B
Python
35 lines
719 B
Python
import sys
|
|
|
|
try:
|
|
from collections import OrderedDict
|
|
except ImportError:
|
|
from ordereddict import OrderedDict
|
|
|
|
from werkzeug.http import HTTP_STATUS_CODES
|
|
|
|
PY3 = sys.version_info > (3,)
|
|
|
|
|
|
def http_status_message(code):
|
|
"""Maps an HTTP status code to the textual status"""
|
|
return HTTP_STATUS_CODES.get(code, '')
|
|
|
|
|
|
def unpack(value):
|
|
"""Return a three tuple of data, code, and headers"""
|
|
if not isinstance(value, tuple):
|
|
return value, 200, {}
|
|
|
|
try:
|
|
data, code, headers = value
|
|
return data, code, headers
|
|
except ValueError:
|
|
pass
|
|
|
|
try:
|
|
data, code = value
|
|
return data, code, {}
|
|
except ValueError:
|
|
pass
|
|
|
|
return value, 200, {}
|