_compat.py 558 B

123456789101112131415161718192021222324252627282930313233
  1. # -*- coding: utf-8 -*-
  2. """
  3. markupsafe._compat
  4. ~~~~~~~~~~~~~~~~~~
  5. :copyright: 2010 Pallets
  6. :license: BSD-3-Clause
  7. """
  8. import sys
  9. PY2 = sys.version_info[0] == 2
  10. if not PY2:
  11. text_type = str
  12. string_types = (str,)
  13. unichr = chr
  14. int_types = (int,)
  15. def iteritems(x):
  16. return iter(x.items())
  17. from collections.abc import Mapping
  18. else:
  19. text_type = unicode
  20. string_types = (str, unicode)
  21. unichr = unichr
  22. int_types = (int, long)
  23. def iteritems(x):
  24. return x.iteritems()
  25. from collections import Mapping