ó
âdc           @   st  d  Z  d d l m Z e j rû d d l m Z d d l m Z m Z m	 Z	 d d l
 m Z m Z d d l
 Z
 e
 j Z e Z d d l m Z d d l m Z d d	 l m Z d d
 l m Z e ƒ  Z e d „ Z d d d d d d d d d d d g Z nu d d l  Z  e  j Z e  j Z e  j	 Z	 e  j Z e  j Z e  j Z e  j Z e  j Z e  j Z e  j Z e  j Z g  Z d S(   s.  
A module that brings in equivalents of various modified Python 3 builtins
into Py2. Has no effect on Py3.

The builtin functions are:

- ``ascii`` (from Py2's future_builtins module)
- ``hex`` (from Py2's future_builtins module)
- ``oct`` (from Py2's future_builtins module)
- ``chr`` (equivalent to ``unichr`` on Py2)
- ``input`` (equivalent to ``raw_input`` on Py2)
- ``next`` (calls ``__next__`` if it exists, else ``next`` method)
- ``open`` (equivalent to io.open on Py2)
- ``super`` (backport of Py3's magic zero-argument super() function
- ``round`` (new "Banker's Rounding" behaviour from Py3)

``isinstance`` is also currently exported for backwards compatibility
with v0.8.2, although this has been deprecated since v0.9.


input()
-------
Like the new ``input()`` function from Python 3 (without eval()), except
that it returns bytes. Equivalent to Python 2's ``raw_input()``.

Warning: By default, importing this module *removes* the old Python 2
input() function entirely from ``__builtin__`` for safety. This is
because forgetting to import the new ``input`` from ``future`` might
otherwise lead to a security vulnerability (shell injection) on Python 2.

To restore it, you can retrieve it yourself from
``__builtin__._old_input``.

Fortunately, ``input()`` seems to be seldom used in the wild in Python
2...

iÿÿÿÿ(   t   utils(   t   open(   t   asciit   octt   hex(   t   unichrt   powN(   t   newnext(   t   newround(   t   newsuper(   t   newintc         C   sÐ   t  |  t ƒ r t |  ƒ }  n  t  | t ƒ r< t | ƒ } n  t  | t ƒ rZ t | ƒ } n  y- | t k rv t |  | ƒ St |  | | ƒ SWnB t k
 rË | t k r´ t |  d | ƒ St |  d | | ƒ Sn Xd S(   s¿   
        pow(x, y[, z]) -> number

        With two arguments, equivalent to x**y.  With three arguments,
        equivalent to (x**y) % z, but may be more efficient (e.g. for ints).
        y                N(   t
   isinstanceR
   t   longt	   _SENTINELt   _builtin_powt
   ValueError(   t   xt   yt   z(    (    sb   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/_lib/future/future/builtins/misc.pyR   B   s    R   t   chrR   t   inputR   t   nextR   R   R   t   roundt   super(!   t   __doc__t   futureR    t   PY2t   ioR   t   future_builtinsR   R   R   t   __builtin__R   R   R   R   R   t	   raw_inputR   t   future.builtins.newnextR   R   t   future.builtins.newroundR   R   t   future.builtins.newsuperR	   R   t   future.types.newintR
   t   objectR   t   __all__t   builtins(    (    (    sb   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/_lib/future/future/builtins/misc.pyt   <module>%   s:   														                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   '''
This module provides a newnext() function in Python 2 that mimics the
behaviour of ``next()`` in Python 3, falling back to Python 2's behaviour for
compatibility if this fails.

``newnext(iterator)`` calls the iterator's ``__next__()`` method if it exists. If this
doesn't exist, it falls back to calling a ``next()`` method.

For example:

    >>> class Odds(object):
    ...     def __init__(self, start=1):
    ...         self.value = start - 2
    ...     def __next__(self):                 # note the Py3 interface
    ...         self.value += 2
    ...         return self.value
    ...     def __iter__(self):
    ...         return self
    ...
    >>> iterator = Odds()
    >>> next(iterator)
    1
    >>> next(iterator)
    3

If you are defining your own custom iterator class as above, it is preferable
to explicitly decorate the class with the @implements_iterator decorator from
``future.utils`` as follows:

    >>> @implements_iterator
    ... class Odds(object):
    ...     # etc
    ...     pass

This next() function is primarily for consuming iterators defined in Python 3
code elsewhere that we would like to run on Python 2 or 3.
'''

_builtin_next = next

_SENTINEL = object()

def newnext(iterator, default=_SENTINEL):
    """
    next(iterator[, default])
    
    Return the next item from the iterator. If default is given and the iterator
    is exhausted, it is returned instead of raising StopIteration.
    """

    # args = []
    # if default is not _SENTINEL:
    #     args.append(default)
    try:
        try:
            return iterator.__next__()
        except AttributeError:
            try:
                return iterator.next()
            except AttributeError:
                raise TypeError("'{0}' object is not an iterator".format(
                                           iterator.__class__.__name__))
    except StopIteration as e:
        if default is _SENTINEL:
            raise e
        else:
            return default


__all__ = ['newnext']

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           