File: //lib/python3/dist-packages/awscli/__pycache__/compat.cpython-38.pyc
U
<�^�I � @ s� d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl m
Z
d dl mZ e
jZe
j
Z
e
jjZe
jjZe
jZe
jZe
jjjjZe
jZzd dlZejZW n ek
r� ejZY nX zd dlZW n ek
r� dZY nX e jdkZe�rdZndZG dd� de�Z G d d
� d
e!�Z"dd� Z#e
j
�r�d dl$m%Z& d dl'Z'd dl(m)Z* d d
l+m,Z, e-Z.dd� Z/dd� Z0dd� Z1d?dd�Z2d@dd�Z3ndd dl4Z4d dl5Z&d dl'Z'd dl6Z6d dl*Z*d d
l7m,Z, e.Z.dd� Z/dd� Z0dd� Z1dAdd�Z2dBdd�Z3dd� Z8d d!� Z9d"d#� Z:dCd$d%�Z;d&d'� Z<dDd(d)�Z=ej>d*d+� �Z?zd d,lm@Z@ W n� ek
�r� d-ZAd.d/� ZBe�Cd0ejD�ZEe�Cd1ejD�ZFe�Cd2ejD�ZGd3ZHd4d5� ZIe�Cd6ejJ�ZKe�Cd7ejJ�ZLe�Cd8ejJ�ZMd9d9d9eHd:fd;d<�Z@d=d>� ZNY nX dS )E� N)�six)�OrderedDict�win32Zmorezless -Rc s e Zd Z� fdd�Z� ZS )�StdinMissingErrorc s d}t t| ��|� d S )Nz;stdin is required for this operation, but is not available.)�superr �__init__)�self�message�� __class__� �//usr/lib/python3/dist-packages/awscli/compat.pyr B s �zStdinMissingError.__init__)�__name__�
__module__�__qualname__r �
__classcell__r r r
r
r A s r c @ s e Zd ZdZdd� Zdd� ZdS )�NonTranslatedStdouta This context manager sets the line-end translation mode for stdout.
It is deliberately set to binary mode so that `
` does not get added to
the line ending. This can be useful when printing commands where a
windows style line ending would casuse errors.
c C s. t jdkr(dd l}|�t j�� tj�| _t jS �Nr r ) �sys�platform�msvcrt�setmode�stdout�fileno�osZO_BINARY�
previous_mode)r r r r r
� __enter__Q s
�zNonTranslatedStdout.__enter__c C s* t jdkr&dd l}|�t j�� | j� d S r )r r r r r r r )r �type�value� tracebackr r r r
�__exit__X s
zNonTranslatedStdout.__exit__N)r r r �__doc__r r r r r r
r I s r c C s: t | tj�r| S t | tj�r&| �d�S tdt| � ��d S )N�utf-8z,Expected str, unicode or bytes, received %s.)�
isinstancer Z text_type�binary_type�decode�
ValueErrorr )�sr r r
�ensure_text_type^ s
r( )�URLErrorc C s t jd krt� �t jjS �N)r �stdinr �bufferr r r r
�get_binary_stdino s
r- c C s t jjS r* )r r r, r r r r
�get_binary_stdoutt s r. c C s | S r* r )�stream�errorsr r r
�_get_text_writerw s r1 �rc C s d|krt �� }t| ||d�S )a> Back-port open() that accepts an encoding argument.
In python3 this uses the built in open() and in python2 this
uses the io.open() function.
If the file is not being opened in binary mode, then we'll
use locale.getpreferredencoding() to find the preferred
encoding.
�b��encoding)�locale�getpreferredencoding�open��filename�moder5 r r r
�compat_openz s r<