o
    rMf±  ã                   @   s,   d dl Z G dd„ deƒZG dd„ deƒZdS )é    Nc                   @   sT   e Zd Zedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZed	d
„ ƒZedd„ ƒZ	dS )Ú	Converterc                 C   s   t |tƒst‚|S ©N)Ú
isinstanceÚ
basestringÚ
ValueError©ÚclsÚparamÚvalue© r   úS/var/www/html/analyze/labelStudio/lib/python3.10/site-packages/boto/roboto/param.pyÚconvert_string   s   
zConverter.convert_stringc                 C   s   t |ƒS r   )Úintr   r   r   r   Úconvert_integer"   s   zConverter.convert_integerc                 C   s   dS )zt
        For command line arguments, just the presence
        of the option means True so just return True
        Tr   r   r   r   r   Úconvert_boolean'   s   zConverter.convert_booleanc                 C   s    t j |¡rt j |¡s|S t‚r   )ÚosÚpathÚexistsÚisdirr   r   r   r   r   Úconvert_file/   s   zConverter.convert_filec                 C   s   t j |¡r|S t‚r   )r   r   r   r   r   r   r   r   Úconvert_dir5   s   zConverter.convert_dirc                 C   sF   zt | d|j ƒrt| d|j ƒ}n| j}|||ƒW S    t|dƒ‚)NÚconvert_Ú )ÚhasattrÚptypeÚgetattrr   ÚValidationException)r   r	   r
   Úmthdr   r   r   Úconvert;   s   
zConverter.convertN)
Ú__name__Ú
__module__Ú__qualname__Úclassmethodr   r   r   r   r   r   r   r   r   r   r      s    




r   c                       sv   e Zd Z				ddd„Zedd	„ ƒZed
d„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZ	edd„ ƒZ
‡ fdd„Z‡  ZS )ÚParamNÚstringTr   é   c                 C   sL   || _ || _|| _|| _|| _|| _|| _|| _|	| _|
| _	|| _
|| _d S r   )Únamer   ÚoptionalÚ
short_nameÚ	long_nameÚdocÚmetavarÚcardinalityÚdefaultÚchoicesÚencoderÚrequest_param)Úselfr&   r   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r   r   r   Ú__init__H   s   
zParam.__init__c                 C   ó   d }| j r
d| j  }|S ©Nz--%s©r)   ©r1   Úlnr   r   r   Úoptparse_long_nameY   ó   
zParam.optparse_long_namec                 C   r3   r4   r5   r6   r   r   r   Úsynopsis_long_name`   r9   zParam.synopsis_long_namec                 C   ó*   d }| j rd| j  }| jdkr|d7 }|S )Nú%sÚbooleanú=)r)   r   r6   r   r   r   Úgetopt_long_nameg   ó   

zParam.getopt_long_namec                 C   r3   ©Nz-%s©r(   ©r1   Úsnr   r   r   Úoptparse_short_namep   r9   zParam.optparse_short_namec                 C   r3   rA   rB   rC   r   r   r   Úsynopsis_short_namew   r9   zParam.synopsis_short_namec                 C   r;   )Nr<   r=   ú:)r(   r   rC   r   r   r   Úgetopt_short_name~   r@   zParam.getopt_short_namec                    s   t t| ƒ | |¡S )aB  
        Convert a string value as received in the command line
        tools and convert to the appropriate type of value.
        Raise a ValidationError if the value can't be converted.

        :type value: str
        :param value: The value to convert.  This should always
                      be a string.
        )Úsuperr#   r   )r1   r
   ©Ú	__class__r   r   r   ‡   s   
zParam.convert)Nr$   TNNr   Nr%   NNNT)r   r    r!   r2   Úpropertyr8   r:   r?   rE   rF   rH   r   Ú__classcell__r   r   rJ   r   r#   F   s&    
ý





r#   )r   Úobjectr   r#   r   r   r   r   Ú<module>   s   -