https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/boto/mturk/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/boto/mturk/__pycache__/question.cpython-310.pyc
o

ckF[�>�@s�ddlZGdd�de�ZzddlmZGdd�de�ZWney-Gdd�de�ZYnwGdd	�d	e�ZGd
d�de�Z	Gdd
�d
e	�Z
Gdd�de	�ZGdd�de�Z
Gdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de	�ZGdd�de�ZGdd�de�ZGd d!�d!ee�ZGd"d#�d#e�ZGd$d%�d%e�ZGd&d'�d'e�ZGd(d)�d)e�ZGd*d+�d+e�ZGd,d-�d-e�ZGd.d/�d/e�ZGd0d1�d1e�ZGd2d3�d3e�ZGd4d5�d5e�ZGd6d7�d7e�Z dS)8�Nc@s.eZdZdZ	d
dd�Zddd�Zdd	�ZdS)�Questionz<Question>%(items)s</Question>FNcC�|j�t��|`dS�N��__dict__�update�vars�self)r	�
identifier�content�answer_spec�is_required�display_name�r�5/usr/lib/python3/dist-packages/boto/mturk/question.py�__init__szQuestion.__init__cC�||��iSr��
get_as_xml�r	�labelrrr�
get_as_params!�zQuestion.get_as_paramscCsftd|j�tdt|j����|j|jg}|jdur#|�dtd|j��d�	dd�|D��}|j
t�S)N�QuestionIdentifier�
IsRequired��DisplayName�cs��|]}|��VqdSrr��.0�itemrrr�	<genexpr>-��z&Question.get_as_xml.<locals>.<genexpr>)�SimpleFieldr
�strr
�lowerrrr�insert�join�templater�r	�itemsrrrr$s
�
zQuestion.get_as_xml)FN)r)�__name__�
__module__�__qualname__r)rrrrrrrrs
�
r)�etreec@�eZdZdd�ZdS)�
ValidatingXMLcCsDddl}|�|j�}t�|�}t�|�}t�|���}|�|�dS)Nr)	�urllib2�urlopen�
schema_urlr/�parse�	XMLSchema�
fromstringr�assertValid)r	r2�schema_src_file�
schema_doc�schema�docrrr�validate5s

�ValidatingXML.validateN�r,r-r.r=rrrrr13�r1c@r0)r1cCsdSrr�r	rrrr=?sr>Nr?rrrrr1=r@c@s8eZdZdZdZde�Zdd�Zddd�Zdd	�Z	d
S)�ExternalQuestionz:
    An object for constructing an External Question.
    z`http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2006-07-14/ExternalQuestion.xsdz�<ExternalQuestion xmlns="%(schema_url)s"><ExternalURL>%%(external_url)s</ExternalURL><FrameHeight>%%(frame_height)s</FrameHeight></ExternalQuestion>cCstjj�|�|_||_dSr)�xml�sax�saxutils�escape�external_url�frame_height)r	rGrHrrrrJs
zExternalQuestion.__init__cCrrrrrrrrNrzExternalQuestion.get_as_paramscC�|jt|�Sr�r)rrArrrrQ�zExternalQuestion.get_as_xmlN)rB)
r,r-r.�__doc__r4rr)rrrrrrrrBCs

rBc@r0)�XMLTemplatecCrIrrJrArrrrVrKzXMLTemplate.get_as_xmlN)r,r-r.rrrrrrMUsrMc@�eZdZdZdZdd�ZdS)r$z�
    A Simple name/value pair that can be easily rendered as XML.

    >>> SimpleField('Text', 'A text string').get_as_xml()
    '<Text>A text string</Text>'
    z <%(field)s>%(value)s</%(field)s>cC�||_||_dSr)�field�value�r	rPrQrrrrc�
