aboutsummaryrefslogtreecommitdiffstats
path: root/doc/scripts/update_deps.py
blob: 8bada9d7eadccba8b2a62697172c5beb64bc6979 (plain)
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
#!/usr/bin/python

import sys
import re
import os.path

def update_requires(dir, deps):
    lines = map(lambda x: x.strip(),
                open(os.path.join(dir, 'info.txt')).readlines())

    if '<requires>' in lines:
        start = lines.index('<requires>')

        while lines.pop(start) != '</requires>':
            pass

    lines.append('')
    lines.append('<requires>')
    for dep in deps:
        lines.append(dep)
    lines.append('</requires>')
    lines.append('')

    lines = "\n".join(lines).replace("\n\n\n", "\n\n")

    output = open(os.path.join(dir, 'info.txt'), 'w')
    output.write(lines)
    output.close()

def main():
    for line in sys.stdin.readlines():
        (dirname, deps) = line.split(':')
        deps = deps.strip().split(' ')
        update_requires(dirname, deps)

if __name__ == '__main__':
    sys.exit(main())