Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

_compat.py 860B

123456789101112131415161718192021222324252627282930
  1. # This file is dual licensed under the terms of the Apache License, Version
  2. # 2.0, and the BSD License. See the LICENSE file in the root of this repository
  3. # for complete details.
  4. from __future__ import absolute_import, division, print_function
  5. import sys
  6. PY2 = sys.version_info[0] == 2
  7. PY3 = sys.version_info[0] == 3
  8. # flake8: noqa
  9. if PY3:
  10. string_types = str,
  11. else:
  12. string_types = basestring,
  13. def with_metaclass(meta, *bases):
  14. """
  15. Create a base class with a metaclass.
  16. """
  17. # This requires a bit of explanation: the basic idea is to make a dummy
  18. # metaclass for one level of class instantiation that replaces itself with
  19. # the actual metaclass.
  20. class metaclass(meta):
  21. def __new__(cls, name, this_bases, d):
  22. return meta(name, bases, d)
  23. return type.__new__(metaclass, 'temporary_class', (), {})