B
    ?F[                 @   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   7lib/python3.7/site-packages/boto/mturk/qualification.py__init__   s    zQualifications.__init__c             C   s   | j | d S )N)r   append)r   reqr   r   r   add   s    zQualifications.addc             C   s`   i }t | jdkstxDt| jD ]6\}}| }x$|D ]}|| |d|d |f < q8W q"W |S )N
   zQualificationRequirement.%s.%s   )lenr   AssertionError	enumerateget_as_params)r   paramsnr   Z	reqparamsZ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 )N)qualification_type_id
comparatorinteger_valuerequired_to_preview)r   r   r   r   r   r   r   r   r   /   s    zRequirement.__init__c             C   sp   | j | jd}| jdkr@xDt| jdD ]\}}||d| < q&W n| jdkr^| jd k	r^| j|d< | jrld|d< |S )	N)QualificationTypeId
Comparator)In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00000000000000000000)r   r   r   r   )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00000000000000000070)r   r   r   r   )r#   r&   r   )r   r   r   r   )r$   r   r   r   P   s    z/PercentAssignmentsAbandonedRequirement.__init__)F)r   r   r   r!   r   r%   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000000000000000000E0)r   r   r   r   )r#   r'   r   )r   r   r   r   )r$   r   r   r   X   s    z.PercentAssignmentsReturnedRequirement.__init__)F)r   r   r   r!   r   r%   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000000000000000000L0)r   r   r   r   )r#   r(   r   )r   r   r   r   )r$   r   r   r   `   s    z.PercentAssignmentsApprovedRequirement.__init__)F)r   r   r   r!   r   r%   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000000000000000000S0)r   r   r   r   )r#   r)   r   )r   r   r   r   )r$   r   r   r   h   s    z.PercentAssignmentsRejectedRequirement.__init__)F)r   r   r   r!   r   r%   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00000000000000000040)r   r   r   r   )r#   r*   r   )r   r   r   r   )r$   r   r   r   u   s    z&NumberHitsApprovedRequirement.__init__)F)r   r   r   r!   r   r%   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00000000000000000071)r   r   r   r   )r#   r+   r   locale)r   r   r,   r   )r$   r   r   r   }   s    zLocaleRequirement.__init__c             C   s   | j | jd}| jdkrlxt| jdD ]@\}}t|trZ|d |d| < |d |d| < q&||d| < q&W n4t| jtr| jd |d< | jd |d< n
| j|d< | jrd	|d
< |S )N)r   r   )r   r   r       zLocaleValue.%d.CountryzLocaleValue.%d.SubdivisionzLocaleValue.CountryzLocaleValue.Subdivisionr   r   )r   r   r   r,   
isinstancetupler   )r   r   r    r,   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00000000000000000060)r   r   r   r   )r#   r0   r   )r   r   r   r   )r$   r   r   r      s    zAdultRequirement.__init__)F)r   r   r   r!   r   r%   r   r   )r$   r   r0      s   r0   N)objectr   r   r"   r&   r'   r(   r)   r*   r+   r0   r   r   r   r   <module>   s   