aboutsummaryrefslogtreecommitdiff
path: root/scripts/insert_declare.py
blob: 15e0f58ed9cfb2940813574c6ba6954725d44519 (plain)
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
#!/usr/bin/python

import string 
import os,sys
import re
import StringIO

library = os.getcwd().split('/')[-1]

print "current library: " + library + "\n"

for root, dirs, files in os.walk('.'):
    try:
        dirs.remove('.svn')
    except:
        pass
#    print "root: " + root
    for name in files:
        m = re.search(".*\.pd$", name)
        if m:
            helppatch = os.path.join(root, m.string)
            fd = open(helppatch, 'r')
            contents = fd.readlines()
            fd.close()
            firstline = contents[0]
            contents.remove(firstline)
#            fd = open(helppatch + ".new", 'w')
            print helppatch
            fd = open(helppatch, 'w')
            fd.write(firstline)
#            fd.write("#X declare -lib " + library.lower() + ";\n")
            fd.write("#X declare -path ..;\n")
            fd.writelines(contents)
            fd.close()