????
Current Path : /lib/python3.6/site-packages/glances/__pycache__/ |
Current File : //lib/python3.6/site-packages/glances/__pycache__/config.cpython-36.pyc |
3 Eo�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 rtjjd�} n*tr$tjjd�} ntjjd�p:tjjd�} | dkrJd} ntjj| 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 �/usr/lib/python3.6/config.py�user_config_dir s r c C sb t r*tjjtjjd�p tjjd�dd�} n4tr<tjjd�} n"tjjtjjd�pXtjjd�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} ntjjd�} | dkr6d} ntjj| 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} ntjjd�} | dkr0d} ntjj| 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 r r 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 ddddgfdd�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 sX || _ d| _d | _tjd�| _ytd d�| _W n tk rJ t� | _Y nX | j � 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| j � |jtjjt� | j�� |jtjjt� | j�� |jtjjt� | 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'