-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathmake.py
More file actions
78 lines (61 loc) · 2.24 KB
/
make.py
File metadata and controls
78 lines (61 loc) · 2.24 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import glob
import os
import shutil
import subprocess
import tempfile
import PIL.Image
def make():
with tempfile.TemporaryDirectory() as output:
subprocess.run(f'mkdocs build -d {output}', shell=True)
shutil.copytree(f'{output}', 'site', dirs_exist_ok=True)
with open('site/baidu_verify_codeva-bkxO1ABXUL.html', 'w') as f:
f.write('9530b96b26004efa430cc08502bdb442')
with open('site/03890937a90586962ffe04ea5adaa43c.txt', 'w') as f: # 360
f.write('03890937a90586962ffe04ea5adaa43c')
with open('site/google9b75b4b4147e247b.html', 'w') as f:
f.write('google-site-verification: google9b75b4b4147e247b.html')
with open('site/ads.txt', 'w') as f:
f.write('google.com, pub-5236818090688638, DIRECT, f08c47fec0942fa0')
def exam_imgs_unused():
imgs = glob.glob('docs/img/**/*.*', recursive=True)
docs = glob.glob('docs/content/**/*.md', recursive=True)
docs.append('docs/index.md')
imgs_dict = dict.fromkeys(imgs, 0)
for e in docs:
with open(e) as f:
for line in f:
line = line.strip()
if line.startswith('![img]'):
p = line[7:-1]
p = os.path.normpath(os.path.join(os.path.dirname(e), p))
assert p in imgs_dict, f'missed {e} {p}'
imgs_dict[p] += 1
for k, v in imgs_dict.items():
assert v != 0, f'unused {k}'
def exam_imgs_format():
imgs = glob.glob('docs/img/**/*.*', recursive=True)
for e in imgs:
i = PIL.Image.open(e)
assert i.format in ['JPEG', 'GIF'], f'format {e} {i.format}'
i.close()
def exam_imgs_size():
imgs = glob.glob('docs/img/**/*.*', recursive=True)
for e in imgs:
i = PIL.Image.open(e)
assert i.size[0] == 480 and i.size[1] % 2 == 0, f'imsize {e} {i.size[0]}x{i.size[1]}'
i.close()
def exam_link(name: str):
for e in os.scandir(name):
p = os.path.join(name, e.name)
assert not e.is_symlink()
if e.is_dir():
exam_link(p)
def main():
os.chdir(os.path.dirname(os.path.abspath(__file__)))
exam_imgs_unused()
exam_imgs_format()
exam_imgs_size()
make()
exam_link('site')
if __name__ == '__main__':
main()