File tree 1 file changed +13
-7
lines changed
1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env python3
2
2
3
3
import sys
4
+ import re
4
5
5
6
FILE_HEADER = '''#pragma once
6
7
//This File is autogenerated an may be overridden, do not change
7
8
//If you need to change the content of the file please change the file
8
9
//sources/message_hdr.py'''
9
10
10
-
11
11
prefix = sys .argv [1 ] + '/'
12
- with open (sys .argv [2 ], 'w' ) as output :
13
- output .write (f"{ FILE_HEADER } \n " )
14
- for i in range (3 , len (sys .argv )):
15
- for include in sys .argv [i ].split (';' ):
16
- include = include .removeprefix (prefix )
17
- output .write (f"#include <{ include } >\n " )
12
+
13
+ def remove_prefix (text , prefix ):
14
+ return re .sub (r'^{0}' .format (re .escape (prefix )), '' , text )
15
+
16
+
17
+ if __name__ == "__main__" :
18
+ with open (sys .argv [2 ], 'w' ) as output :
19
+ output .write (f"{ FILE_HEADER } \n " )
20
+ for i in range (3 , len (sys .argv )):
21
+ for include in sys .argv [i ].split (';' ):
22
+ include = remove_prefix (include , prefix )
23
+ output .write (f"#include <{ include } >\n " )
You can’t perform that action at this time.
0 commit comments