import sys

PY2 = sys.version_info[0] == 2

if PY2:
    unichr = unichr
    text_type = unicode
    string_types = (str, unicode)
    integer_types = (int, long)
    from urllib import urlretrieve

    from cStringIO import StringIO as BytesIO
    from StringIO import StringIO
    import cPickle as pickle

    import urlparse

    def console_to_str(s):
        return s.decode('utf_8')

    exec('def reraise(tp, value, tb=None):\n raise tp, value, tb')

else:
    unichr = chr
    text_type = str
    string_types = (str,)
    integer_types = (int,)

    from io import StringIO, BytesIO

    import urllib.parse as urllib
    import urllib.parse as urlparse
    from urllib.request import urlretrieve

    console_encoding = sys.__stdout__.encoding

    def console_to_str(s):
        """ From pypa/pip project, pip.backwardwardcompat. License MIT. """
        try:
            return s.decode(console_encoding)
        except UnicodeDecodeError:
            return s.decode('utf_8')

    def reraise(tp, value, tb=None):
        if value.__traceback__ is not tb:
            raise (value.with_traceback(tb))
        raise value


def with_metaclass(meta, *bases):
    """Create a base class with a metaclass."""
    # 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.
    class metaclass(type):
        def __new__(cls, name, this_bases, d):
            return meta(name, bases, d)
    return type.__new__(metaclass, 'temporary_class', (), {})

import sys

PY2 = sys.version_info[0] == 2

if PY2:
    unichr = unichr
    text_type = unicode
    string_types = (str, unicode)
    integer_types = (int, long)
    from urllib import urlretrieve

    from cStringIO import StringIO as BytesIO
    from StringIO import StringIO
    import cPickle as pickle

    import urlparse

    def console_to_str(s):
        return s.decode('utf_8')

    exec('def reraise(tp, value, tb=None):\n raise tp, value, tb')

else:
    unichr = chr
    text_type = str
    string_types = (str,)
    integer_types = (int,)

    from io import StringIO, BytesIO

    import urllib.parse as urllib
    import urllib.parse as urlparse
    from urllib.request import urlretrieve

    console_encoding = sys.__stdout__.encoding

    def console_to_str(s):
        """ From pypa/pip project, pip.backwardwardcompat. License MIT. """
        try:
            return s.decode(console_encoding)
        except UnicodeDecodeError:
            return s.decode('utf_8')

    def reraise(tp, value, tb=None):
        if value.__traceback__ is not tb:
            raise (value.with_traceback(tb))
        raise value

Revert "Port with_metaclass from flask"
Revert "Port with_metaclass from flask"

This reverts commit db23ed0d62789ca995d2dceefd0a1468348c488b.

  import sys
  
  PY2 = sys.version_info[0] == 2
  
  if PY2:
      unichr = unichr
      text_type = unicode
      string_types = (str, unicode)
      integer_types = (int, long)
      from urllib import urlretrieve
  
      from cStringIO import StringIO as BytesIO
      from StringIO import StringIO
      import cPickle as pickle
  
      import urlparse
  
      def console_to_str(s):
          return s.decode('utf_8')
  
      exec('def reraise(tp, value, tb=None):\n raise tp, value, tb')
  
  else:
      unichr = chr
      text_type = str
      string_types = (str,)
      integer_types = (int,)
  
      from io import StringIO, BytesIO
  
      import urllib.parse as urllib
      import urllib.parse as urlparse
      from urllib.request import urlretrieve
  
      console_encoding = sys.__stdout__.encoding
  
      def console_to_str(s):
          """ From pypa/pip project, pip.backwardwardcompat. License MIT. """
          try:
              return s.decode(console_encoding)
          except UnicodeDecodeError:
              return s.decode('utf_8')
  
      def reraise(tp, value, tb=None):
          if value.__traceback__ is not tb:
              raise (value.with_traceback(tb))
          raise value
  
- 
- def with_metaclass(meta, *bases):
-     """Create a base class with a metaclass."""
-     # 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.
-     class metaclass(type):
-         def __new__(cls, name, this_bases, d):
-             return meta(name, bases, d)
-     return type.__new__(metaclass, 'temporary_class', (), {})
- 
Revert "Port with_metaclass from flask"
## Code Before:
import sys

PY2 = sys.version_info[0] == 2

if PY2:
    unichr = unichr
    text_type = unicode
    string_types = (str, unicode)
    integer_types = (int, long)
    from urllib import urlretrieve

    from cStringIO import StringIO as BytesIO
    from StringIO import StringIO
    import cPickle as pickle

    import urlparse

    def console_to_str(s):
        return s.decode('utf_8')

    exec('def reraise(tp, value, tb=None):\n raise tp, value, tb')

else:
    unichr = chr
    text_type = str
    string_types = (str,)
    integer_types = (int,)

    from io import StringIO, BytesIO

    import urllib.parse as urllib
    import urllib.parse as urlparse
    from urllib.request import urlretrieve

    console_encoding = sys.__stdout__.encoding

    def console_to_str(s):
        """ From pypa/pip project, pip.backwardwardcompat. License MIT. """
        try:
            return s.decode(console_encoding)
        except UnicodeDecodeError:
            return s.decode('utf_8')

    def reraise(tp, value, tb=None):
        if value.__traceback__ is not tb:
            raise (value.with_traceback(tb))
        raise value


def with_metaclass(meta, *bases):
    """Create a base class with a metaclass."""
    # 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.
    class metaclass(type):
        def __new__(cls, name, this_bases, d):
            return meta(name, bases, d)
    return type.__new__(metaclass, 'temporary_class', (), {})

## Instruction:
Revert "Port with_metaclass from flask"
## Code After:
import sys

PY2 = sys.version_info[0] == 2

if PY2:
    unichr = unichr
    text_type = unicode
    string_types = (str, unicode)
    integer_types = (int, long)
    from urllib import urlretrieve

    from cStringIO import StringIO as BytesIO
    from StringIO import StringIO
    import cPickle as pickle

    import urlparse

    def console_to_str(s):
        return s.decode('utf_8')

    exec('def reraise(tp, value, tb=None):\n raise tp, value, tb')

else:
    unichr = chr
    text_type = str
    string_types = (str,)
    integer_types = (int,)

    from io import StringIO, BytesIO

    import urllib.parse as urllib
    import urllib.parse as urlparse
    from urllib.request import urlretrieve

    console_encoding = sys.__stdout__.encoding

    def console_to_str(s):
        """ From pypa/pip project, pip.backwardwardcompat. License MIT. """
        try:
            return s.decode(console_encoding)
        except UnicodeDecodeError:
            return s.decode('utf_8')

    def reraise(tp, value, tb=None):
        if value.__traceback__ is not tb:
            raise (value.with_traceback(tb))
        raise value
