File: ata_struct_2_h_dump.py

package info (click to toggle)
diskscan 0.21-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,656 kB
  • sloc: ansic: 11,136; python: 338; xml: 138; sh: 41; makefile: 34
file content (28 lines) | stat: -rwxr-xr-x 527 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/env python

import sys
import yaml

def emit_header(structs):
	for name, struct in list(structs.items()):
		print('void dump_%s(const unsigned char *buf);' % name)

def emit_prefix():
	print('#ifndef _DUMP_H_')
	print('#define _DUMP_H_')

def emit_suffix():
	print('#endif')

def convert_def(filename):
	f = file(filename)
	structs = yaml.load(f)
	f.close()
	emit_header(structs)

if __name__ == '__main__':
	emit_prefix()
	filenames = sys.argv[1:]
	for filename in filenames:
		convert_def(filename)
	emit_suffix()