
    h^&                         S r SSKrSSKrSSKrSSKrSSKrSSKJrJrJ	r	J
r
JrJrJr  SSKJrJr  SSKJrJrJrJrJrJrJrJrJrJr  SSKJr  SrS rS	 r S
 r!S r"S r#S r$S r%S r&S r'S r(SS jr)g)aN  
Usage: humanfriendly [OPTIONS]

Human friendly input/output (text formatting) on the command
line based on the Python package with the same name.

Supported options:

  -c, --run-command

    Execute an external command (given as the positional arguments) and render
    a spinner and timer while the command is running. The exit status of the
    command is propagated.

  --format-table

    Read tabular data from standard input (each line is a row and each
    whitespace separated field is a column), format the data as a table and
    print the resulting table to standard output. See also the --delimiter
    option.

  -d, --delimiter=VALUE

    Change the delimiter used by --format-table to VALUE (a string). By default
    all whitespace is treated as a delimiter.

  -l, --format-length=LENGTH

    Convert a length count (given as the integer or float LENGTH) into a human
    readable string and print that string to standard output.

  -n, --format-number=VALUE

    Format a number (given as the integer or floating point number VALUE) with
    thousands separators and two decimal places (if needed) and print the
    formatted number to standard output.

  -s, --format-size=BYTES

    Convert a byte count (given as the integer BYTES) into a human readable
    string and print that string to standard output.

  -b, --binary

    Change the output of -s, --format-size to use binary multiples of bytes
    (base-2) instead of the default decimal multiples of bytes (base-10).

  -t, --format-timespan=SECONDS

    Convert a number of seconds (given as the floating point number SECONDS)
    into a human readable timespan and print that string to standard output.

  --parse-length=VALUE

    Parse a human readable length (given as the string VALUE) and print the
    number of metres to standard output.

  --parse-size=VALUE

    Parse a human readable data size (given as the string VALUE) and print the
    number of bytes to standard output.

  --demo

    Demonstrate changing the style and color of the terminal font using ANSI
    escape sequences.

  -h, --help

    Show this message and exit.
    N)Timerformat_lengthformat_numberformat_sizeformat_timespanparse_length
