diff options
Diffstat (limited to 'Mac/scripts')
-rw-r--r-- | Mac/scripts/BuildApplication.py | 140 | ||||
-rw-r--r-- | Mac/scripts/BuildApplication.rsrc | bin | 3858 -> 0 bytes | |||
-rw-r--r-- | Mac/scripts/ConfigurePython.py | 179 | ||||
-rw-r--r-- | Mac/scripts/ConfigurePython.rsrc | bin | 9088 -> 0 bytes | |||
-rw-r--r-- | Mac/scripts/EditPythonPrefs.py | 213 | ||||
-rw-r--r-- | Mac/scripts/EditPythonPrefs.rsrc | bin | 9780 -> 0 bytes | |||
-rw-r--r-- | Mac/scripts/EditPythonPrefsBH.bh | 47 | ||||
-rw-r--r-- | Mac/scripts/EditPythonPrefsBH.prj | bin | 24091 -> 0 bytes | |||
-rw-r--r-- | Mac/scripts/EditPythonPrefsBH.rsrc | bin | 4278 -> 0 bytes | |||
-rw-r--r-- | Mac/scripts/MkDistr.py | 318 | ||||
-rw-r--r-- | Mac/scripts/MkDistr.rsrc | bin | 1531 -> 0 bytes | |||
-rw-r--r-- | Mac/scripts/MkDistr_ui.py | 356 | ||||
-rwxr-xr-x | Mac/scripts/buildappbundle.py | 104 | ||||
-rwxr-xr-x | Mac/scripts/crlf.py | 29 | ||||
-rw-r--r-- | Mac/scripts/findgremlins.py | 57 | ||||
-rw-r--r-- | Mac/scripts/fixfiletypes.py | 56 | ||||
-rw-r--r-- | Mac/scripts/fullbuild.py | 434 | ||||
-rw-r--r-- | Mac/scripts/fullbuild.rsrc | bin | 1764 -> 0 bytes | |||
-rw-r--r-- | Mac/scripts/genpluginprojects.py | 181 | ||||
-rw-r--r-- | Mac/scripts/missingcarbonmethods.py | 167 | ||||
-rw-r--r-- | Mac/scripts/unweave.py | 259 |
21 files changed, 0 insertions, 2540 deletions
diff --git a/Mac/scripts/BuildApplication.py b/Mac/scripts/BuildApplication.py deleted file mode 100644 index c919b3f..0000000 --- a/Mac/scripts/BuildApplication.py +++ /dev/null @@ -1,140 +0,0 @@ -"""Create a standalone application from a Python script. - -This puts up a dialog asking for a Python source file ('TEXT'). -The output is a file with the same name but its ".py" suffix dropped. -It is created by copying an applet template, all used shared libs and -then adding 'PYC ' resources containing compiled versions of all used -modules written in Python and the main script itself, as __main__. -""" - - -import sys - -import string -import os -import MacOS -from Carbon import Res -from Carbon import Dlg -import EasyDialogs -import buildtools -import macresource - -# Hmmm... -MACFREEZEPATH = os.path.join(sys.prefix, ":Mac:Tools:macfreeze") -if MACFREEZEPATH not in sys.path: - sys.path.append(MACFREEZEPATH) - -import macgen_bin - -# dialog, items -DLG_ID = 400 -OK_BUTTON = 1 -CANCEL_BUTTON = 2 -GENFAT_BUTTON = 4 -GENPPC_BUTTON = 5 -GEN68K_BUTTON = 6 - -# Define this if we cannot generate 68/fat binaries (Python 1.6) -PPC_ONLY=1 - - -macresource.need('DITL', DLG_ID, "BuildApplication.rsrc") - -def main(): - try: - buildapplication() - except buildtools.BuildError, detail: - EasyDialogs.Message(detail) - - -def buildapplication(debug = 0): - buildtools.DEBUG = debug - - # Ask for source text if not specified in sys.argv[1:] - - if not sys.argv[1:]: - filename = EasyDialogs.AskFileForOpen(message='Select Python source:', - fileTypes=('TEXT',)) - if not filename: - return - else: - if sys.argv[2:]: - raise buildtools.BuildError, "please select one file at a time" - filename = sys.argv[1] - tp, tf = os.path.split(filename) - - # interact with user - architecture, ok = interact(tf) - if not ok: - return - if tf[-3:] == '.py': - tf = tf[:-3] - else: - tf = tf + '.app' - - dstfilename = EasyDialogs.AskFileForSate(message='Save application as:', - savedFileName=tf) - if not ok: - return - - macgen_bin.generate(filename, dstfilename, None, architecture, 1) - - -class radio: - - def __init__(self, dlg, *items): - self.items = {} - for item in items: - ctl = dlg.GetDialogItemAsControl(item) - self.items[item] = ctl - - def set(self, setitem): - for item, ctl in self.items.items(): - if item == setitem: - ctl.SetControlValue(1) - else: - ctl.SetControlValue(0) - - def get(self): - for item, ctl in self.items.items(): - if ctl.GetControlValue(): - return item - - def hasitem(self, item): - return self.items.has_key(item) - - -def interact(scriptname): - if PPC_ONLY: - return 'pwpc', 1 - d = Dlg.GetNewDialog(DLG_ID, -1) - if not d: - raise "Can't get DLOG resource with id =", DLG_ID - d.SetDialogDefaultItem(OK_BUTTON) - d.SetDialogCancelItem(CANCEL_BUTTON) - Dlg.ParamText(scriptname, "", "", "") - - radiogroup = radio(d, GENFAT_BUTTON, GENPPC_BUTTON, GEN68K_BUTTON) - radiogroup.set(GENFAT_BUTTON) - - gentype = 'fat' - while 1: - n = Dlg.ModalDialog(None) - if n == OK_BUTTON or n == CANCEL_BUTTON: - break - elif radiogroup.hasitem(n): - radiogroup.set(n) - genitem = radiogroup.get() - del radiogroup - del d - if genitem == GENFAT_BUTTON: - gentype = 'fat' - elif genitem == GENPPC_BUTTON: - gentype = 'pwpc' - elif genitem == GEN68K_BUTTON: - gentype = 'm68k' - return gentype, n == OK_BUTTON - - -if __name__ == '__main__': - main() diff --git a/Mac/scripts/BuildApplication.rsrc b/Mac/scripts/BuildApplication.rsrc Binary files differdeleted file mode 100644 index 0617418..0000000 --- a/Mac/scripts/BuildApplication.rsrc +++ /dev/null diff --git a/Mac/scripts/ConfigurePython.py b/Mac/scripts/ConfigurePython.py deleted file mode 100644 index 4223101..0000000 --- a/Mac/scripts/ConfigurePython.py +++ /dev/null @@ -1,179 +0,0 @@ -# This python script creates Finder aliases for all the -# dynamically-loaded modules that "live in" in a single -# shared library. -# -# This is sort-of a merger between Jack's MkPluginAliases -# and Guido's mkaliases. -# -# Jack Jansen, CWI, August 1996 - -import sys -import os -import warnings -warnings.filterwarnings("ignore", "macfs.*", DeprecationWarning, __name__) -import macfs -import MacOS -import gestalt -import string -from Carbon import Res - -SPLASH_COPYCORE=512 -SPLASH_COPYCARBON=513 -SPLASH_COPYCLASSIC=514 -SPLASH_BUILDAPPLETS=515 - -ALERT_NOCORE=516 -ALERT_NONBOOT=517 -ALERT_NONBOOT_COPY=1 -ALERT_NONBOOT_ALIAS=2 - -ALERT_NOTPYTHONFOLDER=518 -ALERT_NOTPYTHONFOLDER_REMOVE_QUIT=1 -ALERT_NOTPYTHONFOLDER_QUIT=2 -ALERT_NOTPYTHONFOLDER_CONTINUE=3 - -APPLET_LIST=[ - (":Mac:scripts:EditPythonPrefs.py", "EditPythonPrefs", None), - (":Mac:scripts:BuildApplet.py", "BuildApplet", None), - (":Mac:scripts:BuildApplication.py", "BuildApplication", None), -## (":Mac:scripts:ConfigurePython.py", "ConfigurePython", None), -## (":Mac:scripts:ConfigurePython.py", "ConfigurePythonCarbon", "PythonInterpreterCarbon"), -## (":Mac:scripts:ConfigurePython.py", "ConfigurePythonClassic", "PythonInterpreterClassic"), - (":Mac:Tools:IDE:PythonIDE.py", "Python IDE", None), - (":Mac:Tools:CGI:PythonCGISlave.py", ":Mac:Tools:CGI:PythonCGISlave", None), - (":Mac:Tools:CGI:BuildCGIApplet.py", ":Mac:Tools:CGI:BuildCGIApplet", None), -] - -def getextensiondirfile(fname): - import macfs - import MACFS - try: - vrefnum, dirid = macfs.FindFolder(MACFS.kLocalDomain, MACFS.kSharedLibrariesFolderType, 1) - except macfs.error: - try: - vrefnum, dirid = macfs.FindFolder(MACFS.kOnSystemDisk, MACFS.kSharedLibrariesFolderType, 1) - except macfs.error: - return None - fss = macfs.FSSpec((vrefnum, dirid, fname)) - return fss.as_pathname() - -def mkcorealias(src, altsrc): - import string - import macostools - version = string.split(sys.version)[0] - dst = getextensiondirfile(src+ ' ' + version) - if not dst: - return 0 - if not os.path.exists(os.path.join(sys.exec_prefix, src)): - if not os.path.exists(os.path.join(sys.exec_prefix, altsrc)): - return 0 - src = altsrc - try: - os.unlink(dst) - except os.error: - pass - do_copy = ask_copy() - try: - if do_copy: - macostools.copy(os.path.join(sys.exec_prefix, src), dst) - else: - macostools.mkalias(os.path.join(sys.exec_prefix, src), dst) - except IOError: - return 0 - return 1 - -do_copy = None -def ask_copy(): - global do_copy - if do_copy != None: - return do_copy - # On OSX always copy - if gestalt.gestalt('sysv') > 0x9ff: - do_copy = 1 - return do_copy - do_copy = 0 - if macfs.FSSpec(sys.exec_prefix).as_tuple()[0] != -1: # XXXX - try: - from Carbon import Dlg - rv = Dlg.CautionAlert(ALERT_NONBOOT, None) - if rv == ALERT_NONBOOT_COPY: - do_copy = 1 - except ImportError: - pass - return do_copy - - -# Copied from fullbuild, should probably go to buildtools -def buildapplet(top, dummy, list): - """Create python applets""" - import buildtools - for src, dst, tmpl in list: - template = buildtools.findtemplate(tmpl) - if src[-3:] != '.py': - raise 'Should end in .py', src - base = os.path.basename(src) - src = os.path.join(top, src) - dst = os.path.join(top, dst) - try: - os.unlink(dst) - except os.error: - pass - try: - buildtools.process(template, src, dst, 1) - except buildtools.BuildError, arg: - print '**', dst, arg - -def buildcopy(top, dummy, list): - import macostools - for src, dst in list: - src = os.path.join(top, src) - dst = os.path.join(top, dst) - macostools.copy(src, dst, forcetype="APPL") - -def main(): - verbose = 0 - try: - h = Res.GetResource('DLOG', SPLASH_COPYCORE) - del h - except Res.Error: - verbose = 1 - print "Not running as applet: verbose on" - oldcwd = os.getcwd() - os.chdir(sys.prefix) - newcwd = os.getcwd() - if verbose: - print "Not running as applet: Skipping check for preference file correctness." - elif oldcwd != newcwd: - # Hack to make sure we get the new MACFS - sys.path.insert(0, os.path.join(oldcwd, ':Mac:Lib')) - from Carbon import Dlg - rv = Dlg.CautionAlert(ALERT_NOTPYTHONFOLDER, None) - if rv == ALERT_NOTPYTHONFOLDER_REMOVE_QUIT: - import pythonprefs, preferences - prefpathname = pythonprefs.pref_fss.as_pathname() - os.remove(prefpathname) - sys.exit(0) - elif rv == ALERT_NOTPYTHONFOLDER_QUIT: - sys.exit(0) - - sys.path.append('::Mac:Lib') - import macostools - - # Create the PythonCore alias(es) - MacOS.splash(SPLASH_COPYCORE) - if verbose: - print "Copying PythonCoreCarbon..." - n = 0 - n = n + mkcorealias('PythonCoreCarbon', 'PythonCoreCarbon') - if n == 0: - from Carbon import Dlg - Dlg.CautionAlert(ALERT_NOCORE, None) - if verbose: - print "Warning: PythonCore not copied to Extensions folder" - print " (Applets will not work unless run from the Python folder)" - MacOS.splash(SPLASH_BUILDAPPLETS) - buildapplet(sys.prefix, None, APPLET_LIST) - -if __name__ == '__main__': - main() - MacOS.splash() diff --git a/Mac/scripts/ConfigurePython.rsrc b/Mac/scripts/ConfigurePython.rsrc Binary files differdeleted file mode 100644 index f91ae61..0000000 --- a/Mac/scripts/ConfigurePython.rsrc +++ /dev/null diff --git a/Mac/scripts/EditPythonPrefs.py b/Mac/scripts/EditPythonPrefs.py deleted file mode 100644 index 64c5218..0000000 --- a/Mac/scripts/EditPythonPrefs.py +++ /dev/null @@ -1,213 +0,0 @@ -"""Edit the Python Preferences file.""" -# -# This program is getting more and more clunky. It should really -# be rewritten in a modeless way some time soon. - -from Carbon.Dlg import * -from Carbon.Events import * -from Carbon.Res import * -from Carbon import Controls -import string -import struct -import macfs -import MacOS -import os -import sys -from Carbon import Res # For Res.Error -import pythonprefs -import macresource -import EasyDialogs -try: - from Carbon import Help -except ImportError: - Help = None - -# resource IDs in our own resources (dialogs, etc) -MESSAGE_ID = 256 - -DIALOG_ID = 511 -TEXT_ITEM = 1 -OK_ITEM = 2 -CANCEL_ITEM = 3 -DIR_ITEM = 4 -TITLE_ITEM = 5 -OPTIONS_ITEM = 7 -HELP_ITEM = 9 - -# The options dialog. There is a correspondence between -# the dialog item numbers and the option. -OPT_DIALOG_ID = 510 - -# Map dialog item numbers to option names (and the reverse) -opt_dialog_map = [ - None, - None, - None, - "inspect", - "verbose", - "optimize", - "unbuffered", - "debugging", - "tabwarn", - "nosite", - "nonavservice", - "nointopt", - "noargs", - "delayconsole", - "divisionwarn", - "unixnewlines", - ] -opt_dialog_dict = {} -for i in range(len(opt_dialog_map)): - if opt_dialog_map[i]: - opt_dialog_dict[opt_dialog_map[i]] = i -# 1 thru 10 are the options -# The GUSI creator/type and delay-console -OD_CREATOR_ITEM = 20 -OD_TYPE_ITEM = 21 -OD_OK_ITEM = 1 -OD_CANCEL_ITEM = 2 -OD_HELP_ITEM = 22 -OD_KEEPALWAYS_ITEM = 16 -OD_KEEPOUTPUT_ITEM = 17 -OD_KEEPERROR_ITEM = 18 -OD_KEEPNEVER_ITEM = 19 - -def optinteract(options): - """Let the user interact with the options dialog""" - d = GetNewDialog(OPT_DIALOG_ID, -1) - htext = d.GetDialogItemAsControl(OD_CREATOR_ITEM) - SetDialogItemText(htext, options['creator']) - htext = d.GetDialogItemAsControl(OD_TYPE_ITEM) - SetDialogItemText(htext, options['type']) - d.SetDialogDefaultItem(OD_OK_ITEM) - d.SetDialogCancelItem(OD_CANCEL_ITEM) - if not Help: - d.HideDialogItem(OD_HELP_ITEM) - while 1: - for name in opt_dialog_dict.keys(): - num = opt_dialog_dict[name] - ctl = d.GetDialogItemAsControl(num) - ctl.SetControlValue(options[name]) - ctl = d.GetDialogItemAsControl(OD_KEEPALWAYS_ITEM) - ctl.SetControlValue(options['keep_console'] == 3) - ctl = d.GetDialogItemAsControl(OD_KEEPOUTPUT_ITEM) - ctl.SetControlValue(options['keep_console'] == 1) - ctl = d.GetDialogItemAsControl(OD_KEEPERROR_ITEM) - ctl.SetControlValue(options['keep_console'] == 2) - ctl = d.GetDialogItemAsControl(OD_KEEPNEVER_ITEM) - ctl.SetControlValue(options['keep_console'] == 0) - n = ModalDialog(None) - if n == OD_OK_ITEM: - htext = d.GetDialogItemAsControl(OD_CREATOR_ITEM) - ncreator = GetDialogItemText(htext) - htext = d.GetDialogItemAsControl(OD_TYPE_ITEM) - ntype = GetDialogItemText(htext) - if len(ncreator) == 4 and len(ntype) == 4: - options['creator'] = ncreator - options['type'] = ntype - return options - else: - MacOS.SysBeep() - elif n == OD_CANCEL_ITEM: - return - elif n in (OD_CREATOR_ITEM, OD_TYPE_ITEM): - pass - elif n == OD_KEEPALWAYS_ITEM: - options['keep_console'] = 3; - elif n == OD_KEEPOUTPUT_ITEM: - options['keep_console'] = 1; - elif n == OD_KEEPERROR_ITEM: - options['keep_console'] = 2; - elif n == OD_KEEPNEVER_ITEM: - options['keep_console'] = 0; - elif n == OD_HELP_ITEM and Help: - onoff = Help.HMGetBalloons() - Help.HMSetBalloons(not onoff) - elif 1 <= n <= len(opt_dialog_map): - options[opt_dialog_map[n]] = (not options[opt_dialog_map[n]]) - - -def interact(options, title): - """Let the user interact with the dialog""" - try: - # Try to go to the "correct" dir for GetDirectory - os.chdir(options['dir'].as_pathname()) - except os.error: - pass - d = GetNewDialog(DIALOG_ID, -1) - htext = d.GetDialogItemAsControl(TITLE_ITEM) - SetDialogItemText(htext, title) - path_ctl = d.GetDialogItemAsControl(TEXT_ITEM) - data = string.joinfields(options['path'], '\r') - path_ctl.SetControlData(Controls.kControlEditTextPart, Controls.kControlEditTextTextTag, data) - - d.SelectDialogItemText(TEXT_ITEM, 0, 32767) - d.SelectDialogItemText(TEXT_ITEM, 0, 0) -## d.SetDialogDefaultItem(OK_ITEM) - d.SetDialogCancelItem(CANCEL_ITEM) - if not Help: - d.HideDialogItem(HELP_ITEM) - d.GetDialogWindow().ShowWindow() - d.DrawDialog() - while 1: - n = ModalDialog(None) - if n == OK_ITEM: - break - if n == CANCEL_ITEM: - return None -## if n == REVERT_ITEM: -## return [], pythondir - if n == DIR_ITEM: - fss = EasyDialogs.AskFolder(message='Select python home folder:', - wanted=macfs.FSSpec) - if fss: - options['dir'] = fss - elif n == HELP_ITEM and Help: - onoff = Help.HMGetBalloons() - Help.HMSetBalloons(not onoff) - if n == OPTIONS_ITEM: - noptions = options - for k in options.keys(): - noptions[k] = options[k] - noptions = optinteract(noptions) - if noptions: - options = noptions - data = path_ctl.GetControlData(Controls.kControlEditTextPart, Controls.kControlEditTextTextTag) - tmp = string.splitfields(data, '\r') - newpath = [] - for i in tmp: - if i: - newpath.append(i) - options['path'] = newpath - return options - - -def edit_preferences(): - handler = pythonprefs.PythonOptions() - options = handler.load() - if options['noargs']: - EasyDialogs.Message('Warning: system-wide sys.argv processing is off.\nIf you dropped an applet I have not seen it.') - result = interact(options, 'System-wide preferences') - if result: - handler.save(result) - -def edit_applet(name): - handler = pythonprefs.AppletOptions(name) - result = interact(handler.load(), os.path.split(name)[1]) - if result: - handler.save(result) - -def main(): - macresource.need('DLOG', DIALOG_ID, 'EditPythonPrefs.rsrc') - - MacOS.SchedParams(1, 0) - if len(sys.argv) <= 1: - edit_preferences() - else: - for appl in sys.argv[1:]: - edit_applet(appl) - - -if __name__ == '__main__': - main() diff --git a/Mac/scripts/EditPythonPrefs.rsrc b/Mac/scripts/EditPythonPrefs.rsrc Binary files differdeleted file mode 100644 index 745cbec..0000000 --- a/Mac/scripts/EditPythonPrefs.rsrc +++ /dev/null diff --git a/Mac/scripts/EditPythonPrefsBH.bh b/Mac/scripts/EditPythonPrefsBH.bh deleted file mode 100644 index 9a5e1ac..0000000 --- a/Mac/scripts/EditPythonPrefsBH.bh +++ /dev/null @@ -1,47 +0,0 @@ -STR# 26733 -DIALOG 511 -1.1 Enter folders to include in sys.path. Use the arrow keys to navigate. -2.1 Press when done. -3.1 Press to leave settings as they are. -4.1 Select the folder that will replace $(PYTHON) in sys.path items. -7.1 Press to show a dialog that allows you to set options. -9.1 Press here to turn help balloons off again. -END-DIALOG -DIALOG 510 -1.1 Press here when satisfied with your new settings in this dialog. -2.1 Press here when you're not satisfied with your new settings. -3.1 Turn this item on to get the standard >>> prompt after a script terminates. -3.3 Turn this item off to have the interpreter terminate when a script terminates. -4.1 Turn this option on to get feedback on where modules are found and what their type is. -4.3 Turn this option off to stop import feedback. -5.1 Turn this option on to strip LINO instructions from Python bytecode. Gives a slight speedup. -5.3 Turn this option off to include LINO instructions in the bytecode. This enables line numbers in traceback printouts. -6.1 Turn this on to show output byte-by-byte as it is produced. Slows things down. -6.3 Turn this off to show output on a line-by-line basis, or when input is requested. -7.1 Print gibberish only Guido understands. -7.3 Stop printing gibberish. -8.1 Select to warn about mixing tabs and spaces in your source. -8.3 Deselect to treat tabs as 4 spaces without warning. -9.1 Selecting this disables the site-python feature. -9.3 Deselecting this enables the site-python feature. -10.1 Select this to keep the old behaviour for macfs Standard File calls -10.3 Deselect this to auto-import macfsn which replaces macfs Standard File calls with Navigation Services wrappers -11.1 Turn this on to stop the user from asking for the startup option dialog with the option key. Use this on applets only. -11.3 Turn this off to enable the user to set options by depressing <option> while Python is starting up. -12.1 If you enable this Python will not try to build a unix-style sys.argv, leaving all AppleEvents for your script. Use this for applets only. -12.3 If you disable this Python will create a sys.argv consisting of the files dropped on the interpreter or applet. -13.1 Turn this on to refrain from showing the console window and menu bar until something is printed. Use this for applets only. -13.3 Turn this off to show the console window and menu bar immedeately upon startup. -14.1 Select this to always keep the console window open after script termination. -14.3 The console window is always kept open after script termination. -15.1 Select this to keep the console window open if there is output that you may not have had a chance to look at. -15.3 The console window stays open if there is output that you may not have had a chance to look at. -16.1 Select this to keep the console window open when a script aborts. -16.3 The console window stays open when a script aborts. -17.1 Select this to always close the console window on script termination. -17.3 The console window is always closed on script termination. -18.1 The creator code Python will create files with. Select your favourite text editor. -19.1 The type code Python will create files with. TEXT is probably best. -20.1 Press here to turn help balloons off again. -END-DIALOG -END diff --git a/Mac/scripts/EditPythonPrefsBH.prj b/Mac/scripts/EditPythonPrefsBH.prj Binary files differdeleted file mode 100644 index 6ab97a5..0000000 --- a/Mac/scripts/EditPythonPrefsBH.prj +++ /dev/null diff --git a/Mac/scripts/EditPythonPrefsBH.rsrc b/Mac/scripts/EditPythonPrefsBH.rsrc Binary files differdeleted file mode 100644 index a63db5a..0000000 --- a/Mac/scripts/EditPythonPrefsBH.rsrc +++ /dev/null diff --git a/Mac/scripts/MkDistr.py b/Mac/scripts/MkDistr.py deleted file mode 100644 index 3e2ee27..0000000 --- a/Mac/scripts/MkDistr.py +++ /dev/null @@ -1,318 +0,0 @@ -# -# Interactively decide what to distribute -# -# -# The exclude file signals files to always exclude, -# The pattern file lines are of the form -# *.c -# This excludes all files ending in .c. -# -# The include file signals files and directories to include. -# Records are of the form -# ('Tools:bgen:AE:AppleEvents.py', 'Lib:MacToolbox:AppleEvents.py') -# This includes the specified file, putting it in the given place, or -# ('Tools:bgen:AE:AppleEvents.py', None) -# This excludes the specified file. -# -from MkDistr_ui import * -import fnmatch -import re -import os -import sys -import macfs -import macostools - -DEBUG=0 - -SyntaxError='Include/exclude file syntax error' - -class Matcher: - """Include/exclude database, common code""" - - def __init__(self, filename): - self.filename = filename - self.rawdata = [] - self.parse(filename) - self.rawdata.sort() - self.rebuild() - self.modified = 0 - - def parse(self, dbfile): - try: - fp = open(dbfile) - except IOError: - return - data = fp.readlines() - fp.close() - for d in data: - d = d[:-1] - if not d or d[0] == '#': continue - pat = self.parseline(d) - self.rawdata.append(pat) - - def save(self): - fp = open(self.filename, 'w') - self.savedata(fp, self.rawdata) - self.modified = 0 - - def add(self, value): - if len(value) == 1: - value = value + ('',) - self.rawdata.append(value) - self.rebuild1(value) - self.modified = 1 - - def delete(self, value): - key = value - for i in range(len(self.rawdata)): - if self.rawdata[i][0] == key: - del self.rawdata[i] - self.unrebuild1(i, key) - self.modified = 1 - return - print 'Not found!', key - - def getall(self): - return map(lambda x: x[0], self.rawdata) - - def get(self, value): - for src, dst in self.rawdata: - if src == value: - return src, dst - print 'Not found!', value - - def is_modified(self): - return self.modified - -class IncMatcher(Matcher): - """Include filename database and matching engine""" - - def rebuild(self): - self.idict = {} - self.edict = {} - for v in self.rawdata: - self.rebuild1(v) - - def parseline(self, line): - try: - data = eval(line) - except: - raise SyntaxError, line - if type(data) <> type(()) or len(data) not in (1,2): - raise SyntaxError, line - if len(data) == 1: - data = data + ('',) - return data - - def savedata(self, fp, data): - for d in self.rawdata: - fp.write(`d`+'\n') - - def rebuild1(self, (src, dst)): - if dst == '': - dst = src - if dst == None: - self.edict[src] = None - else: - self.idict[src] = dst - - def unrebuild1(self, num, src): - if self.idict.has_key(src): - del self.idict[src] - else: - del self.edict[src] - - def match(self, patharg): - removed = [] - # First check the include directory - path = patharg - while 1: - if self.idict.has_key(path): - # We know of this path (or initial piece of path) - dstpath = self.idict[path] - # We do want it distributed. Tack on the tail. - while removed: - dstpath = os.path.join(dstpath, removed[0]) - removed = removed[1:] - # Finally, if the resultant string ends in a separator - # tack on our input filename - if dstpath[-1] == os.sep: - dir, file = os.path.split(path) - dstpath = os.path.join(dstpath, file) - if DEBUG: - print 'include', patharg, dstpath - return dstpath -## path, lastcomp = os.path.split(path) -## if not path: -## break -## removed[0:0] = [lastcomp] -## # Next check the exclude directory -## path = patharg -## while 1: - if self.edict.has_key(path): - if DEBUG: - print 'exclude', patharg, path - return '' - path, lastcomp = os.path.split(path) - if not path: - break - removed[0:0] = [lastcomp] - if DEBUG: - print 'nomatch', patharg - return None - - def checksourcetree(self): - rv = [] - for name in self.idict.keys(): - if not os.path.exists(name): - rv.append(name) - return rv - -class ExcMatcher(Matcher): - """Exclude pattern database and matching engine""" - - def rebuild(self): - self.relist = [] - for v in self.rawdata: - self.rebuild1(v) - - def parseline(self, data): - return (data, None) - - def savedata(self, fp, data): - for d in self.rawdata: - fp.write(d[0]+'\n') - - def rebuild1(self, (src, dst)): - pat = fnmatch.translate(src) - if DEBUG: - print 'PATTERN', `src`, 'REGEX', `pat` - self.relist.append(re.compile(pat)) - - def unrebuild1(self, num, src): - del self.relist[num] - - def match(self, path): - comps = os.path.split(path) - file = comps[-1] - for pat in self.relist: - if pat and pat.match(file): - if DEBUG: - print 'excmatch', file, pat - return 1 - return 0 - - -class Main: - """The main program glueing it all together""" - - def __init__(self): - InitUI() - os.chdir(sys.prefix) - if not os.path.isdir(':Mac:Distributions'): - os.mkdir(':Mac:Distributions') - self.typedist = GetType() - self.inc = IncMatcher(':Mac:Distributions:%s.include'%self.typedist) - self.exc = ExcMatcher(':Mac:Distributions:%s.exclude'%self.typedist) - self.ui = MkDistrUI(self) - self.ui.mainloop() - - def check(self): - return self.checkdir(':', 1) - - def checkdir(self, path, istop): - if DEBUG: - print 'checkdir', path - files = os.listdir(path) - rv = [] - todo = [] - for f in files: - if DEBUG: - print 'checkfile', f - if self.exc.match(f): - if DEBUG: - print 'exclude match', f - continue - fullname = os.path.join(path, f) - if DEBUG: - print 'checkpath', fullname - matchvalue = self.inc.match(fullname) - if matchvalue == None: - if os.path.isdir(fullname): - if DEBUG: - print 'do dir', fullname - todo.append(fullname) - else: - if DEBUG: - print 'include', fullname - rv.append(fullname) - elif DEBUG: - print 'badmatch', matchvalue - for d in todo: - if len(rv) > 500: - if istop: - rv.append('... and more ...') - return rv - rv = rv + self.checkdir(d, 0) - return rv - - def run(self): - missing = self.inc.checksourcetree() - if missing: - print '==== Missing source files ====' - for i in missing: - print i - print '==== Fix and retry ====' - return - destprefix = os.path.join(sys.prefix, ':Mac:Distributions:(vise)') - destprefix = os.path.join(destprefix, '%s Distribution'%self.typedist) - if not self.rundir(':', destprefix, 0): - return - self.rundir(':', destprefix, 1) - - def rundir(self, path, destprefix, doit): - files = os.listdir(path) - todo = [] - rv = 1 - for f in files: - if self.exc.match(f): - continue - fullname = os.path.join(path, f) - if os.path.isdir(fullname): - todo.append(fullname) - else: - dest = self.inc.match(fullname) - if dest == None: - print 'Not yet resolved:', fullname - rv = 0 - if dest: - if doit: - print 'COPY ', fullname - print ' -> ', os.path.join(destprefix, dest) - try: - macostools.copy(fullname, os.path.join(destprefix, dest), 1) - except: #DBG - print '*** Copy failed mysteriously, try again' - print '*** cwd', os.getcwd() #DBG - print '*** fsspec', macfs.FSSpec(fullname) #DBG - # Get rid of open files - try: - i = 1 / 0 - except: - pass - macostools.copy(fullname, os.path.join(destprefix, dest), 1) - for d in todo: - if not self.rundir(d, destprefix, doit): - rv = 0 - return rv - - def save(self): - self.inc.save() - self.exc.save() - - def is_modified(self): - return self.inc.is_modified() or self.exc.is_modified() - -if __name__ == '__main__': - Main() - diff --git a/Mac/scripts/MkDistr.rsrc b/Mac/scripts/MkDistr.rsrc Binary files differdeleted file mode 100644 index 47416d9..0000000 --- a/Mac/scripts/MkDistr.rsrc +++ /dev/null diff --git a/Mac/scripts/MkDistr_ui.py b/Mac/scripts/MkDistr_ui.py deleted file mode 100644 index ee7ace0..0000000 --- a/Mac/scripts/MkDistr_ui.py +++ /dev/null @@ -1,356 +0,0 @@ -# -# MkDistr - User Interface. -# -# Jack Jansen, CWI, August 1995 -# -# XXXX To be done (requires mods of FrameWork and toolbox interfaces too): -# - Give dialogs titles (need dlg->win conversion) -# - Place dialogs better (???) -# - <return> as <ok> -# - big box around ok button -# - window-close crashes on reopen (why?) -# - Box around lists (???) -# - Change cursor while busy (need cursor support in Qd) -# -from Carbon import Res -from Carbon import Dlg -from Carbon import Ctl -from Carbon import List -from Carbon import Win -from Carbon import Qd -from FrameWork import * -import EasyDialogs -import os -import sys -import macresource - -# Resource IDs -ID_MAIN = 514 -MAIN_LIST=1 -MAIN_MKDISTR=2 -MAIN_CHECK=3 -MAIN_INCLUDE=4 -MAIN_EXCLUDE=5 - -ID_INCWINDOW=515 -ID_EXCWINDOW=517 -INCEXC_DELETE=2 -INCEXC_CHANGE=3 -INCEXC_ADD=4 - -ID_INCLUDE=512 -ID_EXCLUDE=513 -DLG_OK=1 # Include for include, exclude for exclude -DLG_CANCEL=2 -DLG_SRCPATH=3 -DLG_DSTPATH=4 # include dialog only -DLG_EXCLUDE=5 # Exclude, include dialog only - -ID_DTYPE=516 -DTYPE_EXIST=1 -DTYPE_NEW=2 -DTYPE_CANCEL=3 - -class EditDialogWindow(DialogWindow): - """Include/exclude editor (modeless dialog window)""" - - def open(self, id, (src, dst), callback, cancelrv): - self.id = id - self.callback = callback - self.cancelrv = cancelrv - DialogWindow.open(self, id) - tp, h, rect = self.dlg.GetDialogItem(DLG_SRCPATH) - Dlg.SetDialogItemText(h, src) - self.dlg.SetDialogDefaultItem(DLG_OK) - self.dlg.SetDialogCancelItem(DLG_CANCEL) - if id == ID_INCLUDE: - tp, h, rect = self.dlg.GetDialogItem(DLG_DSTPATH) - if dst == None: - dst = '' - Dlg.SetDialogItemText(h, dst) - self.dlg.DrawDialog() - - def do_itemhit(self, item, event): - if item in (DLG_OK, DLG_CANCEL, DLG_EXCLUDE): - self.done(item) - # else it is not interesting - - def done(self, item): - tp, h, rect = self.dlg.GetDialogItem(DLG_SRCPATH) - src = Dlg.GetDialogItemText(h) - if item == DLG_OK: - if self.id == ID_INCLUDE: - tp, h, rect = self.dlg.GetDialogItem(DLG_DSTPATH) - dst = Dlg.GetDialogItemText(h) - rv = (src, dst) - else: - rv = (src, None) - elif item == DLG_EXCLUDE: - rv = (src, None) - else: - rv = self.cancelrv - self.close() - self.callback((item in (DLG_OK, DLG_EXCLUDE)), rv) - -class ListWindow(DialogWindow): - """A dialog window containing a list as its main item""" - - def open(self, id, contents): - self.id = id - DialogWindow.open(self, id) - Qd.SetPort(self.wid) - tp, h, rect = self.dlg.GetDialogItem(MAIN_LIST) - self.listrect = rect - rect2 = rect[0]+1, rect[1]+1, rect[2]-16, rect[3]-16 # Scroll bar space - self.list = List.LNew(rect2, (0, 0, 1, len(contents)), (0,0), 0, self.wid, - 0, 1, 1, 1) - self.setlist(contents) - - def setlist(self, contents): - self.list.LDelRow(0, 0) - self.list.LSetDrawingMode(0) - if contents: - self.list.LAddRow(len(contents), 0) - for i in range(len(contents)): - self.list.LSetCell(contents[i], (0, i)) - self.list.LSetDrawingMode(1) - ##self.list.LUpdate(self.wid.GetWindowPort().visRgn) - self.wid.InvalWindowRect(self.listrect) - - def additem(self, item): - where = self.list.LAddRow(1, 0) - self.list.LSetCell(item, (0, where)) - - def delgetitem(self, item): - data = self.list.LGetCell(1000, (0, item)) - self.list.LDelRow(1, item) - return data - - def do_listhit(self, event): - (what, message, when, where, modifiers) = event - Qd.SetPort(self.wid) - where = Qd.GlobalToLocal(where) - if self.list.LClick(where, modifiers): - self.do_dclick(self.delgetselection()) - - def delgetselection(self): - items = [] - point = (0,0) - while 1: - ok, point = self.list.LGetSelect(1, point) - if not ok: - break - items.append(point[1]) - point = point[0], point[1]+1 - values = [] - items.reverse() - for i in items: - values.append(self.delgetitem(i)) - return values - - def do_rawupdate(self, window, event): - Qd.SetPort(window) - Qd.FrameRect(self.listrect) - self.list.LUpdate(self.wid.GetWindowPort().visRgn) - - def do_close(self): - self.close() - - def close(self): - del self.list - DialogWindow.close(self) - - def mycb_add(self, ok, item): - if item: - self.additem(item[0]) - self.cb_add(item) - -class MainListWindow(ListWindow): - """The main window""" - - def open(self, id, cb_check, cb_run, cb_add): - ListWindow.open(self, id, []) - self.dlg.SetDialogDefaultItem(MAIN_INCLUDE) - self.cb_run = cb_run - self.cb_check = cb_check - self.cb_add = cb_add - setwatchcursor() - list = self.cb_check() - self.setlist(list) - setarrowcursor() - - def do_itemhit(self, item, event): - if item == MAIN_LIST: - self.do_listhit(event) - if item == MAIN_MKDISTR: - setwatchcursor() - self.cb_run() - setarrowcursor() - if item == MAIN_CHECK: - setwatchcursor() - list = self.cb_check() - self.setlist(list) - setarrowcursor() - if item == MAIN_INCLUDE: - self.do_dclick(self.delgetselection()) - if item == MAIN_EXCLUDE: - for i in self.delgetselection(): - self.cb_add((i, None)) - - def do_dclick(self, list): - if not list: - list = [''] - for l in list: - w = EditDialogWindow(self.parent) - w.open(ID_INCLUDE, (l, None), self.mycb_add, None) - - def mycb_add(self, ok, item): - if item: - self.cb_add(item) - -class IncListWindow(ListWindow): - """An include/exclude window""" - def open(self, id, editid, contents, cb_add, cb_del, cb_get): - ListWindow.open(self, id, contents) - self.dlg.SetDialogDefaultItem(INCEXC_CHANGE) - self.editid = editid - self.cb_add = cb_add - self.cb_del = cb_del - self.cb_get = cb_get - - def do_itemhit(self, item, event): - if item == MAIN_LIST: - self.do_listhit(event) - if item == INCEXC_DELETE: - old = self.delgetselection() - for i in old: - self.cb_del(i) - if item == INCEXC_CHANGE: - self.do_dclick(self.delgetselection()) - if item == INCEXC_ADD: - w = EditDialogWindow(self.parent) - w.open(self.editid, ('', None), self.mycb_add, None) - - def do_dclick(self, list): - if not list: - list = [''] - for l in list: - old = self.cb_get(l) - self.cb_del(l) - w = EditDialogWindow(self.parent) - w.open(self.editid, old, self.mycb_add, old) - -class MkDistrUI(Application): - def __init__(self, main): - self.main = main - Application.__init__(self) - self.mwin = MainListWindow(self) - self.mwin.open(ID_MAIN, self.main.check, self.main.run, self.main.inc.add) - self.iwin = None - self.ewin = None - - def makeusermenus(self): - self.filemenu = m = Menu(self.menubar, "File") - self.includeitem = MenuItem(m, "Show Include window", "", self.showinc) - self.excludeitem = MenuItem(m, "Show Exclude window", "", self.showexc) - self.saveitem = MenuItem(m, "Save databases", "S", self.save) - self.quititem = MenuItem(m, "Quit", "Q", self.quit) - - def quit(self, *args): - if self.main.is_modified(): - rv = EasyDialogs.AskYesNoCancel('Database modified. Save?', -1) - if rv == -1: - return - if rv == 1: - self.main.save() - self._quit() - - def save(self, *args): - self.main.save() - - def showinc(self, *args): - if self.iwin: - if self._windows.has_key(self.iwin): - self.iwin.close() - del self.iwin - self.iwin = IncListWindow(self) - self.iwin.open(ID_INCWINDOW, ID_INCLUDE, self.main.inc.getall(), self.main.inc.add, - self.main.inc.delete, self.main.inc.get) - - def showexc(self, *args): - if self.ewin: - if self._windows.has_key(self.ewin): - self.ewin.close() - del self.ewin - self.ewin = IncListWindow(self) - self.ewin.open(ID_EXCWINDOW, ID_EXCLUDE, self.main.exc.getall(), self.main.exc.add, - self.main.exc.delete, self.main.exc.get) - - def do_about(self, id, item, window, event): - EasyDialogs.Message("Test the MkDistr user interface.") - -def GetType(): - """Ask user for distribution type""" - while 1: - d = Dlg.GetNewDialog(ID_DTYPE, -1) - d.SetDialogDefaultItem(DTYPE_EXIST) - d.SetDialogCancelItem(DTYPE_CANCEL) - while 1: - rv = ModalDialog(None) - if rv in (DTYPE_EXIST, DTYPE_NEW, DTYPE_CANCEL): - break - del d - if rv == DTYPE_CANCEL: - sys.exit(0) - if rv == DTYPE_EXIST: - path = EasyDialogs.AskFileForOpen() - if not path: - sys.exit(0) - basename = os.path.split(path)[-1] - if basename[-8:] <> '.include': - EasyDialogs.Message('That is not a distribution include file') - else: - return basename[:-8] - else: - name = EasyDialogs.AskString('Distribution name:') - if name: - return name - sys.exit(0) - -def InitUI(): - """Initialize stuff needed by UI (a resource file)""" - macresource.need('DLOG', ID_MAIN, 'MkDistr.rsrc', modname=__name__) - -class _testerhelp: - def __init__(self, which): - self.which = which - - def get(self): - return [self.which+'-one', self.which+'-two'] - - def add(self, value): - if value: - print 'ADD', self.which, value - - def delete(self, value): - print 'DEL', self.which, value - -class _test: - def __init__(self): - import sys - InitUI() - self.inc = _testerhelp('include') - self.exc = _testerhelp('exclude') - self.ui = MkDistrUI(self) - self.ui.mainloop() - sys.exit(1) - - def check(self): - print 'CHECK' - return ['rv1', 'rv2'] - - def run(self): - print 'RUN' - -if __name__ == '__main__': - _test() diff --git a/Mac/scripts/buildappbundle.py b/Mac/scripts/buildappbundle.py deleted file mode 100755 index 281c6fe..0000000 --- a/Mac/scripts/buildappbundle.py +++ /dev/null @@ -1,104 +0,0 @@ -#! /usr/bin/env python - -# XXX This will be replaced by a main program in Mac/Lib/bundlebuilder.py, -# but for now this is kept so Jack won't need to change his scripts... - - -"""\ -buildappbundle creates an application bundle -Usage: - buildappbundle [options] executable -Options: - --output o Output file; default executable with .app appended, short -o - --link Symlink the executable instead of copying it, short -l - --plist file Plist file (default: generate one), short -p - --nib file Main nib file or lproj folder for Cocoa program, short -n - --resource r Extra resource file to be copied to Resources, short -r - --creator c 4-char creator code (default: '????'), short -c - --verbose increase verbosity level (default: quiet), short -v - --help This message, short -? or -h -""" - - -import sys -import os -import getopt -from bundlebuilder import AppBuilder -from plistlib import Plist - - -def usage(): - print __doc__ - sys.exit(1) - - -def main(): - output = None - symlink = 0 - creator = "????" - plist = None - nib = None - resources = [] - verbosity = 0 - SHORTOPTS = "o:ln:r:p:c:v?h" - LONGOPTS=("output=", "link", "nib=", "resource=", "plist=", "creator=", "help", - "verbose") - try: - options, args = getopt.getopt(sys.argv[1:], SHORTOPTS, LONGOPTS) - except getopt.error: - usage() - if len(args) != 1: - usage() - executable = args[0] - for opt, arg in options: - if opt in ('-o', '--output'): - output = arg - elif opt in ('-l', '--link'): - symlink = 1 - elif opt in ('-n', '--nib'): - nib = arg - elif opt in ('-r', '--resource'): - resources.append(arg) - elif opt in ('-c', '--creator'): - creator = arg - elif opt in ('-p', '--plist'): - plist = arg - elif opt in ('-v', '--verbose'): - verbosity += 1 - elif opt in ('-?', '-h', '--help'): - usage() - if output is not None: - builddir, bundlename = os.path.split(output) - else: - builddir = os.curdir - bundlename = None # will be derived from executable - if plist is not None: - plist = Plist.fromFile(plist) - - builder = AppBuilder(name=bundlename, executable=executable, - builddir=builddir, creator=creator, plist=plist, resources=resources, - symlink_exec=symlink, verbosity=verbosity) - - if nib is not None: - resources.append(nib) - nibname, ext = os.path.splitext(os.path.basename(nib)) - if ext == '.lproj': - # Special case: if the main nib is a .lproj we assum a directory - # and use the first nib from there. XXX Look: an arbitrary pick ;-) - files = os.listdir(nib) - for f in files: - if f[-4:] == '.nib': - nibname = os.path.split(f)[1][:-4] - break - else: - nibname = "" - if nibname: - builder.plist.NSMainNibFile = nibname - if not hasattr(builder.plist, "NSPrincipalClass"): - builder.plist.NSPrincipalClass = "NSApplication" - builder.setup() - builder.build() - - -if __name__ == '__main__': - main() diff --git a/Mac/scripts/crlf.py b/Mac/scripts/crlf.py deleted file mode 100755 index 6506cdc..0000000 --- a/Mac/scripts/crlf.py +++ /dev/null @@ -1,29 +0,0 @@ -#! /usr/local/bin/python - -# Replace \r by \n -- useful after transferring files from the Mac... -# Run this on UNIX. -# Usage: crlf.py file ... - -import sys -import os -import string - -def main(): - args = sys.argv[1:] - if not args: - print 'usage:', sys.argv[0], 'file ...' - sys.exit(2) - for file in args: - print file, '...' - data = open(file, 'r').read() - lines = string.splitfields(data, '\r') - newdata = string.joinfields(lines, '\n') - if newdata != data: - print 'rewriting...' - os.rename(file, file + '~') - open(file, 'w').write(newdata) - print 'done.' - else: - print 'no change.' - -main() diff --git a/Mac/scripts/findgremlins.py b/Mac/scripts/findgremlins.py deleted file mode 100644 index 3569c77..0000000 --- a/Mac/scripts/findgremlins.py +++ /dev/null @@ -1,57 +0,0 @@ -"""findgremlins - Search through a folder and subfolders for -text files that have characters with bit 8 set, and print -the filename and a bit of context. - -By Just, with a little glue by Jack""" - -import EasyDialogs -import MacOS -import re -import os -import string -import sys - -xpat = re.compile(r"[\200-\377]") - -def walk(top, recurse=1): - if os.path.isdir(top): - if recurse: - for name in os.listdir(top): - path = os.path.join(top, name) - walk(path) - else: - cr, tp = MacOS.GetCreatorAndType(top) - if tp in ('TEXT', '\0\0\0\0') and top[-4:] <> ".hqx": - data = open(top).read() - badcount = 0 - for ch in data[:256]: - if ord(ch) == 0 or ord(ch) >= 0200: - badcount = badcount + 1 - if badcount > 16: - print `top`, 'appears to be a binary file' - return - pos = 0 - gotone = 0 - while 1: - m = xpat.search(data, pos) - if m is None: - break - if not gotone: - print `top` - gotone = 1 - [(i, j)] = m.regs - print " ", string.replace(data[i-15:j+15], '\n', ' ') - pos = j - -def main(): - if sys.argv[1:]: - for pathname in sys.argv[1:]: - walk(pathname) - else: - pathname = EasyDialogs.AskFolder() - if pathname: - walk(pathname) - -if __name__ == '__main__': - main() - diff --git a/Mac/scripts/fixfiletypes.py b/Mac/scripts/fixfiletypes.py deleted file mode 100644 index bbbf807..0000000 --- a/Mac/scripts/fixfiletypes.py +++ /dev/null @@ -1,56 +0,0 @@ -# -# Fixfiletypes - Set mac filetypes to something sensible, -# recursively down a directory tree. -# -# It will only touch extensions it feels pretty sure about. -# This script is useful after copying files from unix. -# -# Jack Jansen, CWI, 1995. -# -import os -import EasyDialogs -import sys -import macostools -import MacOS - -list = [ - ('.py', 'Pyth', 'TEXT'), - ('.pyc', 'Pyth', 'PYC '), - ('.c', 'CWIE', 'TEXT'), - ('.h', 'CWIE', 'TEXT'), - ('.as', 'ToyS', 'TEXT'), - ('.hqx', 'BnHq', 'TEXT'), - ('.cmif', 'CMIF', 'TEXT'), - ('.cmc', 'CMIF', 'CMC '), - ('.aiff', 'SCPL', 'AIFF'), - ('.mpg', 'mMPG', 'MPEG'), -] - -def walktree(name, change): - if os.path.isfile(name): - for ext, cr, tp in list: - if name[-len(ext):] == ext: - curcrtp = MacOS.GetCreatorAndType(name) - if curcrtp <> (cr, tp): - if change: - MacOS.SetCreatorAndType(name, cr, tp) - macostools.touched(fs) - print 'Fixed ', name - else: - print 'Wrong', curcrtp, 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): - pathname = EasyDialogs.AskFolder(message='Folder to search:') - if not pathname: - sys.exit(0) - walktree(pathname, change) - -if __name__ == '__main__': - run(0) - - diff --git a/Mac/scripts/fullbuild.py b/Mac/scripts/fullbuild.py deleted file mode 100644 index 28ad59f..0000000 --- a/Mac/scripts/fullbuild.py +++ /dev/null @@ -1,434 +0,0 @@ -# -# fullbuild creates everything that needs to be created before a -# distribution can be made, and puts it all in the right place. -# -# It expects the projects to be in the places where Jack likes them: -# in directories named like 'build.mac'. That is fixable, -# however. -# -# NOTE: You should proably make a copy of python with which to execute this -# script, rebuilding running programs does not work... - -CARBON_ONLY = 1 - -MACBUILDNO=":Mac:Include:macbuildno.h" - -import os -import sys -import Carbon.File -import MacOS -import EasyDialogs -import re -import string -import genpluginprojects -import macresource - -import aetools -from Carbon import AppleEvents - -import CodeWarrior - -from Carbon import Res -from Carbon import Dlg - -import buildtools -import cfmfile - -# Dialog resource. Note that the item numbers should correspond -# to those in the DITL resource. Also note that the order is important: -# things are built in this order, so there should be no forward dependencies. -DIALOG_ID = 512 - -I_OK=1 -I_CANCEL=2 -# label 3 -I_PPC_EXTLIBS=4 -I_GEN_PROJECTS=5 -I_GEN_PROJECTS_FORCE=6 -I_GEN_IMGPROJECTS=7 -I_GEN_IMGPROJECTS_FORCE=8 -I_INC_BUILDNO=9 -# label 10 -I_PPC_CORE=11 -I_PPC_PLUGINS=12 -I_PPC_EXTENSIONS=13 -# label 14 -I_CARBON_CORE=15 -I_CARBON_PLUGINS=16 -I_CARBON_EXTENSIONS=17 -I_INTERPRETER=18 -# label 19 -I_PPC_FULL=20 -I_PPC_SMALL=21 -# label 22 -I_CARBON_FULL=23 -I_CARBON_SMALL=24 -# label 25 -I_APPLETS=26 - -N_BUTTONS=27 - -if CARBON_ONLY: - BUTTONS_DISABLE = [ - I_PPC_EXTLIBS, - I_PPC_CORE, - I_PPC_PLUGINS, - I_PPC_EXTENSIONS, - I_INTERPRETER, - I_PPC_FULL, - I_PPC_SMALL, - ] -else: - BUTTONS_DISABLE = [] - -RUNNING=[] - -def buildmwproject(top, creator, projects): - """Build projects with an MW compiler""" - mgr = CodeWarrior.CodeWarrior(creator, start=1) - mgr.send_timeout = AppleEvents.kNoTimeOut - - failed = [] - for file in projects: - if type(file) == type(()): - file, target = file - else: - target = '' - file = os.path.join(top, file) - try: - fss = Carbon.File.FSSpec(file) - except MacOS.Error: - print '** file not found:', file - continue - print 'Building', file, target - try: - mgr.open(fss) - except aetools.Error, detail: - print '**', detail, file - continue - if target: - try: - mgr.Set_Current_Target(target) - except aetools.Error, arg: - print '**', file, target, 'Cannot select:', arg - try: - mgr.Make_Project() - except aetools.Error, arg: - print '**', file, target, 'Failed:', arg - failed.append(fss) - mgr.Close_Project() - if failed: - print 'Open failed projects and exit?', - rv = sys.stdin.readline() - if rv[0] in ('y', 'Y'): - for fss in failed: - mgr.open(fss) - sys.exit(0) -## mgr.quit() - -def buildapplet(top, dummy, list): - """Create python applets""" - for src, dst, tmpl in list: - template = buildtools.findtemplate(tmpl) - if src[-3:] != '.py': - raise 'Should end in .py', src - base = os.path.basename(src) - src = os.path.join(top, src) - dst = os.path.join(top, dst) - try: - os.unlink(dst) - except os.error: - pass - print 'Building applet', dst - try: - buildtools.process(template, src, dst, 1) - except buildtools.BuildError, arg: - print '**', dst, arg - -def buildprojectfile(top, arg, list): - """Create CodeWarrior project files with a script""" - for folder, module, routine in list: - print "Generating project files with", module - sys.path.insert(0, os.path.join(top, folder)) - m = __import__(module) - r = getattr(m, routine) - r(arg) - del sys.path[0] - -def buildfat(top, dummy, list): - """Build fat binaries""" - for dst, src1, src2 in list: - dst = os.path.join(top, dst) - src1 = os.path.join(top, src1) - src2 = os.path.join(top, src2) - print 'Building fat binary', dst - cfmfile.mergecfmfiles((src1, src2), dst) - -def buildcopy(top, dummy, list): - import macostools - for src, dst in list: - src = os.path.join(top, src) - dst = os.path.join(top, dst) - macostools.copy(src, dst, forcetype="APPL") - -def buildsetup(top, dummy, list): - print 'Building extensions with setup.py ', ' '.join(list) - argv = ['setup.py'] + list[:] - save_argv = sys.argv - sys.argv = argv - sys.path.insert(0, top) - m = __import__('setup') - r = getattr(m, 'main') - r() - del sys.path[0] - sys.argv = save_argv - -def buildcarbonplugins(top, dummy1, dummy2): -## XXXX Need to convert pathnames, I guess, and adapt distutils Mac-specific -## code to not call GetArgv if not needed. -## buildsetup(top, None, [ -## '--dry_run', -## 'install', -## '--prefix=%s' % sys.prefix, -## '--install-scripts=%s' % os.path.join(sys.prefix, 'Scripts'), -## '--install-platlib=%s' % os.path.join(sys.prefix, 'Lib', 'lib-dynload') -## ]) - buildmwproject(top, "CWIE", [ - (":Mac:Build:_csv.carbon.mcp", "_csv.carbon"), - (":Mac:Build:_weakref.carbon.mcp", "_weakref.carbon"), - (":Mac:Build:_symtable.carbon.mcp", "_symtable.carbon"), - (":Mac:Build:_testcapi.carbon.mcp", "_testcapi.carbon"), - (":Mac:Build:_hotshot.carbon.mcp", "_hotshot.carbon"), - (":Mac:Build:xx.carbon.mcp", "xx.carbon"), - (":Mac:Build:xxsubtype.carbon.mcp", "xxsubtype.carbon"), - (":Mac:Build:pyexpat.carbon.mcp", "pyexpat.carbon"), - (":Mac:Build:calldll.carbon.mcp", "calldll.carbon"), - (":Mac:Build:datetime.carbon.mcp", "datetime.carbon"), - (":Mac:Build:gdbm.carbon.mcp", "gdbm.carbon"), - (":Mac:Build:icglue.carbon.mcp", "icglue.carbon"), - (":Mac:Build:waste.carbon.mcp", "waste.carbon"), - (":Mac:Build:zlib.carbon.mcp", "zlib.carbon"), - (":Mac:Build:hfsplus.carbon.mcp", "hfsplus.carbon"), - (":Mac:Build:ColorPicker.carbon.mcp", "ColorPicker.carbon"), - (":Mac:Build:_AE.carbon.mcp", "_AE.carbon"), - (":Mac:Build:_AH.carbon.mcp", "_AH.carbon"), - (":Mac:Build:_App.carbon.mcp", "_App.carbon"), - (":Mac:Build:_CF.carbon.mcp", "_CF.carbon"), - (":Mac:Build:_CG.carbon.mcp", "_CG.carbon"), - (":Mac:Build:_CarbonEvt.carbon.mcp", "_CarbonEvt.carbon"), - (":Mac:Build:_Cm.carbon.mcp", "_Cm.carbon"), - (":Mac:Build:_Ctl.carbon.mcp", "_Ctl.carbon"), - (":Mac:Build:_Dlg.carbon.mcp", "_Dlg.carbon"), - (":Mac:Build:_Drag.carbon.mcp", "_Drag.carbon"), - (":Mac:Build:_Evt.carbon.mcp", "_Evt.carbon"), - (":Mac:Build:_File.carbon.mcp", "_File.carbon"), - (":Mac:Build:_Fm.carbon.mcp", "_Fm.carbon"), - (":Mac:Build:_Folder.carbon.mcp", "_Folder.carbon"), - (":Mac:Build:_Help.carbon.mcp", "_Help.carbon"), - (":Mac:Build:_IBCarbon.carbon.mcp", "_IBCarbon.carbon"), - (":Mac:Build:_Icn.carbon.mcp", "_Icn.carbon"), - (":Mac:Build:_List.carbon.mcp", "_List.carbon"), - (":Mac:Build:_Menu.carbon.mcp", "_Menu.carbon"), - (":Mac:Build:_Mlte.carbon.mcp", "_Mlte.carbon"), - (":Mac:Build:_Qd.carbon.mcp", "_Qd.carbon"), - (":Mac:Build:_Qdoffs.carbon.mcp", "_Qdoffs.carbon"), - (":Mac:Build:_Qt.carbon.mcp", "_Qt.carbon"), - (":Mac:Build:_Res.carbon.mcp", "_Res.carbon"), - (":Mac:Build:_Scrap.carbon.mcp", "_Scrap.carbon"), - (":Mac:Build:_Snd.carbon.mcp", "_Snd.carbon"), - (":Mac:Build:_Sndihooks.carbon.mcp", "_Sndihooks.carbon"), - (":Mac:Build:_TE.carbon.mcp", "_TE.carbon"), - (":Mac:Build:_Win.carbon.mcp", "_Win.carbon"), - ]) - -def handle_dialog(filename): - """Handle selection dialog, return list of selected items""" - d = Dlg.GetNewDialog(DIALOG_ID, -1) - d.SetDialogDefaultItem(I_OK) - d.SetDialogCancelItem(I_CANCEL) - results = [0]*N_BUTTONS - for n in BUTTONS_DISABLE: - ctl = d.GetDialogItemAsControl(n) - ctl.HideControl() - while 1: - n = Dlg.ModalDialog(None) - if n == I_OK: - break - if n == I_CANCEL: - return [] - if n == I_INC_BUILDNO: - incbuildno(filename) - continue - if n < len(results): - results[n] = (not results[n]) - ctl = d.GetDialogItemAsControl(n) - ctl.SetControlValue(results[n]) - rv = [] - for i in range(len(results)): - if results[i]: - rv.append(i) - return rv - -# -# The build instructions. Entries are (routine, arg, list-of-files) -# XXXX We could also include the builds for stdwin and such here... -BUILD_DICT = { -I_GEN_PROJECTS : (buildprojectfile, 0, [ - (":Mac:scripts", "genpluginprojects", "genallprojects") - ]), - -I_GEN_PROJECTS_FORCE : (buildprojectfile, 1, [ - (":Mac:scripts", "genpluginprojects", "genallprojects") - ]), - -I_GEN_IMGPROJECTS : (buildprojectfile, 0, [ - (":Extensions:img:Mac", "genimgprojects", "genallprojects") - ]), - -I_GEN_IMGPROJECTS_FORCE : (buildprojectfile, 1, [ - (":Extensions:img:Mac", "genimgprojects", "genallprojects") - ]), - -I_INTERPRETER : (buildcopy, None, [ - ("PythonInterpreterCarbon", "PythonInterpreter"), - ]), - -I_PPC_CORE : (buildmwproject, "CWIE", [ - (":Mac:Build:PythonCore.mcp", "PythonCore"), - (":Mac:Build:PythonInterpreter.mcp", "PythonInterpreterClassic"), - ]), - -I_CARBON_CORE : (buildmwproject, "CWIE", [ - (":Mac:Build:PythonCore.mcp", "PythonCoreCarbon"), - (":Mac:Build:PythonInterpreter.mcp", "PythonInterpreterCarbon"), - ]), - -I_PPC_EXTLIBS : (buildmwproject, "CWIE", [ -## (":Mac:Build:buildlibs.mcp", "buildlibs ppc plus tcl/tk"), - (":Mac:Build:buildlibs.mcp", "buildlibs ppc"), - ]), - -I_PPC_PLUGINS : (buildmwproject, "CWIE", [ - (":Mac:Build:_weakref.mcp", "_weakref.ppc"), - (":Mac:Build:_symtable.mcp", "_symtable.ppc"), - (":Mac:Build:_testcapi.mcp", "_testcapi.ppc"), - (":Mac:Build:_hotshot.mcp", "_hotshot.ppc"), - (":Mac:Build:xx.mcp", "xx.ppc"), - (":Mac:Build:xxsubtype.mcp", "xxsubtype.ppc"), - (":Mac:Build:pyexpat.mcp", "pyexpat.ppc"), - (":Mac:Build:calldll.mcp", "calldll.ppc"), - (":Mac:Build:ctb.mcp", "ctb.ppc"), - (":Mac:Build:gdbm.mcp", "gdbm.ppc"), - (":Mac:Build:icglue.mcp", "icglue.ppc"), - (":Mac:Build:macspeech.mcp", "macspeech.ppc"), - (":Mac:Build:waste.mcp", "waste.ppc"), - (":Mac:Build:zlib.mcp", "zlib.ppc"), -## (":Mac:Build:_tkinter.mcp", "_tkinter.ppc"), - (":Extensions:Imaging:_tkinter.mcp", "_tkinter.ppc"), - (":Mac:Build:ColorPicker.mcp", "ColorPicker.ppc"), - (":Mac:Build:Printing.mcp", "Printing.ppc"), - (":Mac:Build:_AE.mcp", "_AE.ppc"), - (":Mac:Build:_App.mcp", "_App.ppc"), - (":Mac:Build:_Cm.mcp", "_Cm.ppc"), - (":Mac:Build:_Ctl.mcp", "_Ctl.ppc"), - (":Mac:Build:_Dlg.mcp", "_Dlg.ppc"), - (":Mac:Build:_Drag.mcp", "_Drag.ppc"), - (":Mac:Build:_Evt.mcp", "_Evt.ppc"), - (":Mac:Build:_Fm.mcp", "_Fm.ppc"), - (":Mac:Build:_Help.mcp", "_Help.ppc"), - (":Mac:Build:_Icn.mcp", "_Icn.ppc"), - (":Mac:Build:_List.mcp", "_List.ppc"), - (":Mac:Build:_Menu.mcp", "_Menu.ppc"), - (":Mac:Build:_Mlte.mcp", "_Mlte.ppc"), - (":Mac:Build:_Qd.mcp", "_Qd.ppc"), - (":Mac:Build:_Qdoffs.mcp", "_Qdoffs.ppc"), - (":Mac:Build:_Qt.mcp", "_Qt.ppc"), - (":Mac:Build:_Res.mcp", "_Res.ppc"), - (":Mac:Build:_Scrap.mcp", "_Scrap.ppc"), - (":Mac:Build:_Snd.mcp", "_Snd.ppc"), - (":Mac:Build:_Sndihooks.mcp", "_Sndihooks.ppc"), - (":Mac:Build:_TE.mcp", "_TE.ppc"), - (":Mac:Build:_Win.mcp", "_Win.ppc"), - ]), - -I_CARBON_PLUGINS : (buildcarbonplugins, None, []), - -I_PPC_FULL : (buildmwproject, "CWIE", [ - (":Mac:Build:PythonStandalone.mcp", "PythonStandalone"), - ]), - -I_PPC_SMALL : (buildmwproject, "CWIE", [ - (":Mac:Build:PythonStandSmall.mcp", "PythonStandSmall"), - ]), - -I_CARBON_FULL : (buildmwproject, "CWIE", [ - (":Mac:Build:PythonStandalone.mcp", "PythonCarbonStandalone"), - ]), - -I_CARBON_SMALL : (buildmwproject, "CWIE", [ - (":Mac:Build:PythonStandSmall.mcp", "PythonStandSmallCarbon"), - ]), - -I_PPC_EXTENSIONS : (buildmwproject, "CWIE", [ - (":Extensions:Imaging:_imaging.mcp", "_imaging.ppc"), -## (":Extensions:Imaging:_tkinter.mcp", "_tkinter.ppc"), - (":Extensions:img:Mac:imgmodules.mcp", "imgmodules.ppc"), - ]), - -I_CARBON_EXTENSIONS : (buildmwproject, "CWIE", [ - (":Extensions:Imaging:_imaging.mcp", "_imaging.carbon"), -## (":Extensions:Imaging:_tkinter.mcp", "_tkinter.carbon"), - (":Extensions:img:Mac:imgmodules.mcp", "imgmodules.carbon"), - ]), - -I_APPLETS : (buildapplet, None, [ - (":Mac:scripts:EditPythonPrefs.py", "EditPythonPrefs", None), - (":Mac:scripts:BuildApplet.py", "BuildApplet", None), - (":Mac:scripts:BuildApplication.py", "BuildApplication", None), - (":Mac:scripts:ConfigurePython.py", "ConfigurePython", None), -## (":Mac:scripts:ConfigurePython.py", "ConfigurePythonCarbon", "PythonInterpreterCarbon"), -## (":Mac:scripts:ConfigurePython.py", "ConfigurePythonClassic", "PythonInterpreterClassic"), - (":Mac:Tools:IDE:PythonIDE.py", "Python IDE", None), - (":Mac:Tools:CGI:PythonCGISlave.py", ":Mac:Tools:CGI:PythonCGISlave", None), - (":Mac:Tools:CGI:BuildCGIApplet.py", ":Mac:Tools:CGI:BuildCGIApplet", None), - ]), -} - -def incbuildno(filename): - fp = open(filename) - line = fp.readline() - fp.close() - - pat = re.compile('#define BUILD ([0-9]+)') - m = pat.search(line) - if not m or not m.group(1): - raise 'Incorrect macbuildno.h line', line - buildno = m.group(1) - new = string.atoi(buildno) + 1 - fp = open(filename, 'w') - fp.write('#define BUILD %d\n'%new) - fp.close() - -def main(): - macresource.need('DLOG', DIALOG_ID, 'fullbuild.rsrc') - dir = EasyDialogs.AskFolder(message='Python source folder:') - if not dir: - sys.exit(0) - # Set genpluginprojects to use this folder (slight hack) - genpluginprojects.PYTHONDIR = dir - - todo = handle_dialog(os.path.join(dir, MACBUILDNO)) - - instructions = [] - for i in todo: - instructions.append(BUILD_DICT[i]) - - for routine, arg, list in instructions: - routine(dir, arg, list) - - if todo: - print "All done!" - -if __name__ == '__main__': - main() - diff --git a/Mac/scripts/fullbuild.rsrc b/Mac/scripts/fullbuild.rsrc Binary files differdeleted file mode 100644 index 68d3175..0000000 --- a/Mac/scripts/fullbuild.rsrc +++ /dev/null diff --git a/Mac/scripts/genpluginprojects.py b/Mac/scripts/genpluginprojects.py deleted file mode 100644 index 929d2c4..0000000 --- a/Mac/scripts/genpluginprojects.py +++ /dev/null @@ -1,181 +0,0 @@ -import mkcwproject -import sys -import os -import string - -PYTHONDIR = sys.prefix -PROJECTDIR = os.path.join(PYTHONDIR, ":Mac:Build") -MODULEDIRS = [ # Relative to projectdirs - "::Modules:%s", - "::Modules", - ":::Modules", -] - -# Global variable to control forced rebuild (otherwise the project is only rebuilt -# when it is changed) -FORCEREBUILD=0 - -def relpath(base, path): - """Turn abs path into path relative to another. Only works for 2 abs paths - both pointing to folders""" - if not os.path.isabs(base) or not os.path.isabs(path): - raise 'Absolute paths only' - if base[-1] == ':': - base = base[:-1] - basefields = string.split(base, os.sep) - pathfields = string.split(path, os.sep) - commonfields = len(os.path.commonprefix((basefields, pathfields))) - basefields = basefields[commonfields:] - pathfields = pathfields[commonfields:] - pathfields = ['']*(len(basefields)+1) + pathfields - rv = string.join(pathfields, os.sep) - return rv - -def genpluginproject(architecture, module, - project=None, projectdir=None, - sources=[], sourcedirs=[], - libraries=[], extradirs=[], - extraexportsymbols=[], outputdir=":::Lib:lib-dynload", - libraryflags=None, stdlibraryflags=None, prefixname=None, - initialize=None): - if architecture != "carbon": - raise 'Unsupported architecture: %s'%architecture - templatename = "template-%s" % architecture - targetname = "%s.%s" % (module, architecture) - dllname = "%s.%s.slb" % (module, architecture) - if not project: - project = "%s.%s.mcp"%(module, architecture) - if not projectdir: - projectdir = PROJECTDIR - if not sources: - sources = [module + 'module.c'] - if not sourcedirs: - for moduledir in MODULEDIRS: - if '%' in moduledir: - # For historical reasons an initial _ in the modulename - # is not reflected in the folder name - if module[0] == '_': - modulewithout_ = module[1:] - else: - modulewithout_ = module - moduledir = moduledir % modulewithout_ - fn = os.path.join(projectdir, os.path.join(moduledir, sources[0])) - if os.path.exists(fn): - moduledir, sourcefile = os.path.split(fn) - sourcedirs = [relpath(projectdir, moduledir)] - sources[0] = sourcefile - break - else: - print "Warning: %s: sourcefile not found: %s"%(module, sources[0]) - sourcedirs = [] - if prefixname: - pass - elif architecture == "carbon": - prefixname = "mwerks_shcarbon_pch" - else: - prefixname = "mwerks_plugin_config.h" - dict = { - "sysprefix" : relpath(projectdir, sys.prefix), - "sources" : sources, - "extrasearchdirs" : sourcedirs + extradirs, - "libraries": libraries, - "mac_outputdir" : outputdir, - "extraexportsymbols" : extraexportsymbols, - "mac_targetname" : targetname, - "mac_dllname" : dllname, - "prefixname" : prefixname, - } - if libraryflags: - dict['libraryflags'] = libraryflags - if stdlibraryflags: - dict['stdlibraryflags'] = stdlibraryflags - if initialize: - dict['initialize'] = initialize - mkcwproject.mkproject(os.path.join(projectdir, project), module, dict, - force=FORCEREBUILD, templatename=templatename) - -def genallprojects(force=0): - global FORCEREBUILD - FORCEREBUILD = force - # Standard Python modules - genpluginproject("carbon", "pyexpat", - sources=["pyexpat.c", "xmlparse.c", "xmlrole.c", "xmltok.c"], - extradirs=[":::Modules:expat"], - prefixname="mwerks_pyexpat_config.h" - ) - genpluginproject("carbon", "zlib", - libraries=["zlib.ppc.Lib"], - extradirs=["::::imglibs:zlib:mac", "::::imglibs:zlib"]) - genpluginproject("carbon", "gdbm", - libraries=["gdbm.ppc.gusi.lib"], - extradirs=["::::gdbm:mac", "::::gdbm"]) - genpluginproject("carbon", "_csv", sources=["_csv.c"]) - genpluginproject("carbon", "_weakref", sources=["_weakref.c"]) - genpluginproject("carbon", "_symtable", sources=["symtablemodule.c"]) - # Example/test modules - genpluginproject("carbon", "_testcapi") - genpluginproject("carbon", "xx") - genpluginproject("carbon", "datetime") - genpluginproject("carbon", "xxsubtype", sources=["xxsubtype.c"]) - genpluginproject("carbon", "_hotshot", sources=["_hotshot.c"]) - - # bgen-generated Toolbox modules - genpluginproject("carbon", "_AE") - genpluginproject("carbon", "_AH") - genpluginproject("carbon", "_App") - genpluginproject("carbon", "_Cm") - genpluginproject("carbon", "_Ctl") - genpluginproject("carbon", "_Dlg") - genpluginproject("carbon", "_Drag") - genpluginproject("carbon", "_Evt", - stdlibraryflags="Debug, WeakImport") - genpluginproject("carbon", "_File", - stdlibraryflags="Debug, WeakImport") - genpluginproject("carbon", "_Fm", - stdlibraryflags="Debug, WeakImport") - genpluginproject("carbon", "_Folder", - stdlibraryflags="Debug, WeakImport") - genpluginproject("carbon", "_Help") - genpluginproject("carbon", "_IBCarbon", sources=[":ibcarbon:_IBCarbon.c"]) - genpluginproject("carbon", "_Icn") - genpluginproject("carbon", "_List") - genpluginproject("carbon", "_Menu") - genpluginproject("carbon", "_Qd", - stdlibraryflags="Debug, WeakImport") - genpluginproject("carbon", "_Qt", - libraryflags="Debug, WeakImport") - genpluginproject("carbon", "_Qdoffs", - stdlibraryflags="Debug, WeakImport") - genpluginproject("carbon", "_Res", - stdlibraryflags="Debug, WeakImport") - genpluginproject("carbon", "_Scrap") - genpluginproject("carbon", "_Snd") - genpluginproject("carbon", "_Sndihooks", sources=[":snd:_Sndihooks.c"]) - genpluginproject("carbon", "_TE") - genpluginproject("carbon", "_Mlte") - genpluginproject("carbon", "_Win") - genpluginproject("carbon", "_CF", sources=["_CFmodule.c", "pycfbridge.c"]) - genpluginproject("carbon", "_CarbonEvt") - genpluginproject("carbon", "hfsplus") - - # Other Mac modules - genpluginproject("carbon", "calldll", sources=["calldll.c"]) - genpluginproject("carbon", "ColorPicker") - genpluginproject("carbon", "waste", - sources=[ - "wastemodule.c", - "WEObjectHandlers.c", - "WETabs.c", "WETabHooks.c"], - libraries=["WASTE.Carbon.lib"], - extradirs=[ - '{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:C_C++ Headers', - '{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:Static Libraries', - '::wastemods', - ] - ) - genpluginproject("carbon", "icglue", sources=["icgluemodule.c"]) - -if __name__ == '__main__': - genallprojects() - - diff --git a/Mac/scripts/missingcarbonmethods.py b/Mac/scripts/missingcarbonmethods.py deleted file mode 100644 index 5db2674..0000000 --- a/Mac/scripts/missingcarbonmethods.py +++ /dev/null @@ -1,167 +0,0 @@ -# Methods that are missing in Carbon. -# This module is mainly for documentation purposes, but you could use -# it to automatically search for usage of methods that are missing. -# - -missing_icglue = [ - 'ICFindConfigFile', - 'ICFindUserConfigFile', - 'ICChooseConfig', - 'ICChooseNewConfig', -] - -missing_Help = [ - 'Help' -] - -missing_Scrap = [ - 'InfoScrap', - 'GetScrap', - 'ZeroScrap', - 'PutScrap', -] - -missing_Win = [ - 'GetAuxWin', - 'GetWindowDataHandle', - 'SaveOld', - 'DrawNew', - 'SetWinColor', - 'SetDeskCPat', - 'InitWindows', - 'InitFloatingWindows', - 'GetWMgrPort', - 'GetCWMgrPort', - 'ValidRgn', # Use versions with Window in their name - 'ValidRect', - 'InvalRgn', - 'InvalRect', - 'IsValidWindowPtr', # I think this is useless for Python, but not sure... - 'GetWindowZoomFlag', # Not available in Carbon - 'GetWindowTitleWidth', # Ditto - ] - -missing_Snd = [ - 'MACEVersion', - 'SPBRecordToFile', - 'Exp1to6', - 'Comp6to1', - 'Exp1to3', - 'Comp3to1', - 'SndControl', - 'SndStopFilePlay', - 'SndStartFilePlay', - 'SndPauseFilePlay', - ] - -missing_Res = [ - 'RGetResource', - 'OpenResFile', - 'CreateResFile', - 'RsrcZoneInit', - 'InitResources', - 'RsrcMapEntry', - ] - -missing_Qt = [ - 'SpriteMediaGetIndImageProperty', # XXXX Why isn't this in carbon? - 'CheckQuickTimeRegistration', - 'SetMovieAnchorDataRef', - 'GetMovieAnchorDataRef', - 'GetMovieLoadState', - 'OpenADataHandler', - 'MovieMediaGetCurrentMovieProperty', - 'MovieMediaGetCurrentTrackProperty', - 'MovieMediaGetChildMovieDataReference', - 'MovieMediaSetChildMovieDataReference', - 'MovieMediaLoadChildMovieFromDataReference', - 'Media3DGetViewObject', - ] - -missing_Qd = [ -## 'device', # Too many false positives - 'portBits', - 'portPixMap', - 'portVersion', - 'grafVars', - ] - -missing_Qdoffs = [ - ] - - -missing_Menu = [ - 'GetMenuItemRefCon2', - 'SetMenuItemRefCon2', - 'EnableItem', - 'DisableItem', - 'CheckItem', - 'CountMItems', - 'OpenDeskAcc', - 'SystemEdit', - 'SystemMenu', - 'SetMenuFlash', - 'InitMenus', - 'InitProcMenu', - ] - -missing_List = [ - ] - -missing_Icn = [ - 'IconServicesTerminate', - ] - -missing_Fm = [ - 'InitFonts', - 'SetFontLock', - 'FlushFonts', - ] - -missing_Evt = [ - 'SystemEvent', - 'SystemTask', - 'SystemClick', - 'GetOSEvent', - 'OSEventAvail', - ] - -missing_Dlg = [ - 'SetGrafPortOfDialog', - ] - -missing_Ctl = [ - 'GetAuxiliaryControlRecord', - 'SetControlColor', - ] - -missing_Cm = [ - 'SetComponentInstanceA5', - 'GetComponentInstanceA5', - ] - -missing_App = [ - 'GetThemeMetric', - ] - -missing_AE = [ - 'AEGetDescDataSize', - 'AEReplaceDescData', - ] - - -missing = [] -for name in dir(): - if name[:8] == 'missing_': - missing = missing + eval(name) -del name - -def _search(): - # Warning: this function only works on Unix - import string, os - re = string.join(missing, '|') - re = """[^a-zA-Z0-9_'"](%s)[^a-zA-Z0-9_'"]""" % re - os.system("find . -name '*.py' -print | xargs egrep '%s'"%re) - -if __name__ == '__main__': - _search() diff --git a/Mac/scripts/unweave.py b/Mac/scripts/unweave.py deleted file mode 100644 index f14287e..0000000 --- a/Mac/scripts/unweave.py +++ /dev/null @@ -1,259 +0,0 @@ -"""An attempt at an unweave script. -Jack Jansen, jack@oratrix.com, 13-Dec-00 -""" -import re -import sys -import macfs -import os -import macostools - -BEGINDEFINITION=re.compile("^<<(?P<name>.*)>>=\s*") -USEDEFINITION=re.compile("^(?P<pre>.*)<<(?P<name>.*)>>(?P<post>[^=].*)") -ENDDEFINITION=re.compile("^@") -GREMLINS=re.compile("[\xa0\xca]") - -DEFAULT_CONFIG=""" -filepatterns = [ - ("^.*\.cp$", ":unweave-src"), - ("^.*\.h$", ":unweave-include"), -] -genlinedirectives = 0 -gencomments = 1 -""" - -class Processor: - def __init__(self, filename, config={}): - self.items = {} - self.filename = filename - self.fp = open(filename) - self.lineno = 0 - self.resolving = {} - self.resolved = {} - self.pushback = None - # Options - if config.has_key("genlinedirectives"): - self.genlinedirectives = config["genlinedirectives"] - else: - self.genlinedirectives = 1 - if config.has_key("gencomments"): - self.gencomments = config["gencomments"] - else: - self.gencomments = 0 - if config.has_key("filepatterns"): - self.filepatterns = config["filepatterns"] - else: - self.filepatterns = [] - self.filepattern_relist = [] - for pat, dummy in self.filepatterns: - self.filepattern_relist.append(re.compile(pat)) - - def _readline(self): - """Read a line. Allow for pushback""" - if self.pushback: - rv = self.pushback - self.pushback = None - return rv - self.lineno = self.lineno + 1 - return self.lineno, self.fp.readline() - - def _linedirective(self, lineno): - """Return a #line cpp directive for this file position""" - return '#line %d "%s"\n'%(lineno-3, os.path.split(self.filename)[1]) - - def _readitem(self): - """Read the definition of an item. Insert #line where needed. """ - rv = [] - while 1: - lineno, line = self._readline() - if not line: - break - if ENDDEFINITION.search(line): - break - if BEGINDEFINITION.match(line): - self.pushback = lineno, line - break - mo = USEDEFINITION.match(line) - if mo: - pre = mo.group('pre') - if pre: -## rv.append((lineno, pre+'\n')) - rv.append((lineno, pre)) - rv.append((lineno, line)) - if mo: - post = mo.group('post') - if post and post != '\n': - rv.append((lineno, post)) - return rv - - def _define(self, name, value): - """Define an item, or append to an existing definition""" - if self.items.has_key(name): - self.items[name] = self.items[name] + value - else: - self.items[name] = value - - def read(self): - """Read the source file and store all definitions""" - savedcomment = [] - while 1: - lineno, line = self._readline() - if not line: break - mo = BEGINDEFINITION.search(line) - if mo: - name = mo.group('name') - value = self._readitem() - if self.gencomments: - defline = [(lineno, '// <%s>=\n'%name)] - if savedcomment: - savedcomment = savedcomment + [(lineno, '//\n')] + defline - else: - savedcomment = defline - savedcomment = self._processcomment(savedcomment) - value = savedcomment + value - savedcomment = [] - isfilepattern = 0 - for rexp in self.filepattern_relist: - if rexp.search(name): - isfilepattern = 1 - break - if 0 and not isfilepattern: - value = self._addspace(value) - self._define(name, value) - else: - if self.gencomments: - # It seems initial blank lines are ignored:-( - if savedcomment or line.strip(): - savedcomment.append((lineno, '// '+line)) - - def _processcomment(self, comment): - # This routine mimicks some artefact of Matthias' code. - rv = [] - for lineno, line in comment: - line = line[:-1] - line = GREMLINS.subn(' ', line)[0] - if len(line) < 75: - line = line + (75-len(line))*' ' - line = line + '\n' - rv.append((lineno, line)) - return rv - - def _addspace(self, value, howmany): - # Yet another routine to mimick yet another artefact - rv = value[0:1] - for lineno, line in value[1:]: - rv.append((lineno, (' '*howmany)+line)) - return rv - - def resolve(self): - """Resolve all references""" - for name in self.items.keys(): - self._resolve_one(name) - - def _resolve_one(self, name): - """Resolve references in one definition, recursively""" - # First check for unknown macros and recursive calls - if not self.items.has_key(name): - print "Undefined macro:", name - return ['<<%s>>'%name] - if self.resolving.has_key(name): - print "Recursive macro:", name - return ['<<%s>>'%name] - # Then check that we haven't handled this one before - if self.resolved.has_key(name): - return self.items[name] - # No rest for the wicked: we have work to do. - self.resolving[name] = 1 - result = [] - lastlineincomplete = 0 - for lineno, line in self.items[name]: - mo = USEDEFINITION.search(line) - if mo: - # We replace the complete line. Is this correct? - macro = mo.group('name') - replacement = self._resolve_one(macro) - if lastlineincomplete: - replacement = self._addspace(replacement, lastlineincomplete) - result = result + replacement - else: - result.append((lineno, line)) - if line[-1] == '\n': - lastlineincomplete = 0 - else: - lastlineincomplete = len(line) - self.items[name] = result - self.resolved[name] = 1 - del self.resolving[name] - return result - - def save(self, dir, pattern): - """Save macros that match pattern to folder dir""" - # Compile the pattern, if needed - if type(pattern) == type(''): - pattern = re.compile(pattern) - # If the directory is relative it is relative to the sourcefile - if not os.path.isabs(dir): - sourcedir = os.path.split(self.filename)[0] - dir = os.path.join(sourcedir, dir) - for name in self.items.keys(): - if pattern.search(name): - pathname = os.path.join(dir, name) - data = self._addlinedirectives(self.items[name]) - self._dosave(pathname, data) - - def _addlinedirectives(self, data): - curlineno = -100 - rv = [] - for lineno, line in data: - curlineno = curlineno + 1 - if self.genlinedirectives and line and line != '\n' and lineno != curlineno: - rv.append(self._linedirective(lineno)) - curlineno = lineno - rv.append(line) - return rv - - def _dosave(self, pathname, data): - """Save data to pathname, unless it is identical to what is there""" - if os.path.exists(pathname): - olddata = open(pathname).readlines() - if olddata == data: - return - macostools.mkdirs(os.path.split(pathname)[0]) - fp = open(pathname, "w").writelines(data) - -def process(file, config): - pr = Processor(file, config) - pr.read() - pr.resolve() - for pattern, folder in config['filepatterns']: - pr.save(folder, pattern) - -def readconfig(): - """Read a configuration file, if it doesn't exist create it.""" - configname = sys.argv[0] + '.config' - if not os.path.exists(configname): - confstr = DEFAULT_CONFIG - open(configname, "w").write(confstr) - print "Created config file", configname -## print "Please check and adapt (if needed)" -## sys.exit(0) - namespace = {} - execfile(configname, namespace) - return namespace - -def main(): - config = readconfig() - if len(sys.argv) > 1: - for file in sys.argv[1:]: - if file[-3:] == '.nw': - print "Processing", file - process(file, config) - else: - print "Skipping", file - else: - fss, ok = macfs.PromptGetFile("Select .nw source file", "TEXT") - if not ok: - sys.exit(0) - process(fss.as_pathname(), config) - -if __name__ == "__main__": - main() |