Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/pyeapi/api/__pycache__/abstract.cpython-39.pyc
Ðазад
a b�hk � @ sh d Z ddlmZmZ ddlmZmZ ddlmZ G dd� de �Z G dd� de e�ZG d d � d e e�ZdS )a Provides an abstract implementation for building API modules This module provides a set of classes that are used to build API modules that work with Node objects. Using this module will allow the API modules to be automatically loaded using the Node.api method. The classes in this module should not be instantiated directly but rather provide parent class for API implementations. All API modules will ultimately derive from BaseEntity which provides some common functions to make building API modules easier. � )�Callable�Mapping)�CommandError�ConnectionError)� make_iterablec @ s` e Zd ZdZdd� Zedd� �Zedd� �Zedd � �Zddd�Z d d� Z ddd�Zdd� ZdS )� BaseEntityaY Base class for all resources to derive from This BaseEntity class should not be directly instatiated. It is designed to be implemented by all resource classes to provide common methods. Attributes: node (Node): The node instance this resource will perform operations against for configuration config (Config): Returns an instance of Config with the nodes current running configuration error (CommandError): Holds the latest CommandError exception instance if raised Args: node (Node): An instance of Node c C s || _ d S �N)�node)�selfr � r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/pyeapi/api/abstract.py�__init__C s zBaseEntity.__init__c C s | j jS r )r �version_number�r r r r r F s zBaseEntity.version_numberc C s | j jS r )r �running_configr r r r �configJ s zBaseEntity.configc C s | j jjS r )r � connection�errorr r r r r N s zBaseEntity.errorr c C s4 zd| }| j j||d�W S ty. Y dS 0 dS )a� Scans the config and returns a block of code Args: parent (str): The parent string to search the config for and return the block config (str): A text config string to be searched. Default is to search the running-config of the Node. Returns: A string object that represents the block from the config. If the parent string is not found, then this method will return None. z^%s$)r N)r �section� TypeError)r �parentr r r r � get_blockR s zBaseEntity.get_blockc C s0 z| j �|� W dS ttfy* Y dS 0 dS )a� Sends the commands list to the node in config mode This method performs configuration the node using the array of commands specified. This method wraps the configuration commands in a try/except block and stores any exceptions in the error property. Note: If the return from this method is False, use the error property to investigate the exception Args: commands (list): A list of commands to be sent to the node in config mode Returns: True if the commands are executed without exception otherwise False is returned TFN)r r r r )r �commandsr r r � configureg s zBaseEntity.configureNc C s@ |rd| S |rd| S |du r$|S |r4d||f S d| S dS )a� Builds a command with keywords Notes: Negating a command string by overriding 'value' with None or an assigned value that evalutates to false has been deprecated. Please use 'disable' to negate a command. Parameters are evaluated in the order 'default', 'disable', 'value' Args: string (str): The command string value (str): The configuration setting to subsititue into the command string. If value is a boolean and True, just the command string is used default (bool): Specifies the command should use the default keyword argument. Default preempts disable and value. disable (bool): Specifies the command should use the no keyword argument. Disable preempts value. Returns: A command string that can be used to configure the node z default %szno %sTz%s %sNr )r �string�value�default�disabler r r �command_builder� s zBaseEntity.command_builderc C s"