Mercurial > repos > guerler > hhblits
comparison lib/python3.8/site-packages/setuptools/py27compat.py @ 0:9e54283cc701 draft
"planemo upload commit d12c32a45bcd441307e632fca6d9af7d60289d44"
author | guerler |
---|---|
date | Mon, 27 Jul 2020 03:47:31 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:9e54283cc701 |
---|---|
1 """ | |
2 Compatibility Support for Python 2.7 and earlier | |
3 """ | |
4 | |
5 import sys | |
6 import platform | |
7 | |
8 from setuptools.extern import six | |
9 | |
10 | |
11 def get_all_headers(message, key): | |
12 """ | |
13 Given an HTTPMessage, return all headers matching a given key. | |
14 """ | |
15 return message.get_all(key) | |
16 | |
17 | |
18 if six.PY2: | |
19 def get_all_headers(message, key): # noqa | |
20 return message.getheaders(key) | |
21 | |
22 | |
23 linux_py2_ascii = ( | |
24 platform.system() == 'Linux' and | |
25 six.PY2 | |
26 ) | |
27 | |
28 rmtree_safe = str if linux_py2_ascii else lambda x: x | |
29 """Workaround for http://bugs.python.org/issue24672""" | |
30 | |
31 | |
32 try: | |
33 from ._imp import find_module, PY_COMPILED, PY_FROZEN, PY_SOURCE | |
34 from ._imp import get_frozen_object, get_module | |
35 except ImportError: | |
36 import imp | |
37 from imp import PY_COMPILED, PY_FROZEN, PY_SOURCE # noqa | |
38 | |
39 def find_module(module, paths=None): | |
40 """Just like 'imp.find_module()', but with package support""" | |
41 parts = module.split('.') | |
42 while parts: | |
43 part = parts.pop(0) | |
44 f, path, (suffix, mode, kind) = info = imp.find_module(part, paths) | |
45 | |
46 if kind == imp.PKG_DIRECTORY: | |
47 parts = parts or ['__init__'] | |
48 paths = [path] | |
49 | |
50 elif parts: | |
51 raise ImportError("Can't find %r in %s" % (parts, module)) | |
52 | |
53 return info | |
54 | |
55 def get_frozen_object(module, paths): | |
56 return imp.get_frozen_object(module) | |
57 | |
58 def get_module(module, paths, info): | |
59 imp.load_module(module, *info) | |
60 return sys.modules[module] |