Spade
Mini Shell
| Directory:~$ /proc/self/root/usr/lib/python2.7/site-packages/past/utils/ |
| [Home] [System Details] [Kill Me] |
�
,�]c@s�dZddlZddlZejddkZejddkZeed�Zd�Zd�Z d �Z
d
ddd
ddgZdS(sj
Various non-built-in utility functions and definitions for Py2
compatibility in Py3.
For example:
>>> # The old_div() function behaves like Python 2's /
operator
>>> # without "from __future__ import division"
>>> from past.utils import old_div
>>> old_div(3, 2) # like 3/2 in Py2
0
>>> old_div(3, 2.0) # like 3/2.0 in Py2
1.5
i����Niiitpypy_translation_infocs/d�f��fd��Y}|ddi�S(s�
Function from jinja2/_compat.py. License: BSD.
Use it like this::
class BaseForm(object):
pass
class FormType(type):
pass
class Form(with_metaclass(FormType, BaseForm)):
pass
This requires a bit of explanation: the basic idea is to make a
dummy metaclass for one level of class instantiation that replaces
itself with the actual metaclass. Because of internal type checks
we also need to make sure that we downgrade the custom metaclass
for one level to something closer to type (that's why __call__ and
__init__ comes back from type etc.).
This has the advantage over six.with_metaclass of not introducing
dummy classes into the final MRO.
t metaclasscs,eZejZejZ��fd�ZRS(cs2|dkr"tj||d|�S�|�|�S(N((tNonettypet__new__(tclstnamet
this_basestd(tbasestmeta(s7/usr/lib/python2.7/site-packages/past/utils/__init__.pyR4s(t__name__t
__module__Rt__call__t__init__R((R R
(s7/usr/lib/python2.7/site-packages/past/utils/__init__.pyR1s ttemporary_classN(R(R
R R((R R
s7/usr/lib/python2.7/site-packages/past/utils/__init__.pytwith_metaclassscCs!t|d�r|j�S|SdS(s�
On Py2, this is a no-op: native(obj) -> obj
On Py3, returns the corresponding native Py3 types that are
superclasses for forward-ported objects from Py2:
>>> from past.builtins import str, dict
>>> native(str(b'ABC')) # Output on Py3 follows.
On Py2, output is 'ABC'
b'ABC'
>>> type(native(str(b'ABC')))
bytes
Existing native types on Py3 will be returned unchanged:
>>> type(native(b'ABC'))
bytes
t
__native__N(thasattrR(tobj((s7/usr/lib/python2.7/site-packages/past/utils/__init__.pytnative;s
cCs8t|tj�r,t|tj�r,||S||SdS(s�
Equivalent to ``a / b`` on Python 2 without ``from __future__ import
division``.
TODO: generalize this to other objects (like arrays etc.)
N(t
isinstancetnumberstIntegral(tatb((s7/usr/lib/python2.7/site-packages/past/utils/__init__.pytold_divUs$tPY3tPY2tPYPYRRR(t__doc__tsysRtversion_infoRRRRRRRt__all__(((s7/usr/lib/python2.7/site-packages/past/utils/__init__.pyt<module>s #