mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-12 19:49:32 +02:00
Handle deprecation of importlib.resources APIs
This commit is contained in:
@@ -8,12 +8,8 @@ import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from functools import partial
|
||||
try:
|
||||
from importlib.resources import read_binary
|
||||
except ImportError:
|
||||
from importlib_resources import read_binary
|
||||
|
||||
from kitty.constants import is_macos
|
||||
from kitty.constants import is_macos, read_kitty_resource
|
||||
from kitty.fast_data_types import (
|
||||
DECAWM, get_fallback_font, sprite_map_set_layout, sprite_map_set_limits,
|
||||
test_render_line, test_sprite_position_for, wcwidth
|
||||
@@ -88,7 +84,7 @@ class Rendering(BaseTest):
|
||||
if name not in font_path_cache:
|
||||
with open(os.path.join(self.tdir, name), 'wb') as f:
|
||||
font_path_cache[name] = f.name
|
||||
data = read_binary(__name__.rpartition('.')[0], name)
|
||||
data = read_kitty_resource(name, __name__.rpartition('.')[0])
|
||||
f.write(data)
|
||||
return font_path_cache[name]
|
||||
|
||||
|
||||
@@ -6,11 +6,21 @@ import importlib
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
try:
|
||||
from typing import Callable, Generator, NoReturn, Sequence, Set, Iterable
|
||||
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from importlib.resources import files
|
||||
|
||||
def contents(package: str) -> Iterable[str]:
|
||||
return (path.name for path in files(package).iterdir())
|
||||
elif sys.version_info < (3, 7):
|
||||
from importlib_resources import files
|
||||
|
||||
def contents(package: str) -> Iterable[str]:
|
||||
return (path.name for path in files(package).iterdir())
|
||||
else:
|
||||
from importlib.resources import contents
|
||||
except Exception:
|
||||
from importlib_resources import contents
|
||||
from typing import Callable, Generator, NoReturn, Sequence, Set
|
||||
|
||||
|
||||
def itertests(suite: unittest.TestSuite) -> Generator[unittest.TestCase, None, None]:
|
||||
|
||||
Reference in New Issue
Block a user