Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/pyeapi/__pycache__/utils.cpython-39.pyc
Ðазад
a b�h9 � @ s6 d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlmZ zd dlm Z W n e yr d dlmZ Y n0 e�e �Ze�ej� ejdkr�ejjdd�Zn ej�� Ze�e� e�d�Ze�� Ze�e� e�e� d d � Zdd� ZG d d� de�Zdd� Zdd� Z dd� Z!dd� Z"ddd�Z#ddd�Z$dS )� N)�tee)�zip_longest)�izip_longest�darwinz/var/run/syslog)�addressz! **** LOG NOTE **** %(message)s c C s$ | t jv rt j| }n t�| �}|S )a� Imports a module into the current runtime environment This function emulates the Python import system that allows for importing full path modules. It will break down the module and import each part (or skip if it is already loaded in cache). Args: name (str): The name of the module to import. This should be the full path of the module Returns: The module that was imported )�sys�modules� importlib� import_module��name�mod� r �|/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/pyeapi/utils.pyr B s r c C sl zDzd}t j| }W n ty. t| �}Y n0 W |sBtd| ��|S |sVtd| ��| Y S 0 dS )a� Attempts to load a module into the current environment This function will load a module specified by name. The module name is first checked to see if it is already loaded and will return the module if it is. If the module hasn't been previously loaded it will attempt to import it Args: name (str): Specifies the full name of the module. For instance pyeapi.api.vlans Returns: The module that has been imported or retrieved from the sys modules Nzunable to import module %s)r r �KeyErrorr �ImportErrorr r r r �load_moduleY s �r c @ s e Zd Zdd� Zdd� ZdS )� ProxyCallc C s || _ || _d S �N��proxy�method)�selfr r r r r �__init__v s zProxyCall.__init__c O s | j | jg|�R i |��S r r )r �args�kwargsr r r �__call__z s zProxyCall.__call__N)�__name__� __module__�__qualname__r r r r r r r t s r c C s t j�d�S )au Checks if running locally on EOS device or remotely This function will return a boolean indicating if the current execution environment is running locally on an EOS device (True) or running remotely and communicating over HTTP/S (False) Returns: A boolean value that indicates whether or not the current thread is local or remote z/etc/Eos-release)�os�path�existsr r r r �islocalconnection~ s r# c C s8 t �� j}|jd }|jj}d||| f }t�|� dS )zbLog a message to syslog and stderr Args: text (str): The string object to print r z %s.%s: %sN)�inspect�currentframe�f_back� f_globals�f_code�co_name�_LOGGER�debug)�text�frame�module�func�msgr r r r+ � s r+ c C sp t jdkrt| t�rt| �} t| t�s0t| t�r6| g} t jdkrVt| tj�sltd��nt| tj j�sltd��| S )a Converts the supplied value to a list object This function will inspect the supplied value and return an iterable in the form of a list. Args: value (object): An valid Python object Returns: An iterable object of type list )� r )r1 r1 z value must be an iterable object) r �version_info� isinstance�unicode�str�dict�collections�Iterable� TypeError�abc)�valuer r r � make_iterable� s r<