B
    t\q                 @   s   d Z ddlZddlZeeejd eejd  ZyeZW n ek
rT   eZY nX e	 dkZ
dd ZyejjZedkrdZW n ek
r   dZY nX d	d
 ZyeZW n ek
r   eZY nX dd ZyddlmZ W n ek
r   dd ZY nX dS )z
To ensure compatibility from Python ``2.6`` - ``3.3``, a module has been
created. Clearly there is huge need to use conforming syntax.
    N   ZPyPyc             G   s   |s
t f}| d|i S )z" Create a class with a metaclass. Z	HackClass)object)metabases r   3lib/python3.7/site-packages/parso/_compatibility.pyuse_metaclass   s    r   zutf-8asciic             C   s,   t dkrt| S t| ts(tt| dS | S )zCast to unicode DAMMIT!
    Written because Python2 repr always implicitly casts to a string, so we
    have to cast back to a unicode (and we know that we always deal with valid
    unicode, because we check that in the beginning).
       zUTF-8)
py_versionstr
isinstanceunicode)stringr   r   r   u$   s
    
r   c                s     fdd}t dkr S |S dS )z
    ``__repr__`` methods in Python 2 don't allow unicode objects to be
    returned. Therefore cast them to utf-8 bytes in this decorator.
    c                s$    | }t |tr|dS |S d S )Nzutf-8)r   r   encode)selfresult)funcr   r   wrapper=   s    

zutf8_repr.<locals>.wrapperr
   N)r   )r   r   r   )r   r   	utf8_repr8   s    r   )total_orderingc             C   s   ddd fddd fddd fgddd fd	d
d fddd fgd	dd fddd fddd fgddd fddd fd	dd fgd}t t| t |@ }|stdt|}x<|| D ]0\}}||kr||_tt|j|_t| || qW | S )z6Class decorator that fills in missing ordering methods__gt__c             S   s   | |k p| |k S )Nr   )r   otherr   r   r   <lambda>Q   s    z total_ordering.<locals>.<lambda>__le__c             S   s   | |k p| |kS )Nr   )r   r   r   r   r   r   R   s    __ge__c             S   s
   | |k  S )Nr   )r   r   r   r   r   r   S   s    c             S   s   | |k p| |kS )Nr   )r   r   r   r   r   r   T   s    __lt__c             S   s   | |ko| |k S )Nr   )r   r   r   r   r   r   U   s    c             S   s
   | |k S )Nr   )r   r   r   r   r   r   V   s    c             S   s   | |kp| |k S )Nr   )r   r   r   r   r   r   W   s    c             S   s   | |kp| |kS )Nr   )r   r   r   r   r   r   X   s    c             S   s
   | |k S )Nr   )r   r   r   r   r   r   Y   s    c             S   s   | |k p| |kS )Nr   )r   r   r   r   r   r   Z   s    c             S   s   | |ko| |k S )Nr   )r   r   r   r   r   r   [   s    c             S   s
   | |k S )Nr   )r   r   r   r   r   r   \   s    )r   r   r   r   z6must define at least one ordering operation: < > <= >=)	setdir
ValueErrormax__name__getattrint__doc__setattr)clsZconvertrootsrootopnameopfuncr   r   r   r   N   s,    







r   )r%   sysplatformr$   r   version_infor   r   	NameErrorZpython_implementationZis_pypyr   stdoutencodingAttributeErrorr   FileNotFoundErrorIOErrorr   	functoolsr   ImportErrorr   r   r   r   <module>   s2    


