mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-08-04 06:36:24 +00:00
More pointless code churn thanks to importlib.resources
They've deprecated a bunch of API but the suggested replacement is either not present in versions of python that are not EOLed or doesn't actually work.
This commit is contained in:
parent
e309e54002
commit
93563f1280
2 changed files with 8 additions and 1 deletions
|
|
@ -221,6 +221,8 @@ def running_in_kitty(set_val: Optional[bool] = None) -> bool:
|
|||
|
||||
def list_kitty_resources(package: str = 'kitty') -> Iterator[str]:
|
||||
try:
|
||||
if sys.version_info[:2] < (3, 10):
|
||||
raise ImportError('importlib.resources.files() doesnt work with frozen builds on python 3.9')
|
||||
from importlib.resources import files
|
||||
except ImportError:
|
||||
from importlib.resources import contents
|
||||
|
|
@ -231,6 +233,8 @@ def list_kitty_resources(package: str = 'kitty') -> Iterator[str]:
|
|||
|
||||
def read_kitty_resource(name: str, package_name: str = 'kitty') -> bytes:
|
||||
try:
|
||||
if sys.version_info[:2] < (3, 10):
|
||||
raise ImportError('importlib.resources.files() doesnt work with frozen builds on python 3.9')
|
||||
from importlib.resources import files
|
||||
except ImportError:
|
||||
from importlib.resources import read_binary
|
||||
|
|
|
|||
|
|
@ -4,12 +4,15 @@
|
|||
import importlib
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
import unittest
|
||||
from typing import Callable, Generator, NoReturn, Sequence, Set, Iterator
|
||||
from typing import Callable, Generator, Iterator, NoReturn, Sequence, Set
|
||||
|
||||
|
||||
def contents(package: str) -> Iterator[str]:
|
||||
try:
|
||||
if sys.version_info[:2] < (3, 10):
|
||||
raise ImportError('importlib.resources.files() doesnt work with frozen builds on python 3.9')
|
||||
from importlib.resources import files
|
||||
except ImportError:
|
||||
from importlib.resources import contents
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue