
    Vh              
      j    d dl mZ d dlZd dlmZ dddddd	d
ddd	Zdddddddddd	Zd ZddZddZ	y)    )annotationsN)	iteritemsl               l            l            l           l        i   @i   i      )	YZEPTGMKB))byter   )bitb))kilobyteKB)kilobitKb))megabyteMB)megabitMb))gigabyteGB)gigabitGb))terabyteTB)terabitTb))petabytePB)petabitPb))exabyteEB)exabitEb))zetabyteZB)zetabitZb))	yottabyteYB)yottabitYb)	r   r   r   r   r
   r	   r   r   r   c                    g }| D ]"  }	 |j                  |j                                $ |S # t        $ r |j                  |       Y Cw xY w)zaLowercase elements of a list.

    If an element is not a string, pass it through untouched.
    )appendlowerAttributeError)lstloweredvalues      [/home/dcms/DCMS/lib/python3.12/site-packages/ansible/module_utils/common/text/formatters.pylenient_lowercaser:   $   sS    
 G "	"NN5;;=)"
 N  	"NN5!	"s   ,A	A	c                j   t        j                  dt        |             }|t        dt        |       z        	 t	        |j                  d            }|j                  d      }||}|t        t        |            S |d	   j                         }	 t        |   }d}d}	|rd}d}	t        |      dkD  rzd||d|}
|dk(  rd|d|	}
t        j                  |d      }|t        d|       |rdnd	}|j!                         ||   d	   k(  rn|||   d   k7  rt        d
| d|
d      t        t        ||z              S # t        $ r" t        d|j                  d      d| d      w xY w# t        $ r6 t        d
| d|ddj                  t        j                                     w xY w)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)^([0-9]*\.?[0-9]+)(?:\s*([A-Za-z]+))?\s*$Nz5human_to_bytes() can't interpret following string: %sr   z3human_to_bytes() can't interpret following number: z (original input string: )   r   z#human_to_bytes() failed to convert z	 (unit = z). The suffix must be one of z, r   r   r   r   zexpect z or z2human_to_bytes() can't interpret a valid unit for z. Value is not a valid string ()researchstr
ValueErrorfloatgroup	ExceptionintroundupperSIZE_RANGESjoinkeyslenVALID_UNITSgetr4   )numberdefault_unitisbitsmnumunit	range_keylimit
unit_classunit_class_nameexpect_message
unit_groupisbits_flags                r9   human_to_bytesr[   2   s   $ 			>FLAyPSVW]S^^__EAGGAJ 771:D||5:QI\I&
 JO

4y1}09:yQ2<oNN __Y5
QR[Q\]^^!aq::<:k2155Z,Q//jp  sA  B  C  CuS5[!""K  Epqpwpwxypz  }C  D  E  	EE  \ntvz  }A  }F  }F  GR  GW  GW  GY  }Z  [  \  	\\s   E 	E3 +E03?F2c                    d}|rd}d}t        t        t              d       D ]'  \  }}|| |k\  s||j                         |d   k(  s' n dk7  r	||d   z  }n|}d| |z  |fz  S )	NBytesbits c                    | d    S )Nr    )items    r9   <lambda>z bytes_to_human.<locals>.<lambda>x   s    $q'     )keyr   r   z%.2f %s)sortedr   rH   rG   )sizerP   rS   basesuffixrU   s         r9   bytes_to_humanrj   r   s    DF	+ 6<QR LTU]t/?DJJLTZ[\T]D] z$q'uf---rd   )NF)FN)

__future__r   r>   ansible.module_utils.sixr   rH   rL   r:   r[   rj   ra   rd   r9   <module>rm      sh   
 # 	 . 
								

 
'	0	0	0	0	0	.	0	2
=#@.rd   