ó J¡Vc@sKddlZddlZddlTddlmZddlmZddlmZddd„Z dd „Z dd „Z d „Z d „Zd d d„Zd„Zd„Zd d„Zdd„Zd„Zdefd„ƒYZdefd„ƒYZdZdZdZded„Zded„Zd„Zed„Zd„Z dS( iÿÿÿÿNi(t*(tutils(tPY3(tinputtycCst|ƒtdƒkr6|dkr-t}q6t}n|dkrb|rU|d7}ql|d7}n ||7}x¥try%ttj|ƒƒjƒjƒ}Wnt k r°qonX|sÁt|fS|dkr×ttfS|dkríttfS|d krt|fStj dƒqoWdS( NtRs (y=yes*, n=no, q=quit) ? s (y=yes, n=no*, q=quit) ? tntqtcs/Please press or enter 'y', 'n', or 'q'.(RR( ttypetTruetFalsetNoneRtlogtboldtlowertstriptEOFErrorterror(tquestiont default_valuet choice_promptt user_input((sX/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/tui.pyt enter_yes_no!s.        %        cCsüxõtr÷y%ttj|ƒƒjƒjƒ}Wntk rDqnX|sd|dk rdt|fSn|dkrzt|fSyt |ƒ}Wn+t k r·tj d||fƒqnX||ksÐ||krítj d||fƒqnt|fSWdS(NRs8Please enter a number between %d and %d, or "q" to quit.( R RR RRRRR R tintt ValueErrorR(Rt min_valuet max_valueRRt value_int((sX/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/tui.pyt enter_rangeGs* %        cCsd|kr|jdƒnxåtry%ttj|ƒƒjƒjƒ}Wntk r`qnX| rn|sz||kr|dkrt|fSt|fSn|dkr³t|fS||krÉt|fStj ddj g|D]}d|^q߃|fƒqWdS(NRs9Please enter %s or press for the default of '%s'.s, s'%s'( tappendR RR RRRRR Rtjoin(RtchoicesRRtx((sX/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/tui.pyt enter_choiceds"  %         cCsTtjdƒtjdƒtjtj|ƒƒtjtjdt|ƒƒƒdS(NRt-(R tinfoRtlen(ttext((sX/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/tui.pyttitle€s  cCsit|ƒ}tjdƒtjd|dƒtjd|dƒtjd|dƒtjdƒdS(NRR#is| s |(R%R R$(R&R((sX/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/tui.pytheader‡s   RcCs|sd}nt|ƒS(NsAA page will be printed. Please load plain paper into the printer.(tcontinue_prompt(tmsgR'((sX/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/tui.pytload_paper_prompts cCs tdƒS(NszLoad the alignment page on the scanner bed and push the 'Scan' or 'Enter' button on the printer to complete the alignment.(R)(((sX/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/tui.pytload_scanner_for_align_prompt–scCs tdƒS(NsVA page will be printed. Please load HP Advanced Photo Paper - Glossy into the printer.(R)(((sX/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/tui.pytload_photo_paper_prompt™scCsxxqtrsy)ttj|dƒƒjƒjƒ}Wntk rHqnX|sStS|dkrctStjdƒqWdS(Ns+ Press to continue or 'q' to quit: Rs*Please press or enter 'q' to quit.( R RR RRRRR R(tpromptR!((sX/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/tui.pyR)s )  cCs²tj|ƒ}xœtr­yttj|ƒƒ}Wntk rGqnX| re|dk re||fS|dkr{t|fS|j |ƒ}|s£tj dƒqnt|fSWdS(NRs,Incorrect input. Please enter correct input.( tretcompileR RR RRR R tsearchR(tregexR.tpatternRtre_objR!tmatch((sX/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/tui.pyt enter_regex­s      cCsyètr1ddl}|jdƒjƒd}n%ddl}|jdƒjƒd}idd6dd6}x\|jdƒD]K}|jƒ}t|ƒdkrz|d||d<|d||d|j}n|jdkrbd|_d|_ntjjd|jƒd|jd|d|j |jd|j||j|f}tjj|ƒtjj ƒt |ƒ|_|jdd|_dS(Nidiss%s [%s%s%s] %d%% %s Rit ( RERRIRHtsyststdouttwriteRFR.RGtflushR%(RKRER*R!R((sX/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/tui.pyRJás     (t__name__t __module__RLRJ(((sX/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/tui.pyRD×s t FormattercBs/eZddddd„Zd„Zd„ZRS(icCs1||_||_g|_||_||_dS(N(tmarginR(R7t max_widthst min_widths(RKRUR(RWRV((sX/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/tui.pyRLús     cCs|jj|ƒdS(N(R7R(RKtrow_data((sX/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/tui.pytaddscCsŸ|jrŽt|jdƒ}x8|jD]-}t|ƒ|kr&tjd|ƒdSq&Wt|jƒ|kr|tjdƒng}xY|jD]N}|jdƒ}d}x#|D]}t|t|ƒƒ}q®W|j|ƒqŒWg}x]t|jƒD]L\}}d}x*|jD]}t|t||ƒƒ}qW|j|ƒqôWd} |j dkr¨t ƒd} d| |d} g|_ xI|jD]}|j j| ƒq‹Wn%t|j ƒ|krÍtjdƒn|j dkr:| dkrøt ƒd} nd | |d} g|_ xI|jD]}|j j| ƒqWn%t|j ƒ|kr_tjd ƒng} g} x{t |j ||j |ƒD]^\}}}}tt||ƒt||ƒƒ}| j|ƒ| ji|d 6|jd 6ƒq‡Wtjt| ƒƒ}tj|j|jƒƒg}x%| D]}|jd t|ƒƒq$Wtj|jt|ƒƒƒx7|jD]}tj|j|ƒƒqkWn tjdƒdS(Nis"Invalid number of items in row: %ss"Invalid number of items in header.RMiii s*Invalid number of items in max col widths.is*Invalid number of items in min col widths.twidthRUR#s No data rows(R7R%R RR(R>tmaxRt enumerateR RVRCRWtziptminRURt TextFormatterttupleR$tcomposeR(RKtnum_colstrtmin_calc_widthsRt header_partst max_widthR!tmax_calc_widthstmax_screen_widthtdef_maxtdef_mint col_widthstformatstm1tm2tm3tm4t col_widtht formattertsep((sX/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/tui.pytoutputsn      ! " N(RRRSR RLRYRt(((sX/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/tui.pyRTùs iiiFcCsh|t|ƒ}|tkr@d|d|d|d|dS|tkrXd||S|d|SdS(NRMi(R%t ALIGN_CENTERt ALIGN_RIGHT(tlineRZt alignmenttspace((sX/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/tui.pytalignXs   cCsã|dkrtƒd}ng}|jƒ}y|d|d}}Wntk r^|gSXxd|D]\}dt|ƒ}t|ƒ||kr´|jt|||ƒƒ|}qf|d|}qfW|jt|||ƒƒ|S(NiiRM(R RCR>t IndexErrorR%RRz(t paragraphRZRxtresulttwordstcurrenttwordt increment((sX/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/tui.pytformat_paragraphfs      c Cs5tdƒtjddƒ}d}tddddd dƒ}d}xqt|ƒD]c\}}|||kr–|jt|ƒd ||fƒ|}qP|jt|ƒ||fƒqPW|jƒ|dk rõt d ||fd||ƒ\}}nt d|d|ƒ\}}|r$||}n t j dƒ|S(NsSELECT PRINTERt last_usedt printer_nameR(tNums CUPS PrinterRViidRWiRsA Enter number 0...%d for printer (q=quit, =default: *%d) ?is+ Enter number 0...%d for printer (q=quit) ?(R…s CUPS Printer(iid(ii( R(t user_conftgetR RTR\RYtstrRtRRNtexit( tprinterstlast_used_printer_nametretttablet default_indexR!t_tokti((sX/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/tui.pyt printer_tables(  ! !    c CsÅtdƒtjddƒ}d}|rFtddddd dƒ}ntddddd dƒ}d}i}x×t|ƒD]É\}}|||<||krø|rÂ|jt|ƒd|fƒn-|jt|ƒd|dj||ƒfƒ|}qz|r|jt|ƒ|fƒqz|jt|ƒ|dj||ƒfƒqzW|j ƒ|dk r…t d||fd||ƒ\} } nt d|d|ƒ\} } | r´|| }n t j dƒ|S(Ns SELECT DEVICERƒt device_uriR(R…sScan device URIRViidRWi s Device URIsCUPS Printer(s)Rt,s@ Enter number 0...%d for device (q=quit, =default: %d*) ?is* Enter number 0...%d for device (q=quit) ?(sNumsScan device URI(iid(ii (sNums Device URIsCUPS Printer(s)(iidid(ii i ( R(R†R‡R RTR\RYRˆRRtRRNR‰( tdevicest scan_flagtlast_used_device_uriRŒRRŽt device_indexR!tdRR‘((sX/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/tui.pyt device_tableŸs:      - -    c Cscdidd6d}}}tjr;d||<|d7}ntjr[d||<|d7}nt|ƒdkrVtd ƒtd dddddƒ}x{t|jƒƒD]g\}}|dkrè|j t |ƒd|d|dfƒq¥|j t |ƒ|d|dfƒq¥W|j ƒt d|d|dƒ\}}|r_||dg}q_n dg}|S(NtusbsUniversal Serial Bus (USB)iitnets:Network/Ethernet/Wireless (direct connection or JetDirect)tparsParallel Port (LPT:)sSELECT CONNECTION (I/O) TYPER(R…sConnection Typet DescriptionRViiiPRWi i(Rs@ Enter number 0...%d for connection type (q=quit, enter=usb*) ? (R›sUniversal Serial Bus (USB)(Rœs:Network/Ethernet/Wireless (direct connection or JetDirect)(RsParallel Port (LPT:)(sNumsConnection TypeRž(iiiP(ii i(( R tpropt net_buildt par_buildR%R(RTtlisttitemsRYRˆRtR(RŒtiosR!RtdataRtval((sX/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/tui.pytconnection_tableËs,         +(   (!RNR/tgRRtsixextRt sixext.movesRR RRR"R'R(R+R,R-R)R6RCtobjectRDRTt ALIGN_LEFTRuRvRzR‚R’R RšR§(((sX/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/tui.pyts4   &         "Z ,