| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- # -*- coding: utf-8 -*-
- """
- -------------------------------------------------
- File Name: six
- Description :
- Author : JHao
- date: 2020/6/22
- -------------------------------------------------
- Change Activity:
- 2020/6/22:
- -------------------------------------------------
- """
- __author__ = 'JHao'
- import sys
- PY2 = sys.version_info[0] == 2
- PY3 = sys.version_info[0] == 3
- if PY3:
- def iteritems(d, **kw):
- return iter(d.items(**kw))
- else:
- def iteritems(d, **kw):
- return d.iteritems(**kw)
- if PY3:
- from urllib.parse import urlparse
- else:
- from urlparse import urlparse
- if PY3:
- from imp import reload as reload_six
- else:
- reload_six = reload
- if PY3:
- from queue import Empty, Queue
- else:
- from Queue import Empty, Queue
- def withMetaclass(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(meta):
- def __new__(cls, name, this_bases, d):
- return meta(name, bases, d)
- return type.__new__(MetaClass, 'temporary_class', (), {})
|