-=[ Mr. Bumblebee ]=-
_Indonesia_

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

σ
ξ:οNc@@s‚dZddlmZddlmZdefd„ƒYZdefd„ƒYZdefd	„ƒYZd
efd„ƒYZ	dS(
s8Classes to provide name-to-object registry-like support.i(tabsolute_import(tget_named_objectt
_ObjectGettercB@s2eZdZdgZd„Zd„Zd„ZRS(sMaintain a reference to an object, and return the object on request.

    This is used by Registry to make plain objects function similarly
    to lazily imported objects.

    Objects can be any sort of python object (class, function, module,
    instance, etc)
    t_objcC@s
||_dS(N(R(tselftobj((s3/usr/lib/python2.7/dist-packages/bzrlib/registry.pyt__init__$scC@s
|jjS(s*Get the module the object was loaded from.(Rt
__module__(R((s3/usr/lib/python2.7/dist-packages/bzrlib/registry.pyt
get_module'scC@s|jS(s.Get the object that was saved at creation time(R(R((s3/usr/lib/python2.7/dist-packages/bzrlib/registry.pytget_obj+s(t__name__Rt__doc__t	__slots__RRR	(((s3/usr/lib/python2.7/dist-packages/bzrlib/registry.pyRs
			t_LazyObjectGettercB@sAeZdZdddgZd„Zd„Zd„Zd„ZRS(sQKeep a record of a possible object.

    When requested, load and return it.
    t_module_namet_member_namet	_importedcC@s5||_||_t|_tt|ƒjdƒdS(N(RRtFalseRtsuperR
RtNone(Rtmodule_nametmember_name((s3/usr/lib/python2.7/dist-packages/bzrlib/registry.pyR8s			cC@s|jS(sBGet the module the referenced object will be loaded from.
        (R(R((s3/usr/lib/python2.7/dist-packages/bzrlib/registry.pyR>scC@s@|js-t|j|jƒ|_t|_ntt|ƒjƒS(s–Get the referenced object.

        Upon first request, the object will be imported. Future requests will
        return the imported object.
        (	RRRRRtTrueRR
R	(R((s3/usr/lib/python2.7/dist-packages/bzrlib/registry.pyR	Cs	cC@s5d|jj|jjt|ƒ|j|j|jfS(Ns8<%s.%s object at %x, module=%r attribute=%r imported=%r>(t	__class__RR
tidRRR(R((s3/usr/lib/python2.7/dist-packages/bzrlib/registry.pyt__repr__Ns(R
RRRRRR	R(((s3/usr/lib/python2.7/dist-packages/bzrlib/registry.pyR
0s			tRegistrycB@sΰeZdZd„Zdded„Zdded„Zddd„Zdd„Z	d„Z
d„Zdd„Zdd	„Z
dd
„Zd„Zd„Zd
„Zd„Zd„Zd„Zd„ZeeeddƒZRS(s	A class that registers objects to a name.

    There are many places that want to collect related objects and access them
    by a key. This class is designed to allow registering the mapping from key
    to object. It goes one step further, and allows registering a name to a
    hypothetical object which has not been imported yet. It also supports
    adding additional information at registration time so that decisions can be
    made without having to import the object (which may be expensive).

    The functions 'get', 'get_info', and 'get_help' also support a
    'default_key' (settable through my_registry.default_key = XXX, XXX must
    already be registered.) Calling my_registry.get() or my_registry.get(None),
    will return the entry for the default key.
    cC@s(d|_i|_i|_i|_dS(sCreate a new Registry.N(Rt_default_keyt_dictt
_help_dictt
_info_dict(R((s3/usr/lib/python2.7/dist-packages/bzrlib/registry.pyRds			cC@s[|s+||jkr+td|ƒ‚q+nt|ƒ|j|<|j|d|d|ƒdS(scRegister a new object to a name.

        :param key: This is the key to use to request the object later.
        :param obj: The object to register.
        :param help: Help text for this entry. This may be a string or
                a callable. If it is a callable, it should take two
                parameters (registry, key): this registry and the key that
                the help was registered under.
        :param info: More information for this entry. Registry.get_info()
                can be used to get this information. Registry treats this as an
                opaque storage location (it is defined by the caller).
        :param override_existing: Raise KeyErorr if False and something has
                already been registered for that key. If True, ignore if there
                is an existing key (always register the new value).
        sKey %r already registeredthelptinfoN(RtKeyErrorRt_add_help_and_info(RtkeyRRR toverride_existing((s3/usr/lib/python2.7/dist-packages/bzrlib/registry.pytregisterls
cC@s^|s+||jkr+td|ƒ‚q+nt||ƒ|j|<|j|d|d|ƒdS(sjRegister a new object to be loaded on request.

        :param key: This is the key to use to request the object later.
        :param module_name: The python path to the module. Such as 'os.path'.
        :param member_name: The member of the module to return.  If empty or
                None, get() will return the module itself.
        :param help: Help text for this entry. This may be a string or
                a callable.
        :param info: More information for this entry. Registry.get_info()
                can be used to get this information. Registry treats this as an
                opaque storage location (it is defined by the caller).
        :param override_existing: If True, replace the existing object
                with the new one. If False, if there is already something
                registered with the same key, raise a KeyError
        sKey %r already registeredRR N(RR!R
R"(RR#RRRR R$((s3/usr/lib/python2.7/dist-packages/bzrlib/registry.pyt
register_lazyƒs
cC@s||j|<||j|<dS(s+Add the help and information about this keyN(RR(RR#RR ((s3/usr/lib/python2.7/dist-packages/bzrlib/registry.pyR"›s
cC@s|j|j|ƒjƒS(sReturn the object register()'ed to the given key.

        May raise ImportError if the object was registered lazily and
        there are any problems, or AttributeError if the module does not
        have the supplied member.

        :param key: The key to obtain the object for. If no object has been
            registered to that key, the object registered for self.default_key
            will be returned instead, if it exists. Otherwise KeyError will be
            raised.
        :return: The previously registered object.
        :raises ImportError: If the object was registered lazily, and there are
            problems during import.
        :raises AttributeError: If registered lazily, and the module does not
            contain the registered member.
        (Rt_get_key_or_defaultR	(RR#((s3/usr/lib/python2.7/dist-packages/bzrlib/registry.pytget scC@s|j|jƒS(s Return the module the object will be or was loaded from.

        :param key: The key to obtain the module for.
        :return: The name of the module
        (RR(RR#((s3/usr/lib/python2.7/dist-packages/bzrlib/registry.pyt_get_module³scC@sGx@|jƒD]2}|j|ƒr
|j|ƒ|t|ƒfSq
WdS(sReturn an object whose key is a prefix of the supplied value.

        :fullname: The name to find a prefix for
        :return: a tuple of (object, remainder), where the remainder is the
            portion of the name that did not match the key.
        N(tkeyst
startswithR(tlen(RtfullnameR#((s3/usr/lib/python2.7/dist-packages/bzrlib/registry.pyt
get_prefix»scC@s9|dk	r|S|jdkr.tdƒ‚n|jSdS(s5Return either 'key' or the default key if key is Nones&Key is None, and no default key is setN(Rtdefault_keyR!(RR#((s3/usr/lib/python2.7/dist-packages/bzrlib/registry.pyR'Ζs
cC@s3|j|j|ƒ}t|ƒr/|||ƒS|S(s/Get the help text associated with the given key(RR'tcallable(RR#tthe_help((s3/usr/lib/python2.7/dist-packages/bzrlib/registry.pytget_helpΟs
cC@s|j|j|ƒS(s7Get the extra information associated with the given key(RR'(RR#((s3/usr/lib/python2.7/dist-packages/bzrlib/registry.pytget_infoΦscC@s|j|=dS(slRemove a registered entry.

        This is mostly for the test suite, but it can be used by others
        N(R(RR#((s3/usr/lib/python2.7/dist-packages/bzrlib/registry.pytremoveΪscC@s
||jkS(N(R(RR#((s3/usr/lib/python2.7/dist-packages/bzrlib/registry.pyt__contains__αscC@st|jjƒƒS(s Get a list of registered entries(tsortedRR*(R((s3/usr/lib/python2.7/dist-packages/bzrlib/registry.pyR*δscc@s5x.|jjƒD]\}}||jƒfVqWdS(N(Rt	iteritemsR	(RR#tgetter((s3/usr/lib/python2.7/dist-packages/bzrlib/registry.pyR7θscC@s8tg|jjƒD]\}}||jƒf^qƒS(N(R6RtitemsR	(RR#R8((s3/usr/lib/python2.7/dist-packages/bzrlib/registry.pyR9μscC@s2|jj|ƒs%td|ƒ‚n	||_dS(Ns"No object registered under key %s.(Rthas_keyR!R(RR#((s3/usr/lib/python2.7/dist-packages/bzrlib/registry.pyt_set_default_keyςscC@s|jS(N(R(R((s3/usr/lib/python2.7/dist-packages/bzrlib/registry.pyt_get_default_keyψstdocsACurrent value of the default key. Can be set to any existing key.N(R
RRRRRR%R&R"R(R)R.R'R2R3R4R5R*R7R9R;R<tpropertyR/(((s3/usr/lib/python2.7/dist-packages/bzrlib/registry.pyRTs,											tFormatRegistrycB@sPeZdZdd„Zdded„Zdded„Zd„Zd„Z	RS(s*Registry specialised for handling formats.cC@stj|ƒ||_dS(N(RRt_other_registry(Rtother_registry((s3/usr/lib/python2.7/dist-packages/bzrlib/registry.pyRs
c
C@s`tj|||d|d|d|ƒ|jdk	r\|jj||d|d|d|ƒndS(NRR R$(RR%R@R(RR#RRR R$((s3/usr/lib/python2.7/dist-packages/bzrlib/registry.pyR%s
cC@sftj||||d|d|d|ƒ|jdk	rb|jj|||d|d|d|ƒndS(NRR R$(RR&R@R(RR#RRRR R$((s3/usr/lib/python2.7/dist-packages/bzrlib/registry.pyR&s
cC@s6tj||ƒ|jdk	r2|jj|ƒndS(N(RR4R@R(RR#((s3/usr/lib/python2.7/dist-packages/bzrlib/registry.pyR4scC@s.tj||ƒ}t|ƒr*|ƒ}n|S(N(RR(R0(Rt
format_stringtr((s3/usr/lib/python2.7/dist-packages/bzrlib/registry.pyR(sN(
R
RRRRRR%R&R4R((((s3/usr/lib/python2.7/dist-packages/bzrlib/registry.pyR?s		N(
Rt
__future__Rtbzrlib.pyutilsRtobjectRR
RR?(((s3/usr/lib/python2.7/dist-packages/bzrlib/registry.pyt<module>s$¬

Copyright © 2017 || Recoded By Mr.Bumblebee