B
    \K              :   @   s  d dl mZ G dd deZdZdZdZdZdZdZ	dZ
dZdZdZdZdZdZdZdZdZdZedZdZdZdZd	d
 Zdddddddddddddddddddddddddddddddddddddddddddddddddddddg g ddd9ZddddZdd Zdd Zeee eeeeedddddeee!e!ee"eddddedZ#x,e$ D ] \Z%Z&e%e#krTe!e&e#e%< qTW dddddddddddddddddddddddddddddddd Z'd)d!d"Z(d*d#d$Z)d%d& Z*d+d'd(Z+dS ),    )absolute_importc               @   s:   e Zd Zg ZdddZdd Zdd Zd	d
 Zdd ZdS )ShouldBeFromDirectiveNFc             C   s&   || _ |p|| _|| _| j|  d S )N)options_namedirective_namedisallowknown_directivesappend)selfr   r   r    r
   6lib/python3.7/site-packages/Cython/Compiler/Options.py__init__   s    
zShouldBeFromDirective.__init__c             C   s   |    d S )N)_bad_access)r	   r
   r
   r   __nonzero__   s    z!ShouldBeFromDirective.__nonzero__c             C   s   |    d S )N)r   )r	   r
   r
   r   __int__   s    zShouldBeFromDirective.__int__c             C   s   t t| d S )N)RuntimeErrorrepr)r	   r
   r
   r   r      s    z!ShouldBeFromDirective._bad_accessc             C   s   d| j | jf S )NzEIllegal access of '%s' from Options module rather than directive '%s')r   r   )r	   r
   r
   r   __repr__   s    zShouldBeFromDirective.__repr__)NF)	__name__
__module____qualname__r   r   r   r   r   r   r
   r
   r
   r   r      s   