zSimpleField.__init__N)r,r-r.rLr)rrrrrr$Zsr$c@�eZdZdZdd�ZdS)�Binaryz�<Binary><MimeType><Type>%(type)s</Type><SubType>%(subtype)s</SubType></MimeType><DataURL>%(url)s</DataURL><AltText>%(alt_text)s</AltText></Binary>cCrrr)r	�type�subtype�url�alt_textrrrrkszBinary.__init__N)r,r-r.r)rrrrrrUhsrUc@rT)�Listz?A bulleted list suitable for OrderedContent or Overview contentcCsd�dd�|D��}d|S)Nrcss�|]}d|VqdS)z<ListItem>%s</ListItem>Nrrrrrr"sr#z"List.get_as_xml.<locals>.<genexpr>z<List>%s</List>�r(r*rrrrrszList.get_as_xmlN)r,r-r.rLrrrrrrZpsrZc@s,eZdZdZdZdd�Zdd�Zdd�Zd	S)
�Applicationz?<Application><%(class_)s>%(content)s</%(class_)s></Application>z-<Name>%(name)s</Name><Value>%(value)s</Value>cKs||_||_||_dSr)�width�height�
parameters)r	r]r^r_rrrr{s
zApplication.__init__cCsL|�d|j�|�d|j�|j��D]\}}|jt�}|�d|�qdS)N�Width�Height�ApplicationParameter)�append_fieldr]r^r_r+�parameter_templater)r	r�namerQrrr�get_inner_content�s�zApplication.get_inner_contentcCs,t�}|�|�|��}|jj}|jt�Sr)�OrderedContentrfr�	__class__r,r)r)r	r�class_rrrr�s

zApplication.get_as_xmlN)r,r-r.r)rdrrfrrrrrr\wsr\c@s4eZdZdZde�Zdd�Zd
dd�Zdd�Zd	S)�HTMLQuestionz\http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2011-11-11/HTMLQuestion.xsdz�<HTMLQuestion xmlns="%(schema_url)s"><HTMLContent><![CDATA[<!DOCTYPE html>%%(html_form)s]]></HTMLContent><FrameHeight>%%(frame_height)s</FrameHeight></HTMLQuestion>cCrOr)�	html_formrH)r	rkrHrrrr�rSzHTMLQuestion.__init__cCrrrrrrrr�rzHTMLQuestion.get_as_paramscCrIrrJrArrrr�rKzHTMLQuestion.get_as_xmlN)rj)	r,r-r.r4rr)rrrrrrrrj�s

rjc�(eZdZ�fdd�Z�fdd�Z�ZS)�
JavaAppletcs&||_||_tt|�j|i|��dSr)�path�filename�superrmr)r	rnro�args�kwargs�rhrrr�szJavaApplet.__init__cs6t�}|�d|j�|�d|j�tt|��|�dS)N�
AppletPath�AppletFilename)rgrcrnrorprmrf�r	rrsrrrf�szJavaApplet.get_inner_content�r,r-r.rrf�
__classcell__rrrsrrm�srmcrl)�Flashcs ||_tt|�j|i|��dSr)rXrpryr)r	rXrqrrrsrrr�szFlash.__init__cs(t�}|�d|j�tt|��|�dS)N�
FlashMovieURL)rgrcrXrpryrfrvrsrrrf�szFlash.get_inner_contentrwrrrsrry�sryc@rN)�FormattedContentzkhttp://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2006-07-14/FormattedContentXHTMLSubset.xsdz<<FormattedContent><![CDATA[%(content)s]]></FormattedContent>cC�
||_dSr)rrvrrrr��
zFormattedContent.__init__N)r,r-r.r4r)rrrrrr{�sr{c@�eZdZdd�Zdd�ZdS)rgcCs|�t||��dSr)�appendr$rRrrrrc��zOrderedContent.append_fieldcCsd�dd�|D��S)Nrcsrrrrrrrr"�r#z,OrderedContent.get_as_xml.<locals>.<genexpr>r[rArrrr�r�zOrderedContent.get_as_xmlN)r,r-r.rcrrrrrrg�srgcs*eZdZdZddd�Z�fdd�Z�ZS)�Overviewz <Overview>%(content)s</Overview>cCrrrrrrrr�rzOverview.get_as_paramsc�tt|���}|jt�Sr)rpr�rr)rrvrsrrr��zOverview.get_as_xml)r�)r,r-r.r)rrrxrrrsrr��s
r�c@s.eZdZdZdZde�Zdd�Zdd�ZdS)	�QuestionForma�
    From the AMT API docs:

    The top-most element of the QuestionForm data structure is a
    QuestionForm element. This element contains optional Overview
    elements and one or more Question elements. There can be any
    number of these two element types listed in any order. The
    following example structure has an Overview element and a
    Question element followed by a second Overview element and
    Question element--all within the same QuestionForm.

    ::

        <QuestionForm xmlns="[the QuestionForm schema URL]">
            <Overview>
                [...]
            </Overview>
            <Question>
                [...]
            </Question>
            <Overview>
                [...]
            </Overview>
            <Question>
                [...]
            </Question>
            [...]
        </QuestionForm>

    QuestionForm is implemented as a list, so to construct a
    QuestionForm, simply append Questions and Overviews (with at least
    one Question).
    z\http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2005-10-01/QuestionForm.xsdz><QuestionForm xmlns="%(schema_url)s">%%(items)s</QuestionForm>cCs$tdd�|D��otdd�|D��S)Ncss�|]}t|t�VqdSr)�
