3 �gaR � @ s� d dl Z d dlZd dlmZ d dlmZmZ yd dlZW n ek rP dZY nX ddl m Z ddlmZm Z mZ ddlmZ ddlmZ G d d � d �ZdS )� N)�Path)�IO�Optional� )� is_windows)�DEFAULT_CONFIG_DIR�Config�ConfigFileError)�UTF8)� repr_dictc @ sJ e Zd ZU dZeZeeZee j Z ee e r8e j � ndZedZee jZeej � ZedZee jZeej � ZedZdZees�er�yej� ejd�ZW q� ejk r� Y q�X n6ddlZejjeddddd �Zejjeddddd �Z[dd d�Z dd � Z!dd� Z"dZ#e$#e%e$d�dd��Z&e%ed�dd��Z'ddd�Z(dS )�Environmenta Information about the execution context (standard streams, config directory, etc). By default, it represents the actual environment. All of the attributes can be overwritten though, which is used by the test suite to simulate various scenarios. FN� Zhttp�colorsr T)Zconvert�stripZ autoresetZwrapc s� t � fdd�|j� D ��st�� jjf |� � j� _|� _� jr^� j dkr^t � jdd�pZt� _ � jdkr�� j }tr�ddlm} t� j |�r�� j j}t |dd�p�t� _dS )zl Use keyword arguments to overwrite any of the class attributes for this instance. c 3 s | ]}t t� �|�V qd S )N)�hasattr�type)�.0�attr)�self� �/usr/lib/python3.6/context.py� <genexpr>C s z'Environment.__init__.<locals>.<genexpr>N�encodingr )�AnsiToWin32)�all�keys�AssertionError�__dict__�update�stderr�_orig_stderr�_devnull�stdin�stdin_encoding�getattrr �stdout_encoding�stdoutr �coloramar � isinstance�wrapped)r �devnull�kwargsZ actual_stdoutr r )r r �__init__= s zEnvironment.__init__c C sB t t| �j�}t |�}|j| j� | j|d<