-
Notifications
You must be signed in to change notification settings - Fork 0
/
7.next-period.py
38 lines (32 loc) · 956 Bytes
/
7.next-period.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
# ----------- IMPORTS ----------- #
import sys
import json
# ----------- FUNCTIONS ----------- #
# Read JSON file
def read_json(filepath):
f = open(filepath, 'r')
json_content = json.load(f)
f.close()
return json_content
# Write JSON file
def write_json(json_content, filepath):
f = open(filepath, 'w')
json.dump(json_content, f, indent = 2)
f.close()
# ----------- MAIN ----------- #
if __name__ == "__main__":
#
# Get configuration
config = read_json(sys.argv[1])
# DEBUG: print(config)
#
# Increment period
config['controller']['temp']['session']['period']['exec'] += 1
# Clear controller.temp.session.period.exec_files list
config['controller']['temp']['session']['period']['exec_files'].clear()
# Clear controller.temp.session.period.power_flow.exec_files list
config['controller']['temp']['session']['period']['power_flow']['exec_files'].clear()
#
#
# rewrite config
write_json(config, sys.argv[1])