Mercurial > cpython-lru_cache-weakref
annotate Mac/scripts/binhextree.py @ 5817:48b94de85bf3 legacy-trunk
Extensive changes by AMK.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Thu, 17 Jul 1997 16:29:42 +0000 |
| parents | b4063c101c2c |
| children | 24ec4624ea9e |
| rev | line source |
|---|---|
|
2977
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
1 # |
| 3391 | 2 # binhextree - Recursively descend a directory and |
|
2977
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
3 # pack all resource files. |
|
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
4 # |
|
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
5 # Jack Jansen, CWI, August 1995. |
|
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
6 # |
|
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
7 |
|
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
8 import os |
|
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
9 import binhex |
|
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
10 import sys |
|
3044
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
11 import macostools |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
12 import macfs |
|
2977
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
13 |
|
3044
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
14 import aetools |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
15 from Metrowerks_Shell_Suite import Metrowerks_Shell_Suite |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
16 from Required_Suite import Required_Suite |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
17 |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
18 class MwShell(aetools.TalkTo, Metrowerks_Shell_Suite, Required_Suite): |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
19 pass |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
20 |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
21 # Top-level directory |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
22 TOP='' |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
23 |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
24 # Where to put CW projects, relative to TOP |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
25 CWDIR=':Mac:mwerks:projects' |
|
4472
f634609f4028
Only copy project files from build* and plugins to the projects
Jack Jansen <jack.jansen@cwi.nl>
parents:
4324
diff
changeset
|
26 # From which folders to put projects there |
|
f634609f4028
Only copy project files from build* and plugins to the projects
Jack Jansen <jack.jansen@cwi.nl>
parents:
4324
diff
changeset
|
27 CWDIRDIRS=['build.macppc.stand', 'build.macppc.shared', 'build.mac68k.stand', 'build.mac68k.shared', 'PlugIns'] |
|
3044
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
28 |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
29 # Helper routines |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
30 def binhexit(path, name): |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
31 dstfile = path + '.hqx' |
|
3475
073550e31273
Compare sourcefile to hqx file (if it exists) before binhexing. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3462
diff
changeset
|
32 if os.path.exists(dstfile): |
|
073550e31273
Compare sourcefile to hqx file (if it exists) before binhexing. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3462
diff
changeset
|
33 print 'Compare', path,'...', |
|
073550e31273
Compare sourcefile to hqx file (if it exists) before binhexing. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3462
diff
changeset
|
34 if binhexcompare(path, dstfile): |
|
073550e31273
Compare sourcefile to hqx file (if it exists) before binhexing. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3462
diff
changeset
|
35 print 'Identical, skipped.' |
|
073550e31273
Compare sourcefile to hqx file (if it exists) before binhexing. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3462
diff
changeset
|
36 return |
|
073550e31273
Compare sourcefile to hqx file (if it exists) before binhexing. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3462
diff
changeset
|
37 else: |
|
073550e31273
Compare sourcefile to hqx file (if it exists) before binhexing. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3462
diff
changeset
|
38 print 'Not up-to-date.' |
|
3044
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
39 print 'Binhexing', path |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
40 binhex.binhex(path, dstfile) |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
41 |
|
3475
073550e31273
Compare sourcefile to hqx file (if it exists) before binhexing. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3462
diff
changeset
|
42 def binhexcompare(source, hqxfile): |
|
073550e31273
Compare sourcefile to hqx file (if it exists) before binhexing. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3462
diff
changeset
|
43 """(source, hqxfile) - Check whether the two files match (forks only)""" |
|
073550e31273
Compare sourcefile to hqx file (if it exists) before binhexing. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3462
diff
changeset
|
44 ifp = binhex.HexBin(hqxfile) |
|
073550e31273
Compare sourcefile to hqx file (if it exists) before binhexing. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3462
diff
changeset
|
45 |
|
073550e31273
Compare sourcefile to hqx file (if it exists) before binhexing. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3462
diff
changeset
|
46 sfp = open(source, 'rb') |
|
073550e31273
Compare sourcefile to hqx file (if it exists) before binhexing. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3462
diff
changeset
|
47 while 1: |
|
073550e31273
Compare sourcefile to hqx file (if it exists) before binhexing. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3462
diff
changeset
|
48 d = ifp.read(128000) |
|
073550e31273
Compare sourcefile to hqx file (if it exists) before binhexing. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3462
diff
changeset
|
49 d2 = sfp.read(128000) |
|
073550e31273
Compare sourcefile to hqx file (if it exists) before binhexing. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3462
diff
changeset
|
50 if d <> d2: |
|
073550e31273
Compare sourcefile to hqx file (if it exists) before binhexing. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3462
diff
changeset
|
51 return 0 |
|
073550e31273
Compare sourcefile to hqx file (if it exists) before binhexing. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3462
diff
changeset
|
52 if not d: break |
|
073550e31273
Compare sourcefile to hqx file (if it exists) before binhexing. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3462
diff
changeset
|
53 sfp.close() |
|
073550e31273
Compare sourcefile to hqx file (if it exists) before binhexing. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3462
diff
changeset
|
54 ifp.close_data() |
|
073550e31273
Compare sourcefile to hqx file (if it exists) before binhexing. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3462
diff
changeset
|
55 |
|
073550e31273
Compare sourcefile to hqx file (if it exists) before binhexing. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3462
diff
changeset
|
56 d = ifp.read_rsrc(128000) |
|
073550e31273
Compare sourcefile to hqx file (if it exists) before binhexing. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3462
diff
changeset
|
57 if d: |
|
073550e31273
Compare sourcefile to hqx file (if it exists) before binhexing. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3462
diff
changeset
|
58 sfp = binhex.openrsrc(source, 'rb') |
|
073550e31273
Compare sourcefile to hqx file (if it exists) before binhexing. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3462
diff
changeset
|
59 d2 = sfp.read(128000) |
|
073550e31273
Compare sourcefile to hqx file (if it exists) before binhexing. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3462
diff
changeset
|
60 if d <> d2: |
|
073550e31273
Compare sourcefile to hqx file (if it exists) before binhexing. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3462
diff
changeset
|
61 return 0 |
|
073550e31273
Compare sourcefile to hqx file (if it exists) before binhexing. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3462
diff
changeset
|
62 while 1: |
|
073550e31273
Compare sourcefile to hqx file (if it exists) before binhexing. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3462
diff
changeset
|
63 d = ifp.read_rsrc(128000) |
|
073550e31273
Compare sourcefile to hqx file (if it exists) before binhexing. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3462
diff
changeset
|
64 d2 = sfp.read(128000) |
|
073550e31273
Compare sourcefile to hqx file (if it exists) before binhexing. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3462
diff
changeset
|
65 if d <> d2: |
|
073550e31273
Compare sourcefile to hqx file (if it exists) before binhexing. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3462
diff
changeset
|
66 return 0 |
|
073550e31273
Compare sourcefile to hqx file (if it exists) before binhexing. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3462
diff
changeset
|
67 if not d: break |
|
073550e31273
Compare sourcefile to hqx file (if it exists) before binhexing. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3462
diff
changeset
|
68 return 1 |
|
073550e31273
Compare sourcefile to hqx file (if it exists) before binhexing. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3462
diff
changeset
|
69 |
|
3044
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
70 # Project files to handle |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
71 project_files = {} |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
72 |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
73 def hexbincwprojects(creator): |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
74 """Compact and hexbin all files remembered with a given creator""" |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
75 try: |
|
4324
1afcd1cd333b
Use auto-start functionality of aetools.TalkTo and aetools.Error for
Jack Jansen <jack.jansen@cwi.nl>
parents:
3535
diff
changeset
|
76 mgr = MwShell(creator, start=1) |
|
3044
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
77 except 'foo': |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
78 print 'Not handled:', creator |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
79 return |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
80 for fss in project_files[creator]: |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
81 srcfile = fss.as_pathname() |
|
3225
e554a61a8469
Take care that filenames for .hqx files are ascii (no more mu's, etc)
Jack Jansen <jack.jansen@cwi.nl>
parents:
3061
diff
changeset
|
82 |
|
e554a61a8469
Take care that filenames for .hqx files are ascii (no more mu's, etc)
Jack Jansen <jack.jansen@cwi.nl>
parents:
3061
diff
changeset
|
83 if srcfile[-1] == 'µ': |
|
e554a61a8469
Take care that filenames for .hqx files are ascii (no more mu's, etc)
Jack Jansen <jack.jansen@cwi.nl>
parents:
3061
diff
changeset
|
84 dstfile = srcfile[:-1]+'mu.hqx' |
|
4472
f634609f4028
Only copy project files from build* and plugins to the projects
Jack Jansen <jack.jansen@cwi.nl>
parents:
4324
diff
changeset
|
85 elif srcfile[-3] == '.mu': |
|
f634609f4028
Only copy project files from build* and plugins to the projects
Jack Jansen <jack.jansen@cwi.nl>
parents:
4324
diff
changeset
|
86 dstfile = srcfile + '.hqx' |
|
3225
e554a61a8469
Take care that filenames for .hqx files are ascii (no more mu's, etc)
Jack Jansen <jack.jansen@cwi.nl>
parents:
3061
diff
changeset
|
87 elif ord(srcfile[-1]) >= 128: |
|
e554a61a8469
Take care that filenames for .hqx files are ascii (no more mu's, etc)
Jack Jansen <jack.jansen@cwi.nl>
parents:
3061
diff
changeset
|
88 dstfile = srcfile[:-1]+`ord(srcfile[-1])`+'.hqx' |
|
e554a61a8469
Take care that filenames for .hqx files are ascii (no more mu's, etc)
Jack Jansen <jack.jansen@cwi.nl>
parents:
3061
diff
changeset
|
89 else: |
|
e554a61a8469
Take care that filenames for .hqx files are ascii (no more mu's, etc)
Jack Jansen <jack.jansen@cwi.nl>
parents:
3061
diff
changeset
|
90 dstfile = srcfile + '.hqx' |
|
e554a61a8469
Take care that filenames for .hqx files are ascii (no more mu's, etc)
Jack Jansen <jack.jansen@cwi.nl>
parents:
3061
diff
changeset
|
91 |
|
3044
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
92 if os.path.exists(dstfile) and \ |
|
4472
f634609f4028
Only copy project files from build* and plugins to the projects
Jack Jansen <jack.jansen@cwi.nl>
parents:
4324
diff
changeset
|
93 os.stat(dstfile)[8] >= os.stat(srcfile)[8]: |
| 3061 | 94 print 'Skip', dstfile,'- Up-to-date' |
|
3044
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
95 continue |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
96 print 'Compacting', dstfile |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
97 mgr.open(fss) |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
98 mgr.Reset_File_Paths() |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
99 mgr.Remove_Binaries() |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
100 mgr.Close_Project() |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
101 |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
102 print 'Binhexing', dstfile |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
103 binhex.binhex(srcfile, dstfile) |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
104 mgr.quit() |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
105 |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
106 def copycwproject(path, name): |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
107 """Copy CW project (if needed) and remember for hexbinning""" |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
108 global project_files |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
109 |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
110 dstdir = os.path.join(TOP, CWDIR) |
|
4472
f634609f4028
Only copy project files from build* and plugins to the projects
Jack Jansen <jack.jansen@cwi.nl>
parents:
4324
diff
changeset
|
111 if path[:len(dstdir)] == dstdir: |
|
3044
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
112 return |
|
4472
f634609f4028
Only copy project files from build* and plugins to the projects
Jack Jansen <jack.jansen@cwi.nl>
parents:
4324
diff
changeset
|
113 srcdir = os.path.split(path)[0] |
|
f634609f4028
Only copy project files from build* and plugins to the projects
Jack Jansen <jack.jansen@cwi.nl>
parents:
4324
diff
changeset
|
114 srcdir = os.path.split(srcdir)[1] |
|
f634609f4028
Only copy project files from build* and plugins to the projects
Jack Jansen <jack.jansen@cwi.nl>
parents:
4324
diff
changeset
|
115 if srcdir in CWDIRDIRS: |
|
f634609f4028
Only copy project files from build* and plugins to the projects
Jack Jansen <jack.jansen@cwi.nl>
parents:
4324
diff
changeset
|
116 if not os.path.exists(dstdir): |
|
f634609f4028
Only copy project files from build* and plugins to the projects
Jack Jansen <jack.jansen@cwi.nl>
parents:
4324
diff
changeset
|
117 print dstdir |
|
f634609f4028
Only copy project files from build* and plugins to the projects
Jack Jansen <jack.jansen@cwi.nl>
parents:
4324
diff
changeset
|
118 print 'No CW-project dir, skip', name |
|
f634609f4028
Only copy project files from build* and plugins to the projects
Jack Jansen <jack.jansen@cwi.nl>
parents:
4324
diff
changeset
|
119 return |
|
4520
b4063c101c2c
Keep the folder structure in Mac:mwerks:projects similar to the
Jack Jansen <jack.jansen@cwi.nl>
parents:
4472
diff
changeset
|
120 dstfile = os.path.join(dstdir, os.path.join(srcdir, name)) |
|
4472
f634609f4028
Only copy project files from build* and plugins to the projects
Jack Jansen <jack.jansen@cwi.nl>
parents:
4324
diff
changeset
|
121 else: |
|
f634609f4028
Only copy project files from build* and plugins to the projects
Jack Jansen <jack.jansen@cwi.nl>
parents:
4324
diff
changeset
|
122 if path[-2:] != '.µ': |
|
f634609f4028
Only copy project files from build* and plugins to the projects
Jack Jansen <jack.jansen@cwi.nl>
parents:
4324
diff
changeset
|
123 return |
|
f634609f4028
Only copy project files from build* and plugins to the projects
Jack Jansen <jack.jansen@cwi.nl>
parents:
4324
diff
changeset
|
124 dstfile = path[:-2]+ '.mu' |
|
3044
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
125 |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
126 # If the destination doesn't exists or is older that the source |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
127 # we copy and remember it |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
128 |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
129 if os.path.exists(dstfile) and \ |
|
4472
f634609f4028
Only copy project files from build* and plugins to the projects
Jack Jansen <jack.jansen@cwi.nl>
parents:
4324
diff
changeset
|
130 os.stat(dstfile)[8] >= os.stat(path)[8]: |
|
3044
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
131 print 'Not copying', path,'- Up-to-date' |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
132 else: |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
133 print 'Copy', path |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
134 macostools.copy(path, dstfile) |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
135 |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
136 fss = macfs.FSSpec(dstfile) |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
137 creator = fss.GetCreatorType()[0] |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
138 |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
139 if project_files.has_key(creator): |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
140 project_files[creator].append(fss) |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
141 else: |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
142 project_files[creator] = [fss] |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
143 |
|
3535
ac8d24f1df08
Copy .exp files to mwerks project directory too.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3503
diff
changeset
|
144 def copycwexpfile(path, name): |
|
ac8d24f1df08
Copy .exp files to mwerks project directory too.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3503
diff
changeset
|
145 """Copy CW export file""" |
|
ac8d24f1df08
Copy .exp files to mwerks project directory too.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3503
diff
changeset
|
146 global project_files |
|
ac8d24f1df08
Copy .exp files to mwerks project directory too.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3503
diff
changeset
|
147 |
|
ac8d24f1df08
Copy .exp files to mwerks project directory too.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3503
diff
changeset
|
148 dstdir = os.path.join(TOP, CWDIR) |
|
4472
f634609f4028
Only copy project files from build* and plugins to the projects
Jack Jansen <jack.jansen@cwi.nl>
parents:
4324
diff
changeset
|
149 if path[:len(dstdir)] == dstdir: |
|
3535
ac8d24f1df08
Copy .exp files to mwerks project directory too.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3503
diff
changeset
|
150 return |
|
4472
f634609f4028
Only copy project files from build* and plugins to the projects
Jack Jansen <jack.jansen@cwi.nl>
parents:
4324
diff
changeset
|
151 srcdir = os.path.split(path)[0] |
|
f634609f4028
Only copy project files from build* and plugins to the projects
Jack Jansen <jack.jansen@cwi.nl>
parents:
4324
diff
changeset
|
152 srcdir = os.path.split(srcdir)[1] |
|
f634609f4028
Only copy project files from build* and plugins to the projects
Jack Jansen <jack.jansen@cwi.nl>
parents:
4324
diff
changeset
|
153 if srcdir in CWDIRDIRS: |
|
f634609f4028
Only copy project files from build* and plugins to the projects
Jack Jansen <jack.jansen@cwi.nl>
parents:
4324
diff
changeset
|
154 if not os.path.exists(dstdir): |
|
f634609f4028
Only copy project files from build* and plugins to the projects
Jack Jansen <jack.jansen@cwi.nl>
parents:
4324
diff
changeset
|
155 print dstdir |
|
f634609f4028
Only copy project files from build* and plugins to the projects
Jack Jansen <jack.jansen@cwi.nl>
parents:
4324
diff
changeset
|
156 print 'No CW-project dir, skip', name |
|
f634609f4028
Only copy project files from build* and plugins to the projects
Jack Jansen <jack.jansen@cwi.nl>
parents:
4324
diff
changeset
|
157 return |
|
4520
b4063c101c2c
Keep the folder structure in Mac:mwerks:projects similar to the
Jack Jansen <jack.jansen@cwi.nl>
parents:
4472
diff
changeset
|
158 dstfile = os.path.join(dstdir, os.path.join(srcdir, name)) |
|
4472
f634609f4028
Only copy project files from build* and plugins to the projects
Jack Jansen <jack.jansen@cwi.nl>
parents:
4324
diff
changeset
|
159 else: |
|
f634609f4028
Only copy project files from build* and plugins to the projects
Jack Jansen <jack.jansen@cwi.nl>
parents:
4324
diff
changeset
|
160 if path[-6:] != '.µ.exp': |
|
f634609f4028
Only copy project files from build* and plugins to the projects
Jack Jansen <jack.jansen@cwi.nl>
parents:
4324
diff
changeset
|
161 return |
|
f634609f4028
Only copy project files from build* and plugins to the projects
Jack Jansen <jack.jansen@cwi.nl>
parents:
4324
diff
changeset
|
162 dstfile = path[:-6] + '.mu.exp' |
|
3535
ac8d24f1df08
Copy .exp files to mwerks project directory too.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3503
diff
changeset
|
163 if dstfile[-6:] == '.µ.exp': |
|
ac8d24f1df08
Copy .exp files to mwerks project directory too.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3503
diff
changeset
|
164 dstfile = dstfile[:-6]+'.mu.exp' |
|
ac8d24f1df08
Copy .exp files to mwerks project directory too.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3503
diff
changeset
|
165 |
|
ac8d24f1df08
Copy .exp files to mwerks project directory too.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3503
diff
changeset
|
166 # If the destination doesn't exists or is older that the source |
|
ac8d24f1df08
Copy .exp files to mwerks project directory too.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3503
diff
changeset
|
167 # we copy and remember it |
|
ac8d24f1df08
Copy .exp files to mwerks project directory too.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3503
diff
changeset
|
168 |
|
ac8d24f1df08
Copy .exp files to mwerks project directory too.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3503
diff
changeset
|
169 if os.path.exists(dstfile) and \ |
|
4472
f634609f4028
Only copy project files from build* and plugins to the projects
Jack Jansen <jack.jansen@cwi.nl>
parents:
4324
diff
changeset
|
170 os.stat(dstfile)[8] >= os.stat(path)[8]: |
|
3535
ac8d24f1df08
Copy .exp files to mwerks project directory too.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3503
diff
changeset
|
171 print 'Not copying', path,'- Up-to-date' |
|
ac8d24f1df08
Copy .exp files to mwerks project directory too.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3503
diff
changeset
|
172 else: |
|
ac8d24f1df08
Copy .exp files to mwerks project directory too.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3503
diff
changeset
|
173 print 'Copy', path |
|
ac8d24f1df08
Copy .exp files to mwerks project directory too.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3503
diff
changeset
|
174 macostools.copy(path, dstfile) |
|
3044
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
175 |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
176 extensions = [ |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
177 ('.rsrc', binhexit), |
| 3503 | 178 ('.gif', binhexit), |
|
3535
ac8d24f1df08
Copy .exp files to mwerks project directory too.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3503
diff
changeset
|
179 ('.µ', copycwproject), |
|
ac8d24f1df08
Copy .exp files to mwerks project directory too.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3503
diff
changeset
|
180 ('.µ.exp', copycwexpfile) |
|
3044
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
181 ] |
|
2977
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
182 |
|
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
183 def walker(arg, top, names): |
| 3441 | 184 lnames = names[:] |
| 185 for n in lnames: | |
| 186 if n[0] == '(' and n[-1] == ')': | |
| 187 names.remove(n) | |
| 188 continue | |
|
3044
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
189 for ext, handler in extensions: |
|
2977
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
190 if n[-len(ext):] == ext: |
|
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
191 name = os.path.join(top, n) |
|
3044
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
192 handler(name, n) |
|
2977
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
193 |
|
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
194 def dodir(name): |
|
3044
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
195 global TOP, project_files |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
196 TOP = name |
|
2977
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
197 os.path.walk(name, walker, None) |
|
3044
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
198 |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
199 for creator in project_files.keys(): |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
200 hexbincwprojects(creator) |
|
7e7bb00a0a2e
Added functionality: locate CW projects, copy them, empty them and
Jack Jansen <jack.jansen@cwi.nl>
parents:
2977
diff
changeset
|
201 project_files = {} |
|
2977
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
202 |
|
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
203 def main(): |
|
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
204 if len(sys.argv) > 1: |
|
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
205 for dir in sys.argv[1:]: |
|
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
206 dodir(dir) |
|
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
207 elif os.name == 'mac': |
|
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
208 import macfs |
|
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
209 dir, ok = macfs.GetDirectory('Folder to search:') |
|
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
210 if not ok: |
|
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
211 sys.exit(0) |
|
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
212 dodir(dir.as_pathname()) |
|
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
213 else: |
|
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
214 print 'Usage: hexbintree dir ...' |
|
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
215 sys.exit(1) |
|
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
216 if os.name == 'mac': |
|
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
217 sys.exit(1) # Keep window |
|
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
218 else: |
|
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
219 sys.exit(0) |
|
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
220 |
|
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
221 if __name__ == '__main__': |
|
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
222 main() |
|
441866be2ec9
Binhexify any .rsrc file in a tree
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
223 |
