,C d dl Z d dlZd dlZd dlZd dlmZ d dlmZ d dlm Z ddl
mZ ddl
mZ ddl
m
Z
dd l
mZ dd
l
mZ ddl
mZ ddl
mZ dd
l
mZ ddl
mZ ddl
mZ ddlmZ ej rd dlZ ej d Z ej d ZdedefdZdJdZ dej! defdZ"dKdede#defdZ$ G d d! Z% G d" d# Z& dLd&ej' ej! d'ej' ej( ej! d(e)d)e)d*ej' e) ddfd+Z*dd,dej+ fd-Z, dMdd,d/ej' e d0ej' e dej- fd1Z. dNd3ed4ed/ej' e d0ej' e d5e)d6e)dej( ej! fd7Z/ dOd3d8d9e)defd:Z0dPd;edZ1 G d? d@ Z2 dQdAej' e dBej' e defdCZ3d$d$d$dDdEej4 e dFe)dGe)dHe)dej5 e f
dIZ6dS )R N)update_wrapper)
ModuleType)
TracebackType )_default_text_stderr)_default_text_stdout)_find_binary_writer)auto_wrap_for_ansi)binary_streams)open_stream)should_strip_ansi)
strip_ansi)text_streams)WIN)resolve_color_defaultPRnamereturnc t d | S )N-)joinsplitlower)r s k/builddir/build/BUILD/imunify360-venv-2.6.2/opt/imunify360/venv/lib/python3.11/site-packages/click/utils.py _posixifyr s( 88DJJLL!!''))) funct.Callable[P, R]t.Callable[P, t.Optional[R]]c f dddddt j t f fd}t | S )z0Wraps a function so that it swallows exceptions.argszP.argskwargszP.kwargsr c : | i |S # t $ r Y nw xY wd S N) Exception)r" r# r s r wrapperzsafecall..wrapper$ sB 4(((( D ts
)tOptionalr r )r r' s ` r safecallr* ! sN x : !*Q- '4(((r valuec t | t rM | t j S # t
$ r | dd cY S w xY wt
| S )z%Converts a value into a valid string.utf-8replace)
isinstancebytesdecodesysgetfilesystemencodingUnicodeErrorstr)r+ s r make_strr6 . su % 4 4<< 9 ; ;<<< 4 4 4<<33333 4u::s %= A A - help
max_lengthc | d }|dk r
| d| } | }|sdS |d dk r
|dd }d}t | dz
}t | D ]b\ }}|t | |dk z z
}||k r nR|d dk r"d |d|dz c S ||k r||k r ncd | S |t d
z
}|dk r1|t || |dk z z }||k rn|dz }|dk 1d |d| d
z S )z+Returns a condensed version of help string.z
N r r . z...)findr len enumerater )r8 r9
paragraph_endwordstotal_length
last_indexiwords r make_default_short_helprI 8 s IIf%%MN]N#
JJLLE r
Qx4abb LUaJU## 4D QU++*$$E8s??88E'AE'N+++++:%%!z//Exx CJJL a%%E!H
Q//:%% Q
a%% 88E"1"I&&r c e Zd ZdZ ddej edf ded ej e d
ej e def
dZ d
edej
fdZdefdZdej
ej
fdZddZddZddZdej ej e dej e dej e ddfdZdej ej fdZdS )LazyFilezA lazy file works like a regular file but it does not fully open
the file but it does perform some basic checks early to see if the
filename parameter does make sense. This is useful for safely opening
files for writing.
rNstrictFfilenamezos.PathLike[str]modeencodingerrorsatomicc 8 t j | | _ || _ || _ || _ || _ | | | j dk r!t |||| \ | _ | _ d S d|v r"t || d | _ d| _ d S )Nr rL T)osfspathr rO rP rQ rR r _fshould_closeopenclose)selfrN rO rP rQ rR s r __init__zLazyFile.__init__q s 8,,
(9)4XtXv)V)V&DGT&&&d{{ Xt$$**,,,DG $Dr r r c F t | | S r% )getattrrX rZ r s r __getattr__zLazyFile.__getattr__ s tyy{{D)))r c x | j t | j S dt | j d| j dS )Nz)rV reprformat_filenamer rO rZ s r __repr__zLazyFile.__repr__ s= 7== L/$)"<"<LL LLLLr c | j | j S t | j | j | j | j | j \ }| _ n0# t $ r#}ddl m
} || j |j |d}~ww xY w|| _ |S )zOpens the file if it's not yet open. This call might fail with
a :exc:`FileError`. Not handling this error will produce an error
that Click shows.
NrR r ) FileError)hint)rV r r rO rP rQ rR rW OSError
exceptionsrh strerror)rZ rverh s r rX z
LazyFile.open s
77N ?$/ 49dmT[% % %!B!! ? ? ?------)DIAJ777Q> ? s 5A
A3A..A3c J | j | j dS dS )z+Closes the underlying file, no matter what.N)rV rY rd s r rY zLazyFile.close s% 7GMMOOOOO r c @ | j r| dS dS )zThis function only closes the file if it was opened by the lazy
file wrapper. For instance this will never close stdin.
N)rW rY rd s r close_intelligentlyzLazyFile.close_intelligently s* JJLLLLL r c | S r% rd s r __enter__zLazyFile.__enter__ r exc_type exc_valuetbc . | d S r% )rq rZ rv rw rx s r __exit__zLazyFile.__exit__ s
"""""r c R | t | j S r% )rX iterrV rd s r __iter__zLazyFile.__iter__ s DG}}r )rL NrM Fr N)r rK )__name__
__module____qualname____doc__r( Unionr5 r) boolr[ Anyr_ re IOrX rY rq rt Type
BaseExceptionr r{ IteratorAnyStrr~ rs r r rK rK j s $("*
% %'#112% % *S/ %
3%
% % % %6* * * * * *M# M M M M
ad15k $
#*QVM23# :m,#
J}% #
# # # #!*QX. r rK c e Zd Zdej ej ddfdZdedej fdZddZ dej
ej e d ej
e d
ej
e
ddfdZdefdZdej ej fd
ZdS )KeepOpenFilefiler Nc || _ d S r% )_file)rZ r s r r[ zKeepOpenFile.__init__ s
"&
r r c , t | j | S r% )r] r r^ s r r_ zKeepOpenFile.__getattr__ s tz4(((r c | S r% rs rd s r rt zKeepOpenFile.__enter__ ru r rv rw rx c d S r% rs rz s r r{ zKeepOpenFile.__exit__ s
r c * t | j S r% )rb r rd s r re zKeepOpenFile.__repr__ DJr c * t | j S r% )r} r rd s r r~ zKeepOpenFile.__iter__ r r )r r )r r r r( r r r[ r5 r_ rt r) r r r r{ re r r r~ rs r r r r s 'QT!%[ 'T ' ' ' ') ) ) ) ) )
*QVM23
:m,
J}%
# !*QX. r r TFmessager nlerrcolorc |#|rt }nt }|dS | 2t | t t t
f st | }n| }|r$|pd}t |t r|dz
}n|dz
}|s| dS t |t t
f rQt | }|?| | | | dS n^t | }t || rt | }n/t r(t t | }n|st | }| | | dS )a Print a message and newline to stdout or a file. This should be
used instead of :func:`print` because it provides better support
for different data, files, and environments.
Compared to :func:`print`, this does the following:
- Ensures that the output encoding is not misconfigured on Linux.
- Supports Unicode in the Windows console.
- Supports writing to binary outputs, and supports writing bytes
to text outputs.
- Supports colors and styles on Windows.
- Removes ANSI color and style codes if the output does not look
like an interactive terminal.
- Always flushes the output.
:param message: The string or bytes to output. Other objects are
converted to strings.
:param file: The file to write to. Defaults to ``stdout``.
:param err: Write to ``stderr`` instead of ``stdout``.
:param nl: Print a newline after the message. Enabled by default.
:param color: Force showing or hiding colors and other styles. By
default Click will remove color if the output does not look like
an interactive terminal.
.. versionchanged:: 6.0
Support Unicode output on the Windows console. Click does not
modify ``sys.stdout``, so ``sys.stdout.write()`` and ``print()``
will still not support Unicode.
.. versionchanged:: 4.0
Added the ``color`` parameter.
.. versionadded:: 3.0
Added the ``err`` parameter.
.. versionchanged:: 2.0
Support colors on Windows if colorama is installed.
Nr<