mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-22 16:28:19 +02:00
Use importlib.resources to enumerate kitten names
This commit is contained in:
@@ -123,14 +123,12 @@ 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]:
|
||||||
n = []
|
from importlib.resources import contents
|
||||||
import glob
|
ans = []
|
||||||
base = os.path.dirname(os.path.abspath(__file__))
|
for name in contents('kittens'):
|
||||||
for x in glob.glob(os.path.join(base, '*', '__init__.py')):
|
if '__' not in name and name != 'tui':
|
||||||
q = os.path.basename(os.path.dirname(x))
|
ans.append(name)
|
||||||
if q != 'tui':
|
return frozenset(ans)
|
||||||
n.append(q)
|
|
||||||
return frozenset(n)
|
|
||||||
|
|
||||||
|
|
||||||
def list_kittens() -> None:
|
def list_kittens() -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user