示例#1
0
文件: api.py 项目: skoranda/pyFF
class MediaAccept(object):
    def __init__(self, accept):
        self._type = AcceptableType(accept)

    def has_key(self, key):
        return True

    def get(self, item):
        return self._type.matches(item)

    def __contains__(self, item):
        return self._type.matches(item)
示例#2
0
文件: api.py 项目: clarin-eric/pyFF
class MediaAccept(object):
    def __init__(self, accept: str):
        self._type = AcceptableType(accept)

    def has_key(self, key: Any) -> bool:  # Literal[True]:
        return True

    def get(self, item: Any) -> Any:
        return self._type.matches(item)

    def __contains__(self, item: Any) -> Any:
        return self._type.matches(item)

    def __str__(self) -> str:
        return str(self._type)
示例#3
0
def _get_return_type(
    accept: Optional[str],
) -> Tuple[Union[Type[CSVResponse], Type[ArrowResponse]], str]:
    if accept is None:
        accept = "*/*"
    type_ = AcceptableType(accept)

    if type_.matches("text/csv"):
        return CSVResponse, "text/csv"
    elif type_.matches("application/vnd.apache.arrow.file"):
        return ArrowResponse, "application/vnd.apache.arrow.file"
    else:
        raise HTTPException(
            status_code=406,
            detail=
            "Only 'text/csv' or 'application/vnd.apache.arrow.file' acceptable",
        )
示例#4
0
文件: api.py 项目: mrvanes/pyFFplus
 def __init__(self, accept):
     self._type = AcceptableType(accept)