o
    3g                     @  s   d dl mZ d dlZd dlZd dlZd dlmZ d dlmZ ej	dkZ
G dd dZedd	d
ZG dd dZdd ZdddZdS )    )annotationsN)contextmanager)StringIOwin32c                   @  s   e Zd Zdd Zdd ZdS )ProcInfoc                 C  s   || _ || _|| _|| _d S Npiduidstatargs)selfr	   r
   r   r    r   C/home/garg/my-data/venv/lib/python3.10/site-packages/plumbum/lib.py__init__   s   
zProcInfo.__init__c              	   C  s&   d| j d| jd| jd| jd	S )Nz	ProcInfo(z, )r   )r   r   r   r   __repr__   s   &zProcInfo.__repr__N)__name__
__module____qualname__r   r   r   r   r   r   r      s    r    c                 c  sJ    t j}t j}t| t _t t _zt jV  W |t _|t _dS |t _|t _w )zp
    Captures stdout (similar to the redirect_stdout in Python 3.4+, but with slightly different arguments)
    N)sysstdinstdoutr   )r   	prevstdin
prevstdoutr   r   r   captured_stdout   s   


r   c                   @  s"   e Zd ZdZdd ZdddZdS )StaticPropertyziThis acts like a static property, allowing access via class or object.
    This is a non-data descriptor.c                 C  s   || _ |j| _d S r   )	_function__doc__)r   functionr   r   r   r   +   s   zStaticProperty.__init__Nc                 C  s   |   S r   )r   )r   objklassr   r   r   __get__/   s   zStaticProperty.__get__r   )r   r   r   r   r   r#   r   r   r   r   r   '   s    r   c                 C  s8   z| j }W n
 ty   Y dS w t|tsdS t|S )z
    This gets a docstring if available, and cleans it, but does not look up docs in
    inheritance tree (Pre Python 3.5 behavior of ``inspect.getdoc``).
    N)r   AttributeError
isinstancestrinspectcleandoc)r!   docr   r   r   getdoc3   s   


r*      c                 C  s   t |  |}tdD ].}z
||dfW   S  ty: } z|jdkr& |t |  d7 }W Y d}~qd}~ww ||dfS )z
    This reads a utf-8 file descriptor and returns a chunk, growing up to
    three bytes if needed to decode the character at the end.

    Returns the data and the decoded text.
       zutf-8zunexpected end of data   N)osreadfilenorangedecodeUnicodeDecodeErrorreason)fdsizedata_er   r   r   read_fd_decode_safelyA   s   
 r:   )r   )r+   )
__future__r   r'   r.   r   
contextlibr   ior   platformIS_WIN32r   r   r   r*   r:   r   r   r   r   <module>   s    
