
    ZeIi	                        d dl mZ d dlZd dlmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
 d dl	mZ d d	l	mZ d d
l	mZ ddlmZ ddlmZ 	 dddZddZddZd dZdS )!    )annotationsN)exists)join)splitext)
check_call)Dict)List)Mapping)Optional   is_posix)CommandErrorfilenamestrenvironOptional[Dict[str, str]]returnNonec                    |t           j        n|}	 t          |          }t          || g           dS # t          $ r}t          d|d          |d}~ww xY w)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.
    NzError executing editor ())osr   _find_editorr   	Exceptionr   )r   r   enveditorexcs        X/var/www/html/MCyber-Diagnostic/venv/lib/python3.11/site-packages/alembic/util/editor.pyopen_in_editorr      s{       "**WCLc""FH%&&&&& L L LlCCCABBKLs    4 
AAAMapping[str, str]c                "   t                      }t          d          D ]H\  }}|| v r?| |         }t          |          r|c S t          j        |vr|                    ||           I|D ]}t          ||           }||c S t          d          )N)EDITORVISUALzSNo suitable editor found. Please set the "EDITOR" or "VISUAL" environment variables)_default_editors	enumerater   r   sepinsert_find_executableOSError)r   
candidatesivaruser_choice	candidatepaths          r   r   r   )   s    !##J011 2 23'>>!#,Kk"" #""""v[((!!![111  		733KKK 
	5      r.   Optional[str]c                   t           st          |           d         dk    r| dz  } |                    dd                              t          j                  D ]%}t          ||           }t          |          r|c S &d S )Nr   z.exePATH )r   r   getsplitr   pathsepr   r   )r.   r   r/   values       r   r(   r(   =   s    
  ++A.&88V	FB''--bj99  T9%%%== 	LLL	4r0   	List[str]c                      t           rg dS g dS )N)zsensible-editorr   nanovimcode)zcode.exeznotepad++.exeznotepad.exer    r0   r   r$   r$   K   s$      <CCCC;;;;r0   )N)r   r   r   r   r   r   )r   r    r   r   )r.   r   r   r    r   r1   )r   r9   )
__future__r   r   os.pathr   r   r   
subprocessr   typingr   r	   r
   r   compatr   r   r   r   r   r(   r$   r>   r0   r   <module>rD      s=   " " " " " " 				                   ! ! ! ! ! !                                     8<L L L L L0   (   < < < < < <r0   