-=[ Mr. Bumblebee ]=-
_Indonesia_

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


5Qc@@sddlmZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
e
edddlm
Z
mZmZmZmZddlmZmZddlZddlmZmZejZejdkrejZneed	dZeed
dZeeddZ dZ!d
Z"dZ#dZ$dZ%da'dZ(dZ)dZ*idd6de)6dd6dd6Z+dZ,eej-ddZ.e.dkrdZ.ndZ/dZ0d Z1d!Z2d"Z3d#Z4d$Z5d%Z6d&Z7d'Z8d(Z9d)Z:d*Z;d+Z<d,Z=d-Z>d.Z?d/Z@e@ejAZAe0ZBe1ZCej-jDZEe2ZFe3ZGe4ZHe5ZIejJZKej-jLZLej-jMZMej-jNZNej-jOZOejPZPejQZQd0ZRd1ZSejdkreTjUd2krCe8ZBne7ZBe9ZCe:ZEe;ZFe<ZKe=ZVe@e>ZAydd3lmWZWWneXk
rnXeWjPZPeWjQZQeWjRZRd4ZSd5ZYeZeYd6Z[eTj!Z\e\dk	re\Z!neTj]ZGeTj^ZHeTj_ZInejd7kr(e?ZKneZd8Z`d9Zad:Zbd;Zcd<Zdd=Zed>Zfd?Zgd@dAddBdCZhddDZidAdEZjdFZkdGZldHZmedIZnedJZodKZpdLZqddMZrdNdOdPdQdRdSdTgZsgesD]ZtetdU^qZuddVdevdWZwiZxdexdXZyddVdevdYZzdZZ{d[Z|d\Z}d]Z~ejZejd^kryed1Wqek
rd_ZqXnd`ZdaZdbZdcZddZgZdeZdfZyddglmZWn-eXk
rWZeeddglmZnXdhZdiZdjZdkZdlZdmZdnZdoZdpZdqZdrZdsZdtZduZejdkreZneZdvZdwZdxZdyZdzZevd{Zd|Zevd}ZeZZejd7krZevZnd~ZdZdZereZneZevdZdZdadadZdZdZdZejdkreZneZdZdZdZejdZdZdZdZddZdefdYZdaddZdefdYZidZddZdZdZdae
dZdZdZdZejejejgZxBddgD]4ZeeedZedk	rejeqqW[dedZdZddZdZdZdZdZdZeaejPdZejPdZdZeeddddZejdkr	dZn	dZejjdr
dZnuejd7kr#
dZnZdejkr>
dZn?ejdkrY
dZn$ejdkrt
dZn	dZdaevdZdejfdYZejdkr
dd@dZneZdZdZdZdZejdkreTjZneZdddddgZgeD]-Zeeeddk	r0eee^q0ZdZdZdZdS(i(tabsolute_importN(tlazy_importsK
from datetime import datetime
import getpass
import locale
import ntpath
import posixpath
import select
# We need to import both shutil and rmtree as we export the later on posix
# and need the former on windows
import shutil
from shutil import rmtree
import socket
import subprocess
# We need to import both tempfile and mkdtemp as we export the later on posix
# and need the former on windows
import tempfile
from tempfile import mkdtemp
import unicodedata

from bzrlib import (
    cache_utf8,
    config,
    errors,
    trace,
    win32utils,
    )
from bzrlib.i18n import gettext
(tDEPRECATED_PARAMETERtdeprecated_functiont
deprecated_intdeprecated_passedtwarn(tmd5tsha1(tsymbol_versioningt_fs_enctwin32tO_BINARYtO_TEXTtO_NOINHERITcC@smy4t}gtjdD]}|j|^qSWn2tk
rhtjtdj||nXdS(NisBParameter {0!r} encoding is unsupported by {1} application locale.(	tget_user_encodingtsystargvtdecodetUnicodeDecodeErrorterrorstBzrErrortgettexttformat(t
user_encodingta((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytget_unicode_argv_s	+
cC@s?tj|j}tj|s;|d@}t||ndS(sMake a filename read-only.imN(tostlstattst_modetstattS_ISLNKtchmod_if_possible(tfilenametmod((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt
make_readonlyhs
cC@s?tj|j}tj|s;|dB}t||ndS(Ni(RRRRRR (R!R"((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt
make_writableps
cC@ssytj||WnXttfk
rn}t|dtjtjfkrhtj	d||fdSnXdS(Nterrnosignore error on chmod of %r: %r(
RtchmodtIOErrortOSErrortgetattrR%tEPERMtEACCESttracetmutter(R!tmodete((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyR ws!	cC@st|dkrt|Sd}tt|d|}|dg}x5|dD])}t|d|sU|j|qUqUWt|S(sReturn the smallset subset of paths which are outside paths.

    :param paths: A container (and hence not None) of paths.
    :return: A set of paths sufficient to include everything in paths via
        is_inside, drawn from the paths parameter.
    icS@s
|jdS(Nt/(tsplit(tpath((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytsort_keystkeyiii(tlentsettsortedtlistt	is_insidetappend(tpathsR3tsorted_pathstsearch_pathsR2((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytminimum_path_selections
	
cC@sAtdkrtjdantj|r9d|dS|SdS(stReturn a quoted filename filename

    This previously used backslash quoting, but that works poorly on
    Windows.s([^a-zA-Z0-9.,:/\\_~-])t"N(t	_QUOTE_REtNonetretcompiletsearch(tf((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytquotefns
t	directorycC@s tjd}tj||S(sReturn the current umaski(Rtumask(RH((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt	get_umasks
ttfileR0t@tsymlinkt+stree-referencecC@s%yt|SWntk
r dSXdS(NRJ(t_kind_marker_maptKeyError(tkind((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytkind_markers
tlexistscC@sxy'ttdtj}||tSWnJtk
rs}|jtjkrOtStj	t
dj||nXdS(NRslstat/stat of ({0!r}): {1!r}(R)RRtTrueR(R%tENOENTtFalseRRRR(RERR/((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyRSs
cC@stjj|}tjj|}d|tjtjtdf}t||}t}y|||Wnt	j
fk
r}ntk
r}|jdtjtjfkrqnRtk
r}t|dddks|jtjtjfkrqnXt}d}	t}
zy|||t}
Wndttfk
r}tj}	|r|jdtjfkr|j|jkrd}	qnXWd|r|
r||q|||nX|	dk	rz|	d|	d|	dWd~	XndS(s/A fancy rename, when you don't have atomic rename.

    :param old: The old path, to rename from
    :param new: The new path, to rename to
    :param rename_func: The potentially non-atomic rename function
    :param unlink_func: A way to delete the target file if the full rename
        succeeds
    stmp.%s.%.9f.%d.%si
R%Niii(RR2tbasenametdirnamettimetgetpidt
rand_charstpathjoinRVRt
NoSuchFileR'R%RARUtENOTDIRt	ExceptionR)RTR(Rtexc_infotlower(toldtnewtrename_functunlink_functbaseRXttmp_nametfile_existedR/tfailure_exctsuccess((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytfancy_renamesJ
	



cC@s1tj|s'tjt|}nt|S(N(t	posixpathtisabstjointgetcwdt_posix_normpath(R2((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt_posix_abspath.scC@stj|jtjtS(N(RltrealpathtencodeR
R(R2((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt_posix_realpath6scC@s/tj|}|jdr+|d}n|S(Ns//i(Rltnormpatht
startswith(R2((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyRp:s	
cC@s`tjj|d}|dkr%|Sy|jtSWn#tk
r[tj|tnXdS(sGet unicode path from `key` in environment or None if not present

    Note that posix systems use arbitrary byte strings for filesystem objects,
    so a path that raises BadFilenameEncoding here may still be accessible.
    N(	RtenvirontgetRARR
RRtBadFilenameEncoding(R4tval((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt_posix_path_from_environIs
cC@sJtjd}y|jtSWn#tk
rEtj|tnXdS(s<Get the home directory of the current user as a unicode patht~N(Rlt
expanduserRR
RRRy(R2((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt_posix_get_home_dirYs

cC@sWtj}t}y|j|SWn*tk
rRtjd||fnXdS(s=Get username from environment or password database as unicodes@Encoding of username %r is unsupported by %s application locale.N(tgetpasstgetuserRRRRR(tnameR((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt_posix_getuser_unicodebs	
	cC@s#tj|\}}|j|S(sIForce drive letters to be consistent.

    win32 is inconsistent whether it returns lower or upper case
    and even if it was consistent the user might type the other
    so we force it to uppercase
    running python.exe under cmd.exe return capital C:\
    running win32 python inside a cygwin shell returns lowercase c:\
    (tntpatht
splitdrivetupper(R2tdrive((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt_win32_fixdrivems	cC@s%ttjt|jddS(Ns\R0(RRtabspathtunicodetreplace(R2((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt_win32_abspathzscC@st|}tj|d}|dkr|d d	krtj}|d d
krwtj|d}|d}n|d|}nttj|jddS(sReturn the absolute version of a path.
    Windows 98 safe implementation (python reimplementation
    of Win32 API function GetFullPathNameW)
    iRJis//s\\iR0s\(s//s\\(R0s\(RRRRtgetcwduRRuR(R2Rtcwd((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt_win98_abspaths
cC@s%ttjt|jddS(Ns\R0(RRRrRR(R2((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt_win32_realpathscG@stj|jddS(Ns\R0(RRnR(targs((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt_win32_pathjoinscC@s%ttjt|jddS(Ns\R0(RRRuRR(R2((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt_win32_normpathscC@sttjjddS(Ns\R0(RRRR(((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt
_win32_getcwdscO@s"ttj||jddS(Ns\R0(RttempfiletmkdtempR(Rtkwargs((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt_win32_mkdtempscC@swy#t||dtjdtjWnMtk
rr}|jtjtjtjtj	fkrltj
|nnXdS(sWe expect to be able to atomically replace 'new' with old.

    On win32, if new exists, it must be moved out of the way first,
    and then deleted.
    RdReN(RkRtrenametunlinkR(R%R*R+tEBUSYtEINVALR(RbRcR/((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt
_win32_renames#'cC@stjdtjS(NtNFC(tunicodedatat	normalizeRR(((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt_mac_getcwdsc@sfd}|S(sAdds extra information to any exceptions that come from rename().

    The exception has an updated message and 'old_filename' and 'new_filename'
    attributes.
    c@sfy||WnNtk
ra}t|j|jd||f}||_||_|nXdS(Ns& [occurred when renaming '%s' to '%s'](R(R%tstrerrortold_filenametnew_filename(RbRcR/tdetailed_error(Rd(s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt_rename_wrappers		((RdR((Rds2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt_rename_wrap_exceptionscC@s|S(N((tst((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt	wrap_statsis
Windows 98(t_walkdirs_win32icC@sa|d}|tjtjfkrZt|trZ|jtjkrZt|||ndS(syError handler for shutil.rmtree function [for win32]
        Helps to remove files and dirs marked as read-only.
        iN(Rtremovetrmdirt
isinstanceR(R%R+R$(tfunctionR2texcinfot	exception((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt_win32_delete_readonly
s


cC@stj|||S(s<Replacer for shutil.rmtree: could remove readonly dirs/files(tshutiltrmtree(R2t
ignore_errorstonerror((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyRstdarwincC@sddlm}ttjdd
}|sttjdd
}|sht}|r|d|qq|}|r|d|qn|r|d|n|dkrt}|r|d|qnytj	|Wn7t
k
rtjjd	|tft}nX|S(sDFind the best encoding for printing to the screen.

    This attempts to check both sys.stdout and sys.stdin to see
    what encoding they are in, and if that fails it falls back to
    osutils.get_user_encoding().
    The problem is that on Windows, locale.getpreferredencoding()
    is not the same encoding as that used by the console:
    http://mail.python.org/pipermail/python-list/2003-May/162357.html

    On my standard US Windows XP, the preferred encoding is
    cp1252, but the console is cp437

    :param trace: If True trace the selected encoding via mutter().
    i(R-tencodings1encoding stdout as osutils.get_user_encoding() %rs(encoding stdout as sys.stdin encoding %rs)encoding stdout as sys.stdout encoding %rtcp0sJcp0 is invalid encoding. encoding stdout as osutils.get_user_encoding() %rsIbzr: warning: unknown terminal encoding %s.
  Using encoding %s instead.
N(
tbzrlib.traceR-R)RtstdoutRAtstdinRtcodecstlookuptLookupErrortstderrtwrite(R,R-toutput_encodingtinput_encoding((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytget_terminal_encoding)s6	

	


cC@sttjdddk	r$t}nt}tjj|\}}|dksf|dksf|dkrp||St|||SdS(NRrRJt.s..(R)RR2RARrRR1R\(REtFtpR/((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt
normalizepath^s	$
cC@s:y!tjtj|tjSWntk
r5tSXdS(s%True if f is an accessible directory.N(RtS_ISDIRRRtST_MODER(RV(RE((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytisdirjs!
cC@s:y!tjtj|tjSWntk
r5tSXdS(sTrue if f is a regular file.N(RtS_ISREGRRRR(RV(RE((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytisfilers!
cC@s:y!tjtj|tjSWntk
r5tSXdS(sTrue if f is a symlink.N(RRRRRR(RV(RE((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytislinkys!
cC@sJ||krtS|dkr tS|ddkr=|d7}n|j|S(s4True if fname is inside dir.

    The parameters should typically be passed to osutils.normpath first, so
    that . and .. and repeated slashes are eliminated, and the separators
    are canonical for the platform.

    The empty string as a dir name is taken as top-of-tree and matches
    everything.
    RJiR0(RTRv(tdirtfname((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyR9s
cC@s(x!|D]}t||rtSqWtS(s*True if fname is inside any of given dirs.(R9RTRV(tdir_listRRX((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt
is_inside_anys
cC@s7x0|D](}t||s+t||rtSqWtS(s?True if fname is a child or a parent of any of the given files.(R9RTRV(RRRX((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytis_inside_or_parent_of_anys
iitreadc
C@sd}|dkrx|dkrt||}|j|}|sIPn|dk	rk|t||n|j|t|}	||	8}||	7}qWnexbtr|j|}|sPn|dk	r|t||n|j||t|7}qW|S(sCopy contents of one file to another.

    The read_length can either be -1 to read to end-of-file (EOF) or
    it can specify the maximum number of bytes to read.

    The buff_size represents the maximum size for each read operation
    performed on from_file.

    :param report_activity: Call this as bytes are read, see
        Transport._report_activity
    :param direction: Will be passed to report_activity

    :return: The number of bytes copied.
    iN(tminRRAR5RRT(
t	from_filetto_filetread_lengtht	buff_sizetreport_activityt	directiontlengthtnum_bytes_to_readtblocktactual_bytes_read((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytpumpfiles,

	
cC@sg|sd}ntt||d}|j}x.|D]&}t||||}||q9WdS(sWrite bytes to file_handle in many smaller writes.

    :param bytes: The string to write.
    :param file_handle: The file to write to.
    iPiN(trangeR5Rtbuffer(tbytestfile_handletsegment_sizetsegmentsRt
segment_indextsegment((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytpump_string_files			
cc@s;x4tr6|j|}t|dkr.Pn|VqWdS(Ni(RTRR5(t
input_filetreadsizetb((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt
file_iterators
	cC@sLt}d}x0trA|j|}|s1Pn|j|qW|jS(sbCalculate the hexdigest of an open file.

    The file cursor should be already at the start.
    ii
i(tshaRTRtupdatet	hexdigest(REtstBUFSIZER((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytsha_files		cC@shd}t}d}x@trW|j|}|s7Pn|t|7}|j|qW||jfS(sCalculate the size and hexdigest of an open file.

    The file cursor should be already at the start and
    the caller is responsible for closing the file afterwards.
    iii
i(RRTRR5RR(REtsizeRRR((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt
size_sha_files		cC@s{t}tj|tjtBtB}z@x9trdtj|d}|sT|jS|j	|q,WWdtj
|XdS(s5Calculate the SHA1 of a file by reading the full textiiNi(RRtopentO_RDONLYRRRTRRRtclose(RRRER((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytsha_file_by_names		
cC@s#|}t|j||jS(s,Return the sha-1 of concatenation of strings(tmapRR(tstringst_factoryR((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytsha_strings!s	cC@s||jS(N(R(RER((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt
sha_string(scC@s0|j}it|d6t|jd6S(NRR(RR5RR(RER((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytfingerprint_file,scC@sUd}xHtrP|j|}|j|}||kr=tS|dkr	tSq	WdS(s!Returns true if equal in contentsiRJN(RTRRV(RRRtaitbi((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt
compare_files2s	cC@sI|dkrtj}ntj|tj|}|jd|jS(sEReturn offset of local zone from GMT, either at present or at time t.iQN(RARYtdatetimet
fromtimestamptutcfromtimestamptdaystseconds(tttoffset((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytlocal_time_offset>stMontTuetWedtThutFritSattSuns %Y-%m-%d %H:%M:%StoriginalcC@sUt|||||\}}}|jdt|d}tj||}||S(sReturn a formatted date string.

    :param t: Seconds since the epoch.
    :param offset: Timezone offset in seconds east of utc.
    :param timezone: How to display the time: 'utc', 'original' for the
         timezone specified by offset, or 'local' for the process's current
         timezone.
    :param date_fmt: strftime format.
    :param show_offset: Whether to append the timezone.
    s%ai(t_format_dateRtweekdaysRYtstrftime(RRttimezonetdate_fmttshow_offsettttt
offset_strtdate_str((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytformat_dateIs
!cC@s|dkrd}ntj||}t|d}tj||}|j|d}|dkrd|d|ddf}|||<n||S(sReturn a formatted date string in the original timezone.

    This routine may be faster then format_date.

    :param t: Seconds since the epoch.
    :param offset: Timezone offset in seconds east of utc.
    iis
 %+03d%02dii<N(RARYtgmtimet_default_format_by_weekday_numRRx(RRt_cacheRRRR((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt,format_date_with_offset_in_original_timezone`s		
cC@sbt|||||\}}}tj||}t|tsZ|jtd}n||S(sReturn an unicode date string formatted according to the current locale.

    :param t: Seconds since the epoch.
    :param offset: Timezone offset in seconds east of utc.
    :param timezone: How to display the time: 'utc', 'original' for the
         timezone specified by offset, or 'local' for the process's current
         timezone.
    :param date_fmt: strftime format.
    :param show_offset: Whether to append the timezone.
    R(RRYRRRRR(RRRRRRRR((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytformat_local_dateus

!cC@s|dkr$tj|}d}np|dkr[|dkrEd}ntj||}n9|dkrtj|}t|}ntj||dkrd}n|rd|d|ddf}nd	}|||fS(
NtutciRtlocals%a %Y-%m-%d %H:%M:%Ss
 %+03d%02dii<RJ(RYRRAt	localtimeRRtUnsupportedTimezoneFormat(RRRRRRR((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyRs"			cC@stjdtj|S(Ns%Y%m%d%H%M%S(RYRR(twhen((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytcompact_datescC@sTt|}|dkr!d}n
d}|}|}|dkrk|dkrZd||fSd||fSnt|d}|d|8}|dkrd	}nd
}|dkr|dkrd||||fSd||||fSnt|d}|d|8}|dkrd	}nd
}|dkr@d
||||fSd||||fS(s=Get a nice looking string for a time delta.

    :param delta: The time difference in seconds, can be positive or negative.
        positive indicates time in the past, negative indicates time in the
        future. (usually time.time() - stored_time)
    :return: String formatted to show approximate resolution
    itagos
in the futureiZis%d second %ss
%d seconds %si<RJRs%d minute, %d second%s %ss%d minutes, %d second%s %ss%d hour, %d minute%s %ss%d hours, %d minute%s %s(tint(tdeltaRRtminutestplural_secondsthourstplural_minutes((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytformat_deltas>					cC@stj|jtjS(sReturn size of given open file.(RtfstattfilenoRtST_SIZE(RE((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytfilesizestntcC@sIddl}d}x0|rD|t|jdd7}|d8}qW|S(NiRJii(trandomtchrtrandint(tnR3R((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt
rand_bytess	t$0123456789abcdefghijklmnopqrstuvwxyzcC@s9d}x,t|D]}|tt|d7}qW|S(sReturn a random string of num alphanumeric characters

    The result only contains lowercase chars because it may be used on
    case-insensitive filesystems.
    RJi$(R7tALNUMtord(tnumRtraw_byte((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyR[scC@s}tjd|}g}x^|D]V}|dkrMtjtd|q|dksu|dkrhq|j|qW|S(sTurn string into list of parts.s[\\/]s..ssorry, %r not allowed in pathRRJ(RBR1RRRR:(RtpstrpsRE((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt	splitpaths
cC@s[xN|D]F}|dks1|dks1|dkrtjtd|qqWt|S(Ns..RJssorry, %r not allowed in path(RARRRR\(RRE((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytjoinpaths
$ cC@sFg}tt|}x'|rA|jt||jqW|S(syReturn the list of parent directories, deepest first.

    For example, parent_directories("a/b/c") -> ["a/b", "a"].
    (R?RXR:R@tpop(R!tparentstparts((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytparent_directoriess	cC@s=t|}|tkr9tjd|tj|ndS(sHandle failing to load a binary extension.

    This should be called from the ImportError block guarding the attempt to
    import the native extension.  If this function returns, the pure-Python
    implementation should be loaded instead::

    >>> try:
    >>>     import bzrlib._fictional_extension_pyx
    >>> except ImportError, e:
    >>>     bzrlib.osutils.failed_to_load_extension(e)
    >>>     import bzrlib._fictional_extension_py
    s%failed to load compiled extension: %sN(tstrt_extension_load_failuresR,R-R:(Rt
exception_str((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytfailed_to_load_extension%scC@sAts
dStjjdr#dSddlm}|ddS(Ntignore_missing_extensionsi(twarningslbzr: warning: some compiled extensions could not be loaded; see <https://answers.launchpad.net/bzr/+faq/703>(RFtconfigtGlobalStackRxRRJ(RJ((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytreport_extension_load_failures@s(tchunks_to_linescC@s*t|trt|gSt|SdS(s@Split s into lines, but without removing the newline characters.N(RRERNt_split_lines(R((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytsplit_linesVs
cC@sR|jd}g|d D]}|d^q}|drN|j|dn|S(sySplit s into lines, but without removing the newline characters.

    This supports Unicode or plain string objects.
    s
i(R1R:(Rtlinestlinetresult((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyROas
!
cC@s
tjdkS(NRtcygwinR(swin32scygwinsdarwin(Rtplatform(((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pythardlinks_goodmscC@sytstj||dSytj||WnAttfk
rt}|jtjkrantj||nXdS(s6Hardlink a file, or copy it if it can't be hardlinked.N(	RVRtcopyfileRtlinkR(R'R%tEXDEV(tsrctdestR/((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytlink_or_copyqs	cC@syt|Wnlttfk
r|}|jtjtjfkrvyt|Wnttfk
rhnXt|q}nXdS(sLDelete a file, symlink or directory.

    Will delete even if readonly.
    N(t_delete_file_or_dirR(R'R%R*R+R$(R2R/((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt
delete_any~s
cC@s-t|rtj|n
tj|dS(N(RRRR(R2((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyR]scC@s$ttdddk	rtStSdS(NRM(R)RRARTRV(((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pythas_symlinksscC@s$ttdddk	rtStSdS(NRX(R)RRARTRV(((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt
has_hardlinksscC@stotjdkS(NRTR(scygwinswin32(R_RRU(((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pythost_os_dereferences_symlinkss	cC@s1|jt}tj|}|jt}|S(sReturn a string representing the path to which the symbolic link points.

    :param abspath: The link absolute unicode path.

    This his guaranteed to return the symbolic link in unicode in all python
    versions.
    (RsR
RtreadlinkR(RRXttarget((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyRbscC@s)x"dD]}||krtSqWtSdS(s1True if there are any whitespace characters in s.s 	

N(RTRV(Rtch((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytcontains_whitespaces

cC@s)x"dD]}||krtSqWtSdS(s.True if there is any vertical whitespace in s.s

N(RTRV(RRd((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytcontains_linebreakss
cC@st|tkr.ttd|fnt|}g}|}x{trt|t|kr||krtj||n||krPnt|\}}|rI|j	|qIqIW|rt
t|SdSdS(sReturn path relative to base, or raise PathNotChild exception.

    The path may be either an absolute path or a path relative to the
    current working directory.

    os.path.commonprefix (python2.4) has a bad bug that it works just
    on string prefixes, assuming that '/u' is a prefix of '/u2'.  This
    avoids that problem.

    NOTE: `base` should not have a trailing slash otherwise you'll get
    PathNotChild exceptions regardless of `path`.
    s,%r is too short to calculate a relative pathRJN(R5tMIN_ABS_PATHLENGTHt
ValueErrorRRRTRtPathNotChildR1R:R\treversed(RfR2trpRtheadttail((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytrelpaths"	$cC@s	t||}|s|St|}|}tj}t|jd}x|D]}|j}y||}	Wn*tk
rt||t	|}PnXxL|	D]+}
||
jkrt||
}PqqWt||t	|}PqPW|t
|jdS(sReturn the canonical path relative to base.

    Like relpath, but on case-insensitive-case-preserving file-systems, this
    will return the relpath as stored on the file-system rather than in the
    case specified in the input string, for all existing portions of the path.

    This will cause O(N) behaviour if called for every path in a tree; if you
    have a number of paths to convert, you should use canonical_relpaths().
    R0(RnRRtlistdirtiterR1RaR(R\R8R5tlstrip(RfR2treltabs_basetcurrentt_listdirtbit_itertbittlbittnext_entriestlook((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt_cicp_canonical_relpaths*	


cC@s g|D]}t||^qS(sCreate an iterable to canonicalize a sequence of relative paths.

    The intent is for this implementation to use a cache, vastly speeding
    up multiple transformations in the same directory.
    (tcanonical_relpath(RfR;R((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytcanonical_relpaths:scC@sQt|tkr|Sy|jtSWn#tk
rLtj|tnXdS(sDecode the filename using the filesystem encoding

    If it is unicode, it is returned.
    Otherwise it is decoded from the the filesystem's encoding. If decoding
    fails, a errors.BadFilenameEncoding exception is raised.
    N(ttypeRRR
RRRy(R!((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytdecode_filenameDs
cC@sKt|tr|Sy|jdSWn tk
rFtj|nXdS(sCoerce unicode_or_utf8_string into unicode.

    If it is unicode, it is returned.
    Otherwise it is decoded from utf-8. If decoding fails, the exception is
    wrapped in a BzrBadParameterNotUnicode exception.
    tutf8N(RRRRRtBzrBadParameterNotUnicode(tunicode_or_utf8_string((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytsafe_unicodeSs
cC@sTt|trGy|jdWn tk
rBtj|nX|S|jdS(sCoerce unicode_or_utf8_string to a utf8 string.

    If it is a str, it is returned.
    If it is Unicode, it is encoded into a utf-8 string.
    sutf-8(RRERRRRRs(R((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt	safe_utf8bs
snUnicode revision ids were deprecated in bzr 0.15. Revision id generators should be creating utf8 revision ids.cC@sK|dks|jtkr|S|r>tjttddntj|S(s&Revision ids should now be utf8, but at one point they were unicode.

    :param unicode_or_utf8_string: A possibly Unicode revision_id. (can also be
        utf8 or None).
    :param warn: Functions that are sanitizing user data can set warn=False
    :return: None or a utf8 revision id.
    t
stackleveliN(	RAt	__class__RER	Rt_revision_id_warningtDeprecationWarningt
cache_utf8Rs(RR((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytsafe_revision_idzs
sbUnicode file ids were deprecated in bzr 0.15. File id generators should be creating utf8 file ids.cC@sK|dks|jtkr|S|r>tjttddntj|S(sFile ids should now be utf8, but at one point they were unicode.

    This is the same as safe_utf8, except it uses the cached encode functions
    to save a little bit of performance.

    :param unicode_or_utf8_string: A possibly Unicode file_id. (can also be
        utf8 or None).
    :param warn: Functions that are sanitizing user data can set warn=False
    :return: None or a utf8 file id.
    RiN(	RARRER	Rt_file_id_warningRRRs(RR((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytsafe_file_ids
cC@stS(sRReturn True if this platform normalizes unicode filenames.

    Only Mac OSX.
    (t_platform_normalizes_filenames(((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytnormalizes_filenamesscC@stjdt|tfS(s!Get the unicode normalized path, and if you can access the file.

    On platforms where the system normalizes filenames (Mac OSX),
    you can access a file by any path which will normalize correctly.
    On platforms where the system does not normalize filenames
    (everything else), you have to access a file by its exact path.

    Internally, bzr only supports NFC normalization, since that is
    the standard for XML documents.

    So return the normalized path, and a flag indicating if the file
    can be accessed by that path.
    R(RRRRT(R2((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt_accessible_normalized_filenamescC@s1tj}tjdt|}|||kfS(NR(Rt__doc__RRR(R2Rt
normalized((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt!_inaccessible_normalized_filenames	c@syddl}|jWn+tk
r-dStk
rFdnX|refd}n}|j|}|rtn|S(stA wrapper for signal.signal that also calls siginterrupt(signum, False)
    on platforms that support that.

    :param restart_syscall: if set, allow syscalls interrupted by a signal to
        automatically restart (by calling `signal.siginterrupt(signum,
        False)`).  May be ignored if the feature is not available on this
        platform or Python version.
    iNcS@sdS(N(RA(tsignumtflag((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt<lambda>sc@st|dS(N(RV(R(thandlertsiginterruptR(s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytsig_handlers
(tsignalRtImportErrorRAtAttributeErrorRV(RRtrestart_syscallRRtold_handler((RRRs2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytset_signal_handlers	



iPtno_datacC@sgyttjd}Wnttfk
r6d}nX|dk	rZ|dkrS|SdSnttjdd}|dks|rdSt	dd\}}}t
dkr|ada
n!t
dkrt|krda
nt
dkr	|dk	r	|dkr	|SnyttjdSWnttfk
r7nXt
dkrc|dk	rc|dkrc|SndS(	sReturn terminal width.

    None is returned if the width can't established precisely.

    The rules are:
    - if BZR_COLUMNS is set, returns its value
    - if there is no controlling terminal, returns None
    - query the OS, if the queried size has changed since the last query,
      return its value,
    - if COLUMNS is set, returns its value,
    - if the OS has a value (even though it's never changed), return its value.

    From there, we need to query the OS to get the size of the controlling
    terminal.

    On Unices we query the OS by:
    - get termios.TIOCGWINSZ
    - if an error occurs or a negative value is obtained, returns None

    On Windows we query the OS by:
    - win32utils.get_console_size() decides,
    - returns None on error (provided default value)
    tBZR_COLUMNSitisattyRt	unchangedtchangedtCOLUMNSN(R'RRwRPRhRAR)RRt_terminal_sizet_terminal_size_statet_first_terminal_size(twidthRtheighttos_size((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytterminal_widths:'
		cC@s(tjd|d|\}}||fS(Ntdefaultxtdefaulty(t
win32utilstget_console_size(RR((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt_win32_terminal_sizeVscC@syzddl}ddl}ddl}|jddddd}|jd|j|}|jd|dd!\}}Wnttfk
rnX||fS(NitHHHHii(	tstructtfcntlttermiostpacktioctlt
TIOCGWINSZtunpackR'R(RRRRRRtx((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt_ioctl_terminal_size[s$#cC@s
tjdkS(NR(RRU(((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytsupports_executabletscC@s
tjdkS(sReturn True if 'readonly' has POSIX semantics, False otherwise.

    Notably, a win32 readonly file cannot be deleted, unlike POSIX where the
    directory controls creation/deletion, etc.

    And under win32, readonly means that the directory itself cannot be
    deleted.  The contents of a readonly directory can be changed, unlike POSIX
    where files in readonly directories cannot be added, deleted or renamed.
    R(RRU(((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytsupports_posix_readonlyxs
cC@sotjj|}|dkr:|dk	rktj|=qkn1t|tr^|jt}n|tj|<|S(s)Modify the environment, setting or removing the env_variable.

    :param env_variable: The environment variable in question
    :param value: The value to set the environment to. If None, then
        the variable will be removed.
    :return: The original value of the environment variable.
    N(RRwRxRARRRsR(tenv_variabletvaluetorig_val((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytset_or_unset_envs
s^([A-Za-z]:[/\\])?[^:<>*"?\|]*$cC@s>tjdkrdStj|dkr:tj|ndS(sCheck whether the supplied path is legal.
    This is only required on Windows, so we don't test on other platforms
    right now.
    RN(RRUt_validWin32PathREtmatchRARtIllegalPath(R2((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytcheck_legal_pathsicC@skt|dd}|tjksctjdkrg|tksc|tjkrgt|ddtkrgtSt	S(seCheck if this exception represents ENOTDIR.

    Unfortunately, python is very inconsistent about the exception
    here. The cases are:
      1) Linux, Mac OSX all versions seem to set errno == ENOTDIR
      2) Windows, Python2.4, uses errno == ERROR_DIRECTORY (267)
         which is the windows error code.
      3) Windows, Python2.5 uses errno == EINVAL and
         winerror == ERROR_DIRECTORY

    :param e: An Exception object (expected to be OSError with an errno
        attribute, but we should be able to cope with anything)
    :return: True if this represents an ENOTDIR error. False otherwise.
    R%RtwinerrorN(
R)RAR%R^RRUt_WIN32_ERROR_DIRECTORYRRTRV(R/ten((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt_is_error_enotdirsc#@sntj}ttj}t}t|ddt|fg}x%|ri|j\}}}}}|ry|d}nd}|d}	g}
|
j}yt	t
t||}Wn%tk
r}
t
|
s2q2nTXxP|D]H}|	|}||}||j}|||||||fqW||f|
fV|jfdt|
DqEWdS(sAYield data about all the directories in a tree.

    This yields all the data about the contents of a directory at a time.
    After each directory has been yielded, if the caller has mutated the list
    to exclude some directories, they are then not descended into.

    The data yielded is of the form:
    ((directory-relpath, directory-path-from-top),
    [(relpath, basename, kind, lstat, path-from-top), ...]),
     - directory-relpath is the relative path of the directory being returned
       with respect to top. prefix is prepended to this.
     - directory-path-from-root is the path including top for this directory.
       It is suitable for use with os functions.
     - relpath is the relative path within the subtree being walked.
     - basename is the basename of the path
     - kind is the kind of the file now. If unknown then the file is not
       present within the tree - but it may be recorded as versioned. See
       versioned_kind.
     - lstat is the stat data *if* the file was statted.
     - planned, not implemented:
       path_from_tree_root is the path from the root of the tree.

    :param prefix: Prefix the relpaths that are yielded with 'prefix'. This
        allows one to walk a subtree but get paths that are relative to a tree
        rooted higher up.
    :return: an iterator over the dirs.
    RJu/c3@s%|]}|dkr|VqdS(iN((t.0td(t
_directory(s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pys	<genexpr>sN(RRt_directory_kindRotfile_kind_from_stat_modeRRARAR:R7RRR(RRtextendRj(ttoptprefixt_lstatRut_kind_from_modetpendingtrelroott_t	relprefixt	top_slashtdirblockR:tnamesR/RRt	statvalueRQ((Rs2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytwalkdirss2!		$	

	


!t	DirReadercB@s#eZdZddZdZRS(s%An interface for reading directories.RJcC@st|jdS(sConverts top and prefix to a starting dir entry

        :param top: A utf8 path
        :param prefix: An optional utf8 path to prefix output relative paths
            with.
        :return: A tuple starting with prefix, and ending with the native
            encoding of top.
        N(tNotImplementedErrorttop_prefix_to_starting_dir(tselfRR((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyRs	cC@st|jdS(s1Read a specific dir.

        :param prefix: A utf8 prefix to be preprended to the path basenames.
        :param top: A natively encoded path to read.
        :return: A list of the directories contents. Each item contains:
            (utf8_relpath, utf8_name, kind, lstatvalue, native_abspath)
        N(Rtread_dir(RRR((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyRs(t__name__t
__module__RRR(((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyRsc
c@std
krtjdkr^tjdkr^yddlm}|aWqtk
rZqXqt	dkryddl
m}|aWqtk
r}t|qXqntd
krt
antj||gg}tj}t}x|r|dj\}}	}	}	}|ds+|jnt|||}
||f|
fVgt|
D]}|d	|kr^|^q^}|r|j|qqWd
S(sYield data about all the directories in a tree.

    This yields the same information as walkdirs() only each entry is yielded
    in utf-8. On platforms which have a filesystem encoding of utf8 the paths
    are returned as exact byte-strings.

    :return: yields a tuple of (dir_info, [file_info])
        dir_info is (utf8_relpath, path-from-top)
        file_info is (utf8_relpath, utf8_name, kind, lstat, path-from-top)
        if top is an absolute path, path-from-top is also an absolute path.
        path-from-top might be unicode or utf8, but it is the correct path to
        pass to os functions to affect the file in question. (such as os.lstat)
    Rs
Windows NTi(tWin32ReadDirsutf-8tascii(t
UTF8DirReaderiiN(sutf-8sascii(t_selected_dir_readerRARRURtwinvertbzrlib._walkdirs_win32RRR
tbzrlib._readdir_pyxRRHtUnicodeDirReaderRRRRAR7RjR:(
RRRRR/RRRRRRRtnext((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt_walkdirs_utf8 s8




		

/RcB@s5eZdZdgZdZddZdZRS(s9A dir reader for non-utf8 file systems, which transcodes.t_utf8_encodecC@stjd|_dS(NR(Rt
getencoderR(R((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt__init__]sRJcC@st|dddt|fS(s)See DirReader.top_prefix_to_starting_dir.N(RRAR(RRR((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyR`scC@s|j}tj}tj}t}|r4|d}nd}|d}g}	|	j}
xt||D]}y||d}Wn1tk
rtj	||d|t
nX||}
||
}||j}|
||||||
fqfW|	S(sRead a single directory from a non-utf8 file system.

        top, and the abspath element in the output are unicode, all other paths
        are utf8. Local disk IO is done via unicode calls to listdir etc.

        This is currently the fallback code path when the filesystem encoding is
        not UTF-8. It may be better to implement an alternative so that we can
        safely handle paths that are not properly decodable in the current
        encoding.

        See DirReader.read_dir for details.
        R0RJu/i(RRRRoRR:R7RRRyR
R(RRRRRRuRRRRR:Rt	name_utf8RRRQ((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyRds*
			

	

!(RRRt	__slots__RRR(((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyRXs
		c
C@sd}d}itjd6|d6|d6}|j|tjj|sc|d||nxQt|d|D]=\}}x.|D]&\}}	}
}}||
||qWqvWdS(scCopy all of the entries in from_path into to_path.

    :param from_path: The base directory to copy.
    :param to_path: The target directory. If it does not exist, it will
        be created.
    :param handlers: A dictionary of functions, which takes a source and
        destinations for files, directories, etc.
        It is keyed on the file kind, such as 'directory', 'symlink', or 'file'
        'file', 'directory', and 'symlink' should always exist.
        If they are missing, they will be replaced with 'os.mkdir()',
        'os.readlink() + os.symlink()', and 'shutil.copy2()', respectively.
    cS@stj|dS(N(Rtmkdir(tsourceR[((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytcopy_dirscS@s#tj|}tj||dS(sCopy the contents of a symlinkN(RRbRM(RR[tlink_to((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt	copy_linksRKRMRGRN(Rtcopy2RRR2texistsR(
t	from_pathtto_paththandlersRRt
real_handlerstdir_infotentriesRnRRQRR((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt	copy_trees		


cC@sttdd}|dkr"dS|dkrXtjj|}|dkrXd}qXny)tj|}|||j|jWn0tk
r}t	j
d||t	jnXdS(sCopy usr/grp ownership from src file/dir to dst file/dir.

    If src is None, the containing directory is used as source. If chown
    fails, the error is ignored and a warning is printed.
    tchownNRJRsLUnable to copy ownership from "%s" to "%s". You may want to set it manually.(R)RRAR2RXRtst_uidtst_gidR(R,RJtlog_exception_quietly(tdstRZRRR/((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytcopy_ownership_from_paths
cC@st||fS(swGenerate a prefix-order path key for path.

    This can be used to sort paths in the same way that walkdirs does.
    (RX(R2((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytpath_prefix_keyscC@s%t|}t|}t||S(sCCompare path_a and path_b to generate the same order walkdirs uses.(Rtcmp(tpath_atpath_btkey_atkey_b((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytcompare_paths_prefix_orderscC@st|r"tdtddntdk	r2tStjdkrnttdddk	rntj	tj
}ntjt}yt
j|j}Wn:tk
r|d
krtjjd|nd	}n(X|d	krtjd
krd}qn|a|S(s#Find out what the preferred user encoding is.

    This is generally the encoding that is used for command line parameters
    and file contents. This may be different from the terminal encoding
    or the filesystem encoding.

    :return: A string defining the preferred user encoding
    s.use_cache should only have been used for testsRitposixtCODESETRJRsCbzr: warning: unknown encoding %s. Continuing with ascii encoding.
RRsutf-8N(RJscp0(Rtwarn_deprecatedRt_cached_user_encodingRARRR)tlocaletnl_langinfoRtgetpreferredencodingRVRRRRRRRU(t	use_cacheR((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyRs(
'

cC@stS(N(R(((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytget_diff_header_encodingscC@s?tjdkrtjSddl}|jjtSdS(sReturn the current unicode host name.

    This is meant to be used in place of socket.gethostname() because that
    behaves inconsistently on different platforms.
    RiN(RRURt
get_host_nametsockettgethostnameRR(R((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyRs
i@it
WSAECONNRESETtWSAECONNABORTEDcC@sxy|j|}WnKtjk
rc}|jd}|tkrHdS|tjkr]qnqX|dk	r|t|dn|SqdS(sRead up to max_read_size of bytes from sock and notify of progress.

    Translates "Connection reset by peer" into file-like EOF (return an
    empty string rather than raise an error), and repeats the recv if
    interrupted by a signal.
    iRJRN(	trecvRterrorRt_end_of_stream_errorsR%tEINTRRAR5(tsockRt
max_read_sizeRR/teno((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytread_bytes_from_socket1s
cC@sYd}xLt||krTt|d|t|}|dkrGPn||7}q	W|S(sReceive an exact number of bytes.

    Regular Socket.recv() may return less than the requested number of bytes,
    depending on what's in the OS buffer.  MSG_WAITALL is not available
    on all platforms, but this should work everywhere.  This will return
    less than the requested amount if the remote end closes.

    This isn't optimized and is intended mostly for use in testing.
    RJN(R5R"RA(RtcountRRc((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytrecv_allLs
cC@sd}t|}x||kry|jt||t}Wn`tjtfk
r}|jdtkrt	j
d|n|jdtjkrqqX|dkrt	j
d|fn||7}|dk	r||dqqWdS(sSend all bytes on a socket.

    Breaks large blocks in smaller chunks to avoid buffering limitations on
    some platforms, and catches EINTR which may be thrown if the send is
    interrupted by a signal.

    This is preferred to socket.sendall(), because it avoids portability bugs
    and provides activity reporting.

    :param report_activity: Call this as bytes are read, see
        Transport._report_activity
    isError trying to write to socketsSending to %s returned 0 bytesRN(R5tsendRtMAX_SOCKET_CHUNKRRR'RRRtConnectionResetR%RRA(RRRt
sent_totalt
byte_counttsentR/((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytsend_all_s"

	
cC@stjd}|\}}xtj||dtjD]}}|\}}}}}	d}
y*tj|||}
|
j|	|
SWq7tjk
r}|
dk	r|
jqq7Xq7W|dS(Ns!getaddrinfo returns an empty listi(RRtgetaddrinfotSOCK_STREAMRAtconnectR(taddressterrthosttporttrestaftsocktypetprotot	canonnametsaR((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytconnect_sockets"
cC@s4tjj|\}}tttd||S(sDetermine the real path to a file.

    All parent elements are dereferenced.  But the file itself is not
    dereferenced.
    :param path: The original path.  May be absolute or relative.
    :return: the real path *to* the file
    R(RR2R1R\Rr(R2tparentRf((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytdereference_pathscC@s
tjdkS(s7Return True if we can use MAPI to launch a mail client.R(RRU(((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt
supports_mapiscC@s|dkr|}nS|jdrU|tdjdtj}t||}ntjd|tt	j
}ttddrtt|dd}ntt||d}z|jSWd|jXdS(	sLoad a resource from a package and return it as a string.

    Note: Only packages that start with bzrlib are currently supported.

    This is designed to be a lightweight implementation of resource
    loading in a way which is API compatible with the same API from
    pkg_resources. See
    http://peak.telecommunity.com/DevCenter/PkgResources#basic-resource-access.
    If and when pkg_resources becomes a standard library, this routine
    can delegate to it.
    tbzrlibsbzrlib.Rs!resource package %s not in bzrlibtfrozens..trUN(RvR5RRtsepR\RRRXR=t__file__R)RRARRKRR(tpackaget
resource_nametresource_relpathRfRE((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytresource_strings
	cC@s_ttkrUy ddlm}|jaWqUtk
rQ}ddlmaqUXnt|S(Ni(R(R(Rtfile_kind_from_stat_mode_thunkRRtkind_from_modeRtbzrlib._readdir_pyR(R.RR/((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyRFscC@say||SWnLtk
r\}t|ddtjtjfkrVtj|nnXdS(NR%(R(R)RAR%RUR^RR](RERR/((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt	file_stats$cC@st||}t|jS(N(RIRR(RERt
stat_value((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt	file_kindscO@sYxRtrTy|||SWqttfk
rP}|jtjkrJqnqXqWdS(svRun f(*a, **kw), retrying if an EINTR error occurs.

    WARNING: you must be certain that it is safe to retry the call repeatedly
    if EINTR does occur.  This is typically only true for low-level operations
    like os.read.  If in any doubt, don't use this.

    Keep in mind that this is not a complete solution to EINTR.  There is
    probably code in the Python standard library and other dependencies that
    may encounter EINTR if a signal arrives (and there is signal handler for
    that signal).  So this function can reduce the impact for IO that bzrlib
    directly controls, but it is not a complete solution.
    N(RTR'R(R%R(RERtkwR/((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytuntil_no_eintrs	icC@ssy'tj||}|jd|SWnEtjk
rn}|rOd|}ntjd||jfnXdS(s@Return a compiled re, or raise a sensible error.

    This should only be used when compiling user-supplied REs.

    :param re_string: Text form of regular expression.
    :param flags: eg re.IGNORECASE
    :param where: Message explaining to the user the context where
        it occurred, eg 'log search filter'.
    RJs in s Invalid regular expression%s: %sN(RBRCRDRtInvalidPatterntBzrCommandErrortmsg(t	re_stringtflagstwheretre_objR/((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytre_compile_checkeds

	cC@sddl}|jS(Ni(tmsvcrttgetch(RV((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytgetchar	scC@swddl}ddl}tjj}|j|}z#|j|tjjd}Wd|j||j	|X|S(Nii(
tttyRRRR/t	tcgetattrtsetrawRt	tcsetattrt	TCSADRAIN(RYRtfdtsettingsRd((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyRX	s
tlinuxcC@s3ytjdSWntttfk
r.dSXdS(NtSC_NPROCESSORS_ONLN(RtsysconfRhR(RRA(((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt_local_concurrency&	scC@s)tjdddgdtjjdS(Ntsysctls-nshw.availcpuRi(t
subprocesstPopentPIPEtcommunicate(((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyRc,	stbsdcC@s)tjdddgdtjjdS(NRds-nshw.ncpuRi(ReRfRgRh(((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyRc0	stsunos5cC@s&tjddgdtjjdS(Ntpsrinfos-pRi(ReRfRgRh(((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyRc4	scC@stjjdS(NtNUMBER_OF_PROCESSORS(RRwRx(((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyRc8	scC@sdS(N(RA(((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyRc<	scC@stdk	r|rtStjjdd}|dkryddl}|j}Wqttfk
ry
t	}Wqt
tfk
rqXqXnyt|}Wnt
tfk
rd}nX|r|}n|S(sReturn how many processes can be run concurrently.

    Rely on platform specific implementations and default to 1 (one) if
    anything goes wrong.
    tBZR_CONCURRENCYiNi(t_cached_local_concurrencyRARRwRxtmultiprocessingt	cpu_countRRRcR(R'R't	TypeErrorRh(RtconcurrencyRot_cached_concurrency((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytlocal_concurrencyC	s&

	tUnicodeOrBytesToBytesWritercB@s#eZdZddZdZRS(s2A stream writer that doesn't decode str arguments.tstrictcC@s#tjj|||||_dS(N(RtStreamWriterRRs(RRststreamR((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyRg	scC@sTt|tkr%|jj|n+|j||j\}}|jj|dS(N(R~RERxRRsR(RtobjecttdataR((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyRk	s(RRRRR(((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyRud	strcC@sd|k}d|k}d|k}d|k}t}|rI|tO}n
|tO}|r|ro|tjO}n
|tjO}|tjtjBO}nc|r|r|tjO}n
|tjO}|tjtjBO}n#|r|tjO}n
|tj	O}tj
tj||||S(s
This function is used to override the ``open`` builtin.

        But it uses O_NOINHERIT flag so the file handle is not inherited by
        child processes.  Deleting or renaming a closed file opened with this
        function is not blocking child processes.
        twRRNR(RRR
RtO_RDWRtO_WRONLYtO_CREATtO_TRUNCtO_APPENDRtfdopenR(R!R.tbufsizetwritingt	appendingtupdatingtbinaryRR((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt	open_files	s,




cC@sGd}d||f}x*||rB|d7}d||f}qW|S(sFind a non-existing backup file name.

    This will *not* create anything, this only return a 'free' entry.  This
    should be used for checking names in a directory below a locked
    tree/branch/repo to avoid race conditions. This is LBYL (Look Before You
    Leap) and generally discouraged.

    :param base: The base name.

    :param exists: A callable returning True if the path parameter exists.
    is%s.~%d~((RfRtcounterR((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytavailable_backup_name	s
cC@s`yBddl}|j||j}|j||j||jBWnttfk
r[nXdS(sqSet a Unix file descriptor's FD_CLOEXEC flag.  Do nothing if platform
    support for this is not available.
    iN(RtF_GETFDtF_SETFDt
FD_CLOEXECRR(R^RRb((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytset_fd_cloexec	s!cC@sctjdkrtjjddjtj}g|D]}|j^q7}tjj	|\}}|dkr|j|krdS|}|g}qn	dg}tjjd}|dk	r.|jtj}xT|D]I}x@|D]8}tjj|||}tj|tj
r|SqWqWntjdkr_tj|}||kr_|SndS(s6Finds an executable on the PATH.
    
    On Windows, this will try to append each extension in the PATHEXT
    environment variable to the name, if it cannot be found with the name
    as given.
    
    :param name: The base name of the executable.
    :return: The path to the executable found or None.
    RtPATHEXTRJtPATHN(RRURRwRxR1tpathsepRaR2tsplitextRARntaccesstX_OKRtget_app_path(RtextstextRfR2RREtapp_path((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytfind_executable_on_path	s.
!	

cC@svytj|dWnWtk
rm}|jtjkr<tS|jtjkrRtStd||ftSnXtSdS(s>True if pid doesn't correspond to live process on this machineisos.kill(%d, 0) failed: %sN(	RtkillR(R%tESRCHRTR*RVR-(tpidR/((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt_posix_is_local_pid_dead	stEAGAINRtENOTSUPt
EOPNOTSUPPR+cC@sttdttdd}|dk	ry||Wqtk
r}tjd|ft|ddtkrqqXndS(sFlush file contents to disk if possible.
    
    :param fileno: Integer OS file handle.
    :raises TransportNotPossible: If flushing to disk is not possible.
    t	fdatasynctfsyncs$ignoring error calling fdatasync: %sR%N(R)RRAR'R,R-t_fdatasync_ignored(R/tfnR/((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyR
scC@sgytj|WnOtk
rb}|jtjkr;ntj|gkrc||qcnXdS(sMake sure a local directory exists and is empty.
    
    If it does not exist, it is created.  If it exists and is not empty, an
    instance of exception_class is raised.
    N(RRR(R%tEEXISTRo(R2texception_classR/((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytensure_empty_directory_exists
scC@sBt|ttjfrtStjdkr>tj|r>tSt	S(sTrue if exception instance is due to a process environment issue

    This includes OSError and IOError, but also other errors that come from
    the operating system or core libraries but are not subclasses of those.
    R(
RtEnvironmentErrortselectRRTRRURt_is_pywintypes_errorRV(tevalue((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pytis_environment_error%
s
(swin32sdarwini(iii(t
__future__RR%RRBRRRYRtbzrlib.lazy_importRtglobalstbzrlib.symbol_versioningRRRRRRthashlibRRRR=R	R
t
timer_funcRUtclockR)RR
RRR#R$R R>RAR@RFRRIRORRR2RSRkRqRtRpR{R~RRRRRRRRRRRRRRRrRnR\Rutpath_from_environt
_get_home_dirtgetuser_unicodeRRoRXRWR1RRR.RRgRRRRRRRVRREtget_environ_unicodetget_home_locationt
get_user_nameRRRRRR9RRRRRRRRRRRRRRtwdRRTRt
_offset_cacheRRRR%R-R1turandomR7RRR9R[R?R@RDRFRHRMtbzrlib._chunks_to_lines_pyxRNR/tbzrlib._chunks_to_lines_pyRPRORVR\R^R]R_R`RaRbReRfRnR{R|R}RRRRRRRRRRRtnormalized_filenameRtdefault_terminal_widthRRRRRRRRRRCRRRRRRyRRRRRRRRRRRRR&t
ECONNRESETtEPIPERRt_enoR:R"R$R+R9R;R<RERFRRIRKRMRURXRvRcRnRtRwRuRRRRRRtis_local_pid_deadt_maybe_ignoredRRRRR(((s2/usr/lib/python2.7/dist-packages/bzrlib/osutils.pyt<module>s"	(									

			O								
															
				
					5							/										1			
					
		
				
										&	4		
								$	U		
				
			B83*		2			!					
				!(		
	$	
-		

Copyright © 2017 || Recoded By Mr.Bumblebee