diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2000-09-12 20:24:50 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2000-09-12 20:24:50 (GMT) |
commit | 9c940ca1438b774b736863981e76ca81f459204f (patch) | |
tree | 73704d48e2a2e5fffe50ce0a67bef1d5cf6d2959 /Mac/scripts | |
parent | f913e542bee40dfb83642a903c74e76566694c69 (diff) | |
download | cpython-9c940ca1438b774b736863981e76ca81f459204f.zip cpython-9c940ca1438b774b736863981e76ca81f459204f.tar.gz cpython-9c940ca1438b774b736863981e76ca81f459204f.tar.bz2 |
Moved to Unsupported.
Diffstat (limited to 'Mac/scripts')
-rw-r--r-- | Mac/scripts/FixCreator.py | 36 | ||||
-rw-r--r-- | Mac/scripts/fixgusidir.py | 89 | ||||
-rw-r--r-- | Mac/scripts/mkfrozenresources.py | 39 |
3 files changed, 0 insertions, 164 deletions
diff --git a/Mac/scripts/FixCreator.py b/Mac/scripts/FixCreator.py deleted file mode 100644 index b5b3a26..0000000 --- a/Mac/scripts/FixCreator.py +++ /dev/null @@ -1,36 +0,0 @@ -# -# FixCreator - Search for files with PYTH creator -# and set it to Pyth. -# -import os -import macfs -import sys -import macostools - -OLD='PYTH' -NEW='Pyth' - -def walktree(name, change): - if os.path.isfile(name): - fs = macfs.FSSpec(name) - cur_cr, cur_tp = fs.GetCreatorType() - if cur_cr == OLD: - fs.SetCreatorType(NEW, cur_tp) - macostools.touched(fs) - print 'Fixed ', name - elif os.path.isdir(name): - print '->', name - files = os.listdir(name) - for f in files: - walktree(os.path.join(name, f), change) - -def run(change): - fss, ok = macfs.GetDirectory('Folder to search:') - if not ok: - sys.exit(0) - walktree(fss.as_pathname(), change) - -if __name__ == '__main__': - run(1) - - diff --git a/Mac/scripts/fixgusidir.py b/Mac/scripts/fixgusidir.py deleted file mode 100644 index 53ca5ba..0000000 --- a/Mac/scripts/fixgusidir.py +++ /dev/null @@ -1,89 +0,0 @@ -# fixgusidir - Modify filenames in the CWGUSI source tree, so -# that it can be put under CVS. Needed because there are files with slashes -# in their name, which CVS does not approve of. -# -# Usage: -# - On importing gusi in cvs: -# - Run the script after unpacking the gusi distribution. This creates -# _s_ files for all / files. -# - Remove all / files with "find file" or some such. -# - import the tree -# - On checking out gusi: -# - After checkout, run the script to create / files for all _s_ files. -# - After modifying stuff, or later checkouts: -# - Run the script. Conflicts between / and _s_ files will be reported. -# - Fix the problems by removing the outdated / or _s_ file. -# - Run the script again. Possibly do a cvs checkin. -import macfs -import os -import sys -import re - -# Substitution for slashes in filenames -SUBST = '_s_' -# Program to find those substitutions -SUBSTPROG = re.compile(SUBST) - -def main(): - if len(sys.argv) > 1: - gusidir = sys.argv[1] - else: - fss, ok = macfs.GetDirectory("CWGUSI source folder?") - if not ok: sys.exit(0) - gusidir = fss.as_pathname() - fixgusifolder(gusidir) - sys.exit(1) - -def fixgusifolder(gusidir): - """Synchronize files with / in their name with their _s_ counterparts""" - os.path.walk(gusidir, gusiwalk, None) - -def gusiwalk(dummy, top, names): - """Helper for fixgusifolder: convert a single directory full of files""" - # First remember names with slashes and with our slash-substitution - macnames = [] - codenames = [] - for name in names: - if '/' in name: - macnames.append(name) - if SUBSTPROG.search(name): - codenames.append(name) - # Next, check whether we need to copy any slash-files to subst-files - for name in macnames: - if os.path.isdir(name): - print '** Folder with slash in name cannot be handled!' - sys.exit(1) - othername = mac2codename(name) - if len(othername) > 31: - print '** Converted filename too long:', othername - sys.exit(1) - if othername in codenames: - codenames.remove(othername) - sync(os.path.join(top, name), os.path.join(top, othername)) - # Now codenames contains only files that have no / equivalent - for name in codenames: - othername = code2macname(name) - sync(os.path.join(top, name), os.path.join(top, othername)) - -def mac2codename(name): - return re.sub('/', SUBST, name) - -def code2macname(name): - return re.sub(SUBST, '/', name) - -def sync(old, new): - if os.path.exists(new): - # Both exist. Check that they are indentical - d1 = open(old, 'rb').read() - d2 = open(new, 'rb').read() - if d1 == d2: - print '-- OK ', old - return - print '** OUT-OF-SYNC', old - fp = open(new, 'wb') - fp.write(open(old, 'rb').read()) - print '-- COPIED ', old - -if __name__ == '__main__': - main() - diff --git a/Mac/scripts/mkfrozenresources.py b/Mac/scripts/mkfrozenresources.py deleted file mode 100644 index b678791..0000000 --- a/Mac/scripts/mkfrozenresources.py +++ /dev/null @@ -1,39 +0,0 @@ -# -# Given a module-list generated by findmodulefiles -# generate the resource file with all needed modules -# -import macfs -import py_resource -import Res -import sys - -def main(): - fss, ok = macfs.PromptGetFile('Module sources listing:', 'TEXT') - if not ok: - sys.exit(0) - ofss, ok = macfs.StandardPutFile('PYC resource output file:') - if not ok: - sys.exit(0) - mfss, ok = macfs.PromptGetFile('Source for __main__ (or cancel):') - if ok: - mainfile = mfss.as_pathname() - else: - mainfile = None - fp = open(fss.as_pathname()) - data = fp.read() - modules = eval(data) - - fsid = py_resource.create(ofss.as_pathname(), creator='RSED') - - if mainfile: - id, name = py_resource.frompyfile(mainfile, '__main__') - for module, source in modules: - if source: - id, name = py_resource.frompyfile(source) - print 'Wrote %d %s: %s'%(id, name, source) - - Res.CloseResFile(fsid) - -if __name__ == '__main__': - main() - sys.exit(1) |