B
    d                 @   s   d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z	 dZ
e	jdddG d	d
 d
ZeedddZeedddZeeddddZeedddZdS )a  
:mod:`braindump` exposes an API to serialize and deserialize Pegasus's braindump file.

Basic Usage::

    >>> from Pegasus import braindump
    >>> braindump.loads("user: mayani
grid_dn: null
")
    {'grid_dn': None, 'user': 'mayani'}

    >>> print(braindump.dumps({"grid_dn": None, "user": "mayani"}))
    '{"grid_dn": null, "user": "mayani"}'

.. moduleauthor:: Rajiv Mayani <mayani@isi.edu>
    )Path)OptionalTextIO)yaml)attr)loadloadsdumpdumps	BraindumpT)slotskw_onlyc               @   s  e Zd ZdZejeddZejeddZejeddZ	ejeddZ
ejeddZejedejedZejeddZejeddZejeddZejeddZejeddZejedejedZejedejedZejedejedZejeddZejeddZejeddZejeddZejeddZejedejedZejeddZejedejedZ ejeddZ!ejeddZ"ejeddZ#ejeddZ$ejeddZ%ejeddZ&dS )r   zw
    Data class representing Braindump file.

    .. todo::

        Use :mod:`dataclasses` instead of :mod:`attr`
    N)typedefault)r   r   	converter)'__name__
__module____qualname____doc__r   ibstruserZgrid_dnZsubmit_hostnameZroot_wf_uuidZwf_uuidr   
convertersoptionalZdaxZ	dax_labelZ	dax_indexZdax_versionZpegasus_wf_name	timestampZbasedirZ
submit_dirZplannerZplanner_versionZplanner_argumentsZpegasus_buildZjsdZrundirZbindirZvogroupboolZuses_pmc
propertiesZ
condor_logZdagr   notifyscript r   r   ^/work/yifan.wang/ringdown/master-ringdown-env/lib/python3.7/site-packages/Pegasus/braindump.pyr      sF   r   )fpreturnc             O   s   t |  S )z
    Deserialize ``fp`` (a ``.read()``-supporting file-like object containing a Braindump document) to a Python object.

    [extended_summary]

    :param fp: [description]
    :type fp: TextIO
    :return: [description]
    :rtype: Dict
    )r   read)r!   argskwargsr   r   r    r      s    r   )sr"   c             O   s.   t j| f||}t|ts$tdtf |S )z
    Deserialize ``s`` (a ``str``, ``bytes`` or ``bytearray`` instance containing a Braindump document) to a Python object.

    [extended_summary]

    :param s: [description]
    :type s: str
    :return: [description]
    :rtype: Dict
    zInvalid braindump file.)r   r   
isinstancedict
ValueErrorr   )r&   r$   r%   _dictr   r   r    r      s    
r   N)objr!   r"   c             O   s   t jt| |f|| dS )a   
    Serialize ``obj`` as a Braindump formatted stream to ``fp`` (a ``.write()``-supporting file-like object).

    [extended_summary]

    :param obj: [description]
    :type obj: Dict
    :param fp: [description]
    :type fp: TextIO
    :return: [description]
    :rtype: NoReturn
    N)r   r	   r   asdict)r+   r!   r$   r%   r   r   r    r	      s    r	   )r+   r"   c             O   s   t jt| f||S )z
    Serialize ``obj`` to a Braindump formatted ``str``.

    [extended_summary]

    :param obj: [description]
    :type obj: Dict
    :return: [description]
    :rtype: str
    )r   r
   r   r,   )r+   r$   r%   r   r   r    r
      s    r
   )r   pathlibr   typingr   r   ZPegasusr   ZPegasus.vendorr   __all__r&   r   r   r   r   r	   r
   r   r   r   r    <module>   s   m