File: //lib/python3.6/site-packages/awscli/customizations/s3/__pycache__/utils.cpython-36.opt-1.pyc
3
�U_Dm � @ s� d dl Z d dlZd dlmZ d dlZd dlZd dlZd dlZd dlZd dlm Z m
Z
d dlmZ d dl
mZmZ d dlmZ d dlmZ d dlmZ eje�Zd]Zeddde� d�Zd_Zdd`dadbddcddded�Zejd�Zejd�Zdd� Zdd� Z G dd� de j!�Z"G d d!� d!e#�Z$G d"d#� d#ej%�Z&d$d%� Z'd&d'� Z(d(d)� Z)dfd*d+�Z*dgd-d.�Z+G d/d0� d0e,�Z-d1d2� Z.ej/j0fd3d4�Z1d5d6� Z2G d7d8� d8e#�Z3d9d:� Z4G d;d<� d<e,�Z5G d=d>� d>e d>d?d@dAdBg��Z6e6Z7G dCdD� dDe,�Z8G dEdF� dFe�Z9G dGdH� dHe�Z:G dIdJ� dJe:�Z;G dKdL� dLe;�Z<G dMdN� dNe<�Z=G dOdP� dPe;�Z>G dQdR� dRe�Z?G dSdT� dTe?�Z@G dUdV� dVe?�ZAG dWdX� dXe:�ZBG dYdZ� dZe�ZCG d[d\� d\e,�ZDdS )h� N)�datetime)�
namedtuple�deque)�parse)�tzlocal�tzutc)�BaseSubscriber)�bytes_print)�queue�KiB�MiB�GiB�TiB�PiB�EiBi� � )Ztzinfo� i � � � )ZkbZmbZgb�tbZkibZmibZgibZtibzT^(?P<bucket>arn:(aws).*:s3:[a-z\-0-9]+:[0-9]{12}:accesspoint[:/][^/]+)/?(?P<key>.*)$z�^(?P<bucket>arn:(aws).*:s3-outposts:[a-z\-0-9]+:[0-9]{12}:outpost[/:][a-zA-Z0-9\-]{1,63}[/:]accesspoint[/:][a-zA-Z0-9\-]{1,63})[/:]?(?P<key>.*)$c C sv d}t | �}|dkrdS ||k r(d| S xHtt�D ]<\}}||d }t|| | �|k r2d|| | |f S q2W dS )a� Convert a size in bytes into a human readable format.
For example::
>>> human_readable_size(1)
'1 Byte'
>>> human_readable_size(10)
'10 Bytes'
>>> human_readable_size(1024)
'1.0 KiB'
>>> human_readable_size(1024 * 1024)
'1.0 MiB'
:param value: The size in bytes.
:return: The size in a human readable format based on base-2 units.
i r z1 Bytez%d Bytesr z%.1f %sN)�float� enumerate�HUMANIZE_SUFFIXES�round)�value�baseZ bytes_int�i�suffixZunit� r �/usr/lib/python3.6/utils.py�human_readable_size8 s r! c C s� | j � } | dd� dkr*| dd� j � }n| dd� j � }t| �dkoL|tk}|s~yt| �S tk
rz td| ��Y q�X n"t| }t| dt|� � �| S dS ) a Converts a human readable size to bytes.
:param value: A string such as "10MB". If a suffix is not included,
then the value is assumed to be an integer representing the size
in bytes.
:returns: The converted value in bytes as an integer
r NZibr zInvalid size value: %s������r"