
    g                         d Z ddlZddlZddlZddlZddlZddlZddlmZm	Z	m
Z
mZ ddlmZmZ ddlmZ  ej"                  e      Zd Zd Zy)aE  
Usage: coloredlogs [OPTIONS] [ARGS]

The coloredlogs program provides a simple command line interface for the Python
package by the same name.

Supported options:

  -c, --convert, --to-html

    Capture the output of an external command (given by the positional
    arguments) and convert ANSI escape sequences in the output to HTML.

    If the `coloredlogs' program is attached to an interactive terminal it will
    write the generated HTML to a temporary file and open that file in a web
    browser, otherwise the generated HTML will be written to standard output.

    This requires the `script' program to fake the external command into
    thinking that it's attached to an interactive terminal (in order to enable
    output of ANSI escape sequences).

    If the command didn't produce any output then no HTML will be produced on
    standard output, this is to avoid empty emails from cron jobs.

  -d, --demo

    Perform a simple demonstration of the coloredlogs package to show the
    colored logging on an interactive terminal.

  -h, --help

    Show this message and exit.
    N)connected_to_terminaloutputusagewarning)captureconvert)demonstrate_colored_loggingc                     g } 	 t        j                   t        j                  dd dg d      \  }}|D ]j  \  }}|dv r,| j                  t	        j
                  t        g|        g }6|dv r| j                  t               P|dv rt        t                yJ d        | st        t               y	 | D ]	  } |         y# t        $ r+}t        d	|       t        j                  d       Y d}~>d}~ww xY w)
z7Command line interface for the ``coloredlogs`` program.   Ncdh)r   zto-htmldemohelp)z-cz	--convertz	--to-html)z-dz--demo)z-hz--helpz$Programming error: Unhandled option!z	Error: %s)getoptsysargvappend	functoolspartialconvert_command_outputr	   r   __doc__	Exceptionr   exit)actionsoptions	argumentsoptionvalueefunctions          D/var/www/openai/venv/lib/python3.12/site-packages/coloredlogs/cli.pymainr!   <   s    G#]]388AB< A
  %MFE99y001GT)TU	++:;++gDDDu % 'N  
   Qs   BC C 	C6!C11C6c                  D   t        |       }t        |      }t               rUt        j                  d      \  }}t        |d      5 }|j                  |       ddd       t        j
                  |       y|r|j                         st        |       yyy# 1 sw Y   ?xY w)a  
    Command line interface for ``coloredlogs --to-html``.

    Takes a command (and its arguments) and runs the program under ``script``
    (emulating an interactive terminal), intercepts the output of the command
    and converts ANSI escape sequences in the output to HTML.
    z.html)suffixwN)
r   r   r   tempfilemkstempopenwrite
webbrowserisspacer   )commandcaptured_outputconverted_outputfdtemporary_filehandles         r    r   r   Z   s     g&O/%--W=N.#&&LL)* ''	!8!8!:  "; '&s   BB)r   r   r   loggingr   r%   r)   humanfriendly.terminalr   r   r   r   coloredlogs.converterr   r   coloredlogs.demor	   	getLogger__name__loggerr!   r        r    <module>r:      sN    F    
   Q P 3 8 
		8	$<!r9   