관리-도구
편집 파일: formatters.cpython-39.opt-1.pyc
a �)g � @ sd d dl mZmZmZ eZd dlZd dlmZ dddddd d ddd � Z dd� Z ddd�Zddd�ZdS )� )�absolute_import�division�print_functionN)� iteritemsl l l l l i @i i � ) �Y�Z�E�P�T�G�M�K�Bc C sB g }| D ]4}z|� |�� � W q ty: |� |� Y q0 q|S )zaLowercase elements of a list. If an element is not a string, pass it through untouched. )�append�lower�AttributeError)ZlstZlowered�value� r �O/usr/lib/python3.9/site-packages/ansible/module_utils/common/text/formatters.py�lenient_lowercase s r Fc C s` t jdt| �t jd�}|du r.tdt| � ��zt|�d��}W n( tyh td|�d�| f ��Y n0 |�d�}|du r�|}|du r�tt |��S |d � � }zt| }W n. ty� td | |d �t� � �f ��Y n0 d}d} |r�d }d} t|�dk�rPd|||f } |dk�r"d|| f } | |�� v �r2n|d |k�rPtd| | f ��tt || ��S )a� Convert number in string format into bytes (ex: '2K' => 2048) or using unit argument. example: human_to_bytes('10M') <=> human_to_bytes(10, 'M'). When isbits is False (default), converts bytes from a human-readable format to integer. example: human_to_bytes('1MB') returns 1048576 (int). The function expects 'B' (uppercase) as a byte identifier passed as a part of 'name' param string or 'unit', e.g. 'MB'/'KB'/etc. (except when the identifier is single 'b', it is perceived as a byte identifier too). if 'Mb'/'Kb'/... is passed, the ValueError will be rased. When isbits is True, converts bits from a human-readable format to integer. example: human_to_bytes('1Mb', isbits=True) returns 8388608 (int) - string bits representation was passed and return as a number or bits. The function expects 'b' (lowercase) as a bit identifier, e.g. 'Mb'/'Kb'/etc. if 'MB'/'KB'/... is passed, the ValueError will be rased. z^\s*(\d*\.?\d*)\s*([A-Za-z]+)?)�flagsNz5human_to_bytes() can't interpret following string: %sr zQhuman_to_bytes() can't interpret following number: %s (original input string: %s)� r zOhuman_to_bytes() failed to convert %s (unit = %s). The suffix must be one of %sz, r Zbyte�b�bitzexpect %s%s or %szexpect %s or %szGhuman_to_bytes() failed to convert %s. Value is not a valid string (%s))�re�search�str� IGNORECASE� ValueError�float�group� Exception�int�round�upper�SIZE_RANGES�join�keys�lenr )�numberZdefault_unit�isbits�mZnum�unitZ range_key�limitZ unit_classZunit_class_nameZexpect_messager r r �human_to_bytes'