U
    3d                     @   s   G d d de ZG dd de ZG dd deZG dd deZG dd	 d	eZG d
d deZG dd deZG dd deZG dd deZ	G dd deZ
dS )c                   @   s&   e Zd ZdddZdd Zdd ZdS )	QualificationsNc                 C   s   |d krg }|| _ d S N)requirements)selfr    r   </tmp/pip-unpacked-wheel-d7dsrkjd/boto/mturk/qualification.py__init__   s    zQualifications.__init__c                 C   s   | j | d S r   )r   append)r   reqr   r   r   add   s    zQualifications.addc                 C   sX   i }t | jdkstt| jD ]2\}}| }|D ]}|| |d|d |f < q4q |S )N
   zQualificationRequirement.%s.%s   )lenr   AssertionError	enumerateget_as_params)r   paramsnr	   Z	reqparamsrpr   r   r   r       s    zQualifications.get_as_params)N)__name__
__module____qualname__r   r
   r   r   r   r   r   r      s   
r   c                   @   s"   e Zd ZdZdddZdd ZdS )	Requirementz0
    Representation of a single requirement
    NFc                 C   s   || _ || _|| _|| _d S r   qualification_type_id
comparatorinteger_valuerequired_to_preview)r   r   r   r   r   r   r   r   r   /   s    zRequirement.__init__c                 C   sl   | j | jd}| jdkr<t| jdD ]\}}||d| < q$n| jdkrZ| jd k	rZ| j|d< | jrhd|d< |S )	NZQualificationTypeIdZ
ComparatorZInZNotInr   zIntegerValue.%d)ZExistsZDoesNotExistZIntegerValuetrueRequiredToPreview)r   r   r   r   r   )r   r   ir   r   r   r   r   5   s    

zRequirement.get_as_params)NF)r   r   r   __doc__r   r   r   r   r   r   r   *   s   
r   c                       s"   e Zd ZdZd fdd	Z  ZS )&PercentAssignmentsSubmittedRequirementz
    The percentage of assignments the Worker has submitted, over all assignments the Worker has accepted. The value is an integer between 0 and 100.
    Fc                    s   t t| jd|||d d S )NZ00000000000000000000r   )superr#   r   r   r   r   r   	__class__r   r   r   H   s    z/PercentAssignmentsSubmittedRequirement.__init__)Fr   r   r   r"   r   __classcell__r   r   r&   r   r#   C   s   r#   c                       s"   e Zd ZdZd fdd	Z  ZS )&PercentAssignmentsAbandonedRequirementz
    The percentage of assignments the Worker has abandoned (allowed the deadline to elapse), over all assignments the Worker has accepted. The value is an integer between 0 and 100.
    Fc                    s   t t| jd|||d d S )NZ00000000000000000070r   )r$   r*   r   r%   r&   r   r   r   P   s    z/PercentAssignmentsAbandonedRequirement.__init__)Fr(   r   r   r&   r   r*   K   s   r*   c                       s"   e Zd ZdZd fdd	Z  ZS )%PercentAssignmentsReturnedRequirementz
    The percentage of assignments the Worker has returned, over all assignments the Worker has accepted. The value is an integer between 0 and 100.
    Fc                    s   t t| jd|||d d S )NZ000000000000000000E0r   )r$   r+   r   r%   r&   r   r   r   X   s    z.PercentAssignmentsReturnedRequirement.__init__)Fr(   r   r   r&   r   r+   S   s   r+   c                       s"   e Zd ZdZd fdd	Z  ZS )%PercentAssignmentsApprovedRequirementz
    The percentage of assignments the Worker has submitted that were subsequently approved by the Requester, over all assignments the Worker has submitted. The value is an integer between 0 and 100.
    Fc                    s   t t| jd|||d d S )NZ000000000000000000L0r   )r$   r,   r   r%   r&   r   r   r   `   s    z.PercentAssignmentsApprovedRequirement.__init__)Fr(   r   r   r&   r   r,   [   s   r,   c                       s"   e Zd ZdZd fdd	Z  ZS )%PercentAssignmentsRejectedRequirementz
    The percentage of assignments the Worker has submitted that were subsequently rejected by the Requester, over all assignments the Worker has submitted. The value is an integer between 0 and 100.
    Fc                    s   t t| jd|||d d S )NZ000000000000000000S0r   )r$   r-   r   r%   r&   r   r   r   h   s    z.PercentAssignmentsRejectedRequirement.__init__)Fr(   r   r   r&   r   r-   c   s   r-   c                       s"   e Zd ZdZd fdd	Z  ZS )NumberHitsApprovedRequirementa  
    Specifies the total number of HITs submitted by a Worker that have been approved. The value is an integer greater than or equal to 0.

    If specifying a Country and Subdivision, use a tuple of valid  ISO 3166 country code and ISO 3166-2 subdivision code, e.g. ('US', 'CA') for the US State of California.

    When using the 'In' and 'NotIn', locale should be a list of Countries and/or (Country, Subdivision) tuples.

    Fc                    s   t t| jd|||d d S )NZ00000000000000000040r   )r$   r.   r   r%   r&   r   r   r   u   s    z&NumberHitsApprovedRequirement.__init__)Fr(   r   r   r&   r   r.   k   s   	r.   c                       s*   e Zd ZdZd fdd	Zdd Z  ZS )LocaleRequirementz
    A Qualification requirement based on the Worker's location. The Worker's location is specified by the Worker to Mechanical Turk when the Worker creates his account.
    Fc                    s"   t t| jd|d |d || _d S )NZ00000000000000000071r   )r$   r/   r   locale)r   r   r0   r   r&   r   r   r   }   s    zLocaleRequirement.__init__c                 C   s   | j | jd}| jdkrht| jdD ]@\}}t|trX|d |d| < |d |d| < q$||d| < q$n4t| jtr| jd |d< | jd |d< n
| j|d< | jrd	|d
< |S )Nr   r   r       zLocaleValue.%d.CountryzLocaleValue.%d.SubdivisionzLocaleValue.CountryzLocaleValue.Subdivisionr   r    )r   r   r   r0   
isinstancetupler   )r   r   r!   r0   r   r   r   r      s     


zLocaleRequirement.get_as_params)F)r   r   r   r"   r   r   r)   r   r   r&   r   r/   x   s   r/   c                       s"   e Zd ZdZd fdd	Z  ZS )AdultRequirementz
    Requires workers to acknowledge that they are over 18 and that they agree to work on potentially offensive content. The value type is boolean, 1 (required), 0 (not required, the default).
    Fc                    s   t t| jd|||d d S )NZ00000000000000000060r   )r$   r4   r   r%   r&   r   r   r      s    zAdultRequirement.__init__)Fr(   r   r   r&   r   r4      s   r4   N)objectr   r   r#   r*   r+   r,   r-   r.   r/   r4   r   r   r   r   <module>   s   