a
    bL                  ;   @   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dg g ddd:Z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#e$ D ] \Z%Z&e%e#vrTe!e&e#e%< qTd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   g/Users/vegardjervell/Documents/master/model/venv/lib/python3.9/site-packages/Cython/Compiler/Options.py__init__   s    
zShouldBeFromDirective.__init__c                 C   s   |    d S r   _bad_accessr
   r   r   r   __nonzero__   s    z!ShouldBeFromDirective.__nonzero__c                 C   s   |    d S r   r   r   r   r   r   __int__   s    zShouldBeFromDirective.__int__c                 C   s   t t| d S r   )RuntimeErrorreprr   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\   t jD ]P} t | j}| jtv s&J t|t s| jrLt	d| j
| jf q|t| j< qtS )Nz+Option '%s' must be set from directive '%s')r   r   globalsgetr   r   _directive_defaults
isinstancer   r   option_name)Z
old_optionvaluer   r   r   get_directive_defaults   s    

r!    bytes):ZboundscheckZ	nonecheckZinitializedcheckZembedsignatureZ
auto_cpdefauto_pickleZ	cdivisionZcdivision_warningsZc_api_binop_methodsZ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autotestdictautotestdict.cdef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.undeclaredwarn.unreachablewarn.maybe_uninitialized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)r6   r5   r7   c                     s    fdd}|S )Nc                    s$   | v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   )r>   r?   r   r=   r   one_of   s    r@   c                 C   sn   |sdS |  dv r|  S ddl}z||}W n tyH   | Y S 0 dD ]}|||krN|  S qN|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)rB   rC   )lowercodecs
getdecoderLookupError)r   encodingrE   decoderr<   r   r   r   normalise_encoding_name  s    

rJ   	bytearraystrunicode)r,   r$   localsfinalr%   internalr(   r:   cfuncccallinlinestaticmethodcclassno_gc_clearno_gcreturns	exceptvalr3   freelistr.   r/   )modulerU   )rU   function)r\   with statement)r\   )rU   )classrU   r]   )r[   )r\   r^   rU   )r[   r\   )r$   rO   r%   rS   rQ   rR   rX   rY   rN   rT   rV   rW   rP   rU   r)   r+   r*   r3   r8   r9   rZ   r&   r'   r.   r/   r0   r,   r   r1   r2   r-   c                 C   s   t | }|sdS |}|tu rtt|}|dkr2dS |dkr>dS |rb| }|dv rVdS |dv rbdS td| |f nb|tu rz
t|W S  ty   td	| |f Y q0 n*|tu rt|S t|r|| |S dsJ 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)trueyes)false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   boolrL   rD   r;   intcallable)r<   r    relaxed_booltypeZ
orig_valuer   r   r   parse_directive_valuen  s>    



rk   c                 C   s   |du ri }n|}|  dD ]}| }|s.qd|vrBtd| dd |  ddD \}}|tvrd}|d	r|dd
 }	tD ](}
|
|	rd}t|
||d}|||
< q|s|std| qt|||d}|||< q|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,=Expected "=" in option "%s"c                 S   s   g | ]}|  qS r   strip.0sr   r   r   
<listcomp>      z(parse_directive_list.<locals>.<listcomp>   Fz.allT)ri   zUnknown option: "%s")splitrp   r;   r   endswith
startswithrk   )rs   ri   Zignore_unknowncurrent_settingsresultitemr<   r    foundprefix	directiveZparsed_valuer   r   r   parse_directive_list  s0    



r   c                 C   s\   | dkrdS | dkrdS | dkr$dS |   r4t| S zt| } W n tyR   Y n0 | 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

    r_   Tr`   FNoneN)isdigitrg   float	Exception)r    r   r   r   parse_variable_value  s    r   c                 C   sn   |du ri }n|}|  dD ]L}| }|s.qd|vrBtd| dd | ddD \}}t|||< q|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
    Nrl   rm   rn   c                 S   s   g | ]}|  qS r   ro   rq   r   r   r   rt   $  ru   z*parse_compile_time_env.<locals>.<listcomp>rv   )rx   rp   r;   r   )rs   r{   r|   r}   r<   r    r   r   r   parse_compile_time_env  s    r   )F)FFN)N),
__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_cpdefembedr   Zcimport_from_pyxZbuffer_max_dimsZclosure_freelist_sizer!   r   Zextra_warningsr@   rJ   rL   rf   dictrj   rg   re   itemskeyvalZdirective_scopesrk   r   r   r   r   r   r   r   <module>   s.  &
	
M
$
'
<  
9$