File: fixHeaderIncludes.py

package info (click to toggle)
massxpert 7.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 71,188 kB
  • sloc: cpp: 47,431; xml: 23,090; javascript: 22,231; python: 501; sh: 272; makefile: 88
file content (39 lines) | stat: -rwxr-xr-x 832 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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/python3

import glob,os

sedCommandList = []

for root, dirs, files in os.walk(os.getcwd()):
  for file in files:
    if file.endswith(".hpp"):
      #print(os.path.join(root, file))
      #print(file)
      dirName = root.replace('/home/rusconi/devel/msxpertsuite/development/', '')

      sedCommand = []
      sedCommand.append('''sed -i 's|include "''')
      sedCommand.append(file)
      sedCommand.append('''"|include <''')
      sedCommand.append(dirName)
      sedCommand.append( '''/''')
      sedCommand.append(file)
      sedCommand.append('''>|\' ${file}''');

      #print(''.join(sedCommand))

      sedCommandList.append(sedCommand)

prefix = '''for file in $(find -name "*.[ch]pp"); do '''
suffix = '''; done'''

for commandList in sedCommandList:
  print(prefix + ''.join(commandList) + suffix)