isinstancerrrrrr"�s�z(QuestionForm.is_valid.<locals>.<genexpr>css�|]
}t|ttf�VqdSr)r�rr�rrrrr"�s�)�any�allrArrr�is_valid�s�zQuestionForm.is_validcCs0|��sJd��d�dd�|D��}|jt�S)Nz&QuestionForm contains invalid elementsrcsrrrrrrrr"r#z*QuestionForm.get_as_xml.<locals>.<genexpr>)r�r(�xml_templaterr*rrrr�szQuestionForm.get_as_xmlN)	r,r-r.rLr4rr�r�rrrrrr��s!
r�c� eZdZdZ�fdd�Z�ZS)�QuestionContentz.<QuestionContent>%(content)s</QuestionContent>cr�r)rpr�rr)rrvrsrrrr�zQuestionContent.get_as_xml�r,r-r.r)rrxrrrsrr��r�c@� eZdZdZdd�Zdd�ZdS)�AnswerSpecificationz3<AnswerSpecification>%(spec)s</AnswerSpecification>cCr|r)�spec�r	r�rrrrr}zAnswerSpecification.__init__cCs|j��}|jt�Sr)r�rr)rr�rrrrs
zAnswerSpecification.get_as_xmlN�r,r-r.r)rrrrrrr�sr�cr�)�Constraintsz&<Constraints>%(content)s</Constraints>cr�r)rpr�rr)rrvrsrrrr�zConstraints.get_as_xmlr�rrrsrr�r�r�c@r~)�
ConstraintcC�&t|j|j�}d�dd�|D��}|S)N� cs�(�|]\}}|durd||fVqdS)Nz%s="%d"r�r rerQrrrr""��
��z,Constraint.get_attributes.<locals>.<genexpr>��zip�attribute_names�attribute_valuesr(�r	�pairs�attrsrrr�get_attributes �

�zConstraint.get_attributescCs|��}|jt�Sr)r�r)r)r	r�rrrr)szConstraint.get_as_xmlN)r,r-r.r�rrrrrr�s	r�c@�eZdZdZdZddd�ZdS)�NumericConstraint)�minValue�maxValuez<IsNumeric %(attrs)s />NcC�||f|_dSr�r�)r	�	min_value�	max_valuerrrr2rKzNumericConstraint.__init__�NN�r,r-r.r�r)rrrrrr�.�r�c@r�)�LengthConstraint)�	minLength�	maxLengthz<Length %(attrs)s />NcCr�rr�)r	�
min_length�
max_lengthrrrr:rKzLengthConstraint.__init__r�r�rrrrr�6r�r�c@s&eZdZdZdZddd�Zdd�ZdS)	�RegExConstraint)�regex�	errorText�flagsz<AnswerFormatRegex %(attrs)s />NcCs|||f|_dSrr�)r	�pattern�
error_textr�rrrrBszRegExConstraint.__init__cCr�)Nr�csr�)Nz%s="%s"rr�rrrr"Gr�z1RegExConstraint.get_attributes.<locals>.<genexpr>r�r�rrrr�Er�zRegExConstraint.get_attributesr�)r,r-r.r�r)rr�rrrrr�>s

