U
    -_g                  	   @   s   d dl Z d dlZd dlmZ dZdZdZdZG dd dZd	Z	d
Z
dZdZdZdZeddddddZe	ee	e
ee deeeeeediZdS )    N)
SoSOptionsz/etc/sos/presets.ddescnoteargsc                   @   sZ   e Zd ZdZdZdZdZe ZdZ	dd Z
dd Zddde fd	d
Zdd Zdd ZdS )PresetDefaultsa  Preset command line defaults to allow for quick reference to sets of
    commonly used options

    :param name: The name of the new preset
    :type name: ``str``

    :param desc: A description for the new preset
    :type desc: ``str``

    :param note: Note for the new preset
    :type note: ``str``

    :param opts: Options set for the new preset
    :type opts: ``SoSOptions``
    NTc              	   C   s*   d| j  d| j d| j dt| j d	S )zeReturn a human readable string representation of this
            ``PresetDefaults`` object.
        zname=z desc=z note=z opts=())namer   r   stroptsself r   6/usr/lib/python3/dist-packages/sos/presets/__init__.py__str__4   s    zPresetDefaults.__str__c              	   C   s*   d| j  d| j d| j dt| j d	S )zgReturn a machine readable string representation of this
            ``PresetDefaults`` object.
        zPresetDefaults(name='z' desc='z' note='z' opts=(r   )r   r   r   reprr
   r   r   r   r   __repr__;   s    zPresetDefaults.__repr__ c                 C   s   || _ || _|| _|| _dS )zInitialise a new ``PresetDefaults`` object with the specified
            arguments.

            :returns: The newly initialised ``PresetDefaults``
        Nr   r   r   r
   )r   r   r   r   r
   r   r   r   __init__B   s    zPresetDefaults.__init__c              	   C   s   | j rtd| j }| jt| jt| jt	|ii}t
j|sLt
j|dd tt
j|| jddd}t|| W 5 Q R X dS )zWrite this preset to disk in JSON notation.

        :param presets_path: the directory where the preset will be written
        :type presets_path: ``str``
        zCannot write built-in preseti  )modewzutf-8)encodingN)builtin	TypeErrorr
   dictr   DESCr   NOTEr   OPTSospathexistsmakedirsopenjoinjsondump)r   presets_pathZodictZpdictZpfiler   r   r   writeM   s    
zPresetDefaults.writec                 C   s   t t j|| j dS )zDelete a preset from disk

        :param presets_path: the directory where the preset is saved
        :type presets_path: ``str``
        N)r   unlinkr   r#   r   )r   r&   r   r   r   deletea   s    zPresetDefaults.delete)__name__
__module____qualname____doc__r   r   r   r   r
   r   r   r   r   r'   r)   r   r   r   r   r      s   r   ZnonezDo not load a presetz+Use to disable automatically loaded presetsZminimalzCSmall and quick report that reduces sos report resource consumptionzXMay be useful for low-resource systems, but may not provide sufficient data for analysis
      T)Zlog_sizeZjournal_sizeZplugin_timeoutZcommand_timeoutZlow_priorityr   )r$   r   Zsos.optionsr   ZPRESETS_PATHr   r   r   r   Z	NO_PRESETZNO_PRESET_DESCZNO_PRESET_NOTEZSMALL_PRESETZSMALL_PRESET_DESCZSMALL_PRESET_NOTEZSMALL_PRESET_OPTSZGENERIC_PRESETSr   r   r   r   <module>   s@   R       