1- from __future__ import absolute_import , unicode_literals
2-
3- import io
4- import abc
51import sys
6- import email
7-
8-
9- if sys .version_info > (3 ,): # pragma: nocover
10- import builtins
11- from configparser import ConfigParser
12- import contextlib
13- FileNotFoundError = builtins .FileNotFoundError
14- IsADirectoryError = builtins .IsADirectoryError
15- NotADirectoryError = builtins .NotADirectoryError
16- PermissionError = builtins .PermissionError
17- map = builtins .map
18- from itertools import filterfalse
19- else : # pragma: nocover
20- from backports .configparser import ConfigParser
21- from itertools import imap as map # type: ignore
22- from itertools import ifilterfalse as filterfalse
23- import contextlib2 as contextlib
24- FileNotFoundError = IOError , OSError
25- IsADirectoryError = IOError , OSError
26- NotADirectoryError = IOError , OSError
27- PermissionError = IOError , OSError
28-
29- str = type ('' )
30-
31- suppress = contextlib .suppress
32-
33- if sys .version_info > (3 , 5 ): # pragma: nocover
34- import pathlib
35- else : # pragma: nocover
36- import pathlib2 as pathlib
37-
38- try :
39- ModuleNotFoundError = builtins .FileNotFoundError
40- except (NameError , AttributeError ): # pragma: nocover
41- ModuleNotFoundError = ImportError # type: ignore
42-
43-
44- if sys .version_info >= (3 ,): # pragma: nocover
45- from importlib .abc import MetaPathFinder
46- else : # pragma: nocover
47- class MetaPathFinder (object ):
48- __metaclass__ = abc .ABCMeta
492
503
51- __metaclass__ = type
52- __all__ = [
53- 'install' , 'NullFinder' , 'MetaPathFinder' , 'ModuleNotFoundError' ,
54- 'pathlib' , 'ConfigParser' , 'map' , 'suppress' , 'FileNotFoundError' ,
55- 'NotADirectoryError' , 'email_message_from_string' ,
56- ]
4+ __all__ = ['install' , 'NullFinder' , 'PyPy_repr' ]
575
586
597def install (cls ):
@@ -104,20 +52,6 @@ def find_spec(*args, **kwargs):
10452 find_module = find_spec
10553
10654
107- def py2_message_from_string (text ): # nocoverpy3
108- # Work around https://bugs.python.org/issue25545 where
109- # email.message_from_string cannot handle Unicode on Python 2.
110- io_buffer = io .StringIO (text )
111- return email .message_from_file (io_buffer )
112-
113-
114- email_message_from_string = (
115- py2_message_from_string
116- if sys .version_info < (3 ,) else
117- email .message_from_string
118- )
119-
120-
12155class PyPy_repr :
12256 """
12357 Override repr for EntryPoint objects on PyPy to avoid __iter__ access.
@@ -135,18 +69,3 @@ def make_param(name):
13569 if affected : # pragma: nocover
13670 __repr__ = __compat_repr__
13771 del affected
138-
139-
140- # from itertools recipes
141- def unique_everseen (iterable ): # pragma: nocover
142- "List unique elements, preserving order. Remember all elements ever seen."
143- seen = set ()
144- seen_add = seen .add
145-
146- for element in filterfalse (seen .__contains__ , iterable ):
147- seen_add (element )
148- yield element
149-
150-
151- unique_ordered = (
152- unique_everseen if sys .version_info < (3 , 7 ) else dict .fromkeys )
0 commit comments