관리-도구
편집 파일: base.cpython-37.pyc
B �A�[�L � @ s� d dl mZmZ d dlZd dlZd dlZd dlZd dlZd dlZd dl Z d dl mZ d dlm Z mZmZmZmZ d dlmZmZmZ er�d dlZdd� Zdd � ZG d d� de�ZG dd � d e�ZG dd� de�ZG dd� dej�Ze�ed�Zdd� Z dd� Z!dd� Z"dd� Z#e$ejd��s(ejj%ej_&d$dd�Z'e$ejd��sNe ejde'� G dd� de(�Z)G d d!� d!e)�Z*d%d"d#�Z+e$ejd#��s�e ejd#e+� dS )&� )�print_function�absolute_importN)�dedent)�bind_method�PY26�PY3�PY2�PY27)�check_output�STDOUT�CalledProcessErrorc C s | � d�r| dd� } t| �S )z, Removes any leading and dedents. � � N)� startswithr )�code� r �B/opt/alt/python37/lib/python3.7/site-packages/future/tests/base.py� reformat_code s r c sh | � d�� dd� t� �D �}dd� t� �D �}dd� t� �D �}| �� | ksTtd��dd� }d d � }||�||�ks|td��t� fdd�|D ��}tt||��}t� fd d�|D ��}tt||��} t� fdd�|D ��} tt|| ��}g }xptt� ��D ]`} | |k�r|� || � q�| |k�r2|� | | � q�| |k�rL|� || � q�|� � | � q�W d� |�S )a Returns the code block with any ``__future__`` import lines sorted, and then any ``future`` import lines sorted, then any ``builtins`` import lines sorted. This only sorts the lines within the expected blocks. See test_order_future_lines() for an example. r c S s g | ]\}}|� d �r|�qS )zfrom __future__ import )r )�.0�i�liner r r � <listcomp>* s z&order_future_lines.<locals>.<listcomp>c S s( g | ] \}}|� d �s |� d�r|�qS )zfrom futurez from past)r )r r r r r r r - s c S s g | ]\}}|� d �r|�qS )z from builtins)r )r r r r r r r 1 s zIinternal usage error: dedent the code before calling order_future_lines()c S s t | �dkrt| �S dS )Nr )�len�max)�numbersr r r �mymax7 s z!order_future_lines.<locals>.mymaxc S s t | �dkrt| �S td�S )Nr �inf)r �min�float)r r r r �mymin: s z!order_future_lines.<locals>.myminz2the __future__ and future imports are out of orderc s g | ]}� | �qS r r )r r )�linesr r r C s c s g | ]}� | �qS r r )r r )r r r r F s c s g | ]}� | �qS r r )r r )r r r r I s )�split� enumerate�lstrip�AssertionError�sorted�dict�zip�ranger �append�join)r Zuufuture_line_numbersZfuture_line_numbersZbuiltins_line_numbersr r ZuulZsorted_uufuture_linesZflZsorted_future_linesZblZsorted_builtins_linesZ new_linesr r )r r �order_future_lines s2 r+ c @ s"