bg ddlmZddlZddlmZddlmZddlmZddlmZddl m Z ddl m Z dd l m Z dd l m Z d d lmZd d lmZ dddZddZddZd dZdS)!) annotationsN)exists)join)splitext) check_call)Dict)List)Mapping)Optionalis_posix) CommandErrorfilenamestrenvironOptional[Dict[str, str]]returnNonec| tjn|} t|}t||gdS#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 ())osr _find_editorr Exceptionr)rrenveditorexcs J/opt/cloudlinux/venv/lib64/python3.11/site-packages/alembic/util/editor.pyopen_in_editorrs{  "**WCLc""FH%&&&&& LLLlCCCABBKLs 4 AAAMapping[str, str]c"t}tdD]H\}}||vr?||}t|r|cStj|vr|||I|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!##J011223 '>>!#,Kk"" #""""v[((!!![111  733  KKK   5  r. Optional[str]ctst|ddkr|dz }|ddtjD]%}t ||}t|r|cS&dS)Nr z.exePATH)rrgetsplitrpathseprr)r.rr/values rr(r(=s ++A.&88V  FB''--bj99T9%% %== LLL  4r0 List[str]c trgdSgdS)N)zsensible-editorrnanovimcode)zcode.exez notepad++.exez notepad.exer r0rr$r$Ks$<CCCC;;;;r0)N)rrrrrr)rr rr)r.rrr rr1)rr9) __future__rros.pathrrr subprocessrtypingrr r r compatrrrrrr(r$r>r0rrDs="""""" !!!!!!8<LLLLL0(    <<<<<