File: meson-gen-def.py

package info (click to toggle)
libvirt 11.10.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 211,176 kB
  • sloc: ansic: 537,214; xml: 335,516; python: 12,041; perl: 2,626; sh: 2,185; makefile: 448; javascript: 126; cpp: 22
file content (23 lines) | stat: -rwxr-xr-x 512 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env python3

import re
import sys

if len(sys.argv) != 3:
    print('invalid arguments')
    print('usage: {0} INPUT OUTPUT'.format(sys.argv[0]))
    sys.exit(1)

infilepath = sys.argv[1]
outfilepath = sys.argv[2]

with open(infilepath) as f:
    text = f.read()

text = re.sub(r'^(|.*[#:}*].*|LIBVIRT_.*)\n?', '', text, flags=re.M)
text = re.sub(r'\n$', '', text)
text = re.sub(r'^[ ]*(.*);', r'    \1', text, flags=re.M)

with open(outfilepath, 'w') as f:
    f.write('EXPORTS\n')
    f.write(text)