iutest_incg_test.main()   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 9
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 9
nop 0
dl 0
loc 9
rs 9.95
c 0
b 0
f 0
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
#
4
# iutest_incg_test.py
5
#
6
# Copyright (C) 2016, Takazumi Shirayanagi
7
# This software is released under the new BSD License,
8
# see LICENSE
9
#
10
11
import os
12
import sys
13
import re
14
import codecs
15
16
17
def main():
18
    filepath = sys.argv[1]
19
    incg = os.path.basename(filepath).upper().replace('.', '_')
20
    f = codecs.open(filepath, 'r', 'utf-8-sig')
21
    text = f.read()
22
    f.close()
23
    r = '\s*#\s*ifndef[/\s]*INCG_IRIS_{0}\S*\s*'.format(incg)
24
    if not re.search(r, text):
25
        exit(1)
26
27
28
if __name__ == '__main__':
29
    main()
30