anki/python/stubs/gatherstubs.py

33 lines
921 B
Python
Raw Normal View History

# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import os
import subprocess
import sys
import re
import shutil
stubs_remap = {"protobuf": "google", "futures": "concurrent"}
def copy_folder(pkgname, path, outbase):
stubname = stubs_remap.get(pkgname, pkgname)
os.listdir(path)
path = f"{path}/{stubname}-stubs"
shutil.copytree(path, os.path.join(outbase, f"{stubname}-stubs"))
2022-01-15 07:09:50 +01:00
name_re = re.compile("deps_types_(.+?)$")
if __name__ == "__main__":
outbase = os.path.abspath(sys.argv[1])
# copy stubs into top level folder, renaming
folder = os.path.join(os.path.dirname(__file__), "../../external")
os.chdir(folder)
for folder in os.listdir("."):
2021-10-02 15:13:24 +02:00
if "futures" in folder:
continue
if match := name_re.search(folder):
copy_folder(match.group(1), folder, outbase)