jf^ zdZddlZddlZddlZddlZddlZddlZddlmZ ddl m Z ddl m Z ddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZddlmZddlmZejdZejdkrdZdZndZdZGddej eZ!d0dej"e#dej$e%ddfdZ&dej"e#de#dej$e%ddfdZ'dej"e#de#dej$e%ddfdZ(d ej)dej"e#dej$e%ddfd!Z*Gd"d#Z+d1d%e#d&e%d'e%de,fd(Z-d)e#dej$e.fd*Z/er,ddl0Z0ej1dej2e,fd+Z3d,e%de#fd-Z4dSddl5Z5ddl6Z6ej1dej2e,fd.Z3d,e%de#fd/Z4dS)2z This module contains implementations for the termui module. To keep the import time of Click down, some infrequently used functionality is placed in this module and only imported as needed. N)gettext)StringIO) TracebackType)_default_text_stdout)CYGWIN)get_best_encoding)isatty) open_stream) strip_ansi)term_len)WIN)ClickException)echoVnt  z [?25lz[?25h c!"eZdZ d3d ejejed ejed ed ededede deje de dejej ejegejefdejedejej deje dededdf dZ d4dZ dejejedejedejeddfd Zdejefd!Zdefd"Zd5d#Zedefd$Zedefd%Zedefd&Zdefd'Zdefd(Zdefd)Zdefd*Zdefd+Zd5d,Z d-eddfd.Z!d6d-ed/ejeddfd0Z"d5d1Z#dejefd2Z$dS)7 ProgressBarN# %(bar)s TFriterablelength fill_char empty_char bar_templateinfo_sepshow_eta show_percentshow_positem_show_funclabelfilecolorupdate_min_stepswidthreturnc||_||_||_||_||_||_| |_| |_| pd|_| t} | t} | |_ | |_ ||_ d|_||_|dk|_|ddlm}||d}|dkrd}|H|t'dt)jt(jt.t1|}t3||_||_d|_g|_||t;jx|_|_d|_ d|_!d|_"d|_#d|_$tK|j  |_&d|_'dS)Nr) length_hintziterable or length is requiredF)(rrr r!r"r#r$r%r&rrr'r(r)_completed_intervalsr* autowidthoperatorr. TypeErrortcastIterablerrangeiterrposavgtimestartlast_eta eta_knownfinished max_widthentered current_itemr is_hidden _last_line)selfrrrrr r!r"r#r$r%r&r'r(r)r*r.s r/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/click/_termui_impl.py__init__zProgressBar.__init__&s$#$(    (  ,+2 <'))D|zz  0$%! $z > , , , , , , [2..F||  ~ @AAAvajmU6]];;H#'>>  "$  %)Y[[0 T]$# *." +/#)$)#4#44+/ProgressBar[V]c<d|_||S)NT)rArender_progressrEs rF __enter__zProgressBar.__enter__ks    rHexc_type exc_valuetbc.|dSN) render_finish)rErNrOrPs rF__exit__zProgressBar.__exit__ps rHc~|jstd||S)N.You need to use progress bars in a with block.)rA RuntimeErrorrK generatorrLs rF__iter__zProgressBar.__iter__xs>| QOPP P ~~rHc:tt|SrR)nextr8rLs rF__next__zProgressBar.__next__~s DJJrHc|jrdS|jt|jdSrR)rCr'write AFTER_BARflushrLs rFrSzProgressBar.render_finishs= >  F  """ rHcp|jrdSt|jt|jpdpdz dS)N?r)r?minr9floatrrLs rFpctzProgressBar.pcts< = 348uT[%5A66;!intrl)rEr4secondsminuteshourss rF format_etazProgressBar.format_etas > ?DH A"fG "HA"fG "HAFE "HA1uuCCuCCC'CCCwCCCC>>>W>>>'>>>>rrHcVt|j}|j |d|jz }|S)N/)strr9r)rEr9s rF format_poszProgressBar.format_poss1$(mm ; " $t{$$ $C rHcHt|jdzddddS)Ndz 4%r)rrrerLs rF format_pctzProgressBar.format_pcts+dhn%%++++ABB//rHc|j >CC ] !.4:-CCDJO!<==E&!++ N $(T-D"DEEKcQ*% ''%..C rHcj|j}g}|j ||j }|jr'|||r'|||jr5|jr.|js'|| |j 1| |j }||||j |j ||j|dzS)N)r&rinfo)r#rr$appendrzr~r"r>r?rvr%rBr r&rr!rrstrip)rEr# info_bits item_infos rFformat_progress_linez ProgressBar.format_progress_lines3(  ; "|';#},L = 0   T__.. / / /  0   T__.. / / / = 0T^ 0DM 0   T__.. / / /   *++D,=>>I$  +++  (( **955  &(( rHcddl}|jr?|j|jkr-|j|_t |j|j|jdSg}|jr|j}d|_t| }td| j |z }||kr>|t|d|jz||_||_|j}|j|j}|t| }t|}|j |j|kr||_|||d||z zd|}||jkr?||_t ||j|jd|jdSdS)Nr)r'r(rr-F)r'r(nl)shutilrCrDr&rr'r(r1r*r rmaxget_terminal_sizecolumnsr BEFORE_BARr@rr`) rErbuf old_widthclutter_length new_width clear_widthlineline_lens rFrKzProgressBar.render_progresss > $*,,"&*TZditzBBBB F > # IDJ%d&?&?&A&ABBNAv7799ANRSSI9$$ :&&& 3/000!*"DJj > %.K :((**D>> > !T^h%>%>%DN 4 3+01222wws|| 4? " ""DO DITZE B B B B IOO      # "rHn_stepsc|xj|z c_|j|j|jkrd|_tj|jz dkrdStj|_|jr$tj|jz |jz }ntj|jz }|jdd|gz|_|jdu|_dS)NTrbi)r9rr?r;r=r<r:r>)rErsteps rF make_stepzProgressBar.make_steps G ; "tx4;'>'> DM IKK$- '3 . . F  8 ,IKK$*,8DD9;;+D8BCC=D6)D0rHrBc|||_|xj|z c_|j|jkr7||j|d|_dSdS)aUpdate the progress bar by advancing a specified number of steps, and optionally set the ``current_item`` for this new position. :param n_steps: Number of steps to advance. :param current_item: Optional item to set as ``current_item`` for the updated position. .. versionchanged:: 8.0 Added the ``current_item`` optional parameter. .. versionchanged:: 8.0 Only render when the number of steps meets the ``update_min_steps`` threshold. Nr)rBr0r)rrK)rErrBs rFupdatezProgressBar.update'st  # ,D  !!W,!!  $(= = = NN44 5 5 5  " " "()D % % % > =rHc0d|_d|_d|_dS)NFT)r>rBr?rLs rFfinishzProgressBar.finishAs  rHc#DK|jstd|jr|jEd{VdS|jD]A}||_|jdkr||V|dB||dS)zReturn a generator which yields the items added to the bar during construction, and updates the progress bar *after* the yielded block returns. rVNrr) rArWrCr8rBr0rKrr)rErvs rFrXzProgressBar.generatorFs| QOPP P > #y i  $&! ,11((*** A KKMMM  " " " " "rH)NrrrrTNFNNNNrr)r+rI)r+NrR)%__name__ __module__ __qualname__r4Optionalr6rrrryboolCallableTextIOrGrMType BaseExceptionrrTIteratorrYr\rSpropertyrdrerjrlrvrzr~rrrKrrrrXrHrFrr%s#'%)-SW!%%)"& !!C0C0*QZ]+C0 3C0 C0  C0  C0C0C0j&C0C0 1:qz!}oqz#.N#OPC0z#C0j"C0z$C0C0 !C0" #C0C0C0C0J *QVM23:m, J} %    !*Q-     !     CUCCCXC 4E444X4 UX C    C 0C0000C&c6++++Z111111,**c*A*$****4 #1:a=######rHrrXr(r+cDt}|t}ttjrt|st |||St jddpd }|r)trt|||St|||St jddvrt |||Ststj drt|d|Stt dr)t jd d krt|d |Sd dl}|\}}t j| tt drAt jd |d d kr%t|d|t j|St |||t j|S#t j|wxYw)z2Decide what method to use for paging through text.NPAGERr-TERM)dumbemacsos2zmore <systemz(less) 2>/dev/nullrlesszmore ""more)rrr sysstdin _nullpagerosenvirongetstripr_tempfilepager _pipepagerplatform startswithhasattrrtempfilemkstempcloseunlink)rXr(stdout pager_cmdrfdfilenames rFpagerrhs ! # #F~ #)  4F6NN4&)U333..4";;==I7  ?!)Y>> >)Y666 z~~f!222&)U333 :cl%%e,,:i5999r84+?!@!@A!E!E)VU333OOO##%%LBHRLLL 2x  8RY/C/C/C/C%D%D%I%Ii77 (&)U33 ( (sAH $H Hcmdc(ddl}ttj}|ddd}|_|ddkrStjddd |dd}|sd |d<d }n d |vsd |vrd }||d |j |}tj tj |j }t|} |D]<} |st| } || | d= |n#t&t(f$rYnwxYw |dS#t($rYnwxYw()zqPage through text by feeding it to another program. Invoking a pager through this might support colors. rNrxrr/rLESSr-r-RTrR)shellrenvreplace) subprocessdictrrrsplitsplitrrPopenPIPEr4r5BinaryIOrr r r^encoderOSErrorKeyboardInterruptwait) rXrr(rr cmd_detail less_flagscrencodingtexts rFrrs rz  CC##B'--//J }A&00 vr22NCHHZ^4L4LNN  CKEE J  #"3"3ED SIIA F1:qw ' 'E ''H  : :D (!$'' KK Hi88 9 9 9 9  :   & '       FFHHH E!    D s$??EE('E(-F FFcFddl}|\}}d|}|st|}t t j}t|dd5}|| |dddn #1swxYwY tj |d|dtj |tj |dS#tj |tj |wxYw)zSimply print unformatted text. This is the ultimate fallback.N)r r^)rrXr(rs rFrrsG $d##D TrHc eZdZ ddejedejejeefdededdf d Zdefd Z d eddfd Z d ejej dejej fdZ dS)EditorNT.txteditorr require_save extensionr+c>||_||_||_||_dSrR)rrrr)rErrrrs rFrGzEditor.__init__s% ("rHc|j|jSdD]'}tj|}|r|cS(trdSdD]"}tjd|ddkr|cS#dS)N)VISUALEDITORnotepad)zsensible-editorvimnanozwhich z >/dev/null 2>&1rvi)rrrrrr)rEkeyrrs rF get_editorzEditor.get_editors ; "; %  C$$B     96  Fy:&:::;;q@@ AtrHrcddl}|}d}|jr8tj}||j ||d|d|d}|}|dkr0ttd |dS#t$r7}ttd || |d}~wwxYw) NrrrT)rrz{editor}: Editing failed)rz{editor}: Editing failed: {e})re) rrrrrcopyrrrr_formatr)rErrrrr exit_coders rF edit_filezEditor.edit_files"""04 8 %joo''G NN48 $ $ $   F!9!9h!9!9!9wd SSAIA~~$011888GG~    1229919MM  sA(C D2DDrcddl}|sd}nt|ttfr|}nb|r|ds|dz }t r*|ddd}n|d}|d|j \}} tj |d 5}| |dddn #1swxYwYtj |tj|tj|d z ftj|}|||jr:tj||kr tj|dSt)|d 5}|}dddn #1swxYwYt|ttfr|tj|S|dddtj|S#tj|wxYw) NrrHrz z utf-8-sigzutf-8zeditor-)prefixsuffixrrb)r isinstancebytes bytearrayendswithrrrrrrfdopenr^utimepathgetatimegetmtimerrropenreaddecode) rErrdatarnamer timestamprs rFeditz Editor.edit s ,DD ui0 1 1 ,DD DMM$//   ,||D&1188EE{{7++##9T^#LLD 2t$$                  HTBG,,T22BG4D4DT4J4JQ4NO P P P((..I NN4   RW%5%5d%;%;y%H%H IdOOOOOdD!! QVVXX               $ 233  IdOOOO99[))11&$?? IdOOOOBIdOOOOsa+I!C" I!"C&&I!)C&*B5I!6I!G' I!'G++I!.G+/ I!$(I!!I7)NNTr) rrrr4rryMappingrrGrrAnyStrrrrHrFrrs#'/3! # # 3 #Z #s(+ , # #  #  # # # # C    #$,-AH--!*QX2F------rHrFurlrlocatecddl}dtdtfd}tjdkrdg}|r|d|r|d|||t d d } ||| |S#|wxYwtra|r&|| d d }d|d }n%| d d }|rdnd }d|d|d }tj |Str~|rCtj|| d d }d|d }n%| d d }|rdnd }d|d|d }tj |S |r+tj||pd}n ||}|d|g}|r|SdS#t $r9|dr |s|sddl} | |YdSYdSwxYw)Nrrr+cbddlm}|dr||dd}|S)Nr)unquotezfile://) urllib.parser#r)rr#s rF _unquote_filezopen_url.._unquote_file@sD(((((( >>) $ $ #'#abb'""C rHdarwinrz-Wrz /dev/nullw)stderrrr-zexplorer /select,"z/WAITzstart z "" "z cygstart "z-wz cygstart r.zxdg-open)zhttp://zhttps://r)rryrrrrrrrrrrrrrdirnamerr webbrowser) rrr rr&argsnullwait_strrr,s rFopen_urlr0=s33 |xx   KK      KK    MM#&&'''K%% ##D#66;;== JJLLLLDJJLLLL   2- C 4 455C....DD++c2&&C"&.wwBH1H113111Dy   2'//--"4"4"<">1 2 2 6 $      OOC 11qq s(CC A$H22DD=D TVV ! ! ! $$&&LBR    rHc#Kttjs$td}|}n tj}d} t j|} tj||Vt j |t j |tj || dSdS#t j |t j |tj || wwxYw#t j$rYdSwxYw)Nz/dev/tty)r rrrfilenotermios tcgetattrttysetraw tcsetattr TCSADRAINrr`rerror)rr old_settingss rFr9r9s6 ci   Z  ABB!!##BA ",R00L  2!"g&7FFF   """=GGIIIII!=!"g&7FFF   """=GGIIII!}    DD s,!E6C&AE&AD==EEEcht5}tj|dt t jd}|r8tt jrt j |t||cdddS#1swxYwYdS)N r) r9rrrr rrr rr^r7)rrr1s rFrArAs ^^ rR''(9#)(D(DiPPB %sz** %   $$$  $ $ $                  sB B''B+.B+rR)FF)7__doc__ contextlibrrrr;typingr4rriortypesr_compatrrr r r r r r exceptionsrutilsrTypeVarrrrr_Genericrr6ryrrrrrrrrrrr0rr7r=contextmanagerrr9rArFrDrrHrFrYs   ))))))&&&&&& &&&&&& AIcNN7d??JIIJI@#@#@#@#@#!)A,@#@#@#F  QZ_ QZ-=     F/!*S///AJt    ]MMM!*S/-d-s------`JJJNNN!*S/4dsrH