-=[ Mr. Bumblebee ]=-
_Indonesia_

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

ó
	ƒ_Oc@@sdZddlmZddlZddlmZmZmZddlZddl	m
Z
e
eƒdƒddlm
Z
ejejBejBejBejBZejejBejBejBejBZde
jfd	„ƒYZd
efd„ƒYZd„ZdS(
sWTransport for the local filesystem.

This is a fairly thin wrapper on regular file IO.
i(tabsolute_importN(tST_MODEtS_ISDIRtS_IMODE(tlazy_imports¥
import errno
import shutil

from bzrlib import (
    atomicfile,
    osutils,
    urlutils,
    symbol_versioning,
    )
from bzrlib.transport import LateReadError
(t	transporttLocalTransportcB@sÐeZdZd„Zd'd„Zd„Zd„Zd„Zd„Z	d„Z
d„Zd'd	„Zd'd
„Z
d'ed'd„Zd'ed'd„Zd'ed'd
„Zd„Zd'd„Zd'd„Zd'd„Zd'd„Zd'd„Zd'd„Zd'd„Zd„Zd„Zd„Zd„Zd„Zd„Zd'd'd„Z d„Z!d„Z"d„Z#d „Z$d!„Z%d"„Z&e'j(ƒr•d#„Z)ne'j*ƒr­d$„Z+ne'j,ƒrÅd%„Z-nd&„Z.RS((s8This is the transport agent for local filesystem access.cC@sÕ|jdƒs"td|ƒ‚n|ddkr?|d}ntjdkrƒ|dkrƒd}d|_tt|ƒj|ƒdStt|ƒj|ƒtj	|ƒ|_|jddkrÑ|jd|_ndS(	s-Set the base path where files will be stored.sfile://snot a file:// url: %riÿÿÿÿt/twin32sfile:///tN(
t
startswithtAssertionErrortsystplatformt_local_basetsuperRt__init__turlutilstlocal_path_from_url(tselftbase((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pyR4s
	cC@sN|dkrt|jƒS|j|ƒ}|dkr@|j}nt|ƒSdS(s±Return a new LocalTransport with root at self.base + offset
        Because the local filesystem does not require a connection,
        we can just return a new object.
        sfile://N(tNoneRRtabspath(RtoffsetR((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pytcloneHs
cC@s4|dkr tj|jƒdS|jtj|ƒS(s´Return a path for use in os calls.

        Several assumptions are made:
         - relative_reference does not contain '..'
         - relative_reference is url escaped.
        t.R	i(RR	(tosutilstsplitRRtunescape(Rtrelative_reference((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pyt_abspathXscC@sutjtj|jtj|ƒƒƒ}tjdkrh|jdd!dkrh|dkrh|jd }ntj|ƒS(s.Return the full url to the given relative URL.Riit:Ri(	RtnormpathtpathjoinRRRRR
tlocal_path_to_url(Rtrelpathtpath((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pyRfs%cC@s|j|ƒ}tj|ƒS(sTransform the given relative path URL into the actual path on disk

        This function only exists for the LocalTransport, since it is
        the only one that has direct local access.
        This is mostly for stuff like WorkingTree which needs to know
        the local working directory.  The returned path will always contain
        forward slashes as the path separator, regardless of the platform.

        This function is quite expensive: it calls realpath which resolves
        symlinks.
        (RRR(RR#tabsurl((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pyt
local_abspathyscC@s(|dkrd}ntj|j|ƒS(sBReturn the local path portion from a given absolute path.
        u.N(RRtfile_relpathR(RR((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pyR#‰s	cC@stj|j|ƒtjƒS(N(tostaccessRtF_OK(RR#((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pythas‘scC@s¡|j|ƒ}|tjkr2tj|jƒny#|j|ƒ}tj|dƒSWnEttfk
rœ}|j	t	j
kr‰t|ƒS|j||ƒnXdS(shGet the file at the given relative path.

        :param relpath: The relative path to the file
        trbN(
RRt
_file_streamstflushRRt	open_filetIOErrortOSErrorterrnotEISDIRt
LateReadErrort_translate_error(RR#t
canonical_urlR$te((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pytget”s
cC@sœ|}y8|j|ƒ}tj|ƒtj|dd|ƒ}Wn)ttfk
ri}|j||ƒnXz |j||ƒ}|j	ƒWd|j
ƒX|S(sCopy the file-like object into the location.

        :param relpath: Location to put the contents, relative to base.
        :param f:       File-like object.
        :param mode: The mode for the newly created file,
                     None means just use the default
        twbtnew_modeN(RRtcheck_legal_patht
atomicfilet
AtomicFileR0R1R5t_pumptcommittclose(RR#tftmodeR$tfpR7tlength((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pytput_file¤s	
cC@s |}y8|j|ƒ}tj|ƒtj|dd|ƒ}Wn)ttfk
ri}|j||ƒnXz$|rƒ|j|ƒn|j	ƒWd|j
ƒXdS(s“Copy the string into the location.

        :param relpath: Location to put the contents, relative to base.
        :param bytes:   String
        R9R:N(RRR;R<R=R0R1R5twriteR?R@(RR#tbytesRBR$RCR7((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pyt	put_bytes»s
cC@s}|j|ƒ}|dkr$d}n|}ytj|t|ƒ}WnÑttfk
r}	|s}|	jtjtj	fkr|j
|	|ƒntjj|ƒ}
|
s»|j
|	|ƒn|j
|
d|ƒytj|t|ƒ}Wqttfk
r}	|j
|	|ƒqXnXzQtj|ƒ}|dk	r]|t|jƒkr]tj||ƒn||ƒWdtj|ƒXdS(sÍCommon functionality information for the put_*_non_atomic.

        This tracks all the create_parent_dir stuff.

        :param relpath: the path we are putting to.
        :param writer: A function that takes an os level file descriptor
            and writes whatever data it needs to write there.
        :param mode: The final file mode.
        :param create_parent_dir: Should we be creating the parent directory
            if it doesn't exist?
        i¶RBN(RRR(topent_put_non_atomic_flagsR0R1R2tENOENTtENOTDIRR5R$tdirnamet_mkdirtfstatRtst_modeRtchmod_if_possibleR@(RR#twriterRBtcreate_parent_dirtdir_modeRt
local_modetfdR7t
parent_dirtst((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pyt_put_non_atomic_helperÐs0	!c	@s8‡‡fd†}ˆj||d|d|d|ƒdS(sCopy the file-like object into the target location.

        This function is not strictly safe to use. It is only meant to
        be used when you already know that the target does not exist.
        It is not safe, because it will open and truncate the remote
        file. So there may be a time when the file has invalid contents.

        :param relpath: The remote location to put the contents.
        :param f:       File-like object.
        :param mode:    Possible access permissions for new file.
                        None means do not set remote permissions.
        :param create_parent_dir: If we cannot create the target file because
                        the parent directory does not exist, go ahead and
                        create it, and then try again.
        c@sˆjˆ|ƒdS(N(t_pump_to_fd(RV(RAR(s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pyRRsRBRSRTN(RY(RR#RARBRSRTRR((RARs:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pytput_file_non_atomicsc	@s5‡fd†}|j||d|d|d|ƒdS(Nc@sˆrtj|ˆƒndS(N(R(RF(RV(RG(s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pyRRsRBRSRT(RY(RR#RGRBRSRTRR((RGs:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pytput_bytes_non_atomicscc@sšt|jdƒƒ}x~|r•|jdƒ}|j|ƒ}t|tƒrxCt|j|ƒƒD]$\}}|j||d|ƒqbWq|VqWdS(s<Iter the relative paths of files in the transports sub-tree.u.iRN(tlisttlist_dirtpoptstatRRt	enumeratetinsert(RtqueueR#RXtitbasename((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pytiter_files_recursive"s	"cC@s®|dkrd}n|}ytj||ƒWn)ttfk
rZ}|j||ƒnX|dk	rªytj||ƒWqªttfk
r¦}|j||ƒqªXndS(s/Create a real directory, filtering through modeiÿN(RR(tmkdirR0R1R5RRQ(RRRBRUR7((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pyRN.s	cC@s |j|j|ƒd|ƒdS(s%Create a directory at the given path.RBN(RNR(RR#RB((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pyRg?scC@s¬|j|ƒ}ytj|dƒ}Wn)ttfk
rP}|j||ƒnX|jƒ|dk	rƒ|j||j	ƒ|ƒn|t
j|j|ƒ<t
j
|||ƒS(s See Transport.open_write_stream.R9N(RRR/R0R1R5ttruncateRt_check_mode_and_sizetfilenoRR-RtFileFileStream(RR#RBRthandleR7((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pytopen_write_streamCs
cC@sw|j|ƒ}|dkr$d}n|}y|tj|t|ƒfSWn)ttfk
rr}|j||ƒnXdS(s$Call os.open() for the given relpathi¶N(RRR(RIt
_append_flagsR0R1R5(RR#RBtfile_abspathRUR7((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pyt_get_append_filePs	cC@sJtj|ƒ}|dk	rC|t|jƒkrCtj||ƒn|jS(s7Check the mode of the file, and return the current sizeN(R(RORRRPRRQtst_size(RRoRVRBRX((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pyRi]s!cC@s\|j|d|ƒ\}}z,|j||d|ƒ}|j||ƒWdtj|ƒX|S(s@Append the text in the file-like object into the final location.RBN(RpRiRZR(R@(RR#RARBRoRVtresult((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pytappend_filefscC@se|j|d|ƒ\}}z5|j||d|ƒ}|rOtj||ƒnWdtj|ƒX|S(s6Append the text in the string into the final location.RBN(RpRiR(RFR@(RR#RGRBRoRVRr((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pytappend_bytespscC@s@d}x3tr;|j|ƒ}|s(Pntj||ƒq	WdS(s%Copy contents of one file to another.i€N(tTruetreadR(RF(Rtfromfiletto_fdtBUFSIZEtb((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pyRZ{s	cC@sb|j|ƒ}|j|ƒ}ytj||ƒWn)ttfk
r]}|j||ƒnXdS(s3Copy the item at rel_from to the location at rel_toN(RtshutiltcopyR0R1R5(Rtrel_fromtrel_tot	path_fromtpath_toR7((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pyR|„scC@sb|j|ƒ}|j|ƒ}ytj||ƒWn)ttfk
r]}|j||ƒnXdS(N(RR(trenameR0R1R5(RR}R~RR€R7((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pyRŽscC@sb|j|ƒ}|j|ƒ}ytj||ƒWn)ttfk
r]}|j||ƒnXdS(s3Move the item at rel_from to the location at rel_toN(RRRR0R1R5(RR}R~RR€R7((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pytmovešscC@sV|}y |j|ƒ}tj|ƒWn)ttfk
rQ}|j||ƒnXdS(sDelete the item at relpathN(RR(tremoveR0R1R5(RR#R$R7((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pytdelete¦scC@s|jS(s,See bzrlib.transport.Transport.external_url.(R(R((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pytexternal_url¯scC@sÿt|tƒrÖ|j|ƒ}d}x«|D]£}|j|d||ƒyQ|j|ƒ}|j|ƒ}	tj||	ƒ|dk	r—tj	|	|ƒnWn)t
tfk
rÃ}
|j|
|ƒnX|d7}q+W|St
t|ƒj||d|d|ƒSdS(s„Copy a set of entries from self into another Transport.

        :param relpaths: A list/generator of entries to be copied.
        iscopy-toiRBtpbN(t
isinstanceRt
_get_totalt
_update_pbRR{R|RRRQR0R1R5Rtcopy_to(RtrelpathstotherRBR†ttotaltcountR$tmypatht	otherpathR7((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pyRŠ´s 
cC@stS(sSee Transport.listable.(Ru(R((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pytlistableÎscC@sn|j|ƒ}ytj|ƒ}Wn)ttfk
rM}|j||ƒnXg|D]}tj|ƒ^qUS(s¥Return a list of all files at the given location.
        WARNING: many transports do not support this, so trying avoid using
        it if at all possible.
        (RR(tlistdirR0R1R5Rtescape(RR#R$tentriesR7tentry((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pyR^ÒscC@sV|}y |j|ƒ}tj|ƒSWn)ttfk
rQ}|j||ƒnXdS(s0Return the stat information for a file.
        N(RR(tlstatR0R1R5(RR#R$R7((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pyR`ÞscC@scddlm}|}y|j|ƒ}||ƒSWn)ttfk
r^}|j||ƒnXdS(sƒLock the given file for shared (read) access.
        :return: A lock object, which should be passed to Transport.unlock()
        i(tReadLockN(tbzrlib.lockR—RR0R1R5(RR#R—R$R7((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pyt	lock_readèscC@s#ddlm}||j|ƒƒS(s×Lock the given file for exclusive (write) access.
        WARNING: many transports do not support this, so trying avoid using it

        :return: A lock object, which should be passed to Transport.unlock()
        i(t	WriteLock(R˜RšR(RR#Rš((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pyt
lock_writeôscC@sV|}y |j|ƒ}tj|ƒWn)ttfk
rQ}|j||ƒnXdS(sSee Transport.rmdir.N(RR(trmdirR0R1R5(RR#R$R7((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pyRœýscC@stj|j|ƒƒS(sSee Transport.readlink.(RtreadlinkR(RR#((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pyRscC@sVy&tj|j|ƒ|j|ƒƒWn)ttfk
rQ}|j||ƒnXdS(sSee Transport.link.N(R(tlinkRR0R1R5(Rtsourcet	link_nameR7((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pythardlinks&cC@s€tj|j|ƒƒ}tj||j|ƒƒ}ytj||j|ƒƒWn)ttfk
r{}|j	||ƒnXdS(sSee Transport.symlink.N(
RRMRR'R(tsymlinkRR0R1R5(RRŸR tabs_link_dirpatht
source_relR7((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pyR¢scC@stjdkrtStSdS(NR(RR
tFalseRu(R((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pyt_can_roundtrip_unix_modebitssN(/t__name__t
__module__t__doc__RRRRRR&R#R+R8RERHR¥RYR[R\RfRNRgRmRpRiRsRtRZR|RR‚R„R…RŠR‘R^R`R™R›RœRthost_os_dereferences_symlinksRthardlinks_goodR¡thas_symlinksR¢R¦(((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pyR1s^							.	

	
			
								
					tEmulatedWin32LocalTransportcB@s,eZdZd„Zd„Zdd„ZRS(s>Special transport for testing Win32 [UNC] paths on non-windowscC@sI|ddkr|d}ntt|ƒj|ƒtj|ƒ|_dS(NiÿÿÿÿR(RRRRt_win32_local_path_from_urlR(RR((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pyR*s
cC@s4tjtj|jtj|ƒƒƒ}tj|ƒS(N(Rt_win32_normpathR!RRRt_win32_local_path_to_url(RR#R$((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pyR0scC@sN|dkrt|jƒS|j|ƒ}|dkr@|j}nt|ƒSdS(s±Return a new LocalTransport with root at self.base + offset
        Because the local filesystem does not require a connection,
        we can just return a new object.
        sfile://N(RR­RR(RRR((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pyR5s
N(R§R¨R©RRRR(((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pyR­'s		cC@s ddlm}t|jfgS(s.Return the permutations to be used in testing.i(ttest_server(tbzrlib.testsR±RtLocalURLServer(R±((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pytget_test_permutationsFs(R©t
__future__RR(R`RRRRtbzrlib.lazy_importRtglobalstbzrlibRtO_CREATtO_APPENDtO_WRONLYRtO_BINARYtO_NOINHERITRntO_TRUNCRJt	TransportRR­R´(((s:/usr/lib/python2.7/dist-packages/bzrlib/transport/local.pyt<module>s	%%ÿ÷

Copyright © 2017 || Recoded By Mr.Bumblebee