Файловый менеджер - Редактировать - /usr/lib/python3.9/site-packages/glances/__pycache__/config.cpython-39.pyc
Назад
a ���c. � @ s� d Z ddlZddlZddlZddlmZ ddlZddlmZm Z m Z mZ ddlm Z mZmZmZmZ ddlmZ dd� Zd d � Zdd� Zd d� ZG dd� de�ZdS )zManage the configuration file.� N)�open)�ConfigParser� NoOptionError�NoSectionError�system_exec)�BSD�LINUX�MACOS�SUNOS�WINDOWS)�loggerc C s\ t rtj�d�} n*tr$tj�d�} ntj�d�p:tj�d�} | du rJd} ntj�| d�} | S )z�Return the per-user config dir (full path). - Linux, *BSD, SunOS: ~/.config/glances - macOS: ~/Library/Application Support/glances - Windows: %APPDATA%\glances �APPDATAz~/Library/Application SupportZXDG_CONFIG_HOMEz ~/.configN� �glances)r �os�environ�getr �path� expanduser�join�r � r �2/usr/lib/python3.9/site-packages/glances/config.py�user_config_dir s r c C sb t r*tj�tj�d�p tj�d�dd�} n4tr<tj�d�} n"tj�tj�d�pXtj�d�d�} | S )z�Return the per-user cache dir (full path). - Linux, *BSD, SunOS: ~/.cache/glances - macOS: ~/Library/Caches/glances - Windows: {%LOCALAPPDATA%,%APPDATA%}\glances\cache ZLOCALAPPDATAr r �cachez~/Library/Caches/glancesZXDG_CACHE_HOMEz~/.cache)r r r r r r r r r r r r �user_cache_dir, s &"r c C sH t strd} ntstrd} ntj�d�} | du r6d} ntj�| d�} | S )z�Return the system-wide config dir (full path). - Linux, SunOS: /etc/glances - *BSD, macOS: /usr/local/etc/glances - Windows: %APPDATA%\glances z/etcz/usr/local/etcr Nr r � r r r r r r r r r r r r r �system_config_dir= s r c C sB t stststrd} ntj�d�} | du r0d} ntj�| d�} | S )z�Return the system-wide config dir (full path). - Linux, SunOS, *BSD, macOS: /usr/share/doc (as defined in the setup.py files) - Windows: %APPDATA%\glances z/usr/share/docr Nr r r r r r r �default_config_dirR s r c @ s� e Zd ZdZd%dd�Zdd� Zdd� Zd d � Zedd� �Z d d� Z dd� Zdd� Zdd� Z dg d�fdd�Zdd� Zd&dd�Zd'dd�Zd(d d!�Zd)d#d$�ZdS )*�Configz�This class is used to access/read config file, if it exists. :param config_dir: the path to search for config file :type config_dir: str or None Nc C sV || _ d| _d | _t�d�| _ztd d�| _W n tyH t� | _Y n0 | � � d S )Nzglances.confz (\`.+?\`))Z interpolation) � config_dir�config_filename�_loaded_config_file�re�compile� re_patternr �parser� TypeError�read)�selfr r r r �__init__l s zConfig.__init__c C sb g }| j r|�| j � |�tj�t� | j�� |�tj�t� | j�� |�tj�t� | j�� |S )a� Get a list of config file paths. The list is built taking into account of the OS, priority and location. * custom path: /path/to/glances * Linux, SunOS: ~/.config/glances, /etc/glances * *BSD: ~/.config/glances, /usr/local/etc/glances * macOS: ~/Library/Application Support/glances, /usr/local/etc/glances * Windows: %APPDATA%\glances The config file will be searched in the following order of priority: * /path/to/file (via -C flag) * user's home directory (per-user settings) * system-wide directory (system-wide settings) * default pip directory (as defined in the setup.py file) ) r �appendr r r r r! r r )r) �pathsr r r �config_file_paths{ s zConfig.config_file_pathsc C s� | � � D ]�}t�d�|�� tj�|�rzXt|dd��(}| j� |� | j� |� W d � n1 sd0 Y t�d�|�� W n@ ty� } z(t� d�||�� t�d� W Y d}~n d}~0 0 || _ q�q| �� dS )z=Read the config file, if it exists. Using defaults otherwise.zSearch glances.conf file in {}zutf-8)�encodingNzRead configuration file '{}'z(Can not read configuration file '{}': {}� )r- r �debug�formatr r �existsr r&