]> git.saurik.com Git - wxWidgets.git/blame - wxPython/scripts/CreateMacScripts.py
Swtch to using Bind, and use better styles for the code viewer
[wxWidgets.git] / wxPython / scripts / CreateMacScripts.py
CommitLineData
2eb31f8b 1#----------------------------------------------------------------------
9c6b4824 2# Name: CreateMacScripts.py
1e4a197e 3# Purpose: Massages the scripts to be usable with MachoPython
2eb31f8b
RD
4#
5# Author: Robin Dunn
6#
7# Created: 12-Aug-2002
8# Copyright: (c) 2002 by Total Control Software
9# Licence: wxWindows license
10#----------------------------------------------------------------------
11
12import sys, os
13
14python = sys.executable
15destdir = os.path.split(python)[0]
1e4a197e 16prefix = destdir
2eb31f8b
RD
17pythonw = os.path.join(destdir, 'pythonw')
18scriptdir = os.getcwd()
19
9c6b4824 20if len(sys.argv) > 1:
1e4a197e
RD
21 root = sys.argv[1]
22 p = prefix = sys.argv[2]
23 if p[0] == '/': p = p[1:]
24 destdir = os.path.join(root, p)
25
9c6b4824 26
2eb31f8b
RD
27from CreateBatchFiles import scripts
28repltxt = "#!/usr/bin/env python"
29
1e4a197e
RD
30
31# use the existing pythonw as a template
32gui_template = open(pythonw, "r").read().replace('"$@"', '"%s.py" "$@"')
33
2eb31f8b
RD
34
35def main():
36 for script, usegui in scripts:
37 destfile = os.path.join(destdir, script)
1e4a197e
RD
38 prefixfile = os.path.join(prefix, script)
39
2eb31f8b
RD
40 thescript = open(script).read()
41 if usegui:
42 f = open(destfile+'.py', 'w')
9c6b4824 43 print destfile+'.py'
2eb31f8b
RD
44 f.write(thescript.replace(repltxt, ''))
45 f.close()
46 f = open(destfile, 'w')
9c6b4824 47 print destfile
1e4a197e 48 f.write(gui_template % prefixfile)
2eb31f8b
RD
49 f.close()
50
51 else:
52 thescript = thescript.replace(repltxt, '#!'+python)
53 f = open(destfile, 'w')
9c6b4824 54 print destfile
2eb31f8b
RD
55 f.write(thescript)
56 f.close()
57
58 os.chmod(destfile, 0755)
59
60
61if __name__ == '__main__':
62 main()
63