forked from hse-tex/hse-tex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget-build-dependencies.py
executable file
·55 lines (38 loc) · 1.29 KB
/
get-build-dependencies.py
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
#!/bin/python3
import sys
import argparse
from pathlib import Path
def err(*args):
print(*args, file=sys.stderr)
def main(args):
source = Path(args.source)
if not source.is_file():
err("Not a file:", source)
exit(-1)
result = []
current = Path('.')
for part in source.parts:
if current == source.parent:
if args.directory:
for file in current.glob('**/*'):
result.append(file)
if args.single:
for file in current.glob('*header*'):
result.append(file)
break
for header in current.glob('*.tex'):
result.append(header)
for header in current.glob('*.sty'):
result.append(header)
current /= part
if args.single:
result.append(source)
print('\n'.join([p.as_posix() for p in result]))
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Get .tex build dependencies')
mode = parser.add_mutually_exclusive_group(required=True)
mode.add_argument('--single', '-s', action='store_true', default=False)
mode.add_argument('--directory', '-d', action='store_true', default=False)
parser.add_argument('source')
args = parser.parse_args()
main(args)