File manager - Edit - /usr/lib/mysqlsh/python-packages/mysqlsh/plugin_manager/__pycache__/registrar.cpython-39.pyc
Back
a kb�g;x � @ s` d Z ddlZddlZddlmZmZ g Zdd� Zddd�ZG dd � d �Z dd d�Z ddd�ZdS )z6Plugin Manager used for simplified plugin registration� N)�wraps�partialc C s t �| � d S �N)�_registration_callbacks�append)�callback� r �D/usr/lib/mysqlsh/python-packages/mysqlsh/plugin_manager/registrar.py�add_registration_callback% s r c C s ddl }|jjj}tdd� |�� d �d�d �d�D ��}d}| durhtd d� | �d�D ��}||k}d}|dur�td d� |�d�D ��}||k}d} |r�|s�| dur�|dur�d| � d |� d�} n*| dur�d| � d�} n|dur�d|� d�} t| �dk�rt| ��dS )zE Validates the plugin Shell version requirements for plugin. r Nc S s g | ]}t |��qS r ��int��.0�vr r r � <listcomp>0 � z*validate_shell_version.<locals>.<listcomp>� �-�.Tc S s g | ]}t |��qS r r r r r r r 5 r c S s g | ]}t |��qS r r r r r r r : r � 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�maxr Zraw_versionZ shell_versionZmin_version_okZmin_versionZmax_version_okZmax_version�errorr r r �validate_shell_version) s* *r! c @ s� e Zd ZdZedd� �ZG dd� d�ZG dd� d�ZG dd � d �ZG d d� d�Z dd � Z dd� Zddd�Zdd� Z ddd�Zdd� ZdS )�PluginRegistrara Helper 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. c C s8 | dkrdS | dkrdS | dkr$dS | dkr0dS | S d S ) zZHelper function to translate the sphinx types into the types required by the shell�str�stringr Zinteger�dict� dictionary�listZarrayNr )�typer r r �sphinx_2shell_typed s z"PluginRegistrar.sphinx_2shell_typec @ s e Zd ZdZdd� ZdS )zPluginRegistrar.ItemDocz> Simple container for brief and details of the different itemsc C s d| _ d | _d S �Nr ��brief�details��selfr r r �__init__v s z PluginRegistrar.ItemDoc.__init__N)�__name__� __module__�__qualname__�__doc__r0 r r r r �ItemDocs s r5 c @ s e Zd ZdZdd� 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) c C s� t �� | _|d | _|�d�| _|d | j_g | _|�dd�| _d|v rT|d | j_ d|v r||d D ]}| j� t �|�� qdd | _d S )N�namer( r, �requiredFr- �options) r"