-=[ Mr. Bumblebee ]=-
_Indonesia_

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

ó
LrOc@@sdZddlmZdefd„ƒYZd„Zdefd„ƒYZdefd	„ƒYZdd
„Z	e	e
ƒdƒdS(
soFunctionality to create lazy evaluation objects.

This includes waiting to import a module until it is actually used.

Most commonly, the 'lazy_import' function is used to import other modules
in an on-demand fashion. Typically use looks like::

    from bzrlib.lazy_import import lazy_import
    lazy_import(globals(), '''
    from bzrlib import (
        errors,
        osutils,
        branch,
        )
    import bzrlib.branch
    ''')

Then 'errors, osutils, branch' and 'bzrlib' will exist as lazy-loaded
objects which will be replaced with a real object on first use.

In general, it is best to only load modules in this way. This is because
it isn't safe to pass these variables to other functions before they
have been replaced. This is especially true for constants, sometimes
true for classes or functions (when used as a factory, or you want
to inherit from them).
i(tabsolute_importt
ScopeReplacercB@sGeZdZd
ZeZd„Zd„Zd„Zd„Z	d	„Z
RS(sA lazy object that will replace itself in the appropriate scope.

    This object sits, ready to create the real object the first time it is
    needed.
    t_scopet_factoryt_namet	_real_objcC@sZtj|d|ƒtj|d|ƒtj|d|ƒtj|ddƒ|||<dS(sgCreate a temporary object in the specified scope.
        Once used, a real object will be placed in the scope.

        :param scope: The scope the object should appear in
        :param factory: A callable that will create the real object.
            It will be passed (self, scope, name)
        :param name: The variable name in the given scope.
        RRRRN(tobjectt__setattr__tNone(tselftscopetfactorytname((s6/usr/lib/python2.7/dist-packages/bzrlib/lazy_import.pyt__init__>s
	cC@sñtj|dƒ}tj|dƒ}|dkrÌtj|dƒ}tj|dƒ}||||ƒ}||krŠtj|ddƒ‚ntj|dƒ}|dkrÌtj|d|ƒ|||<|Sntjsítj|ddƒ‚n|S(	s6Return the real object for which this is a placeholderRRRRtmsgsCObject tried to replace itself, check it's not using its own scope.s?Object already replaced, did you assign it to another variable?N(Rt__getattribute__RterrorstIllegalUseOfScopeReplacerRRt
_should_proxy(R	Rtreal_objRR
tobj((s6/usr/lib/python2.7/dist-packages/bzrlib/lazy_import.pyt_resolveMs"
	cC@s"tj|dƒƒ}t||ƒS(NR(RRtgetattr(R	tattrR((s6/usr/lib/python2.7/dist-packages/bzrlib/lazy_import.pyRkscC@s%tj|dƒƒ}t|||ƒS(NR(RRtsetattr(R	RtvalueR((s6/usr/lib/python2.7/dist-packages/bzrlib/lazy_import.pyRoscO@s"tj|dƒƒ}|||ŽS(NR(RR(R	targstkwargsR((s6/usr/lib/python2.7/dist-packages/bzrlib/lazy_import.pyt__call__ss(s_scopes_factorys_names	_real_obj(t__name__t
__module__t__doc__t	__slots__tTrueRR
RRRR(((s6/usr/lib/python2.7/dist-packages/bzrlib/lazy_import.pyR/s				cC@s
tt_dS(sLDisallow lazily imported modules to be used as proxies.

    Calling this function might cause problems with concurrent imports
    in multithreaded environments, but will help detecting wasteful
    indirection, so it should be called when executing unit tests.

    Only lazy imports that happen after this call are affected.
    N(tFalseRR(((s6/usr/lib/python2.7/dist-packages/bzrlib/lazy_import.pytdisallow_proxyingxs	tImportReplacercB@s,eZdZdZdid„Zd„ZRS(sîThis is designed to replace only a portion of an import list.

    It will replace itself with a module, and then make children
    entries also ImportReplacer objects.

    At present, this only supports 'import foo.bar.baz' syntax.
    t_import_replacer_childrent_membert_module_pathcC@s’|d	k	r!|r!tdƒ‚ntj|d|ƒtj|d|ƒtj|d|ƒtj|dƒ}tj|d|d|d|jƒd	S(
s€Upon request import 'module_path' as the name 'module_name'.
        When imported, prepare children to also be imported.

        :param scope: The scope that objects should be imported into.
            Typically this is globals()
        :param name: The variable name. Often this is the same as the
            module_path. 'bzrlib'
        :param module_path: A list for the fully specified module path
            ['bzrlib', 'foo', 'bar']
        :param member: The member inside the module to import, often this is
            None, indicating the module is being imported.
        :param children: Children entries to be imported later.
            This should be a map of children specifications.
            ::
            
                {'foo':(['bzrlib', 'foo'], None,
                    {'bar':(['bzrlib', 'foo', 'bar'], None {})})
                }

        Examples::

            import foo => name='foo' module_path='foo',
                          member=None, children={}
            import foo.bar => name='foo' module_path='foo', member=None,
                              children={'bar':(['foo', 'bar'], None, {}}
            from foo import bar => name='bar' module_path='foo', member='bar'
                                   children={}
            from foo import bar, baz would get translated into 2 import
            requests. On for 'name=bar' and one for 'name=baz'
        s(Cannot supply both a member and childrenR%R&R't	__class__R
RRN(Rt
ValueErrorRRRRR
t_import(R	R
Rtmodule_pathtmembertchildrentcls((s6/usr/lib/python2.7/dist-packages/bzrlib/lazy_import.pyR
–scC@stj|dƒ}tj|dƒ}tj|dƒ}dj|ƒ}|dk	r|t||||gddƒ}t||ƒSt|||gddƒ}x!|dD]}t||ƒ}q¢WxZ|jƒD]L\}	\}
}}tj|dƒ}
|
|jd	|	d
|
d|d|ƒqÈW|S(
NR%R&R't.tleveliiR(RR+R,R-(RRtjoinRt
__import__Rt	iteritemst__dict__(R	R
RR-R,R+tmodule_python_pathtmoduletpatht
child_namet
child_pathtchild_membert
grandchildrenR.((s6/usr/lib/python2.7/dist-packages/bzrlib/lazy_import.pyR*Âs"
(s_import_replacer_childrens_members_module_pathN(RRRR RR
R*(((s6/usr/lib/python2.7/dist-packages/bzrlib/lazy_import.pyR$„s	,tImportProcessorcB@s\eZdZddgZd
d„Zd„Zd„Zd„Zd„Z	d„Z
d	„ZRS(s7Convert text that users input into lazy import requeststimportst_lazy_import_classcC@s.i|_|dkr!t|_n	||_dS(N(R=RR$R>(R	tlazy_import_class((s6/usr/lib/python2.7/dist-packages/bzrlib/lazy_import.pyR
æs	cC@s|j|ƒ|j|ƒdS(s§Convert the given text into a bunch of lazy import objects.

        This takes a text string, which should be similar to normal python
        import markup.
        N(t
_build_mapt_convert_imports(R	R
ttext((s6/usr/lib/python2.7/dist-packages/bzrlib/lazy_import.pytlazy_importís
cC@sUxN|jjƒD]=\}}|j|d|d|dd|dd|dƒqWdS(NRR+iR,iR-i(R=R3R>(R	R
Rtinfo((s6/usr/lib/python2.7/dist-packages/bzrlib/lazy_import.pyRAöscC@snxg|j|ƒD]V}|jdƒr5|j|ƒq|jdƒrT|j|ƒqtj|dƒ‚qWdS(s?Take a string describing imports, and build up the internal mapsimport sfrom s'doesn't start with 'import ' or 'from 'N(t_canonicalize_import_textt
startswitht_convert_import_strt_convert_from_strRtInvalidImportLine(R	RBtline((s6/usr/lib/python2.7/dist-packages/bzrlib/lazy_import.pyR@üs	cC@s¼|jdƒs%td|fƒ‚n|tdƒ}x€|jdƒD]o}|jƒ}|scqEn|jdƒ}t|ƒdkrç|djƒ}|djƒjdƒ}||jkrÎtj|ƒ‚n|d	if|j|<qE|jdƒ}|d}||jkr1|gd	if}||j|<n
|j|}|g}|d}x`|dD]T}	|j	|	ƒ|	|krŒ||	d}q\|d	if}
|
||	<|
d}q\WqEWd	S(
s½This converts a import string into an import map.

        This only understands 'import foo, foo.bar, foo.bar.baz as bing'

        :param import_str: The import string to process
        simport sbad import string %rt,s as iiiR/N(
RFR)tlentsplittstripR=RtImportNameCollisionRtappend(R	t
import_strR7tas_hunksRR+t
module_deftcur_pathtcurtchildtnext((s6/usr/lib/python2.7/dist-packages/bzrlib/lazy_import.pyRGs:

	


c	C@s|jdƒs"td|ƒ‚n|tdƒ}|jdƒ\}}|jdƒ}x´|jdƒD]£}|jƒ}|s„qfn|jdƒ}t|ƒdkrÈ|djƒ}|d	jƒ}n
|}}||jkrótj|ƒ‚n||if|j|<qfWd
S(s€This converts a 'from foo import bar' string into an import map.

        :param from_str: The import string to process
        sfrom sbad from/import %rs import R/RKs as iiiN(RFR)RLRMRNR=RRO(	R	tfrom_strtfrom_moduletimport_listtfrom_module_pathR7RRRR6((s6/usr/lib/python2.7/dist-packages/bzrlib/lazy_import.pyRH7s"
cC@s7g}d	}t}xý|jdƒD]ì}|jƒ}|jdƒ}|dkrb|| jƒ}n|snq"n|d	k	r¼|jdƒr«|j|d|d ƒd	}q|d|7}q"d|kréd|kré|jddƒ}q"|j|jddƒjddƒƒq"W|d	k	r3tj	|dƒ‚n|S(
sÄTake a list of imports, and split it into regularized form.

        This is meant to take regular import text, and convert it to
        the forms that the rest of the converters prefer.
        s
t#iÿÿÿÿt)t t(tsUnmatched parenthesisN(
RR"RMRNtfindtendswithRPtreplaceRRI(R	RBtoutRUt
continuingRJtloc((s6/usr/lib/python2.7/dist-packages/bzrlib/lazy_import.pyREUs*	)N(RRRR RR
RCRAR@RGRHRE(((s6/usr/lib/python2.7/dist-packages/bzrlib/lazy_import.pyR<Ûs					0	cC@std|ƒ}|j||ƒS(sÒCreate lazy imports for all of the imports in text.

    This is typically used as something like::

        from bzrlib.lazy_import import lazy_import
        lazy_import(globals(), '''
        from bzrlib import (
            foo,
            bar,
            baz,
            )
        import bzrlib.branch
        import bzrlib.transport
        ''')

    Then 'foo, bar, baz' and 'bzrlib' will exist as lazy-loaded
    objects which will be replaced with a real object on first use.

    In general, it is best to only load modules in this way. This is
    because other objects (functions/classes/variables) are frequently
    used without accessing a member, which means we cannot tell they
    have been used.
    R?(R<RC(R
RBR?tproc((s6/usr/lib/python2.7/dist-packages/bzrlib/lazy_import.pyRCwss
from bzrlib import errors
N(Rt
__future__RRRR#R$R<RRCtglobals(((s6/usr/lib/python2.7/dist-packages/bzrlib/lazy_import.pyt<module>*sI	Wœ!	

Copyright © 2017 || Recoded By Mr.Bumblebee