o
    [h                     @   s`   d dl Z d dlmZ d dlmZ d dlmZ dd Zefdedee fd	d
Z	de
fddZdS )    N)Path)Optional)__version__c                 C   s   t dd | dD S )Nc                 S      g | ]}t |qS  )int).0nr   r   s/home/ubuntu/experiments/live_experiments/Pythonexperiments/Otree/venv/lib/python3.10/site-packages/otree/update.py
<listcomp>	       z(split_dotted_version.<locals>.<listcomp>.)tuplesplit)versionr   r   r
   split_dotted_version   s   r   requirements_pathreturnc                 C   sh   |   sdS zt|}W n
 ty   Y dS w | d D ]}t| |}|r1d| d  S qdS )zNrewrote this without pkg_resources since that takes 0.4 seconds just to importNutf8zFThis project requires a different oTree version. Enter: pip3 install "")existsr   
ValueError	read_text
splitlinescheck_update_needed_linestrip)r   current_versionZcurrent_version_tuplelineresr   r   r
   check_update_needed   s   r   r   c                    st    fdd}|d}|r|\}||krdS |d}|r$|\}||k r$dS |d}|r8|\}}||k s6||kr8dS dS )Nc                    s^   d}| j dd}t||  }|r-| dd  }zdd |D W S  ty,   Y d S w d S )Nzotree(\[mturk\])?z	([\d\.]+))VERSION   c                 S   r   r   )r   )r   gr   r   r
   r   *   r   z;check_update_needed_line.<locals>.check.<locals>.<listcomp>)formatrematchgroupsr   )Zrhs_fmtlhsrhsr%   r&   r   r   r
   check#   s   z'check_update_needed_line.<locals>.checkz=={VERSION}Tz>={VERSION}z>={VERSION},<{VERSION}Fr   )r   r   r*   r%   r   Ztoo_high_versionr   r)   r
   r      s"   r   )r$   pathlibr   typingr   Zotreer   r   strr   r   r   r   r   r   r
   <module>   s    
