Fallback to importlib_resources on python 3.6
This commit is contained in:
parent
c2a924a5ea
commit
dbc1ade5a9
@ -123,7 +123,10 @@ def run_kitten(kitten: str, run_name: str = '__main__') -> None:
|
||||
|
||||
@run_once
|
||||
def all_kitten_names() -> FrozenSet[str]:
|
||||
try:
|
||||
from importlib.resources import contents
|
||||
except ImportError:
|
||||
from importlib_resources import contents # type: ignore
|
||||
ans = []
|
||||
for name in contents('kittens'):
|
||||
if '__' not in name and '.' not in name and name != 'tui':
|
||||
|
||||
@ -197,5 +197,8 @@ def resolve_custom_file(path: str) -> str:
|
||||
|
||||
|
||||
def read_kitty_resource(name: str) -> bytes:
|
||||
try:
|
||||
from importlib.resources import read_binary
|
||||
except ImportError:
|
||||
from importlib_resources import read_binary # type: ignore
|
||||
return read_binary('kitty', name)
|
||||
|
||||
@ -8,7 +8,10 @@ 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.fast_data_types import (
|
||||
|
||||
@ -6,7 +6,10 @@ import importlib
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
try:
|
||||
from importlib.resources import contents
|
||||
except Exception:
|
||||
from importlib_resources import contents
|
||||
from typing import Callable, Generator, NoReturn, Sequence, Set
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user