pytorch

Форк
0
/
process.py 
62 строки · 2.0 Кб
1
#!/usr/bin/env python3
2
## @package process
3
# Module doxygen.process
4
# Script to insert preamble for doxygen and regen API docs
5

6
import os
7
import shutil
8

9

10
# Module caffe2...caffe2.python.control_test
11
def insert(originalfile, first_line, description):
12
    with open(originalfile) as f:
13
        f1 = f.readline()
14
        if f1.find(first_line) < 0:
15
            docs = first_line + description + f1
16
            with open("newfile.txt", "w") as f2:
17
                f2.write(docs)
18
                f2.write(f.read())
19
            os.rename("newfile.txt", originalfile)
20
        else:
21
            print("already inserted")
22

23

24
# move up from /caffe2_root/doxygen
25
os.chdir("..")
26
os.system("git checkout caffe2/contrib/.")
27
os.system("git checkout caffe2/distributed/.")
28
os.system("git checkout caffe2/experiments/.")
29
os.system("git checkout caffe2/python/.")
30

31
for root, dirs, files in os.walk("."):
32
    for file in files:
33
        if (
34
            file.endswith(".py")
35
            and not file.endswith("_test.py")
36
            and not file.endswith("__.py")
37
        ):
38
            filepath = os.path.join(root, file)
39
            print("filepath: " + filepath)
40
            directory = os.path.dirname(filepath)[2:]
41
            directory = directory.replace("/", ".")
42
            print("directory: " + directory)
43
            name = os.path.splitext(file)[0]
44
            first_line = "## @package " + name
45
            description = "\n# Module " + directory + "." + name + "\n"
46
            print(first_line, description)
47
            insert(filepath, first_line, description)
48

49
if os.path.exists("doxygen/doxygen-python"):
50
    print("Looks like you ran this before, so we need to cleanup those old files...")
51
    shutil.rmtree("doxygen/doxygen-python")
52
else:
53
    os.makedirs("doxygen/doxygen-python")
54

55
if os.path.exists("doxygen/doxygen-c"):
56
    print("Looks like you ran this before, so we need to cleanup those old files...")
57
    shutil.rmtree("doxygen/doxygen-c")
58
else:
59
    os.makedirs("doxygen/doxygen-c")
60

61
os.system("doxygen .Doxyfile-python")
62
os.system("doxygen .Doxyfile-c")
63

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.