From db47ba2d7e039c98135983159bf9ce2f8818a720 Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Mon, 4 May 2020 07:17:20 +0100 Subject: [PATCH] Move get_files tests to separate file --- my/common.py | 13 ++++++++----- tests/{common.py => get_files.py} | 0 2 files changed, 8 insertions(+), 5 deletions(-) rename tests/{common.py => get_files.py} (100%) diff --git a/my/common.py b/my/common.py index 0d26310..2ce3d38 100644 --- a/my/common.py +++ b/my/common.py @@ -182,15 +182,18 @@ def _magic(): # TODO could reuse in pdf module? -import mimetypes # TODO do I need init()? -def fastermime(path: str) -> str: +import mimetypes # todo do I need init()? +# todo wtf? fastermime thinks it's mime is application/json even if the extension is xz?? +# whereas magic detects correctly: application/x-zstd and application/x-xz +def fastermime(path: PathIsh) -> str: + paths = str(path) # mimetypes is faster - (mime, _) = mimetypes.guess_type(path) + (mime, _) = mimetypes.guess_type(paths) if mime is not None: return mime # magic is slower but returns more stuff - # TODO FIXME Result type; it's inherently racey - return _magic().from_file(path) + # TODO Result type?; it's kinda racey, but perhaps better to let the caller decide? + return _magic().from_file(paths) Json = Dict[str, Any] diff --git a/tests/common.py b/tests/get_files.py similarity index 100% rename from tests/common.py rename to tests/get_files.py