1995-08-09 15:16:58 +00:00
|
|
|
# This python script creates Finder aliases for all the
|
|
|
|
# dynamically-loaded modules that "live in" in a single
|
|
|
|
# shared library.
|
|
|
|
# It needs a fully functional non-dynamic python to work
|
|
|
|
# (since it creates aliases to stuff it needs itself),
|
|
|
|
# you should probably drag it onto your non-dynamic python.
|
|
|
|
#
|
|
|
|
# If you compare it to MkPluginAliases.as it also serves
|
|
|
|
# as a comparison between python and AppleScript:-)
|
|
|
|
#
|
|
|
|
# Jack Jansen, CWI, August 1995
|
|
|
|
|
|
|
|
import sys
|
|
|
|
|
1995-09-24 21:06:50 +00:00
|
|
|
def help():
|
|
|
|
print"""
|
|
|
|
Try the following:
|
|
|
|
1. Remove any old "Python Preferences" files from the system folder.
|
|
|
|
2. Remove any old "PythonCore" files from the system folder.
|
|
|
|
3. Make sure this script, PythonPPC and PythonCore are all located in the
|
|
|
|
python home folder (where the Lib and PlugIns folders are)
|
|
|
|
4. Run this script again, by dropping it on PythonPPC.
|
|
|
|
|
|
|
|
If this fails try removing starting afresh from the distribution archive.
|
|
|
|
"""
|
|
|
|
sys.exit(1)
|
|
|
|
|
1995-08-09 15:16:58 +00:00
|
|
|
try:
|
1995-09-24 21:06:50 +00:00
|
|
|
import os
|
1995-08-09 15:16:58 +00:00
|
|
|
except ImportError:
|
|
|
|
print """
|
1995-09-24 21:06:50 +00:00
|
|
|
I cannot import the 'os' module, so something is wrong with sys.path
|
|
|
|
"""
|
|
|
|
help()
|
|
|
|
|
|
|
|
try:
|
|
|
|
import Res
|
|
|
|
except ImportError:
|
|
|
|
#
|
|
|
|
# Check that we are actually in the main python directory
|
|
|
|
#
|
|
|
|
try:
|
|
|
|
os.chdir(':PlugIns')
|
|
|
|
except IOError:
|
|
|
|
print """
|
|
|
|
I cannot find the 'PlugIns' folder, so I am obviously not run from the Python
|
|
|
|
home folder.
|
|
|
|
"""
|
|
|
|
help()
|
|
|
|
import imp
|
|
|
|
cwd = os.getcwd()
|
|
|
|
tblibname = os.path.join(cwd, "toolboxmodules.slb")
|
1995-10-09 23:17:18 +00:00
|
|
|
if not os.path.exists(tblibname):
|
1995-09-24 21:06:50 +00:00
|
|
|
print """
|
|
|
|
I cannot find the 'toolboxmodules.slb' file in the PlugIns directory.
|
|
|
|
Start afresh from a clean distribution.
|
|
|
|
"""
|
|
|
|
sys.exit(1)
|
|
|
|
try:
|
|
|
|
for wtd in ["Ctl", "Dlg", "Evt", "Qd", "Res", "Win"]:
|
1995-10-09 23:17:18 +00:00
|
|
|
imp.load_dynamic(wtd, tblibname)
|
1995-09-24 21:06:50 +00:00
|
|
|
except ImportError:
|
|
|
|
print """
|
|
|
|
I cannot load the toolbox modules by hand. Are you sure you are
|
|
|
|
using a PowerPC mac?
|
|
|
|
"""
|
|
|
|
sys.exit(1)
|
|
|
|
|
1995-08-09 15:16:58 +00:00
|
|
|
|
1995-09-24 21:06:50 +00:00
|
|
|
import macfs
|
1995-08-09 15:16:58 +00:00
|
|
|
import EasyDialogs
|
1995-08-14 12:20:22 +00:00
|
|
|
import macostools
|
1995-08-09 15:16:58 +00:00
|
|
|
|
|
|
|
goals = [
|
|
|
|
("AE.slb", "toolboxmodules.slb"),
|
1995-11-30 15:16:42 +00:00
|
|
|
("Cm.slb", "toolboxmodules.slb"),
|
1995-08-09 15:16:58 +00:00
|
|
|
("Ctl.slb", "toolboxmodules.slb"),
|
|
|
|
("Dlg.slb", "toolboxmodules.slb"),
|
|
|
|
("Evt.slb", "toolboxmodules.slb"),
|
1996-01-09 17:16:52 +00:00
|
|
|
("Fm.slb", "toolboxmodules.slb"),
|
1995-08-09 15:16:58 +00:00
|
|
|
("Menu.slb", "toolboxmodules.slb"),
|
1995-08-14 12:20:22 +00:00
|
|
|
("List.slb", "toolboxmodules.slb"),
|
1995-08-09 15:16:58 +00:00
|
|
|
("Qd.slb", "toolboxmodules.slb"),
|
1995-12-09 14:01:28 +00:00
|
|
|
("Qt.slb", "toolboxmodules.slb"),
|
1995-08-09 15:16:58 +00:00
|
|
|
("Res.slb", "toolboxmodules.slb"),
|
1996-04-12 16:34:58 +00:00
|
|
|
("Scrap.slb", "toolboxmodules.slb"),
|
1995-08-09 15:16:58 +00:00
|
|
|
("Snd.slb", "toolboxmodules.slb"),
|
1996-04-10 14:52:18 +00:00
|
|
|
("TE.slb", "toolboxmodules.slb"),
|
1995-08-09 15:16:58 +00:00
|
|
|
("Win.slb", "toolboxmodules.slb"),
|
|
|
|
("imgcolormap.slb", "imgmodules.slb"),
|
|
|
|
("imgformat.slb", "imgmodules.slb"),
|
|
|
|
("imggif.slb", "imgmodules.slb"),
|
|
|
|
("imgjpeg.slb", "imgmodules.slb"),
|
|
|
|
("imgop.slb", "imgmodules.slb"),
|
1995-10-12 10:34:31 +00:00
|
|
|
("imgpbm.slb", "imgmodules.slb"),
|
1995-08-09 15:16:58 +00:00
|
|
|
("imgpgm.slb", "imgmodules.slb"),
|
|
|
|
("imgppm.slb", "imgmodules.slb"),
|
1995-10-12 10:34:31 +00:00
|
|
|
("imgtiff.slb", "imgmodules.slb"),
|
|
|
|
("imgsgi.slb", "imgmodules.slb")
|
1995-08-09 15:16:58 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
# Ask the user for the plugins directory
|
1995-08-14 12:20:22 +00:00
|
|
|
dir, ok = macfs.GetDirectory('Where is the PlugIns folder?')
|
1995-08-09 15:16:58 +00:00
|
|
|
if not ok: sys.exit(0)
|
|
|
|
os.chdir(dir.as_pathname())
|
|
|
|
|
|
|
|
# Remove old .slb aliases and collect a list of .slb files
|
|
|
|
if EasyDialogs.AskYesNoCancel('Proceed with removing old aliases?') <= 0:
|
|
|
|
sys.exit(0)
|
|
|
|
LibFiles = []
|
|
|
|
allfiles = os.listdir(':')
|
|
|
|
for f in allfiles:
|
|
|
|
if f[-4:] == '.slb':
|
|
|
|
finfo = macfs.FSSpec(f).GetFInfo()
|
|
|
|
if finfo.Flags & 0x8000:
|
|
|
|
os.unlink(f)
|
|
|
|
else:
|
|
|
|
LibFiles.append(f)
|
|
|
|
|
|
|
|
print LibFiles
|
|
|
|
# Create the new aliases.
|
|
|
|
if EasyDialogs.AskYesNoCancel('Proceed with creating new ones?') <= 0:
|
|
|
|
sys.exit(0)
|
|
|
|
for dst, src in goals:
|
|
|
|
if src in LibFiles:
|
1995-08-14 12:20:22 +00:00
|
|
|
macostools.mkalias(src, dst)
|
1995-08-09 15:16:58 +00:00
|
|
|
else:
|
|
|
|
EasyDialogs.Message(dst+' not created: '+src+' not found')
|
|
|
|
|
|
|
|
EasyDialogs.Message('All done!')
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|