-=[ Mr. Bumblebee ]=-
_Indonesia_

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

ó
þiOc@@s>dZddlmZddlZddlmZmZddlmZddl	m
Z
dejfd„ƒYZd	ejfd
„ƒYZ
dejfd„ƒYZd
efd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZd„ZejƒdS(s+Branch opening with URL-based restrictions.i(tabsolute_importN(terrorsturlutils(tBranch(t
ControlDirtBadUrlcB@seZdZRS(s.Tried to access a branch from bad URL %(url)s.(t__name__t
__module__t_fmt(((s:/usr/lib/python2.7/dist-packages/bzrlib/url_policy_open.pyR!stBranchReferenceForbiddencB@seZdZRS(sRTrying to mirror a branch reference and the branch type does not allow references.(RRR(((s:/usr/lib/python2.7/dist-packages/bzrlib/url_policy_open.pyR	&stBranchLoopErrorcB@seZdZdZRS(sýEncountered a branch cycle.

    A URL may point to a branch reference or it may point to a stacked branch.
    In either case, it's possible for there to be a cycle in these references,
    and this exception is raised when we detect such a cycle.
    sEncountered a branch cycle(RRt__doc__R(((s:/usr/lib/python2.7/dist-packages/bzrlib/url_policy_open.pyR
,stBranchOpenPolicycB@s)eZdZd„Zd„Zd„ZRS(sÄPolicy on how to open branches.

    In particular, a policy determines which branches are okay to open by
    checking their URLs and deciding whether or not to follow branch
    references.
    cC@st|jƒ‚dS(sWhether we traverse references when mirroring.

        Subclasses must override this method.

        If we encounter a branch reference and this returns false, an error is
        raised.

        :returns: A boolean to indicate whether to follow a branch reference.
        N(tNotImplementedErrortshould_follow_references(tself((s:/usr/lib/python2.7/dist-packages/bzrlib/url_policy_open.pyR?s
cC@st|jƒ‚dS(s´Validate, maybe modify, 'url' to be used as a stacked-on location.

        :param branch:  The branch that is being opened.
        :param url: The URL that the branch provides for its stacked-on
            location.
        :return: (new_url, check) where 'new_url' is the URL of the branch to
            actually open and 'check' is true if 'new_url' needs to be
            validated by check_and_follow_branch_reference.
        N(R
ttransform_fallback_location(Rtbranchturl((s:/usr/lib/python2.7/dist-packages/bzrlib/url_policy_open.pyRKs
cC@st|jƒ‚dS(súCheck a URL.

        Subclasses must override this method.

        :param url: The source URL to check.
        :raise BadUrl: subclasses are expected to raise this or a subclass
            when it finds a URL it deems to be unacceptable.
        N(R
t
check_one_url(RR((s:/usr/lib/python2.7/dist-packages/bzrlib/url_policy_open.pyRWs	(RRRRRR(((s:/usr/lib/python2.7/dist-packages/bzrlib/url_policy_open.pyR7s		t_BlacklistPolicycB@s5eZdZdd„Zd„Zd„Zd„ZRS(sªBranch policy that forbids certain URLs.

    This doesn't cope with various alternative spellings of URLs,
    with e.g. url encoding. It's mostly useful for tests.
    cC@s.|dkrtƒ}n||_||_dS(N(tNonetsett	_bad_urlst_should_follow_references(RRtbad_urls((s:/usr/lib/python2.7/dist-packages/bzrlib/url_policy_open.pyt__init__js	cC@s|jS(N(R(R((s:/usr/lib/python2.7/dist-packages/bzrlib/url_policy_open.pyRpscC@s"||jkrt|ƒ‚ndS(N(RR(RR((s:/usr/lib/python2.7/dist-packages/bzrlib/url_policy_open.pyRsscC@stj|j|ƒtfS(sõSee `BranchOpenPolicy.transform_fallback_location`.

        This class is not used for testing our smarter stacking features so we
        just do the simplest thing: return the URL that would be used anyway
        and don't check it.
        (RtjointbasetFalse(RRR((s:/usr/lib/python2.7/dist-packages/bzrlib/url_policy_open.pyRwsN(RRRRRRRR(((s:/usr/lib/python2.7/dist-packages/bzrlib/url_policy_open.pyRcs
		tAcceptAnythingPolicycB@seZdZd„ZRS(s(Accept anything, to make testing easier.cC@s tt|ƒjttƒƒdS(N(tsuperRRtTrueR(R((s:/usr/lib/python2.7/dist-packages/bzrlib/url_policy_open.pyR„s(RRRR(((s:/usr/lib/python2.7/dist-packages/bzrlib/url_policy_open.pyRstWhitelistPolicycB@s8eZdZded„Zd„Zd„Zd„ZRS(s,Branch policy that only allows certain URLs.cC@s;|dkrg}ntd„|Dƒƒ|_||_dS(Ncs@s|]}|jdƒVqdS(t/N(trstrip(t.0R((s:/usr/lib/python2.7/dist-packages/bzrlib/url_policy_open.pys	<genexpr>s(RRtallowed_urlstcheck(RRR%R&((s:/usr/lib/python2.7/dist-packages/bzrlib/url_policy_open.pyR‹s	cC@s|jS(N(R(R((s:/usr/lib/python2.7/dist-packages/bzrlib/url_policy_open.pyR’scC@s+|jdƒ|jkr't|ƒ‚ndS(NR"(R#R%R(RR((s:/usr/lib/python2.7/dist-packages/bzrlib/url_policy_open.pyR•scC@stj|j|ƒ|jfS(s—See `BranchOpenPolicy.transform_fallback_location`.

        Here we return the URL that would be used anyway and optionally check
        it.
        (RRRR&(RRR((s:/usr/lib/python2.7/dist-packages/bzrlib/url_policy_open.pyR™sN(	RRRRRRRRR(((s:/usr/lib/python2.7/dist-packages/bzrlib/url_policy_open.pyR!ˆs		tSingleSchemePolicycB@s2eZdZd„Zd„Zd„Zd„ZRS(s=Branch open policy that rejects URLs not on the given scheme.cC@s
||_dS(N(tallowed_scheme(RR(((s:/usr/lib/python2.7/dist-packages/bzrlib/url_policy_open.pyR¥scC@stS(N(R (R((s:/usr/lib/python2.7/dist-packages/bzrlib/url_policy_open.pyR¨scC@stj|j|ƒtfS(N(RRRR (RRR((s:/usr/lib/python2.7/dist-packages/bzrlib/url_policy_open.pyR«scC@s7tjjt|ƒƒj|jkr3t|ƒ‚ndS(s!Check that `url` is okay to open.N(RtURLtfrom_stringtstrtschemeR(R(RR((s:/usr/lib/python2.7/dist-packages/bzrlib/url_policy_open.pyR®s$(RRRRRRR(((s:/usr/lib/python2.7/dist-packages/bzrlib/url_policy_open.pyR'¢s
			tBranchOpenercB@sheZdZejƒZdd„Zed„ƒZ	d„Z
ed„ƒZd„Zd„Z
d„ZRS(	s1Branch opener which uses a URL policy.

    All locations that are opened (stacked-on branches, references) are
    checked against a policy object.

    The policy object is expected to have the following methods:
    * check_one_url 
    * should_follow_references
    * transform_fallback_location
    cC@s"||_tƒ|_||_dS(sÆCreate a new BranchOpener.

        :param policy: The opener policy to use.
        :param probers: Optional list of probers to allow.
            Defaults to local and remote bzr probers.
        N(tpolicyRt
_seen_urlstprobers(RR.R0((s:/usr/lib/python2.7/dist-packages/bzrlib/url_policy_open.pyRÂs	cC@stjjd|jdƒdS(sØInstall the ``transform_fallback_location`` hook.

        This is done at module import time, but transform_fallback_locationHook
        doesn't do anything unless the `_active_openers` threading.Local
        object has a 'opener' attribute in this thread.

        This is in a module-level function rather than performed at module
        level so that it can be called in setUp for testing `BranchOpener`
        as bzrlib.tests.TestCase.setUp clears hooks.
        Rs,BranchOpener.transform_fallback_locationHookN(Rthookstinstall_named_hookttransform_fallback_locationHook(tcls((s:/usr/lib/python2.7/dist-packages/bzrlib/url_policy_open.pytinstall_hookÍs	cC@sxˆtrŠ||jkr$tƒ‚n|jj|ƒ|jj|ƒ|j|ƒ}|dkrc|S|}|jjƒst	|ƒ‚qqWdS(sCheck URL (and possibly the referenced URL).

        This method checks that `url` passes the policy's `check_one_url`
        method, and if `url` refers to a branch reference, it checks whether
        references are allowed and whether the reference's URL passes muster
        also -- recursively, until a real branch is found.

        :param url: URL to check
        :raise BranchLoopError: If the branch references form a loop.
        :raise BranchReferenceForbidden: If this opener forbids branch
            references.
        N(
R R/R
taddR.Rtfollow_referenceRRR	(RRtnext_url((s:/usr/lib/python2.7/dist-packages/bzrlib/url_policy_open.pyt!check_and_follow_branch_referenceÞs
	cC@sayt|jdƒ}Wntk
r*|SX|jj||ƒ\}}|rY|j|ƒS|SdS(sInstalled as the 'transform_fallback_location' Branch hook.

        This method calls `transform_fallback_location` on the policy object and
        either returns the url it provides or passes it back to
        check_and_follow_branch_reference.
        topenerN(tgetattrt_threading_datatAttributeErrorR.RR9(R4RRR:tnew_urlR&((s:/usr/lib/python2.7/dist-packages/bzrlib/url_policy_open.pyR3÷s

cO@s_|jtjdkr%tdƒ‚n||j_z|||ŽSWd|j`tƒ|_XdS(NRshook not installed(R3RR1tAssertionErrorR<R:RR/(Rtcallabletargstkw((s:/usr/lib/python2.7/dist-packages/bzrlib/url_policy_open.pyt3run_with_transform_fallback_location_hook_installed	s	cC@s"tj|d|jƒ}|jƒS(s‹Get the branch-reference value at the specified url.

        This exists as a separate method only to be overriden in unit tests.
        R0(RtopenR0tget_branch_reference(RRtbzrdir((s:/usr/lib/python2.7/dist-packages/bzrlib/url_policy_open.pyR7sc@sIt|ƒtkrt‚nˆj|ƒ}‡fd†}ˆj||ƒS(s¯Open the Bazaar branch at url, first checking it.

        What is acceptable means is defined by the policy's `follow_reference` and
        `check_one_url` methods.
        c@s"tj|dˆjƒ}|jƒS(NR0(RRDR0topen_branch(Rtdir(R(s:/usr/lib/python2.7/dist-packages/bzrlib/url_policy_open.pyRG*s(ttypeR+t	TypeErrorR9RC(RRRG((Rs:/usr/lib/python2.7/dist-packages/bzrlib/url_policy_open.pyRDs	N(RRRt	threadingtlocalR<RRtclassmethodR5R9R3RCR7RD(((s:/usr/lib/python2.7/dist-packages/bzrlib/url_policy_open.pyR-´s
			cC@stt|ƒƒj|ƒS(s¨Open the branch at `url`, only accessing URLs on `allowed_scheme`.

    :raises BadUrl: An attempt was made to open a URL that was not on
        `allowed_scheme`.
    (R-R'RD(R(R((s:/usr/lib/python2.7/dist-packages/bzrlib/url_policy_open.pytopen_only_scheme1s(Rt
__future__RRKtbzrlibRRt
bzrlib.branchRtbzrlib.controldirRtBzrErrorRR	R
tobjectRRRR!R'R-RNR5(((s:/usr/lib/python2.7/dist-packages/bzrlib/url_policy_open.pyt<module>s ,}		

Copyright © 2017 || Recoded By Mr.Bumblebee