
    >h                     D    S r SSKJr  SSKJr   " S S5      rS rS	S jrg)
z$
Handle file opening for read/write
    )Path)_is_string_likec                   0    \ rS rSrSrS rS rS rS rSr	g)	EmptyContextManager	   zk
This class is needed to allow file-like object to be used as
context manager, but without getting closed.
c                     Xl         g N_obj)selfobjs     mC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\statsmodels/iolib/openfile.py__init__EmptyContextManager.__init__   s    	    c                     U R                   $ )z)When entering, return the embedded objectr
   )r   s    r   	__enter__EmptyContextManager.__enter__   s    yyr   c                     g)zDo not hide anythingF )r   argss     r   __exit__EmptyContextManager.__exit__   s    r   c                 .    [        U R                  U5      $ r	   )getattrr   )r   names     r   __getattr__EmptyContextManager.__getattr__   s    tyy$''r   r
   N)
__name__
__module____qualname____firstlineno____doc__r   r   r   r   __static_attributes__r   r   r   r   r   	   s    
(r   r   c                 j    U R                  S5      (       a  SS KnUR                  XUS9$ [        XUS9$ )Nz.gzr   encoding)endswithgzipopen)fnamemoder'   r)   s       r   _openr-      s4    ~~eyyxy88E(33r   Nc                    [        U 5      (       a  [        U 5      n [        U [        5      (       a  U R                  XS9$ [	        U S5      (       a  U R                  XS9$  [        XUS9$ ! [
         aS     SU;   a  U R                    SU;   d  SU;   a  U R                    O! [         a    [        S5      ef = f[        U 5      s $ f = f)a  
Light wrapper to handle strings, path objects and let files (anything else)
pass through.

It also handle '.gz' files.

Parameters
----------
fname : str, path object or file-like object
    File to open / forward
mode : str
    Argument passed to the 'open' or 'gzip.open' function
encoding : str
    For Python 3 only, specify the encoding of the file

Returns
-------
A file-like object that is always a context-manager. If the `fname` was
already a file-like object, the returned context manager *will not
close the file*.
)r,   r'   r*   r&   rwaz,fname must be a string or a file-like object)r   r   
isinstancer*   hasattr	TypeErrorreadwriteAttributeError
ValueErrorr   )r+   r,   r'   s      r   get_file_objr9   '   s    . uU%zztz77			zztz77*E(33 	*	Md{

d{cTk 	MKLL	M"5))	*s*   !	A+ +
C6*B! C!B77CC)r/   N)r#   pathlibr   numpy.lib._iotoolsr   r   r-   r9   r   r   r   <module>r<      s&     .( (*4(*r   