add python manifest generation
This commit is contained in:
34
manifest_src/gen_manifest_json.py
Normal file
34
manifest_src/gen_manifest_json.py
Normal file
@@ -0,0 +1,34 @@
|
||||
import sys
|
||||
import csv
|
||||
import json
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 2:
|
||||
print('provide manifest data directory')
|
||||
return
|
||||
manifest_dir = sys.argv[1]
|
||||
|
||||
mem_segments = []
|
||||
out_manifest = {
|
||||
'mem_segments': mem_segments
|
||||
}
|
||||
|
||||
with open(manifest_dir + '/seg_data.csv', 'r', newline='') as csvfile:
|
||||
reader = csv.DictReader(csvfile, delimiter=';')
|
||||
for line in reader:
|
||||
mem_segments.append(
|
||||
{
|
||||
'seg_id': int(line['seg_id']),
|
||||
'name': line['name'],
|
||||
'word_len': int(line['word_len']),
|
||||
'default_size': int(line['default_size']),
|
||||
'default_addr': int(line['default_addr']),
|
||||
'is_executable': line['is_executable'] == '1'
|
||||
}
|
||||
)
|
||||
|
||||
with open(manifest_dir + '/MANIFEST.json', 'w') as f:
|
||||
json.dump(out_manifest, f, indent=4)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user