U if :@s<ddlZddlZdgZdZejejdZGdddZdS)NCmdz(Cmd) _c@seZdZeZeZdZdZdZ dZ dZ dZ dZ dZdZd/d d Zd0d d ZddZddZddZddZddZddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Z d1d-d.Z!dS)2r=Nz(Documented commands (type help ):zMiscellaneous help topics:zUndocumented commands:z*** No help on %stabcCs@|dk r||_ntj|_|dk r(||_ntj|_g|_||_dSN)stdinsysstdoutcmdqueue completekey)selfr r r r(/opt/alt/python38/lib64/python3.8/cmd.py__init__Ls z Cmd.__init__cCs||jr\|jr\z2ddl}||_||j||jdWnt k rZYnXz|dk rl||_ |j r|j t |j dd}|s4|jr|jd}nl|jrzt|j}Wntk rd}YnXn<|j |j|j |j}t|sd}n |d}||}||}|||}q|W5|jr|jrzddl}||jWnt k r~YnXXdS)Nrz : complete EOFz )preloop use_rawinputr readlineZ get_completerZ old_completerZ set_completercompleteparse_and_bind ImportErrorintror writestrr popinputpromptEOFErrorflushr lenrstripprecmdonecmdpostcmdpostloop)rrrstoplinerrrcmdloopbsN           z Cmd.cmdloopcCs|Srrrr)rrrr$sz Cmd.precmdcCs|Srr)rr(r)rrrr&sz Cmd.postcmdcCsdSrrrrrrrsz Cmd.preloopcCsdSrrr,rrrr'sz Cmd.postloopcCs|}|sdd|fS|ddkr4d|dd}n2|ddkrft|dr\d|dd}n dd|fSdt|}}||kr|||jkr|d}qt|d|||d}}|||fS)Nr?zhelp r!Zdo_shellzshell )striphasattrr" identchars)rr)incmdargrrr parselines      z Cmd.parselinecCs||\}}}|s|S|dkr.||S||_|dkrBd|_|dkrT||Szt|d|}Wntk r||YSX||SdS)Nrrdo_)r6 emptylinedefaultlastcmdgetattrAttributeError)rr)r4r5funcrrrr%s   z Cmd.onecmdcCs|jr||jSdSr)r:r%r,rrrr8sz Cmd.emptylinecCs|jd|dS)Nz*** Unknown syntax: %s )r rr+rrrr9sz Cmd.defaultcGsgSrr)rignoredrrrcompletedefaultszCmd.completedefaultcsd|fdd|DS)Nr7cs"g|]}|r|ddqS)N startswith.0aZdotextrr s z%Cmd.completenames..) get_names)rtextr>rrFr completenamesszCmd.completenamesc Cs|dkrddl}|}|}t|t|}||}||}|dkr||\} } } | dkrp|j} qzt|d| } Wqt k r|j} YqXn|j } | |||||_ z |j |WSt k rYdSXdS)NrrZ complete_) rZget_line_bufferlstripr"Z get_begidxZ get_endidxr6r?r;r<rJZcompletion_matches IndexError) rrIstaterZorigliner)strippedZbegidxZendidxr4argsZfooZcompfuncrrrrs*   z Cmd.completecCs t|jSr)dir __class__r,rrrrHsz Cmd.get_namescs4t|j}tfdd|D}t||BS)Nc3s,|]$}|ddr|ddVqdS)help_rNrArCrOrr sz$Cmd.complete_help..)setrJrHlist)rrOZcommandsZtopicsrrTr complete_helpszCmd.complete_helpc Cs|rzt|d|}Wn|tk rz4t|d|j}|rX|jdt|WYdSWntk rnYnX|jdt|j|fYdSX|n|}g}g}i}|D]$}|dddkrd||dd<q|d} |D]p}|dddkr|| kr q|} |dd} | |kr8| | || =qt||jrR| | q| | q|jdt|j | |j |dd | |j t|dd | |j|dd dS) NrRr7%s rSrrr@P)r;r<__doc__r rrnohelprHsortappend doc_leader print_topics doc_header misc_headerrWkeys undoc_header) rr5r=docnamesZcmds_docZ cmds_undochelpnameZprevnamer4rrrdo_help$sN        z Cmd.do_helpcCs\|rX|jdt||jr<|jdt|jt||||d|jddS)NrYrr)r rrrulerr" columnize)rheaderZcmdsZcmdlenZmaxcolrrrraRs zCmd.print_topicsr[css|jddSfddttD}|rJtddtt|t}|dkrv|jdtddStdtD]}||d|}g}d }t|D]h} d} t|D]2} | || } | |krq| } t| t| } q| | || d 7}||krqq||krq4qt}d}dg}t|D]} g}t|D]4} | || } | |krld } n| } | | qL|r|d s|d =qtt|D]} ||  || || <q|jdtd |q csg|]}t|ts|qSr) isinstancer)rDr2rWrrrGdsz!Cmd.columnize..z list[i] not a string for i in %sz, rrYrrz ) r rranger" TypeErrorjoinmaprmaxr_ljust)rrWZ displaywidthZ nonstringssizeZnrowsZncolsZ colwidthsZtotwidthcolZcolwidthrowr2xZtextsrrorrlZs\           z Cmd.columnize)rNN)N)r[)"__name__ __module__ __qualname__PROMPTr IDENTCHARSr1rkr:rr`rbrcrer]rrr*r$r&rr'r6r%r8r9r?rJrrHrXrjrarlrrrrr4s:   4   .)stringr __all__rZ ascii_lettersZdigitsrrrrrr-s