Use a nicer decorator for functions that only need to be run once

This commit is contained in:
Kovid Goyal
2021-02-05 10:40:52 +05:30
parent 726d736aac
commit fe07306ff1
11 changed files with 67 additions and 31 deletions

View File

@@ -6,9 +6,11 @@
import importlib
import os
import sys
from functools import lru_cache, partial
from functools import partial
from typing import Any, Dict, FrozenSet, List
from kitty.types import run_once
aliases = {'url_hints': 'hints'}
@@ -57,8 +59,9 @@ def create_kitten_handler(kitten: str, orig_args: List[str]) -> Any:
def set_debug(kitten: str) -> None:
from kittens.tui.loop import debug
import builtins
from kittens.tui.loop import debug
setattr(builtins, 'debug', debug)
@@ -118,7 +121,7 @@ def run_kitten(kitten: str, run_name: str = '__main__') -> None:
m['main'](sys.argv)
@lru_cache(maxsize=2)
@run_once
def all_kitten_names() -> FrozenSet[str]:
n = []
import glob