summaryrefslogtreecommitdiffstats
path: root/third_party/python/pathspec/pathspec/compat.py
blob: f5d17bf3ced789593b955546eb12cd27f15cd31f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# encoding: utf-8
"""
This module provides compatibility between Python 2 and 3. Hardly
anything is used by this project to constitute including `six`_.

.. _`six`: http://pythonhosted.org/six
"""

import sys

if sys.version_info[0] < 3:
	# Python 2.
	unicode = unicode
	string_types = (basestring,)

	from collections import Iterable
	from itertools import izip_longest

	def iterkeys(mapping):
		return mapping.iterkeys()

else:
	# Python 3.
	unicode = str
	string_types = (unicode,)

	from collections.abc import Iterable
	from itertools import zip_longest as izip_longest

	def iterkeys(mapping):
		return mapping.keys()

try:
	# Python 3.6+.
	from collections.abc import Collection
except ImportError:
	# Python 2.7 - 3.5.
	from collections import Container as Collection

CollectionType = Collection
IterableType = Iterable