-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH: drop importlib_resources dependency
Signed-off-by: Filipe Laíns <[email protected]>
- Loading branch information
Showing
3 changed files
with
11 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
# SPDX-FileCopyrightText: 2021 Filipe Laíns <[email protected]> | ||
|
||
import functools | ||
import importlib.resources | ||
import os | ||
import pathlib | ||
import sys | ||
|
@@ -37,6 +38,13 @@ | |
cached_property = lambda x: property(functools.lru_cache(maxsize=None)(x)) # noqa: E731 | ||
|
||
|
||
if sys.version_info >= (3, 9): | ||
def read_binary(package: str, resource: str) -> bytes: | ||
return importlib.resources.files(package).joinpath(resource).read_bytes() | ||
else: | ||
read_binary = importlib.resources.read_binary | ||
|
||
|
||
Path = Union[str, os.PathLike] | ||
|
||
|
||
|
@@ -52,6 +60,7 @@ def is_relative_to(path: pathlib.Path, other: Union[pathlib.Path, str]) -> bool: | |
__all__ = [ | ||
'cached_property', | ||
'is_relative_to', | ||
'read_binary', | ||
'typing_get_args', | ||
'Collection', | ||
'Iterable', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters