DRYer
This commit is contained in:
parent
e6e339fcd3
commit
8c23f9e526
@ -360,12 +360,8 @@ def load_custom_processor(customize_processing: str) -> Any:
|
||||
return {k: getattr(m, k) for k in dir(m)}
|
||||
if customize_processing == '::linenum::':
|
||||
return {'mark': linenum_marks, 'handle_result': linenum_handle_result}
|
||||
from kitty.constants import config_dir
|
||||
customize_processing = os.path.expandvars(os.path.expanduser(customize_processing))
|
||||
if os.path.isabs(customize_processing):
|
||||
custom_path = customize_processing
|
||||
else:
|
||||
custom_path = os.path.join(config_dir, customize_processing)
|
||||
from kitty.constants import resolve_custom_file
|
||||
custom_path = resolve_custom_file(customize_processing)
|
||||
import runpy
|
||||
return runpy.run_path(custom_path, run_name='__main__')
|
||||
|
||||
|
||||
@ -198,3 +198,10 @@ def running_in_kitty(set_val: Optional[bool] = None) -> bool:
|
||||
if set_val is not None:
|
||||
setattr(running_in_kitty, 'ans', set_val)
|
||||
return bool(getattr(running_in_kitty, 'ans', False))
|
||||
|
||||
|
||||
def resolve_custom_file(path: str) -> str:
|
||||
path = os.path.expandvars(os.path.expanduser(path))
|
||||
if not os.path.isabs(path):
|
||||
path = os.path.join(config_dir, path)
|
||||
return path
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user