Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/pathspec/compat.py: 57%

21 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-06-07 06:35 +0000

1# encoding: utf-8 

2""" 

3This module provides compatibility between Python 2 and 3. Hardly 

4anything is used by this project to constitute including `six`_. 

5 

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

7""" 

8 

9import sys 

10 

11if sys.version_info[0] < 3: 

12 # Python 2. 

13 unicode = unicode 

14 string_types = (basestring,) 

15 

16 from collections import Iterable 

17 from itertools import izip_longest 

18 

19 def iterkeys(mapping): 

20 return mapping.iterkeys() 

21 

22else: 

23 # Python 3. 

24 unicode = str 

25 string_types = (unicode,) 

26 

27 from collections.abc import Iterable 

28 from itertools import zip_longest as izip_longest 

29 

30 def iterkeys(mapping): 

31 return mapping.keys() 

32 

33try: 

34 # Python 3.6+. 

35 from collections.abc import Collection 

36except ImportError: 

37 # Python 2.7 - 3.5. 

38 from collections import Container as Collection 

39 

40CollectionType = Collection 

41IterableType = Iterable