Line | |
---|
1 | #!/usr/bin/env python3
|
---|
2 | import datetime
|
---|
3 | import json
|
---|
4 | import os
|
---|
5 | import socket
|
---|
6 | import sys
|
---|
7 |
|
---|
8 | comment = 'Autogenerated by %s@%s at %s' % (os.environ.get('USER'), socket.gethostname(), datetime.datetime.today().isoformat())
|
---|
9 |
|
---|
10 | points_seens = []
|
---|
11 | points = []
|
---|
12 | links = []
|
---|
13 |
|
---|
14 | # Include auto-generated data
|
---|
15 | data = json.load(open(sys.argv[1], 'r'))
|
---|
16 | for point in data['points']:
|
---|
17 | if not point['name'] in points_seens:
|
---|
18 | points_seens.append(point['name'])
|
---|
19 | point['comment'] = comment
|
---|
20 | points.append(point)
|
---|
21 | for link in data['links']:
|
---|
22 | link['comment'] = comment
|
---|
23 | links.append(link)
|
---|
24 |
|
---|
25 |
|
---|
26 | # Filter out manual modifications
|
---|
27 | data = json.load(open(sys.argv[2], 'r'))
|
---|
28 | for point in data['points']:
|
---|
29 | if not point['name'] in points_seens:
|
---|
30 | if point['state'] in ['planned', 'wish']:
|
---|
31 | points.append(point)
|
---|
32 |
|
---|
33 | for link in data['links']:
|
---|
34 | if link['state'] in ['planned', 'wish']:
|
---|
35 | links.append(link)
|
---|
36 |
|
---|
37 |
|
---|
38 |
|
---|
39 | print(json.dumps({'points': points, 'links': links}, indent=2, sort_keys=True))
|
---|
Note:
See
TracBrowser
for help on using the repository browser.