summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordherrada <33632497+dherrada@users.noreply.github.com>2020-04-29 13:30:40 -0400
committerGitHub <noreply@github.com>2020-04-29 13:30:40 -0400
commit8cdc67a157195fee66095d53311baa6f11adf3ca (patch)
tree361edfda732995829ec51f0cd10affe4223b454a
parentc7b721f4f19b561006d9d2e1c46d79d9f22bf4b0 (diff)
parent8c77252adf4b78a2a4fe5d138e470fb70ae7233b (diff)
Merge pull request #2 from tannewt/improve_verification
Better handle //| and do __init__.c first.
-rw-r--r--tools/extract_pyi.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/tools/extract_pyi.py b/tools/extract_pyi.py
index c7f3e4604..de783eb27 100644
--- a/tools/extract_pyi.py
+++ b/tools/extract_pyi.py
@@ -20,12 +20,22 @@ for module in modules:
if not os.path.isdir(module_path):
continue
pyi_lines = []
- for class_file in os.listdir(module_path):
+ classes = os.listdir(module_path)
+ classes = [x for x in sorted(classes) if x.endswith(".c")]
+ if classes[-1] == "__init__.c":
+ classes.insert(0, classes.pop())
+ for class_file in classes:
class_path = os.path.join(module_path, class_file)
with open(class_path, "r") as f:
for line in f:
- if line.startswith("//| "):
- pyi_lines.append(line[4:])
+ if line.startswith("//|"):
+ if line[3] == " ":
+ line = line[4:]
+ elif line[3] == "\n":
+ line = line[3:]
+ else:
+ continue
+ pyi_lines.append(line)
stub_filename = os.path.join(stub_directory, module + ".pyi")
print(stub_filename)