You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
607 B
Python
22 lines
607 B
Python
# Copyright (C) 2022 Intel Corporation
|
|
# Copyright (C) 2022 CVAT.ai Corporation
|
|
#
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any, Dict, Sequence
|
|
|
|
import urllib3
|
|
|
|
|
|
def assert_status(code: int, response: urllib3.HTTPResponse) -> None:
|
|
if response.status != code:
|
|
raise Exception(f"Unexpected status code received {response.status}")
|
|
|
|
|
|
def filter_dict(
|
|
d: Dict[str, Any], *, keep: Sequence[str] = None, drop: Sequence[str] = None
|
|
) -> Dict[str, Any]:
|
|
return {k: v for k, v in d.items() if (not keep or k in keep) and (not drop or k not in drop)}
|