|L i ddlmZddlZddlmZddlmZddlmZddlmZddl m Z ddl m Z dd l m Z dd l m Z d d lmZd d lmZ d ddZddZ ddZddZy)) annotationsN)exists)join)splitext) check_call)Dict)List)Mapping)Optionalis_posix) CommandErrorc|tjn|} t|}t||gy#t$r}t d|d|d}~wwxYw)a Opens the given file in a text editor. If the environment variable ``EDITOR`` is set, this is taken as preference. Otherwise, a list of commonly installed editors is tried. If no editor matches, an :py:exc:`OSError` is raised. :param filename: The filename to open. Will be passed verbatim to the editor command. :param environ: An optional drop-in replacement for ``os.environ``. Used mainly for testing. NzError executing editor ())osenviron _find_editorr Exceptionr)filenamerenveditorexcs Y/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/alembic/util/editor.pyopen_in_editorrsR  "**WCLc"FH%& LCABKLs/ A AA ct}tdD]C\}}||vs ||}t|r|cStj|vs2|j ||E|D]}t ||}||cStd)N)EDITORVISUALzSNo suitable editor found. Please set the "EDITOR" or "VISUAL" environment variables)_default_editors enumeraterrsepinsert_find_executableOSError)r candidatesivar user_choice candidatepaths rrr)s!#J0123 '>!#,Kk"""vv[(!!![1 2   73  K  5 ctst|ddk7r|dz }|jddjtj D]}t ||}t|s|cSy)Nr z.exePATH)rrgetsplitrpathseprr)r)rr*values rr#r#=sh +A.&8V  FB'--bjj9T9% %=L r+ctrgdSgdS)N)zsensible-editorrnanovimcode)zcode.exez notepad++.exez notepad.exer r+rrrKsCC;;r+)N)rstrrzOptional[Dict[str, str]]returnNone)rMapping[str, str]r9r8)r)r8rr;r9z Optional[str])r9z List[str]) __future__rros.pathrrr subprocessrtypingrr r r compatrrrrrr#rr7r+rrAsv" !8<LL4L L0(  .