-=[ Mr. Bumblebee ]=-
_Indonesia_

Path : /usr/lib/python2.7/dist-packages/bzrlib/ui/
File Upload :
Current File : //usr/lib/python2.7/dist-packages/bzrlib/ui/text.pyc


Pc
@@sdZddlmZddlZddlZddlZddlmZeedddl	m
Z
mZdefdYZ
ejd	d
ddd
gddddZde
fdYZdefdYZdefdYZdS(s&Text UI, write output to the console.
i(tabsolute_importN(tlazy_imports
import codecs
import getpass
import warnings

from bzrlib import (
    config,
    debug,
    progress,
    osutils,
    trace,
    )

(t	UIFactorytNullProgressViewt	_ChooseUIcB@sDeZdZdZdZdZdZdZdZRS(s- Helper class for choose implementation.
    cC@s*||_|j|j|||dS(N(tuit_setup_modet_build_alternatives(tselfRtmsgtchoicestdefault((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pyt__init__6s	
cC@swtjjddkrT|jjtjkrT|jjjrTt|_t	|_
nt	|_|jjj|_
dS(sSetup input mode (line-based, char-based) and echo-back.

        Line-based input is used if the BZR_TEXTUI_INPUT environment
        variable is set to 'line-based', or if there is no controlling
        terminal.
        tBZR_TEXTUI_INPUTs
line-basedN(tostenvirontgetRtstdintsystisattytFalset
line_basedtTruet	echo_back(R((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pyR;s'		cC@sd}g}i|_|jd}|dk	rZ|tdt|krZtdnx|D]|}|jddj}||f}||jkrtd|n||j|<|jd}	d|	kr2|	dt|kr2||	 }
|
d	||	dd
7}
|
||	d7}
||	d}	n0|jdd}|d}	d|	|df}
|	j}	|	|jkrtd
|	n||j|	<||kr||jd<||jd<n|j	|
|d7}qaWd|dj
|f|_dS(suParse choices string.

        Setup final prompt and the lists of choices and associated
        shortcuts.
        is
sinvalid default indext&tsduplicated choice: %siit[t]is[%s]%ssduplicated shortcut: %ss
u	%s (%s): s, N(talternativestsplittNonetrangetlent
ValueErrortreplacetlowertfindtappendtjointprompt(RR	R
Rtindext	help_listtctnametchoicetshortcutthelp((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pyRJs>	'

"




cC@s1|jjj}d|kr'tn|jS(NR(RRtreadlinetEOFErrortstrip(Rtline((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pyt_getliness	cC@sFtj}|tdkr'tn|tdkrBtn|S(Nii(tosutilstgetchartchrtKeyboardInterruptR0(Rtchar((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pyt_getcharys		cC@s |jr|j}n	|j}d}xtr|d7}d|ksL|jrb|jj|jny
|}WnNtk
r|jjjddSt
k
r|jjjdt
nX|j}||jkrq'n|j|\}}|j
r|jjj|dn|SWdS(s;Keep asking the user until a valid choice is made.
        iis
N(RR3R9RRR'R0tstderrtwriteRR7R#RR(Rt	getchoicetiterR,R+R(((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pytinteracts.			




	(	t__name__t
__module__t__doc__RRRR3R9R>(((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pyR1s			)		tprogress_barR.sProgress bar type.tdefault_from_envtBZR_PROGRESS_BARRtinvalidterrort
TextUIFactorycB@seZdZddddZddZdZdZdZdZ	ddZ
d	Zd
ZdZ
dZd
ZdZedZdZdZdZdZdZdZRS(s&A UI factory for Text user interfaces.cC@sAtt|j||_||_||_|j|_dS(s Create a TextUIFactory.
        N(tsuperRGRRtstdoutR:tmake_progress_viewt_progress_view(RRRIR:((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pyRs
			cC@st||||}|jS(sPrompt the user for a list of alternatives.

        Support both line-based and char-based editing.

        In line-based mode, both the shortcut and full choice name are valid
        answers, e.g. for choose('prompt', '&yes
&no'): 'y', ' Y ', ' yes',
        'YES ' are all valid input lines for choosing 'yes'.

        An empty line, when in line-based mode, or pressing enter in char-based
        mode will select the default choice (if any).

        Choice is echoed back if:
        - input is char-based; which means a controlling terminal is available,
          and osutils.getchar is used
        - input is line-based, and no controlling terminal is available
        (RR>(RR	R
Rt	choose_ui((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pytchoosescC@s@|r|jr|jntj|||j|_dS(N(t_quiett
clear_termRtbe_quietRJRK(Rtstate((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pyRPs
cC@s|jjdS(sPrepare the terminal for output.

        This will, clear any progress bars, and leave the cursor at the
        leftmost position.N(RKtclear(R((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pyROs	cC@sOxHtrJ|j||jj}yt|SWqtk
rFqXqWdS(N(RR'RR/tintR!(RR'R2((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pytget_integers	

cC@st|jdd}|dk	r<|r<tjd}nP|jj}|sZd}n2|j|jj}|ddkr|d }n|S(NRRis
(tgetattrRRtgetpassR/tdecodetencoding(RRtpassword((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pytget_non_echoed_passwords	
ucK@s$|d7}|j|||jS(s|Prompt the user for a password.

        :param prompt: The prompt to present the user
        :param kwargs: Arguments which will be expanded into the prompt.
                       This lets front ends display different things if
                       they so choose.
        :return: The password string, return None if the user
                 canceled the request.
        s: (R'RZ(RR'tkwargs((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pytget_passwords

cK@sn|d7}|j|||jj}|s8d}n2|j|jj}|ddkrj|d }n|S(s|Prompt the user for a username.

        :param prompt: The prompt to present the user
        :param kwargs: Arguments which will be expanded into the prompt.
                       This lets front ends display different things if
                       they so choose.
        :return: The username string, return None if the user
                 canceled the request.
        s: is
N(R'RR/RRWRX(RR'R[tusername((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pytget_usernames

	
cC@sm|jrtStjjd}|dkr;tS|dksYtj|jrft|jStS(sFConstruct and return a new ProgressView subclass for this UI.
        RBtnonettext(	tis_quietRtconfigtGlobalStackRtprogresst_supports_progressR:tTextProgressView(Rtpb_type((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pyRJs
cC@s|dkrntjdkr^t|jdd}|r^ddl}|j|tjq^nt	||jSt
j||jd|}||_t	||SdS(Ntexacttwin32tfilenoiterrors(
RtplatformRURIRtmsvcrttsetmodeRtO_BINARYtTextUIOutputStreamtcodecst	getwriterRX(RRXt
encoding_typeRjRmtencoded_stdout((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pyt_make_output_stream_explicit/s		cC@s"|j|jj|ddS(sKWrite an already-formatted message, clearing the progress bar if necessary.s
N(RORIR;(RR	((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pytnoteCs
cK@st|tkr%td|n|r8||}ny|j|jj}Wn/ttfk
r|jtj	d}nX|j
|jj|jj
|dS(sEmit prompt on the CLI.
        
        :param kwargs: Dictionary of arguments to insert into the prompt,
            to allow UIs to reformat the prompt.
        sprompt %r not a unicode stringR"N(ttypetunicodeR!tencodeR:RXtUnicodeErrortAttributeErrorR4tget_terminal_encodingRORItflushR;(RR'R[((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pyR'Hs


cC@s|jj|||dS(sCalled by transports as they do IO.

        This may update a progress bar, spinner, or similar display.
        By default it does nothing.
        N(RKtshow_transport_activity(Rt	transportt
byte_countt	direction((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pytreport_transport_activity^scC@s5t|jdd}|dk	r1|d|ndS(s&See UIFactory.log_transport_activity()tlog_transport_activitytdisplayN(RURKR(RRtlog((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pyRgscC@s"|j|jjd|dS(Nsbzr: error: %s
(ROR:R;(RR	((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pyt
show_errorms
cC@s|j|dS(N(Rv(RR	((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pytshow_messageqscC@sR|jt|tr:tj}|j|d}n|jjd|dS(NR"sbzr: warning: %s
(ROt
isinstanceRxR4R|RyR:R;(RR	tte((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pytshow_warningts

cC@sJ|js tjd|fn||jdkr6n|jj|dS(s;A task has been updated and wants to be displayed.
        s"%r updated but no tasks are activeiN(t_task_stacktwarningstwarnRKt
show_progress(Rttask((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pyt_progress_updated{s		cC@s|jjdS(N(RKRR(R((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pyt_progress_all_finishedscK@s6||jkr2|jj|j||dndS(syShow a text message to the user.

        Explicitly not for warnings about bzr apis, deprecations or internals.
        s
N(tsuppressed_warningsR:R;tformat_user_warning(Rt
warning_idtmessage_args((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pytshow_user_warningsN(R?R@RARRRMRPRORTRZR\R^RJRuRvR'RRRRRRRRR(((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pyRGs.																	RfcB@seZdZdddZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZed
ZRS(sDisplay of progress bar and other information on a tty.

    This shows one line of text, including possibly a network indicator, spinner,
    progress bar, message, etc.

    One instance of this is created and held by the UI, and fed updates when a
    task wants to be painted.

    Transports feed data to this through the ui_factory object.

    The Progress views can comprise a tree with _parent_task pointers, but
    this only prints the stack from the nominated current task up to the root.
    R"cC@s||_|dkr3t|ddp*d|_n	||_||_t|_d|_d|_d|_	d|_
d|_d|_d|_
idd6dd6dd6|_d|_d|_t|_dS(NRXtasciiRitunknowntreadR;(t
_term_fileRRUt	_encodingt_encoding_errorsRt_have_outputt_last_transport_msgt	_spin_post
_last_repaintt_transport_update_timet
_last_taskt_total_byte_countt_bytes_since_updatet_bytes_by_directiont_first_byte_timet	_fractiont
enable_bar(Rt	term_fileRXRk((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pyRs"													cC@s(tj}|dkrdS|dSdS(Ni(R4tterminal_widthR(Rtw((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pyt_avail_widthscC@sb|j|j|j}|j}|dk	rFd|||f}n|jjd|ddS(Ns%-*.*ss
(RyRRRRRR;(Rtutstwidth((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pyt
_show_lines
cC@s&|jr|jdnt|_dS(NR(RRR(R((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pyRRs	cC@sN|jr|jdks$|jjrd|jd}|jd7_d}|jdkrkd}d|_n|jjp}d}||jkrdtjkrddl	}|j
n||_ttt
||d}dd||j|d	}|S|jdks|jjrFd|jd}|jd7_|d
SdSdS(Ns/-\|iiiiRdRt#s] t R(RRRtshow_barRRt_overall_completion_fractiontdebugtdebug_flagstpdbt	set_traceRStroundtfloattljusttshow_spinner(Rtspin_strtcolstcompletion_fractionRtmarkerstbar_str((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pyt_render_bars,	
	 cC@s|jsd}n\|jdk	rI|jdk	rId|j|jf}n%|jdk	rhd|j}nd}|}|j}x3|jr|j}|jr|jd|}qqW||fS(swFormat task-specific parts of progress bar.

        :returns: (text_part, counter_part) both unicode strings.
        Rs %d/%ds %dt:N(t
show_counttcurrent_cntRt	total_cntR	t_parent_task(RRRtttm((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pyt_format_tasks					c	C@sW|j}|jr0|j|j\}}n
d}}|jrY|jjrYd}n	|j}|sn|r~|r~d}n|j}|dk	rt|t|t|t|}||}|dkr||d d}qn||||}|dk	rSt||kr1|j|}qSt||krS|| }qSn|S(NRs| iis..(	RRRR~RRRR R(	Rt
bar_stringt	task_parttcounter_partttranstavail_widthtcurrent_lentgapR((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pyt_render_lines,	
			*
cC@s&|j}|j|t|_dS(N(RRRR(RR((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pyt_repaint/s
cC@s{||jk	}||_tj}|rE||j|jkrEdS||jdkrdd|_n||_|jdS(sCalled by the task object when it has changed.
        
        :param task: The top task object; its parents are also included 
            by following links.
        Ni
R(RttimeRtupdate_latencyRRR(RRtmust_updatetnow((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pyR4s		cC@sA|j|7_|j|7_|jdkr?tj|_n||jkrd|j|c|7<n|jdc|7<dtjkrdStj}|jdkrdS|jdkr||_ny||jdkr=|j||j}d|jdt	|df}||_||_
d|_||_|jndS(	sCalled by transports via the ui_factory, as they do IO.

        This may update a progress bar, spinner, or similar display.
        By default it does nothing.
        Rtno_activityNig?s%6dkB %5dkB/s ii(
RRRRRRRRRRSRRR(RRRRRtrateR	((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pyR~Es0				cC@s|jdkrd}n5tj|j}|dkr@d}n|j|}d|jd|d|jdd|jddf}|jddkr|d	|jdd7}n
|d
7}|S(NggMbP?s/Transferred: %.0fkB (%.1fkB/s r:%.0fkB w:%.0fkBg@@RR;Ris
 u:%.0fkB)t)(RRRRR(Rtbpst
transfer_timeR	((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pyt_format_bytes_by_directionss 		


cC@sS|j}tj||rO|jdkrO|j|jj|dndS(Nis
(RttracetmutterRRRRR;(RRR	((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pyRs


N(R?R@RARRRRRRRRRRRR~RRR(((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pyRfs
					!		 			.	RpcB@s2eZdZdZdZdZdZRS(sDecorates an output stream so that the terminal is cleared before writing.

    This is supposed to ensure that the progress bar does not conflict with bulk
    text output.
    cC@s+||_||_t|dd|_dS(NRX(t
ui_factorytwrapped_streamRURRX(RRR((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pyRs		cC@s|jj|jjdS(N(RRORR}(R((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pyR}s
cC@s!|jj|jj|dS(N(RRORR;(Rtto_write((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pyR;s
cC@s!|jj|jj|dS(N(RRORt
writelines(Rtlines((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pyRs
(R?R@RARR}R;R(((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pyRps
			(RAt
__future__RRRRtbzrlib.lazy_importRtglobalst	bzrlib.uiRRtobjectRRbtOptionRtopt_progress_barRGRfRp(((s2/usr/lib/python2.7/dist-packages/bzrlib/ui/text.pyt<module>s 	
n	

Copyright © 2017 || Recoded By Mr.Bumblebee