• File: newrange.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/lib/python2.7/site-packages/future/types/newrange.pyc
  • Date Modified: 01/24/2020 11:55 AM
  • File size: 7.33 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit

,]c@@sdZddlmZddlmZerEddlmZmZnddlmZmZddl	m
Z
ddlmZeZ
defdYZd	efd
YZdgZdS(sw
Nearly identical to xrange.py, by Dan Crosta, from

    https://github.com/dcrosta/xrange.git

This is included here in the ``future`` package rather than pointed to as
a dependency because there is no package for ``xrange`` on PyPI. It is
also tweaked to appear like a regular Python 3 ``range`` object rather
than a Python 2 xrange.

From Dan Crosta's README:

    "A pure-Python implementation of Python 2.7's xrange built-in, with
    some features backported from the Python 3.x range built-in (which
    replaced xrange) in that version."

    Read more at
        https://late.am/post/2012/06/18/what-the-heck-is-an-xrange
i(tabsolute_import(tPY2(tSequencetIterator(tislice(tcounttnewrangecB@seZdZdZedZedZedZdZdZ	dZ
dZd	Zd
Z
dZdZd
ZdZRS(s
    Pure-Python backport of Python 3's range object.  See `the CPython
    documentation for details:
    <http://docs.python.org/py3k/library/functions.html#range>`_
    cG@sbt|dkr-d|dd}}}nat|dkr^|d|dd}}}n0t|dkr|\}}}ntdy*t|t|t|}}}Wntk
rtdnX|dkrtdn-|dkrt||}nt||}||_||_||_|||t	||||_
dS(Niiiis"range() requires 1-3 int argumentssan integer is requiredsrange() arg 3 must not be zero(tlent	TypeErrortintt
ValueErrortmintmaxt_startt_stopt_steptboolt_len(tselftargststarttstoptstep((s9/usr/lib/python2.7/site-packages/future/types/newrange.pyt__init__*s(*
			cC@s|jS(N(R
(R((s9/usr/lib/python2.7/site-packages/future/types/newrange.pyREscC@s|jS(N(R(R((s9/usr/lib/python2.7/site-packages/future/types/newrange.pyRIscC@s|jS(N(R(R((s9/usr/lib/python2.7/site-packages/future/types/newrange.pyRMscC@s=|jdkr#d|j|jfSd|j|j|jfS(Nis
range(%d, %d)srange(%d, %d, %d)(RR
R(R((s9/usr/lib/python2.7/site-packages/future/types/newrange.pyt__repr__QscC@s_t|to^|jdko,|jknp^|j|j|jf|j|j|jfkS(Ni(t
isinstanceRRR
R(Rtother((s9/usr/lib/python2.7/site-packages/future/types/newrange.pyt__eq__Vs"cC@s|jS(N(R(R((s9/usr/lib/python2.7/site-packages/future/types/newrange.pyt__len__\scC@sy||j}Wn!tk
r4td|nXt||j\}}|dkrd|kos|jknrt|Std|dS(s]Return the 0-based position of integer `value` in
        the sequence this range represents.s%r is not in rangeiN(R
RR
tdivmodRRtabs(Rtvaluetdifftquotientt	remainder((s9/usr/lib/python2.7/site-packages/future/types/newrange.pytindex_s
+
cC@st||kS(saReturn the number of ocurrences of integer `value`
        in the sequence this range represents.(R	(RR((s9/usr/lib/python2.7/site-packages/future/types/newrange.pyRkscC@s.y|j|tSWntk
r)tSXdS(s\Return ``True`` if the integer `value` occurs in
        the sequence this range represents.N(R#tTrueR
tFalse(RR((s9/usr/lib/python2.7/site-packages/future/types/newrange.pyt__contains__qs


cC@st|dddS(Ni(titer(R((s9/usr/lib/python2.7/site-packages/future/types/newrange.pyt__reversed__zscC@stt|tr|j|S|dkr8|j|}n|dksS||jkrbtdn|j||jS(sReturn the element at position ``index`` in the sequence
        this range represents, or raise :class:`IndexError` if the
        position is out of range.isrange object index out of range(Rtslicet_newrange__getitem_sliceRt
IndexErrorR
R(RR#((s9/usr/lib/python2.7/site-packages/future/types/newrange.pyt__getitem__}s
c@sOfd|jjD}|\}}}tj|j||S(snReturn a range which represents the requested slce
        of the sequence represented by this range.
        c3@s|]}j|VqdS(N(R(t.0tn(R(s9/usr/lib/python2.7/site-packages/future/types/newrange.pys	<genexpr>s(tindicesRRR
(Rtslcetscaled_indiceststart_offsettstop_offsettnew_step((Rs9/usr/lib/python2.7/site-packages/future/types/newrange.pyt__getitem_slices
"

cC@s
t|S(s_Return an iterator which enumerates the elements of the
        sequence this range represents.(trange_iterator(R((s9/usr/lib/python2.7/site-packages/future/types/newrange.pyt__iter__s(t__name__t
__module__t__doc__RtpropertyRRRRRRR#RR&R(R,R*R7(((s9/usr/lib/python2.7/site-packages/future/types/newrange.pyR#s										
	
R6cB@s2eZdZdZdZdZdZRS(s&An iterator for a :class:`range`.
    cC@s+tt|j|jt||_dS(N(RRRRRt_stepper(Rtrange_((s9/usr/lib/python2.7/site-packages/future/types/newrange.pyRscC@s|S(N((R((s9/usr/lib/python2.7/site-packages/future/types/newrange.pyR7scC@s
t|jS(N(tnextR<(R((s9/usr/lib/python2.7/site-packages/future/types/newrange.pyt__next__scC@s
t|jS(N(R>R<(R((s9/usr/lib/python2.7/site-packages/future/types/newrange.pyR>s(R8R9R:RR7R?R>(((s9/usr/lib/python2.7/site-packages/future/types/newrange.pyR6s
			N(R:t
__future__Rtfuture.utilsRtcollectionsRRtcollections.abct	itertoolsRtfuture.backports.miscRt_countRR6t__all__(((s9/usr/lib/python2.7/site-packages/future/types/newrange.pyt<module>sw