Improve some utility functions

Make expandvars accept both $VARNAME and ${VARNAME} now matches
the behavior of posixpath.expandvars

Allow overriding the environment variables to_cmdline expands against
This commit is contained in:
Kovid Goyal
2020-09-18 13:25:59 +05:30
parent e36d41b46f
commit be1ff61e4a
3 changed files with 44 additions and 14 deletions

View File

@@ -13,7 +13,7 @@ from typing import (
from . import fast_data_types as defines
from .conf.definition import Option, Shortcut, option_func
from .conf.utils import (
choices, positive_float, positive_int, to_bool, to_cmdline, to_color,
choices, positive_float, positive_int, to_bool, to_cmdline as tc, to_color,
to_color_or_none, unit_float
)
from .constants import FloatEdges, config_dir, is_macos
@@ -29,6 +29,10 @@ mod_map = {'CTRL': 'CONTROL', 'CMD': 'SUPER', '⌘': 'SUPER',
'': 'ALT', 'OPTION': 'ALT', 'KITTY_MOD': 'KITTY'}
def to_cmdline(x: str) -> List[str]:
return tc(x)
def parse_mods(parts: Iterable[str], sc: str) -> Optional[int]:
def map_mod(m: str) -> str: