관리-도구
편집 파일: editor.cpython-311.pyc
� �܋f� � � � 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 ddd�Zdd�Zdd�Zd d�ZdS )!� )�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� � dS # t $ r}t d|�d�� � |�d}~ww xY 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. NzError executing editor (�))�osr �_find_editorr � Exceptionr )r r �env�editor�excs �J/opt/cloudlinux/venv/lib64/python3.11/site-packages/alembic/util/editor.py�open_in_editorr s{ � � ��"�*�*�W�C�L��c�"�"���F�H�%�&�&�&�&�&��� L� L� L��l�C�C�C�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 |vr|� ||� � �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�����K�K�K� � � 5�� � � r. � Optional[str]c � � t st | � � d dk r| dz } |� dd� � � 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�� ����F�B�'�'�-�-�b�j�9�9� � ���T�9�%�%���%�=�=� ��L�L�L� ��4r0 � List[str]c � � t rg d�S g d�S )N)zsensible-editorr �nano�vim�code)zcode.exez notepad++.exeznotepad.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>