관리-도구
편집 파일: editor.cpython-38.pyc
U 0?�f� � @ s� d dl mZ d dlZd dlmZ d dlmZ d dlmZ d dlmZ d dl m Z d dl mZ d d l mZ d d l m Z ddlmZ dd lmZ d dddd�dd�Zddd�dd�Zdddd�dd�Zdd�dd�ZdS )!� )�annotationsN)�exists)�join)�splitext)� check_call)�Dict)�List)�Mapping)�Optional� ��is_posix)�CommandError�strzOptional[Dict[str, str]]�None)�filename�environ�returnc C sb |dkrt jn|}zt|�}t|| g� W n2 tk r\ } ztd|f �|�W 5 d}~X Y nX dS )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 (%s))�osr �_find_editorr � Exceptionr )r r �env�editor�exc� r �A/opt/hc_python/lib/python3.8/site-packages/alembic/util/editor.py�open_in_editor s r zMapping[str, str])r r c C s~ t � }td�D ]>\}}|| kr| | }t|�r6| S tj|kr|�||� q|D ]}t|| �}|d k rR| S qRtd��d S )N)ZEDITORZVISUALzSNo suitable editor found. Please set the "EDITOR" or "VISUAL" environment variables)�_default_editors� enumerater r �sep�insert�_find_executable�OSError)r � candidates�i�varZuser_choice� candidate�pathr r r r ) s �r z Optional[str])r&