%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/thread-self/root/usr/lib/python2.7/site-packages/salt/modules/inspectlib/
Upload File :
Create Path :
Current File : //proc/thread-self/root/usr/lib/python2.7/site-packages/salt/modules/inspectlib/fsdb.pyc

�
���^c@�s�dZddlmZmZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddl
mZdefd��YZdefd	��YZdS(
s+
    :codeauthor: Bo Maryniuk <bo@suse.de>
i(tabsolute_importtwith_statementN(tOrderedDict(tziptCsvDBEntitycB�seZdZd�ZRS(s,
    Serializable object for the table.
    cC�s g|D]}t||�^qS(sm
        Serialize the object to a row for CSV according to the table description.

        :return:
        (tgetattr(tselftdescriptiontattr((s@/usr/lib/python2.7/site-packages/salt/modules/inspectlib/fsdb.pyt
_serialize%s(t__name__t
__module__t__doc__R	(((s@/usr/lib/python2.7/site-packages/salt/modules/inspectlib/fsdb.pyR!stCsvDBcB�s�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zdd
�Z
d�Zd�Zd
�Zed�Zddddd�Zddddd�Zd�Zddddd�Zddddd�Zd�ZRS(sr
    File-based CSV database.
    This database is in-memory operating relatively small plain text csv files.
    cC�s5|j|�t|_d|_t|_i|_dS(sP
        Constructor to store the database files.

        :param path:
        N(t_preparetFalset_openedtNonetdb_patht_tables(Rtpath((s@/usr/lib/python2.7/site-packages/salt/modules/inspectlib/fsdb.pyt__init__3s

			cC�s5||_tjj|j�s1tj|j�ndS(N(Rtostexiststmakedirs(RR((s@/usr/lib/python2.7/site-packages/salt/modules/inspectlib/fsdb.pyR?s	cC�stjj�jd�S(sY
        Create label of the database, based on the date-time.

        :return:
        s
%Y%m%d-%H%M%S(tdatetimetutcnowtstrftime(R((s@/usr/lib/python2.7/site-packages/salt/modules/inspectlib/fsdb.pyt_labelDscC�sf|j�}tjj|j|�|_tjj|j�sOtj|j�nt|_|j	�|S(sG
        Create a new database and opens it.

        :return:
        (
RRRtjoinRRRtTrueRtlist_tables(Rtdbname((s@/usr/lib/python2.7/site-packages/salt/modules/inspectlib/fsdb.pytnewLs	
cC�sEtjj|j|�}tjj|�rAtj|dt�tStS(sL
        Purge the database.

        :param dbid:
        :return:
        t
ignore_errors(RRRRtshutiltrmtreeRR(RtdbidR((s@/usr/lib/python2.7/site-packages/salt/modules/inspectlib/fsdb.pytpurge[s
cC�s>tjj|j|�}tjj|�r:tj|�ndS(sF
        Flush table.

        :param table:
        :return:
        N(RRRRRtunlink(Rttablet
table_path((s@/usr/lib/python2.7/site-packages/salt/modules/inspectlib/fsdb.pytflushhscC�sFg}x'tj|j�D]}|j|�qWttt|���S(sM
        List all the databases on the given path.

        :return:
        (RtlistdirRtappendtlisttreversedtsorted(Rt	databasesR ((s@/usr/lib/python2.7/site-packages/salt/modules/inspectlib/fsdb.pyR-sscC�sL|js?x3tj|j�D]}|j|�|j|<qWn|jj�S(sP
        Load existing tables and their descriptions.

        :return:
        (RRR+Rt_load_tabletkeys(Rt
table_name((s@/usr/lib/python2.7/site-packages/salt/modules/inspectlib/fsdb.pyR~s	c
C�sltjtjj|j|�d��B}tgttj	|��D]}t
|jd��^q@�SWdQXdS(Ntrbt:(tgziptopenRRRRRtnexttcsvtreaderttupletsplit(RR3R(telm((s@/usr/lib/python2.7/site-packages/salt/modules/inspectlib/fsdb.pyR1�s'cC�su|j�}|j�rqtjj|j|pF|r=|dpF|j��|_|jsq|j�t	|_qqndS(s�
        Open database from the path with the name or latest.
        If there are no yet databases, create a new implicitly.

        :return:
        iN(
R-t	is_closedRRRR!RRRR(RR R0((s@/usr/lib/python2.7/site-packages/salt/modules/inspectlib/fsdb.pyR7�s7	
cC�s
t|_dS(s7
        Close the database.

        :return:
        N(RR(R((s@/usr/lib/python2.7/site-packages/salt/modules/inspectlib/fsdb.pytclose�scC�s|jS(sE
        Return if the database is closed.

        :return:
        (R(R((s@/usr/lib/python2.7/site-packages/salt/modules/inspectlib/fsdb.pyR>�scC�s�d�}tjjtjj|j|j��s�tjtjj|j|j�d��_}tj	|�j
gt|jj
��D],}djd|dd||d��^q�WdQX|j|j�|j|j<ndS(	s�
        Create a table from the object.
        NOTE: This method doesn't stores anything.

        :param obj:
        :return:
        cS�stt|��jd�dS(Nt'i(tstrttypeR<(titem((s@/usr/lib/python2.7/site-packages/salt/modules/inspectlib/fsdb.pyt<lambda>�stwbs{col}:{type}tcoliRBiN(RRRRRt_TABLER6R7R9twritertwriterowR;t__dict__titemstformatR1R(Rtobjtget_typet
table_fileR=((s@/usr/lib/python2.7/site-packages/salt/modules/inspectlib/fsdb.pytcreate_table_from_object�s	'*LcC�s�|rttt|j|jj�|j|j|j���}|j|jd|�}|rt|rttd��qtnt	j
tjj
|j|j�d��&}tj|�j|j|��WdQXdS(s�
        Store an object in the table.

        :param obj: An object to store
        :param distinct: Store object only if there is none identical of such.
                          If at least one field is different, store it.
        :return:
        teqsObject already in the database.taN(tdictRRRGR2R	tgett	__class__t	ExceptionR6R7RRRRR9RHRIt_validate_object(RRMtdistincttfieldstdb_objR(((s@/usr/lib/python2.7/site-packages/salt/modules/inspectlib/fsdb.pytstore�s	*c	C�s�t}t�}xd|j|j�D]P}|j|d|d|d|d|�re|j|�t}q"|j|�q"W|j|j�|j	|�x|D]}|j
|�q�W|S(s�
        Update object(s) in the database.

        :param obj:
        :param matches:
        :param mt:
        :param lt:
        :param eq:
        :return:
        tmatchestmttltRQ(RR-RTRUt_CsvDB__criteriaR,RR*RGRPR[(	RRMR\R]R^RQtupdatedtobjectst_obj((s@/usr/lib/python2.7/site-packages/salt/modules/inspectlib/fsdb.pytupdate�s	'
	

c	C�s�t}t�}xT|j|�D]C}|j|d|d|d|d|�s\|j|�qt}qW|j|j�|j|��x|D]}|j	|�q�W|S(s�
        Delete object from the database.

        :param obj:
        :param matches:
        :param mt:
        :param lt:
        :param eq:
        :return:
        R\R]R^RQ(
RR-RTR_R,RR*RGRPR[(	RRMR\R]R^RQtdeletedRaRb((s@/usr/lib/python2.7/site-packages/salt/modules/inspectlib/fsdb.pytdelete�s	'

cC�sS|jj|j�}|dkr<tdj|j���n|j|j|j�S(NsTable {0} not found.(RRTRGRRVRLR	(RRMtdescr((s@/usr/lib/python2.7/site-packages/salt/modules/inspectlib/fsdb.pyRWscC�sx9|pij�D]%\}}t||�|krtSqWx9|pHij�D]%\}}t||�|krOtSqOWx9|p�ij�D]%\}}t||�|kr�tSq�WxE|p�ij�D]1\}}tj|tt||���s�tSq�WtS(s�
        Returns True if object is aligned to the criteria.

        :param obj:
        :param matches:
        :param mt:
        :param lt:
        :param eq:
        :return: Boolean
        (RKRRtretsearchRAR(RRMR\R]R^RQtfieldtvalue((s@/usr/lib/python2.7/site-packages/salt/modules/inspectlib/fsdb.pyt
__criterias!cC�s�g}tjtjj|j|j�d���}d}x�tj	|�D]�}	|s^|	}qFn|�}
xNt
||	�D]=\}}|jd�\}}
t|
||j
||
��qwW|j|
d|d|d|d|�rF|j|
�qFqFWWdQX|S(s�
        Get objects from the table.

        :param table_name:
        :param matches: Regexp.
        :param mt: More than.
        :param lt: Less than.
        :param eq: Equals.
        :return:
        R4R5R\R]R^RQN(R6R7RRRRRGRR9R:RR<tsetattrt_to_typeR_R,(RRMR\R]R^RQRaR(theadertdataRbtt_attrtt_datatt_type((s@/usr/lib/python2.7/site-packages/salt/modules/inspectlib/fsdb.pyRT(s*	 'cC�s�|dkrt|�}na|dkr6t|�}nF|dkrptjddkrat|�pjt|�}nt|�}|S(Ntinttfloattlongii(RsRttsystversion_infoRuRA(RRoRB((s@/usr/lib/python2.7/site-packages/salt/modules/inspectlib/fsdb.pyRmBs.N(R
RRRRRR!R&R*R-RR1RR7R?R>RPRR[RcReRWR_RTRm(((s@/usr/lib/python2.7/site-packages/salt/modules/inspectlib/fsdb.pyR
.s*					
								!(Rt
__future__RRRRvRgR9RR6R#tsalt.utils.odictRtsalt.ext.six.movesRtobjectRR
(((s@/usr/lib/python2.7/site-packages/salt/modules/inspectlib/fsdb.pyt<module>s

Zerion Mini Shell 1.0