blob: a58cc89081f60ddb062ba1882d4a62ce4af3d457 (
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
42
43
44
45
|
#!/usr/bin/env python3
from sphinx.ext.intersphinx import fetch_inventory
URL = "https://docs.python.org/{}/objects.inv"
PATH = "isort/stdlibs/py{}.py"
VERSIONS = [("2", "7"), ("3",)]
DOCSTRING = """
File contains the standard library of Python {}.
DO NOT EDIT. If the standard library changes, a new list should be created
using the mkstdlibs.py script.
"""
class FakeConfig:
intersphinx_timeout = None
tls_verify = True
class FakeApp:
srcdir = ""
config = FakeConfig()
for version_info in VERSIONS:
version = ".".join(version_info)
url = URL.format(version)
invdata = fetch_inventory(FakeApp(), "", url)
modules = set()
for module in invdata["py:module"]:
root, *_ = module.split(".")
if root not in ["__future__", "__main__"]:
modules.add(root)
path = PATH.format("".join(version_info))
with open(path, "w") as fp:
docstring = DOCSTRING.format(version)
fp.write('"""{}"""\n\n'.format(docstring))
fp.write("stdlib = [\n")
for module in sorted(modules):
fp.write(' "{}",\n'.format(module))
fp.write("]\n")
|