a
    B^i                     @   s  d Z ddlmZmZmZmZmZ ddlZddl	Zddl
Z
ddlZddlZddlZeZej  ejjZerejZddlZeje_ne
jZdd ZerddlZedZede edZede ddlZe  ejjZ e!Z"ejj#Z!ejj#Z$ejj%Z%ere&Z'nd	d
 Z'ejj(Z(ddl)m&Z& dd Z*zer@ddl+m*Z* W n" e,yd   e-dej.d Y n0 erre/Z0ne
j0Z0e
j1Z1erddlZddl2Z2dd Z3e*ej4dej4j5 e*ej4de26e3dej4 g dZ7erdd e7D Z7ddkrddl8m9Z9 ddl8m:Z: ddl8m;Z; dS )af  
This module is defined to allow us to program in Python 2 with a high degree
of compatibility with Python 3, and vice versa. It's intended to be invoked
with the following preamble::

    from __future__ import division, absolute_import, with_statement, print_function, unicode_literals
    from renpy.compat import *

Right now, it does the following things:

* Sets up aliases for Python 3 module moves, allowing the Python 3 names
  to be used in Python 2.

* Defines PY2 in the current context, to make Python 2 conditional.

* Aliases pickle to cPickle on Python 3, to support Python 2 code
  choosing between the implementations, where the choice is meaningful

* Replaces open with a function that mimics the Python 3 behavior, of
  opening files in a unicode-friendly mode by default.

* Redefines the text types, so that str is always the unicode type, and
  basestring is the list of string types available on the system.

* Exposes bchr, bord, and tobytes from future.utils.

* Changes the meaning of the .items(), .keys(), and .values() methods of
  dict to return views, rather than lists. (This is a fairly major change,
  and so is only available when with_statement and division are both
  imported.

* Aliases xrange to range on Python 2.

* Changes the behavior of TextIOWrapper.write so that bytes strings are promoted
  to unicode strings before being written.
    )divisionabsolute_importwith_statementprint_functionunicode_literalsNc                  O   s6   t djjd@ dkr$t| i |S t| i |S d S )N   i   )sys	_getframef_codeco_flagsopenpython_open)argskwargs r   ;C:\Users\PahaGest\Downloads\Selene\renpy\compat\__init__.pycompat_open\   s    r   strictZpython_strictsurrogateescapec                 C   s
   t | gS Nbytes)ir   r   r   bchr}   s    r   )chrc                 C   s   d S r   r   )objnamevaluer   r   r   add_attribute   s    r   )r   z(Could not import renpy.compat.dictviews.)filec                 C   s    t |tr|dd}| |S )Nzutf-8r   )
isinstancer   decode_write)selfsr   r   r   
text_write   s    
r%   r"   write)PY2r   
basestringstrpystrrangeroundbordr   tobytesr   unicodec                 C   s   g | ]}t |qS r   r   ).0r   r   r   r   
<listcomp>       r1   r   )	dictviews)fixes)pickle)<__doc__
__future__r   r   r   r   r   Zfuture.standard_libraryZfutureZfuture.utilsbuiltinsior   operatorr   r   Zstandard_libraryZinstall_aliasesZutilsr'   reZ_pattern_typePatternr   codecslookup_errorZstrict_errorregister_errorZsurrogateescape_errorrenpyupdate_pathZstring_typesr(   r)   r*   Z	text_typer/   r-   r   r   r.   Zfuture.builtinsr   Zrenpy.compat.dictviewsImportErrorprintstderrZxranger+   r,   typesr%   TextIOWrapperr&   
MethodType__all__ r3   r4   r5   r   r   r   r   <module>   sr   %

	