parse_size)format_pretty_tableformat_smart_table)
ANSI_COLOR_CODESANSI_TEXT_STYLESHIGHLIGHT_COLOR
ansi_strip	ansi_wrapenable_ansi_supportfind_terminal_sizeoutputusagewarning)Spinner)demonstrate_256_colorsdemonstrate_ansi_formattingmainprint_formatted_lengthprint_formatted_numberprint_formatted_sizeprint_formatted_tableprint_formatted_timespanprint_parsed_lengthprint_parsed_sizerun_commandc                  8   [        5          [        R                  " [        R                  SS S/ SQ5      u  p/ nSnSn[        S W  5       5      nU  GH  u  pxUS;   a  UnM  US	:X  a,  UR                  [        R                  " [        U5      5        MB  US
:X  a,  UR                  [        R                  " [        U5      5        Mt  US;   a,  UR                  [        R                  " [        W5      5        M  US;   a,  UR                  [        R                  " [        U5      5        M  US;   a-  UR                  [        R                  " [        U5      5        GM  US;   a-  UR                  [        R                  " [         X5      5        GM>  US:X  a  SnGMI  US;   a-  UR                  [        R                  " ["        U5      5        GM|  US:X  a  UR                  [$        5        GM  US;   d  GM  ['        [(        5          g   U(       a*  UR                  [        R                  " [*        U5      5        U(       d  ['        [(        5        gU H
  n	U	" 5         M     g! [         a-  n[        SU5        [        R                  " S5         SnAGN[SnAff = f)z9Command line interface for the ``humanfriendly`` program.   Nzcd:l:n:s:bt:h)zrun-commandzformat-tablez
delimiter=zformat-length=zformat-number=zformat-size=binaryzformat-timespan=zparse-length=zparse-size=demohelpz	Error: %sFc              3   0   #    U  H  u  pUS ;   v   M     g7f))z-bz--binaryN ).0ovs      K/var/www/fran/franai/venv/lib/python3.13/site-packages/humanfriendly/cli.py	<genexpr>main.<locals>.<genexpr>   s     =WTQ((Ws   )z-dz--delimiterz--parse-sizez--parse-length)z-cz--run-command)z-lz--format-length)z-nz--format-number)z-sz--format-sizez--format-tableT)z-tz--format-timespanz--demo)z-hz--help)r   getoptsysargv	Exceptionr   exitanyappend	functoolspartialr    r   r!   r   r   r   r   r   r   __doc__r   )
options	argumentseactions	delimitershould_format_tabler$   optionvaluer7   s
             r,   r   r      s   #]]388AB< K
  GI=W==F **I~%NN9,,->FG''NN9,,-@%HI..NN9,,[)DE00NN9,,-CUKL00NN9,,-CUKL..NN9,,-A5QR''"&22NN9,,-EuMNxNN67'''N/ !0 y(()>	JKg	 I  Qs   -I" "
J,"JJc                    [        5       nSSR                  [        [        R                  U 5      5      -  n[        X!S9 n[        R                  " U 5      n UR                  5         UR                  5         UR                  5       b  OM4  SSS5        [        R                  " WR                  5        g! , (       d  f       N/= f)zHRun an external command and show a spinner while the command is running.zWaiting for command: %s )labeltimerN)r   joinmappipesquoter   
subprocessPopenstepsleeppollr0   r3   
returncode)command_linerD   spinner_labelspinnerprocesss        r,   r!   r!      s    GE-U[[,9W0XXM	}	2g""<0LLNMMO||~)	  
3 HHW  
3	2s    AB55
Cc                     SU ;   a  [        [        [        U 5      5      5        g[        [        [        U 5      5      5        g)zPrint a human readable length..N)r   r   floatintr@   s    r,   r   r      s+    
e|}U5\*+}SZ()    c                 >    [        [        [        U 5      5      5        g)z/Print large numbers in a human readable format.N)r   r   rU   rW   s    r,   r   r      s    
=u&'rX   c                 <    [        [        [        U 5      US95        g)zPrint a human readable size.)r$   N)r   r   rV   )r@   r$   s     r,   r   r      s    
;s5z&12rX   c                     / n[         R                   H3  nUR                  5       nUR                  UR	                  U 5      5        M5     [        [        U5      5        g)z8Read tabular data from standard input and print a table.N)r0   stdinrstripr5   splitr   r
   )r=   datalines      r,   r   r      sE    D		{{}DJJy)*  t$%rX   c                 >    [        [        [        U 5      5      5        g)z Print a human readable timespan.N)r   r   rU   rW   s    r,   r   r      s    
?5<()rX   c                 ,    [        [        U 5      5        g)z=Parse a human readable length and print the number of metres.N)r   r   rW   s    r,   r   r      s    
<rX   c                 ,    [        [        U 5      5        g)z?Parse a human readable data size and print the number of bytes.N)r   r	   rW   s    r,   r    r       s    
:erX   c                     [        S[        SSS95        SS/n U R                  [        R                  " 5       5        [        U 5       HP  n[        [        S9nUS:w  a  SX!'   UR                  SS	5      R                  5       n[        S
[        U40 UD65        MR     S GH  u  pES[        5       4S[        SS94/nUS:w  a  UR                  SS[        SS945        [        S[        SU-  SS9-  5        [        [        [        [        R                  " 5       5       VVV	s/ s HU  nU/U VV	s/ s H>  u  p[        US:w  a  SOS40 [        [        U	R                  5       5      XG4/-   5      D6PM@     sn	n-   PMW     sn	nnS/U VV	s/ s H  u  pUR                  5       PM     sn	n-   S95        GM     [        SSS5        [        SSS5        [        SSS5        [        SS S!5        g"s  sn	nf s  sn	nnf s  sn	nf )#z-Demonstrate the use of ANSI escape sequences.z%szText styles:Tboldnormalbrightcolor_rB   z - %s))rj   zForeground colors)
backgroundzBackground colors)rh   rl   r   faint)rm   z
%s%s:XXXXXXz      Color)column_names   zstandard colors      zhigh-intensity colors      z
216 colors      zgray scale colorsN)r   r   extendr   keyssorteddictr   replace
capitalizeinsertr   r   listitemsr   )
styles
style_namer9   style_label
color_typecolor_labelintensities
color_namerC   kws
             r,   r   r      s    4>56!F
MM"'')*Vn
_-!"&G ((c2==?w	+99: %$I
 tvt4()
 %q7Dt,<"=>v	%+"5DAAB! !''7'<'<'> ?#
 !@* L $/	 $/ie  *l :H4
+
/G.HHI $/	 
 !@#
 !	0;%
0;95E%
 
	 		$I( 1a!231b"9:2sL13%89#
%
s   !G0.AG*3
G0G7*G0c                 n   SnU(       a  USU-  -  n[        S[        SU-  SS9-   5        SR                  S [        XS	-   5       5       5      n[	        5       u  pVU[        [        U5      5      :  a  [        U5        g[        [        U5      5      S	-   n[        Xg-  5      n[        XS	-   5       V	s/ s H%  n	[        [        U	5      R                  U5      U	S
9PM'     n
n	[        S[        U
5      U5       V	s/ s H	  oXU-    PM     nn	[        SR                  S U 5       5      5        gs  sn	f s  sn	f )z#Demonstrate 256 color mode support.z256 color modez (%s)
rn   Tre    c              3   N   #    U  H  nS [        [        U5      US9-   v   M     g7f)rB   ri   N)r   str)r)   ns     r,   r-   )demonstrate_256_colors.<locals>.<genexpr>  s      TOq#	#a& ::Os   #%r#   ri   r   c              3   D   #    U  H  nS R                  U5      v   M     g7f)r   N)rE   )r)   bs     r,   r-   r   #  s     4VVs    N)
r   r   rE   ranger   lenr   r   rV   rjust)ijgrouprC   single_linelinescolumnswidthcolors_per_liner   colorsblockss               r,   r   r     s    E5 
4)EEM556 ''TE!QRUOTTK')NE#j-..{ CFago.CHPQE?S?a)CFLL/q9?S9>q#f+9_`9_A./9_`tyy4V445 T`s   3,D-9D2)N)*r8   r6   r/   rG   rI   r0   humanfriendlyr   r   r   r   r   r   r	   humanfriendly.tablesr
   r   humanfriendly.terminalr   r   r   r   r   r   r   r   r   r   humanfriendly.terminal.spinnersr   __all__r   r!   r   r   r   r   r   r   r    r   r   r(   rX   r,   <module>r      s   FR     
   I   4.b!*(
3
&*
 

$:N6rX   