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
|
@run_once
|
||||||
def all_kitten_names() -> FrozenSet[str]:
|
def all_kitten_names() -> FrozenSet[str]:
|
||||||
from importlib.resources import contents
|
try:
|
||||||
|
from importlib.resources import contents
|
||||||
|
except ImportError:
|
||||||
|
from importlib_resources import contents # type: ignore
|
||||||
ans = []
|
ans = []
|
||||||
for name in contents('kittens'):
|
for name in contents('kittens'):
|
||||||
if '__' not in name and '.' not in name and name != 'tui':
|
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:
|
def read_kitty_resource(name: str) -> bytes:
|
||||||
from importlib.resources import read_binary
|
try:
|
||||||
|
from importlib.resources import read_binary
|
||||||
|
except ImportError:
|
||||||
|
from importlib_resources import read_binary # type: ignore
|
||||||
return read_binary('kitty', name)
|
return read_binary('kitty', name)
|
||||||
|
|||||||
@ -8,7 +8,10 @@ import sys
|
|||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from importlib.resources import read_binary
|
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
|
||||||
from kitty.fast_data_types import (
|
from kitty.fast_data_types import (
|
||||||
|
|||||||
@ -6,7 +6,10 @@ import importlib
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
from importlib.resources import contents
|
try:
|
||||||
|
from importlib.resources import contents
|
||||||
|
except Exception:
|
||||||
|
from importlib_resources import contents
|
||||||
from typing import Callable, Generator, NoReturn, Sequence, Set
|
from typing import Callable, Generator, NoReturn, Sequence, Set
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user