Spade
Mini Shell
| Directory:~$ /lib/python2.7/site-packages/future/standard_library/ |
| [Home] [System Details] [Kill Me] |
�
,�]c@`s1dZddlmZmZmZddlZddlZddlZddlZddl Z ddl
Z
ddlZejd�Z
ejej�Zej�Zeje�e
je�e
jej�ddlmZmZedddd g�Zi
d
d6dd
6dd6dd6dd6dd6dd6dd6dd6dd6dd6d
d!6d"d#6Zeeej��ee�@�dks�t�d_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqdrgZ
dGe!fdH��YZ"dIe!fdJ��YZ#er2eeej��eej$�@�dks2t�ndK�Z%dL�Z&dM�Z'dNe!fdO��YZ(dP�Z)dQ�Z*dR�Z+dS�Z,e-dT�Z.dU�Z/dV�Z0e1edW�s�ie_2ndX�Z3e-dY�Z4dZ�Z5d[e!fd\��YZ6d
ddd ddddd]dddd"dgZ7d^�Z8dS(ss�
Python 3 reorganized the standard library (PEP 3108). This module exposes
several standard library modules to Python 2 under their new Python 3
names.
It is designed to be used as follows::
from future import standard_library
standard_library.install_aliases()
And then these normal Py3 imports work on both Py3 and Py2::
import builtins
import copyreg
import queue
import reprlib
import socketserver
import winreg # on Windows only
import test.support
import html, html.parser, html.entites
import http, http.client, http.server
import http.cookies, http.cookiejar
import urllib.parse, urllib.request, urllib.response, urllib.error,
urllib.robotparser
import xmlrpc.client, xmlrpc.server
import _thread
import _dummy_thread
import _markupbase
from itertools import filterfalse, zip_longest
from sys import intern
from collections import UserDict, UserList, UserString
from collections import OrderedDict, Counter, ChainMap # even on
Py2.6
from subprocess import getoutput, getstatusoutput
from subprocess import check_output # even on Py2.6
(The renamed modules and functions are still available under their old
names on Python 2.)
This is a cleaner alternative to this idiom (see
http://docs.pythonsprints.com/python3_porting/py-porting.html)::
try:
import queue
except ImportError:
import Queue as queue
Limitations
-----------
We don't currently support these modules, but would like to::
import dbm
import dbm.dumb
import dbm.gnu
import collections.abc # on Py33
import pickle # should (optionally) bring in cPickle on Python 2
i(tabsolute_importtdivisiontprint_functionNt
future_stdlib(tPY2tPY3ttestturllibtpickletdbmtbuiltinst__builtin__tcopyregtcopy_regtqueuetQueuetsocketserversfuture.moves.socketservertconfigparsertConfigParsertreprlibtreprtwinregt_winregt_threadtthreadt
_dummy_threadtdummy_threadtxmlrpcsfuture.moves.xmlrpcthtmlsfuture.moves.htmlthttpsfuture.moves.httpt_markupbasesfuture.moves._markupbasetcollectionstUserListtUserDictt
UserStringtChainMapsfuture.backports.misct itertoolstfilterfalsetifilterfalsetzip_longesttizip_longesttsystinterntretASCIItstattST_MODEtbase64tencodebytestencodestringtdecodebytestdecodestringt
subprocesst getoutputtcommandstgetstatusoutputtcheck_outputtmathtceiltOrderedDicttCountertcounttrecursive_reprt functoolst
cmp_to_keytRenameImportcB`s>eZdZeZd�Zdd�Zd�Zdd�Z RS(sX
A class for import hooks mapping Py3 module names etc. to the Py2
equivalents.
cC`s�||_t|j��t|j��@}t|�dkrgtt|j���t|j��ksstd��td�|j�D��|_dS(s�
Pass in a dictionary-like object mapping from old names to new
names. E.g. {'ConfigParser': 'configparser',
'cPickle': 'pickle'}
is/Ambiguity in renaming (handler not
implemented)cs`s!|]\}}||fVqdS(N((t.0toldtnew((sD/usr/lib/python2.7/site-packages/future/standard_library/__init__.pys <genexpr>�sN( t
old_to_newtsettkeystvaluestlentAssertionErrortdicttitemst
new_to_old(tselfREtboth((sD/usr/lib/python2.7/site-packages/future/standard_library/__init__.pyt__init__�s "- cC`sCtg|jD]}|jd�d^q
�}||kr?|SdS(Nt.i(RFRMtsplittNone(RNtfullnametpathtstnew_base_names((sD/usr/lib/python2.7/site-packages/future/standard_library/__init__.pytfind_modules/cC`snd}|tjkr
tj|S||jkrN|j|}|j|�}n|j|�}|tj|<|S(N(RSR)tmodulesRMt_find_and_load_module(RNtnameRUtoldnametmodule((sD/usr/lib/python2.7/site-packages/future/standard_library/__init__.pytload_module s
cC`s�|jd�}x�t|�dkr�|jd�}|j||�}y
|j}Wqtk
r�tjdj|��|t j
kr�t j
|Stjd�qXqW|d}tj||�}tj
||�S(sb
Finds and loads it. But if there's a . in the name, handles it
properly.
RQiisPackage {0} has no __path__.sWhat to do
here?(RRRItpopRZt__path__tAttributeErrortflogtdebugtformatR)RYtimpRXR^(RNR[RUtbitstpackagenametpackagetmodule_info((sD/usr/lib/python2.7/site-packages/future/standard_library/__init__.pyRZs
N(
t__name__t
__module__t__doc__tTruetRENAMERRPRSRXR^RZ(((sD/usr/lib/python2.7/site-packages/future/standard_library/__init__.pyRA�s thookscB`s
eZdZd�Zd�ZRS(s
Acts as a context manager. Saves the state of sys.modules and restores
it
after the 'with' block.
Use like this:
>>> from future import standard_library
>>> with standard_library.hooks():
... import http.client
>>> import requests
For this to work, http.client will be scrubbed from sys.modules after
the
'with' block. That way the modules imported in the
'with' block will
continue to be accessible in the current namespace but not from any
imported modules (like requests).
cC`s,tjtj�|_t�|_t�|S(N(tcopyR)RYtold_sys_modulestdetect_hooksthooks_were_installedt
install_hooks(RN((sD/usr/lib/python2.7/site-packages/future/standard_library/__init__.pyt __enter__AscG`s|jst�ndS(N(Rstremove_hooks(RNtargs((sD/usr/lib/python2.7/site-packages/future/standard_library/__init__.pyt__exit__Is (RjRkRlRuRx(((sD/usr/lib/python2.7/site-packages/future/standard_library/__init__.pyRo0s cC`str
tSdtjkr�tjtjtjg}g|D]}tjj |�d^q8}t
t|��dks�tj
d|�n|dt_n|jtjkr�tSt|d�r�tjj |j�}|djtj�r�d|dkr�tSntS(s�
Tries to infer whether the module m is from the Python 2 standard
library.
This may not be reliable on all systems.
tstdlib_pathiis<Multiple locations found for the Python standard
library:
%st__file__s
site-packages(RtFalsetis_py2_stdlib_modulet__dict__t
contextlibRztosRpRURRRIRFRbtwarnRyRjR)tbuiltin_module_namesRmthasattrt
startswith(tmtstdlib_filestftstdlib_pathstmodpath((sD/usr/lib/python2.7/site-packages/future/standard_library/__init__.pyR|Vs") cC`s�tr
iSi}x�tttj��@D]h}|tjkrBq'ntj|}t|�r'tj dj
|��tj|||<tj|=q'q'W|S(sE
Removes any Python 2 standard library modules from ``sys.modules`` that
would interfere with Py3-style imports using import hooks. Examples are
modules with the same names (like urllib or email).
(Note that currently import hooks are disabled for modules like these
with ambiguous names anyway ...)
s"Deleting (Py2) {} from
sys.modules(RtREPLACED_MODULESRFtRENAMESRGR)RYR|RbRcRd(tscrubbedt
modulenameR]((sD/usr/lib/python2.7/site-packages/future/standard_library/__init__.pytscrub_py2_sys_modulests
cC`siS(s
Deprecated.
((((sD/usr/lib/python2.7/site-packages/future/standard_library/__init__.pytscrub_future_sys_modules�st
suspend_hookscB`s
eZdZd�Zd�ZRS(s�
Acts as a context manager. Use like this:
>>> from future import standard_library
>>> standard_library.install_hooks()
>>> import http.client
>>> # ...
>>> with standard_library.suspend_hooks():
>>> import requests # incompatible with
``future``'s standard library hooks
If the hooks were disabled before the context, they are not installed
when
the context is left.
cC`st�|_t�|S(N(RrRsRv(RN((sD/usr/lib/python2.7/site-packages/future/standard_library/__init__.pyRu�scG`s|jrt�ndS(N(RsRt(RNRw((sD/usr/lib/python2.7/site-packages/future/standard_library/__init__.pyRx�s (RjRkRlRuRx(((sD/usr/lib/python2.7/site-packages/future/standard_library/__init__.pyR��s
cC`sgttj�t|�@}t|�dkrSt|�d}tdj|���ntjj|�dS(sp
Add any previously scrubbed modules back to the sys.modules cache,
but only if it's safe to do so.
is(future module {} clashes with Py2
moduleN(RFR)RYRItlisttImportErrorRdtupdate(R�tclashtfirst((sD/usr/lib/python2.7/site-packages/future/standard_library/__init__.pytrestore_sys_modules�s cC`sjtr
dSxgtD]_\}}}}t|�tj|}t|�tj|}t||�}t|||�qWddl}ddlm }ddlm
} ddlm}
ddlm}ddlm
}||_ | |_
|
|_||_||_
|tjd<| tjd <|
tjd
<|tjd<|tjd<yddl}
Wntk
ranXydd
lm}Wntk
r�nX||
_|tjd<yddl}Wntk
r�n�Xddlm}||_|tjd<yddlm}Wntk
rnX||_|tjd<yddlm}Wntk
rOnX||_|tjd<dS(sm
Monkey-patches the standard library in Py2.6/7 to provide
aliases for better Py3 compatibility.
Ni(trequest(tresponse(tparse(terror(trobotparsersurllib.requestsurllib.responsesurllib.parsesurllib.errorsurllib.robotparser(tsupportstest.support(tdumbsdbm.dumb(tgnusdbm.gnu(tndbmsdbm.ndbm(RtMOVESt
__import__R)RYtgetattrtsetattrRtfuture.backports.urllibR�R�R�R�R�RR�tfuture.moves.testR�R tfuture.moves.dbmR�R�R�(t
newmodnamet
newobjnamet
oldmodnamet
oldobjnametnewmodtoldmodtobjRR�R�R�R�R�RR�R R�R�R�((sD/usr/lib/python2.7/site-packages/future/standard_library/__init__.pytinstall_aliases�sl
cC`s|tr
dSt�tjdjtj��tjd�tt�}t �s_tjj
|�ntjdjtj��dS(s`
This function installs the future.standard_library import hook into
sys.meta_path.
Nssys.meta_path was: {0}sInstalling hooks ...ssys.meta_path is now:
{0}(RR�RbRcRdR)t meta_pathRAR�Rrtappend(tnewhook((sD/usr/lib/python2.7/site-packages/future/standard_library/__init__.pyRts
cC`st�dS(s_
Deprecated. Use install_hooks() instead. This will be removed by
``future`` v1.0.
N(Rt(((sD/usr/lib/python2.7/site-packages/future/standard_library/__init__.pytenable_hooksscC`sztr
dStjd�xLtttj��ddd�D](\}}t|d�r:tj|=q:q:W|rvt�ndS(sC
This function removes the import hook from sys.meta_path.
NsUninstalling hooks
...i����Rn( RRbRcR�t enumerateR)R�R�R�(tscrub_sys_modulestithook((sD/usr/lib/python2.7/site-packages/future/standard_library/__init__.pyRv's
/cC`st�dS(s^
Deprecated. Use remove_hooks() instead. This will be removed by
``future`` v1.0.
N(Rv(((sD/usr/lib/python2.7/site-packages/future/standard_library/__init__.pyt
disable_hooks;scC`s_tjd�tgtjD]}t|d�^q�}|rNtjd�n
tjd�|S(sG
Returns True if the import hooks are installed, False if not.
sDetecting hooks ...Rns Detected.s
Not
detected.(RbRctanyR)R�R�(R�tpresent((sD/usr/lib/python2.7/site-packages/future/standard_library/__init__.pyRrCs
+
tpy2_modulescC`sxttj�dkrdSt�s)t�ddl}|tjd<ddl}|tjd<ddl}|tjd<dS(s�
Currently this function is unneeded, as we are not attempting to
provide import hooks
for modules with ambiguous names: email, urllib, pickle.
iNRtemailR(RIR)R�RrRJRR�R(RR�R((sD/usr/lib/python2.7/site-packages/future/standard_library/__init__.pytcache_py2_modulesXs
c C`s�ddl}trt|�S|r+d}nd}|jd�|jd�}g}xGt|�D]9\}}dj||d
�}|j|j|��q`WxRtt t|���D]8\}}|dkr�Pnt
||d|||�q�W|dSdS(s�
Pass a (potentially dotted) module name of a Python 3 standard library
module. This function imports the module compatibly on Py2 and Py3 and
returns the top-level module.
Example use:
>>> http = import_('http.client')
>>> http = import_('http.server')
>>> urllib = import_('urllib.request')
Then:
>>> conn = http.client.HTTPConnection(...)
>>> response =
urllib.request.urlopen('http://mywebsite.com')
>>> # etc.
Use as follows:
>>> package_name = import_(module_name)
On Py3, equivalent to this:
>>> import module_name
On Py2, equivalent to this if backport=False:
>>> from future.moves import module_name
or to this if backport=True:
>>> from future.backports import module_name
except that it also handles dotted module names such as ``http.client``
The effect then is like this:
>>> from future.backports import module
>>> from future.backports.module import submodule
>>> module.submodule = submodule
Note that this would be a SyntaxError in Python:
>>> from future.backports import http.client
iNsfuture.backportssfuture.movesRQii(t importlibRR�RRR�tjoinR�t
import_moduletreversedR�R�( tmodule_nametbackportR�tprefixtpartsRYR�tparttsofar((sD/usr/lib/python2.7/site-packages/future/standard_library/__init__.pytimport_ts
.
%
cO`s�trt|�Sd|kr5t|d�r5d}nd}|jd�|jd�}tj|d|�}g|D]}t||�^qu}t|�dkr�|dS|SdS(sa
Example use:
>>> HTTPConnection = from_import('http.client',
'HTTPConnection')
>>> HTTPServer = from_import('http.server',
'HTTPServer')
>>> urlopen, urlparse =
from_import('urllib.request', 'urlopen',
'urlparse')
Equivalent to this on Py3:
>>> from module_name import symbol_names[0],
symbol_names[1], ...
and this on Py2:
>>> from future.moves.module_name import symbol_names[0],
...
or:
>>> from future.backports.module_name import
symbol_names[0], ...
except that it also handles dotted module names such as
``http.client``.
R�sfuture.backportssfuture.movesRQiiN(RR�tboolRRR�R�R�RI(R�tsymbol_namestkwargsR�R�R]R[toutput((sD/usr/lib/python2.7/site-packages/future/standard_library/__init__.pytfrom_import�s
"texclude_local_folder_importscB`s)eZdZd�Zd�Zd�ZRS(sZ
A context-manager that prevents standard library modules like
configparser
from being imported from the local python-future source folder on Py3.
(This was need prior to v0.16.0 because the presence of a configparser
folder would otherwise have prevented setuptools from running on Py3.
Maybe
it's not needed any more?)
cG`s\t|�dkst�||_tg|jD]}d|k^q.�rXtd��ndS(NiRQs%Dotted
module names are not
supported(RIRJtmodule_namesR�tNotImplementedError(RNRwR�((sD/usr/lib/python2.7/site-packages/future/standard_library/__init__.pyRP�s (cC`s�tjtj�|_tjtj�|_tjddkrAdSdddddg}x^|jD]S}tg|D]'}tjj tjj
||��^qp�r`tjj|�q`q`Wx;|jD]0}yt
|dd�}Wq�tk
r�q�Xq�WdS( Niitfuturetpasttlibfuturizet
libpasteurizeR
tlevel(RpR)RUtold_sys_pathRYRqtversion_infotallRtexistsR�tremoveR�R�R�(RNtFUTURE_SOURCE_SUBFOLDERStfoldert subfolderR�R]((sD/usr/lib/python2.7/site-packages/future/standard_library/__init__.pyRu�s4
cG`sW|jt_xDt|jj��ttjj��D]}|j|tj|<q5WdS(N(R�R)RURFRqRGRY(RNRwR�((sD/usr/lib/python2.7/site-packages/future/standard_library/__init__.pyRxs/(RjRkRlRPRuRx(((sD/usr/lib/python2.7/site-packages/future/standard_library/__init__.pyR��s
ttkinterc
C`sJtt��8x0tD](}yt|�Wqtk
r;qXqWWdQXdS(N(R�tTOP_LEVEL_MODULESR�R�(R�((sD/usr/lib/python2.7/site-packages/future/standard_library/__init__.pytimport_top_level_modules)s
(RR
R R
(RsUserDictsUserDictsUserDict(RR"R"R"(RR#sfuture.backports.miscR#(R$R%R$R&(R$R'R$R((ssyssinterns__builtin__sintern(sreR,sstatsST_MODE(sbase64R0sbase64R1(sbase64R2sbase64R3(s
subprocessR5R6R5(s
subprocessR7R6R7(s
subprocessR8sfuture.backports.miscR8(R9R:sfuture.backports.miscR:(RR;sfuture.backports.miscR;(RR<sfuture.backports.miscR<(RR#sfuture.backports.miscR#(R$scountsfuture.backports.miscscount(RR>sfuture.backports.miscR>(R?R@sfuture.backports.miscR@(9Rlt
__future__RRRR)tloggingReR~ttypesRpRt getLoggerRbt FormattertBASIC_FORMATt
_formattert
StreamHandlert_handlertsetFormattert
addHandlertsetLeveltWARNtfuture.utilsRRRFR�R�RIRHRJR�tobjectRARoR�R|R�R�R�R�R�RtR�R{RvR�RrR�R�R�R�R�R�R�R�(((sD/usr/lib/python2.7/site-packages/future/standard_library/__init__.pyt<module>;s�
.
F"4 P I &6