r   TFNold_style_globals   c              C   s`   xZt jD ]P} t | j}| jtks(tt|t s| j	rNt
d| j| jf q|t| j< qW tS )Nz+Option '%s' must be set from directive '%s')r   r   globalsgetr   r   _directive_defaultsAssertionError
isinstancer   r   option_name)Z
old_optionvaluer
   r
   r   get_directive_defaults   s    
r    bytes)9ZboundscheckZ	nonecheckZinitializedcheckZembedsignatureZ
auto_cpdefauto_pickleZ	cdivisionZcdivision_warningsZoverflowcheckzoverflowcheck.foldZalways_allow_keywordsZallow_none_for_extension_argsZ
wraparoundZccomplexZcallspecnogilZprofileZ	linetraceemit_code_commentsannotation_typinginfer_typeszinfer_types.verboseautotestdictzautotestdict.cdefzautotestdict.alllanguage_levelZfast_getattrZ
py2_importZpreliminary_late_includes_cy28iterable_coroutinec_string_typec_string_encodingtype_version_tagZunraisable_tracebacksr   
np_pythranfast_gilset_initial_pathwarnzwarn.undeclaredzwarn.unreachablezwarn.maybe_uninitializedzwarn.unusedzwarn.unused_argzwarn.unused_resultzwarn.multiple_declaratorszoptimize.inline_defnode_callszoptimize.unpack_method_callsz&optimize.unpack_method_calls_in_pyinitzoptimize.use_switchZremove_unreachablezcontrol_flow.dot_outputzcontrol_flow.dot_annotate_defstest_assert_path_existstest_fail_if_path_existsbindingZformal_grammar)zwarn.maybe_uninitializedzwarn.unreachablezwarn.unusedc                 s    fdd}|S )Nc                s$   | krt d|  |f n|S d S )Nz(%s directive must be one of %s, got '%s')
ValueError)namer   )argsr
   r   validate   s    zone_of.<locals>.validater
   )r6   r7   r
   )r6   r   one_of   s    r8   c             C   sl   |sdS |  dkr|  S ddl}y||}W n tk
rF   |S X xdD ]}|||krN|S qNW |S )a  
    >>> normalise_encoding_name('c_string_encoding', 'ascii')
    'ascii'
    >>> normalise_encoding_name('c_string_encoding', 'AsCIi')
    'ascii'
    >>> normalise_encoding_name('c_string_encoding', 'us-ascii')
    'ascii'
    >>> normalise_encoding_name('c_string_encoding', 'utF8')
    'utf8'
    >>> normalise_encoding_name('c_string_encoding', 'utF-8')
    'utf8'
    >>> normalise_encoding_name('c_string_encoding', 'deFAuLT')
    'default'
    >>> normalise_encoding_name('c_string_encoding', 'default')
    'default'
    >>> normalise_encoding_name('c_string_encoding', 'SeriousLyNoSuch--Encoding')
    'SeriousLyNoSuch--Encoding'
    r    )defaultasciiutf8r   N)r:   r;   )lowercodecs
getdecoderLookupError)r   encodingr=   decoderr5   r
   r
   r   normalise_encoding_name  s    
rB   	bytearraystrZunicode)r(   r"   localsfinalr#   internalr&   r3   cfuncccallinlinestaticmethodcclassno_gc_clearno_gcreturns	exceptvalr/   freelistr*   r+   )modulerL   )rL   function)rS   zwith statement)rS   )rL   )classrL   zwith statement)rR   )rS   rT   rL   )rR   rS   )r"   rF   r#   rJ   rH   rI   rO   rP   rE   rK   rM   rN   rG   rL   r'   zautotestdict.allzautotestdict.cdefr/   r1   r2   rQ   r$   r%   r*   r+   r,   r(   r   r-   r.   r)   c             C   s   t | }|sdS |}|tkrtt|}|dkr2dS |dkr>dS |rb| }|dkrVdS |dkrbdS td| |f nb|tkryt|S  tk
r   td	| |f Y qX n*|tkrt|S t|r|| |S dstdS )
a  
    Parses value as an option value for the given name and returns
    the interpreted value. None is returned if the option does not exist.

    >>> print(parse_directive_value('nonexisting', 'asdf asdfd'))
    None
    >>> parse_directive_value('boundscheck', 'True')
    True
    >>> parse_directive_value('boundscheck', 'true')
    Traceback (most recent call last):
       ...
    ValueError: boundscheck directive must be set to True or False, got 'true'

    >>> parse_directive_value('c_string_encoding', 'us-ascii')
    'ascii'
    >>> parse_directive_value('c_string_type', 'str')
    'str'
    >>> parse_directive_value('c_string_type', 'bytes')
    'bytes'
    >>> parse_directive_value('c_string_type', 'bytearray')
    'bytearray'
    >>> parse_directive_value('c_string_type', 'unicode')
    'unicode'
    >>> parse_directive_value('c_string_type', 'unnicode')
    Traceback (most recent call last):
    ValueError: c_string_type directive must be one of ('bytes', 'bytearray', 'str', 'unicode'), got 'unnicode'
    NTrueTFalseF)trueZyes)ZfalseZnoz3%s directive must be set to True or False, got '%s'z0%s directive must be set to an integer, got '%s')	directive_typesr   boolrD   r<   r4   intcallabler   )r5   r   relaxed_booltypeZ
orig_valuer
   r
   r   parse_directive_valuei  s:    

r^   c             C   s   |dkri }n|}x|  dD ]}| }|s0qd|krDtd| dd |  ddD \}}|tkrd}|d	r|dd
 }	x0tD ](}
|
|	rd}t|
||d}|||
< qW |s|std| qt|||d}|||< qW |S )aJ  
    Parses a comma-separated list of pragma options. Whitespace
    is not considered.

    >>> parse_directive_list('      ')
    {}
    >>> (parse_directive_list('boundscheck=True') ==
    ... {'boundscheck': True})
    True
    >>> parse_directive_list('  asdf')
    Traceback (most recent call last):
       ...
    ValueError: Expected "=" in option "asdf"
    >>> parse_directive_list('boundscheck=hey')
    Traceback (most recent call last):
       ...
    ValueError: boundscheck directive must be set to True or False, got 'hey'
    >>> parse_directive_list('unknown=True')
    Traceback (most recent call last):
       ...
    ValueError: Unknown option: "unknown"
    >>> warnings = parse_directive_list('warn.all=True')
    >>> len(warnings) > 1
    True
    >>> sum(warnings.values()) == len(warnings)  # all true.
    True
    N,=zExpected "=" in option "%s"c             S   s   g | ]}|  qS r
   )strip).0sr
   r
   r   
<listcomp>  s    z(parse_directive_list.<locals>.<listcomp>   Fz.allT)r\   zUnknown option: "%s")splitra   r4   r   endswith
startswithr^   )rc   r\   Zignore_unknowncurrent_settingsresultitemr5   r   foundprefixZ	directiveZparsed_valuer
   r
   r   parse_directive_list  s0    


ro   c             C   s^   | dkrdS | dkrdS | dkr$dS |   r4t| S yt| } W n tk
rT   Y nX | S dS )a  
    Parses value as an option value for the given name and returns
    the interpreted value.

    >>> parse_variable_value('True')
    True
    >>> parse_variable_value('true')
    'true'
    >>> parse_variable_value('us-ascii')
    'us-ascii'
    >>> parse_variable_value('str')
    'str'
    >>> parse_variable_value('123')
    123
    >>> parse_variable_value('1.23')
    1.23

    rU   TrV   FNoneN)isdigitrZ   float	Exception)r   r
   r
   r   parse_variable_value  s    rt   c             C   sr   |dkri }n|}xZ|  dD ]L}| }|s0qd|krDtd| dd | ddD \}}t|||< qW |S )a  
    Parses a comma-separated list of pragma options. Whitespace
    is not considered.

    >>> parse_compile_time_env('      ')
    {}
    >>> (parse_compile_time_env('HAVE_OPENMP=True') ==
    ... {'HAVE_OPENMP': True})
    True
    >>> parse_compile_time_env('  asdf')
    Traceback (most recent call last):
       ...
    ValueError: Expected "=" in option "asdf"
    >>> parse_compile_time_env('NUM_THREADS=4') == {'NUM_THREADS': 4}
    True
    >>> parse_compile_time_env('unknown=anything') == {'unknown': 'anything'}
    True
    Nr_   r`   zExpected "=" in option "%s"c             S   s   g | ]}|  qS r
   )ra   )rb   rc   r
   r
   r   rd     s    z*parse_compile_time_env.<locals>.<listcomp>re   )rg   ra   r4   rt   )rc   rj   rk   rl   r5   r   r
   r
   r   parse_compile_time_env  s    ru   )F)FFN)N),Z
__future__r   objectr   Z
docstringsZembed_pos_in_docstringr$   Z
pre_importZgenerate_cleanup_codeZclear_to_noneZannotateZannotate_coverage_xmlZ	fast_failZwarning_errorsZerror_on_unknown_namesZerror_on_uninitializedZconvert_rangeZcache_builtinsZgcc_branch_hintsZlookup_module_cpdefZembedr   Zcimport_from_pyxZbuffer_max_dimsZclosure_freelist_sizer   r   Zextra_warningsr8   rB   rD   rY   dictr]   rZ   rX   itemskeyvalZdirective_scopesr^   ro   rt   ru   r
   r
   r
   r   <module>   s"  &	

$

< 
8$