r�c@s"eZdZdZddd�Zdd�ZdS)	�NumberOfLinesSuggestionz@<NumberOfLinesSuggestion>%(num_lines)s</NumberOfLinesSuggestion>rcCr|r)�	num_lines�r	r�rrrrRr}z NumberOfLinesSuggestion.__init__cCs|j}|jt�Sr)r�r)rr�rrrrUsz"NumberOfLinesSuggestion.get_as_xmlN)rr�rrrrr�Os
r�c@s"eZdZdZddd�Zdd�ZdS)�FreeTextAnswerz*<FreeTextAnswer>%(items)s</FreeTextAnswer>NcCs,||_|durt�|_nt|�|_||_dSr)�defaultr��constraintsr�)r	r�r�r�rrrr]s



zFreeTextAnswer.__init__cCsV|jg}|jr|�td|j��|jr|�t|j��d�dd�|D��}|jt�S)N�DefaultTextrcsrrrrrrrr"kr#z,FreeTextAnswer.get_as_xml.<locals>.<genexpr>)	r�r�rr$r�r�r(r)rr*rrrreszFreeTextAnswer.get_as_xml)NNNr�rrrrr�Zs
r�c@r�)�FileUploadAnswerz�<FileUploadAnswer><MaxFileSizeInBytes>%(max_bytes)d</MaxFileSizeInBytes><MinFileSizeInBytes>%(min_bytes)d</MinFileSizeInBytes></FileUploadAnswer>cCs6d|kr|krdksJ�J�||_||_dS)Nri�5w)�	min_bytes�	max_bytes)r	r�r�rrrrrs&
zFileUploadAnswer.__init__cCrIrrJrArrrrwrKzFileUploadAnswer.get_as_xmlNr�rrrrr�osr�c@sFeZdZdZdZdZdZdZdZdZ	gd�Z
d	Zddd�Zdd�Z
dS)�SelectionAnswerzw
    A class to generate SelectionAnswer XML data structures.
    Does not yet implement Binary selection options.
    zB<SelectionAnswer>%s%s<Selections>%s</Selections></SelectionAnswer>zF<Selection><SelectionIdentifier>%s</SelectionIdentifier>%s</Selection>z<%s>%s</%s>z%<StyleSuggestion>%s</StyleSuggestion>z)<MinSelectionCount>%s</MinSelectionCount>z)<MaxSelectionCount>%s</MaxSelectionCount>)�radiobutton�dropdown�checkbox�list�combobox�multichooser�OtherSelectionrN�textFcCs�|dur|tjvr
||_ntd|d�tj�f��d|_|dur$td��||_||_||_t|�|jks;Jd|j��||_	||_
dS)Nz.style '%s' not recognized; should be one of %sz, z_SelectionAnswer.__init__(): selections must be a non-empty list of (content, identifier) tuplesz*# of selections is less than minimum of %d)r��ACCEPTED_STYLES�style_suggestion�
ValueErrorr(�
selections�min_selections�max_selections�lenrV�other)r	�min�max�styler�rVr�rrrr�s

zSelectionAnswer.__init__c	Cs|jdkrd}n|jdkrd}n	tdt|j���d}|jD]}tj||d|f}tj|d|f}||7}q|jr[t|jd	�rWt	|jt
�sKJd
��||j���dd�7}n|d
7}|j
durgtj|j
}nd}|j
dkr}tj|j}|tj|j7}nd}tj|||f}|S)Nr��Text�binaryrUz3illegal type: %s; must be either 'text' or 'binary'rrrrz+OtherSelection can only be a FreeTextAnswerr�r�z<OtherSelection />r�)rVr�r%r�r��SELECTION_VALUE_XML_TEMPLATE�SELECTION_XML_TEMPLATEr��hasattrr�r�r�replacer��STYLE_XML_TEMPLATE� MIN_SELECTION_COUNT_XML_TEMPLATEr�� MAX_SELECTION_COUNT_XML_TEMPLATEr��SELECTIONANSWER_XML_TEMPLATE)	r	�TYPE_TAG�selections_xml�tpl�	value_xml�
selection_xml�	style_xml�	count_xml�retrrrr�s0





zSelectionAnswer.get_as_xml)rrNNr�F)r,r-r.rLr�r�r�r�r�r�r��OTHER_SELECTION_ELEMENT_NAMErrrrrrr�{s
r�)!�xml.sax.saxutilsrC�objectr�lxmlr/r1�ImportErrorrBrMr$rUr�rZr\rjrmryr{rgr�r�r�r�r�r�r�r�r�r�r�r�r�rrrr�<module>s@	�
	2

https://t.me/RX1948 - 2025