o
    Ph:$                     @   s   d Z ddlmZ ddlmZ ddlmZ ddlmZ G dd dZ	G dd	 d	Z
G d
d dZG dd dZG dd dZG dd dZG dd dZG dd dZG dd dZdS )z<
Module containing various models for holding informations.
    )BytesIO)dumps)Union)Languagec                   @   sD   e Zd ZdZdddZdefddZdefdd	Zdefd
dZdS )TranslationResultz7
    Class that holds the result of a Translation.
    returnNc                 C   2   || _ t|| _t|| _t|| _t|| _d S Nservicestrsourcer   source_languagedestination_languageresultselfr   r   r   r   r    r   M/var/www/html/env_mimamsha/lib/python3.10/site-packages/translatepy/models.py__init__   
   


zTranslationResult.__init__c                 C      | j S r	   r   r   r   r   r   __str__      zTranslationResult.__str__c                 C      dj | j| j| j| j| jdS )NzTranslationResult(service={service}, source={source}, source_language={source_language}, destination_language={destination_language}, result={result})r   r   r   r   r   formatr   r   r   r   r   r   r   r   r   __repr__      zTranslationResult.__repr__c              	   K   d   t dt| jt| jtt| jtr| jjn| jtt| jtr#| jjn| jt| j	dfi |S NT)successr   r   sourceLanguagedestinationLanguager   
r   r   r   r   
isinstancer   r   idr   r   r   kwargsr   r   r   as_json%      zTranslationResult.as_json)r   N	__name__
__module____qualname____doc__r   r   r   r    r,   r   r   r   r   r      s    
	r   c                   @   B   e Zd ZdZdd ZdefddZdefddZdefd	d
ZdS )TransliterationResultz;
    Class that holds the result of a Transliteration.
    c                 C   r   r	   r
   r   r   r   r   r   5   r   zTransliterationResult.__init__r   c                 C   r   r	   r   r   r   r   r   r   <   r   zTransliterationResult.__str__c                 C   r   )NzTransliterationResult(service={service}, source={source}, source_language={source_language}, destination_language={destination_language}, result={result})r   r   r   r   r   r   r    ?   r!   zTransliterationResult.__repr__c              	   K   r"   r#   r'   r*   r   r   r   r,   H   r-   zTransliterationResult.as_jsonNr.   r   r   r   r   r4   0       	r4   c                   @   r3   )SpellcheckResultz9
    Class that holds the result of a Spellchecking.
    c                 C   s(   || _ t|| _t|| _t|| _d S r	   )r   r   r   r   r   r   )r   r   r   r   r   r   r   r   r   X   s   

zSpellcheckResult.__init__r   c                 C   r   r	   r   r   r   r   r   r   ^   r   zSpellcheckResult.__str__c                 C   s   dj | j| j| j| jdS )NzhSpellcheckResult(service={service}, source={source}, source_language={source_language}, result={result}))r   r   r   r   )r   r   r   r   r   r   r   r   r   r    a   s   zSpellcheckResult.__repr__c                 K   sH   t dt| jt| jtt| jtr| jjn| jt| jdfi |S )NT)r$   r   r   r%   r   )	r   r   r   r   r(   r   r   r)   r   r*   r   r   r   r,   i   s   zSpellcheckResult.as_jsonNr.   r   r   r   r   r6   S   s    r6   c                   @   r3   )LanguageResultz4
    Class that holds the result of a Language.
    c                 C   s   || _ t|| _t|| _d S r	   )r   r   r   r   r   )r   r   r   r   r   r   r   r   x   s   
zLanguageResult.__init__r   c                 C   r   r	   r   r   r   r   r   r   }   r   zLanguageResult.__str__c                 C   s   dj | j| j| jdS )NzCLanguageResult(service={service}, source={source}, result={result}))r   r   r   )r   r   r   r   r   r   r   r   r       s
   zLanguageResult.__repr__c                 K   s,   t dt| jt| jt| jdfi |S )NT)r$   r   r   r   )r   r   r   r   r   r*   r   r   r   r,      s   zLanguageResult.as_jsonNr.   r   r   r   r   r7   s   s    r7   c                   @   r3   )ExampleResultz3
    Class that holds the result of a Example.
    c                 C   .   || _ t|| _t|| _t|| _|| _d S r	   r
   r   r   r   r   r      
   



zExampleResult.__init__r   c                 C   r   r	   r   r   r   r   r   r      s   zExampleResult.__str__c                 C   r   )NzExampleResult(service={service}, source={source}, source_language={source_language}, destination_language={destination_language}, result={result})r   r   r   r   r   r   r       r!   zExampleResult.__repr__c              	   K   r"   r#   r'   r*   r   r   r   r,      r-   zExampleResult.as_jsonNr.   r   r   r   r   r8      s    		r8   c                   @   r3   )DictionaryResultz6
    Class that holds the result of a Dictionary.
    c                 C   r9   r	   r
   r   r   r   r   r      r:   zDictionaryResult.__init__r   c                 C   r   r	   r   r   r   r   r   r      r   zDictionaryResult.__str__c                 C   r   )NzDictionaryResult(service={service}, source={source}, source_language={source_language}, destination_language={destination_language}, result={result})r   r   r   r   r   r   r       r!   zDictionaryResult.__repr__c              	   K   r"   r#   r'   r*   r   r   r   r,      r-   zDictionaryResult.as_jsonNr.   r   r   r   r   r;      r5   r;   c                   @   sJ   e Zd ZdZdd Zdeeef fddZdefdd	Z	defd
dZ
dS )TextToSpechResultz9
    Class that holds the result of a text to spech.
    c                 C   s:   || _ t|| _t|| _t|f| _t|| _|| _d S r	   )	r   r   r   r   r   intspeedgenderr   )r   r   r   r   r>   r?   r   r   r   r   r      s   



zTextToSpechResult.__init__filec                 C   sZ   t |dr|| j dS tt|d}|| j W d   dS 1 s&w   Y  dS )zi
        Writes the spoken text to an MP3 file.

        Args:
            file: The output file
        writeNwb)hasattrrA   r   openr   )r   r@   fpr   r   r   write_to_file   s   

zTextToSpechResult.write_to_filer   c                 C   r   r	   r   r   r   r   r   r      r   zTextToSpechResult.__str__c                 C   r   )NzTextToSpechResult(service={service}, source={source}, source_language={source_language}, speed={speed}, gender={gender}, result=<RawAudioFile>))r   r   r   r>   r?   )r   r   r   r   r>   r?   r   r   r   r   r       r!   zTextToSpechResult.__repr__N)r/   r0   r1   r2   r   r   r   r   rF   r   r    r   r   r   r   r<      s    r<   c                   @   s   e Zd ZdZdZdZeZdS )Speedd   2      N)r/   r0   r1   FULLHALFQUARTERSLOWr   r   r   r   rG     s
    rG   c                   @   s   e Zd ZdZdZdS )GendermalefemaleN)r/   r0   r1   MALEFEMALEr   r   r   r   rO   
  s    rO   N)r2   ior   jsonr   typingr   translatepy.languager   r   r4   r6   r7   r8   r;   r<   rG   rO   r   r   r   r   <module>   s    ## &#*