From 8426477bbb7647755352bdbd7bee834da8ad2899 Mon Sep 17 00:00:00 2001 From: Jack Jansen Date: Tue, 3 Oct 1995 14:35:58 +0000 Subject: Modified/recreated to use keyword arguments --- Mac/Lib/toolbox/AppleScript_Suite.py | 1194 +++++++++-------------------- Mac/Lib/toolbox/Finder_Suite.py | 466 ++++------- Mac/Lib/toolbox/Metrowerks_Shell_Suite.py | 950 +++++++---------------- Mac/Lib/toolbox/Required_Suite.py | 138 ++-- Mac/Lib/toolbox/Standard_Suite.py | 705 +++++++---------- Mac/Lib/toolbox/aetools.py | 1 + Mac/scripts/gensuitemodule.py | 58 +- 7 files changed, 1152 insertions(+), 2360 deletions(-) diff --git a/Mac/Lib/toolbox/AppleScript_Suite.py b/Mac/Lib/toolbox/AppleScript_Suite.py index 73ea0cc..c47da96 100644 --- a/Mac/Lib/toolbox/AppleScript_Suite.py +++ b/Mac/Lib/toolbox/AppleScript_Suite.py @@ -36,38 +36,26 @@ _Enum_misc = { class AppleScript_Suite: - def activate(self, *arguments): + def activate(self, _no_object=None, _attributes={}, **_arguments): """activate: Bring targeted application program to the front. Keyword argument _attributes: AppleEvent attribute dictionary """ _code = 'misc' _subcode = 'actv' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + if _no_object != None: raise TypeError, 'No direct arg expected' + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def log(self, object, *arguments): + def log(self, _object, _attributes={}, **_arguments): """log: Cause a comment to be logged. Required argument: anything Keyword argument _attributes: AppleEvent attribute dictionary @@ -75,125 +63,76 @@ class AppleScript_Suite: _code = 'ascr' _subcode = 'cmnt' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def stop_log(self, *arguments): + def stop_log(self, _no_object=None, _attributes={}, **_arguments): """stop log: Keyword argument _attributes: AppleEvent attribute dictionary """ _code = 'ToyS' _subcode = 'log0' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + if _no_object != None: raise TypeError, 'No direct arg expected' + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def start_log(self, *arguments): + def start_log(self, _no_object=None, _attributes={}, **_arguments): """start log: Keyword argument _attributes: AppleEvent attribute dictionary """ _code = 'ToyS' _subcode = 'log1' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + if _no_object != None: raise TypeError, 'No direct arg expected' + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def copy(self, *arguments): + def copy(self, _no_object=None, _attributes={}, **_arguments): """copy: Copy an object to the clipboard Keyword argument _attributes: AppleEvent attribute dictionary """ _code = 'misc' _subcode = 'copy' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + if _no_object != None: raise TypeError, 'No direct arg expected' + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def do_script(self, object, *arguments): + def do_script(self, _object, _attributes={}, **_arguments): """do script: Execute a script Required argument: the script to execute Keyword argument _attributes: AppleEvent attribute dictionary @@ -202,32 +141,19 @@ class AppleScript_Suite: _code = 'misc' _subcode = 'dosc' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def idle(self, *arguments): + def idle(self, _no_object=None, _attributes={}, **_arguments): """idle: Sent to a script application when it is idle Keyword argument _attributes: AppleEvent attribute dictionary Returns: Number of seconds to wait for next idle event @@ -235,31 +161,19 @@ class AppleScript_Suite: _code = 'misc' _subcode = 'idle' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + if _no_object != None: raise TypeError, 'No direct arg expected' + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def launch(self, *arguments): + def launch(self, _no_object=None, _attributes={}, **_arguments): """launch: Start an application for scripting Keyword argument _attributes: AppleEvent attribute dictionary Returns: anything @@ -267,31 +181,19 @@ class AppleScript_Suite: _code = 'ascr' _subcode = 'noop' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + if _no_object != None: raise TypeError, 'No direct arg expected' + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def tell(self, *arguments): + def tell(self, _no_object=None, _attributes={}, **_arguments): """tell: Magic tell event for event logging Keyword argument _attributes: AppleEvent attribute dictionary Returns: anything @@ -299,31 +201,19 @@ class AppleScript_Suite: _code = 'ascr' _subcode = 'tell' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + if _no_object != None: raise TypeError, 'No direct arg expected' + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def end_tell(self, *arguments): + def end_tell(self, _no_object=None, _attributes={}, **_arguments): """end tell: Start an application for scripting Keyword argument _attributes: AppleEvent attribute dictionary Returns: anything @@ -331,29 +221,17 @@ class AppleScript_Suite: _code = 'ascr' _subcode = 'tend' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + if _no_object != None: raise TypeError, 'No direct arg expected' + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] _argmap_error = { 'number' : 'errn', @@ -362,7 +240,7 @@ class AppleScript_Suite: 'to' : 'errt', } - def error(self, object, *arguments): + def error(self, _object=None, _attributes={}, **_arguments): """error: Raise an error Required argument: anything Keyword argument number: an error number @@ -375,36 +253,17 @@ class AppleScript_Suite: _code = 'ascr' _subcode = 'err ' - if len(arguments): - object = arguments[0] - arguments = arguments[1:] - else: - object = None - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - aetools.keysubst(arguments, self._argmap_error) - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + aetools.keysubst(_arguments, self._argmap_error) + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] _argmap_Call_a5_subroutine = { 'at' : 'at ', @@ -439,7 +298,7 @@ class AppleScript_Suite: 'returning' : 'Krtn', } - def Call_a5_subroutine(self, object, *arguments): + def Call_a5_subroutine(self, _object=None, _attributes={}, **_arguments): """Call¥subroutine: A subroutine call Required argument: anything Keyword argument at: a preposition @@ -478,38 +337,19 @@ class AppleScript_Suite: _code = 'ascr' _subcode = 'psbr' - if len(arguments): - object = arguments[0] - arguments = arguments[1:] - else: - object = None - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - aetools.keysubst(arguments, self._argmap_Call_a5_subroutine) - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + aetools.keysubst(_arguments, self._argmap_Call_a5_subroutine) + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def _3d_(self, object, *arguments): + def _3d_(self, _object, _attributes={}, **_arguments): """=: Equality Required argument: an AE object reference Keyword argument _attributes: AppleEvent attribute dictionary @@ -518,32 +358,19 @@ class AppleScript_Suite: _code = 'ascr' _subcode = '= ' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def _ad_(self, object, *arguments): + def _ad_(self, _object, _attributes={}, **_arguments): """­: Inequality Required argument: an AE object reference Keyword argument _attributes: AppleEvent attribute dictionary @@ -552,32 +379,19 @@ class AppleScript_Suite: _code = 'ascr' _subcode = '\255 ' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def _2b_(self, object, *arguments): + def _2b_(self, _object, _attributes={}, **_arguments): """+: Addition Required argument: an AE object reference Keyword argument _attributes: AppleEvent attribute dictionary @@ -586,32 +400,19 @@ class AppleScript_Suite: _code = 'ascr' _subcode = '+ ' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def _2d_(self, object, *arguments): + def _2d_(self, _object, _attributes={}, **_arguments): """-: Subtraction Required argument: an AE object reference Keyword argument _attributes: AppleEvent attribute dictionary @@ -620,32 +421,19 @@ class AppleScript_Suite: _code = 'ascr' _subcode = '- ' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def _2a_(self, object, *arguments): + def _2a_(self, _object, _attributes={}, **_arguments): """*: Multiplication Required argument: an AE object reference Keyword argument _attributes: AppleEvent attribute dictionary @@ -654,32 +442,19 @@ class AppleScript_Suite: _code = 'ascr' _subcode = '* ' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def _d6_(self, object, *arguments): + def _d6_(self, _object, _attributes={}, **_arguments): """Ö: Division Required argument: an AE object reference Keyword argument _attributes: AppleEvent attribute dictionary @@ -688,32 +463,19 @@ class AppleScript_Suite: _code = 'ascr' _subcode = '/ ' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def div(self, object, *arguments): + def div(self, _object, _attributes={}, **_arguments): """div: Quotient Required argument: an AE object reference Keyword argument _attributes: AppleEvent attribute dictionary @@ -722,32 +484,19 @@ class AppleScript_Suite: _code = 'ascr' _subcode = 'div ' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def mod(self, object, *arguments): + def mod(self, _object, _attributes={}, **_arguments): """mod: Remainder Required argument: an AE object reference Keyword argument _attributes: AppleEvent attribute dictionary @@ -756,32 +505,19 @@ class AppleScript_Suite: _code = 'ascr' _subcode = 'mod ' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def _5e_(self, object, *arguments): + def _5e_(self, _object, _attributes={}, **_arguments): """^: Exponentiation Required argument: an AE object reference Keyword argument _attributes: AppleEvent attribute dictionary @@ -790,32 +526,19 @@ class AppleScript_Suite: _code = 'ascr' _subcode = '^ ' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def _3e_(self, object, *arguments): + def _3e_(self, _object, _attributes={}, **_arguments): """>: Greater than Required argument: an AE object reference Keyword argument _attributes: AppleEvent attribute dictionary @@ -824,32 +547,19 @@ class AppleScript_Suite: _code = 'ascr' _subcode = '> ' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def _b3_(self, object, *arguments): + def _b3_(self, _object, _attributes={}, **_arguments): """³: Greater than or equal to Required argument: an AE object reference Keyword argument _attributes: AppleEvent attribute dictionary @@ -858,32 +568,19 @@ class AppleScript_Suite: _code = 'ascr' _subcode = '>= ' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def _3c_(self, object, *arguments): + def _3c_(self, _object, _attributes={}, **_arguments): """<: Less than Required argument: an AE object reference Keyword argument _attributes: AppleEvent attribute dictionary @@ -892,32 +589,19 @@ class AppleScript_Suite: _code = 'ascr' _subcode = '< ' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def _b2_(self, object, *arguments): + def _b2_(self, _object, _attributes={}, **_arguments): """²: Less than or equal to Required argument: an AE object reference Keyword argument _attributes: AppleEvent attribute dictionary @@ -926,32 +610,19 @@ class AppleScript_Suite: _code = 'ascr' _subcode = '<= ' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def _26_(self, object, *arguments): + def _26_(self, _object, _attributes={}, **_arguments): """&: Concatenation Required argument: an AE object reference Keyword argument _attributes: AppleEvent attribute dictionary @@ -960,32 +631,19 @@ class AppleScript_Suite: _code = 'ascr' _subcode = 'ccat' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def starts_with(self, object, *arguments): + def starts_with(self, _object, _attributes={}, **_arguments): """starts with: Starts with Required argument: an AE object reference Keyword argument _attributes: AppleEvent attribute dictionary @@ -994,32 +652,19 @@ class AppleScript_Suite: _code = 'ascr' _subcode = 'bgwt' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def ends_with(self, object, *arguments): + def ends_with(self, _object, _attributes={}, **_arguments): """ends with: Ends with Required argument: an AE object reference Keyword argument _attributes: AppleEvent attribute dictionary @@ -1028,32 +673,19 @@ class AppleScript_Suite: _code = 'ascr' _subcode = 'ends' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def contains(self, object, *arguments): + def contains(self, _object, _attributes={}, **_arguments): """contains: Containment Required argument: an AE object reference Keyword argument _attributes: AppleEvent attribute dictionary @@ -1062,32 +694,19 @@ class AppleScript_Suite: _code = 'ascr' _subcode = 'cont' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def _and(self, object, *arguments): + def _and(self, _object, _attributes={}, **_arguments): """and: Logical conjunction Required argument: an AE object reference Keyword argument _attributes: AppleEvent attribute dictionary @@ -1096,32 +715,19 @@ class AppleScript_Suite: _code = 'ascr' _subcode = 'AND ' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def _or(self, object, *arguments): + def _or(self, _object, _attributes={}, **_arguments): """or: Logical disjunction Required argument: an AE object reference Keyword argument _attributes: AppleEvent attribute dictionary @@ -1130,32 +736,19 @@ class AppleScript_Suite: _code = 'ascr' _subcode = 'OR ' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def as(self, object, *arguments): + def as(self, _object, _attributes={}, **_arguments): """as: Coercion Required argument: an AE object reference Keyword argument _attributes: AppleEvent attribute dictionary @@ -1164,32 +757,19 @@ class AppleScript_Suite: _code = 'ascr' _subcode = 'coer' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def _not(self, object, *arguments): + def _not(self, _object, _attributes={}, **_arguments): """not: Logical negation Required argument: an AE object reference Keyword argument _attributes: AppleEvent attribute dictionary @@ -1198,32 +778,19 @@ class AppleScript_Suite: _code = 'ascr' _subcode = 'NOT ' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def negate(self, object, *arguments): + def negate(self, _object, _attributes={}, **_arguments): """negate: Numeric negation Required argument: an AE object reference Keyword argument _attributes: AppleEvent attribute dictionary @@ -1232,30 +799,17 @@ class AppleScript_Suite: _code = 'ascr' _subcode = 'neg ' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] # Class '' ('undf') -- 'the undefined value' diff --git a/Mac/Lib/toolbox/Finder_Suite.py b/Mac/Lib/toolbox/Finder_Suite.py index 10d6f99..5b20037 100644 --- a/Mac/Lib/toolbox/Finder_Suite.py +++ b/Mac/Lib/toolbox/Finder_Suite.py @@ -39,7 +39,7 @@ class Finder_Suite: 'by' : 'by ', } - def clean_up(self, object, *arguments): + def clean_up(self, _object, _attributes={}, **_arguments): """clean up: Arrange items in window nicely Required argument: the window to clean up Keyword argument by: the order in which to clean up the objects @@ -48,37 +48,23 @@ class Finder_Suite: _code = 'fndr' _subcode = 'fclu' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - aetools.keysubst(arguments, self._argmap_clean_up) - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + aetools.keysubst(_arguments, self._argmap_clean_up) + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] _argmap_computer = { 'has' : 'has ', } - def computer(self, object, *arguments): + def computer(self, _object, _attributes={}, **_arguments): """computer: Test attributes of this computer Required argument: the attribute to test Keyword argument has: test specific bits of response @@ -88,33 +74,19 @@ class Finder_Suite: _code = 'fndr' _subcode = 'gstl' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - aetools.keysubst(arguments, self._argmap_computer) - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + aetools.keysubst(_arguments, self._argmap_computer) + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def eject(self, object, *arguments): + def eject(self, _object=None, _attributes={}, **_arguments): """eject: Eject the specified disk(s), or every ejectable disk if no parameter is specified Required argument: the items to eject Keyword argument _attributes: AppleEvent attribute dictionary @@ -122,37 +94,19 @@ class Finder_Suite: _code = 'fndr' _subcode = 'ejct' - if len(arguments): - object = arguments[0] - arguments = arguments[1:] - else: - object = None - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def empty(self, object, *arguments): + def empty(self, _object=None, _attributes={}, **_arguments): """empty: Empty the trash Required argument: ÒemptyÓ and Òempty trashÓ both do the same thing Keyword argument _attributes: AppleEvent attribute dictionary @@ -160,37 +114,19 @@ class Finder_Suite: _code = 'fndr' _subcode = 'empt' - if len(arguments): - object = arguments[0] - arguments = arguments[1:] - else: - object = None - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def erase(self, object, *arguments): + def erase(self, _object, _attributes={}, **_arguments): """erase: Erase the specified disk(s) Required argument: the items to erase Keyword argument _attributes: AppleEvent attribute dictionary @@ -198,36 +134,23 @@ class Finder_Suite: _code = 'fndr' _subcode = 'fera' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] _argmap_put_away = { 'items' : 'fsel', } - def put_away(self, object, *arguments): + def put_away(self, _object, _attributes={}, **_arguments): """put away: Put away the specified object(s) Required argument: the items to put away Keyword argument items: DO NOT USE: provided for backwards compatibility with old event suite. Will be removed in future Finders @@ -237,64 +160,38 @@ class Finder_Suite: _code = 'fndr' _subcode = 'ptwy' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - aetools.keysubst(arguments, self._argmap_put_away) - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + aetools.keysubst(_arguments, self._argmap_put_away) + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def restart(self, *arguments): + def restart(self, _no_object=None, _attributes={}, **_arguments): """restart: Restart the Macintosh Keyword argument _attributes: AppleEvent attribute dictionary """ _code = 'fndr' _subcode = 'rest' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + if _no_object != None: raise TypeError, 'No direct arg expected' + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def reveal(self, object, *arguments): + def reveal(self, _object, _attributes={}, **_arguments): """reveal: Bring the specified object(s) into view Required argument: the object to be made visible Keyword argument _attributes: AppleEvent attribute dictionary @@ -302,32 +199,19 @@ class Finder_Suite: _code = 'misc' _subcode = 'mvis' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def select(self, object, *arguments): + def select(self, _object, _attributes={}, **_arguments): """select: Select the specified object(s) Required argument: the object to select Keyword argument _attributes: AppleEvent attribute dictionary @@ -335,98 +219,61 @@ class Finder_Suite: _code = 'misc' _subcode = 'slct' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def shut_down(self, *arguments): + def shut_down(self, _no_object=None, _attributes={}, **_arguments): """shut down: Shut Down the Macintosh Keyword argument _attributes: AppleEvent attribute dictionary """ _code = 'fndr' _subcode = 'shut' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + if _no_object != None: raise TypeError, 'No direct arg expected' + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def sleep(self, *arguments): + def sleep(self, _no_object=None, _attributes={}, **_arguments): """sleep: Sleep the Macintosh Keyword argument _attributes: AppleEvent attribute dictionary """ _code = 'fndr' _subcode = 'snoz' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + if _no_object != None: raise TypeError, 'No direct arg expected' + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] _argmap_sort = { 'by' : 'by ', } - def sort(self, object, *arguments): + def sort(self, _object, _attributes={}, **_arguments): """sort: Return the specified object(s) in a sorted list Required argument: a list of finder objects to sort Keyword argument by: the property to sort the items by @@ -436,33 +283,19 @@ class Finder_Suite: _code = 'DATA' _subcode = 'SORT' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - aetools.keysubst(arguments, self._argmap_sort) - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + aetools.keysubst(_arguments, self._argmap_sort) + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def update(self, object, *arguments): + def update(self, _object, _attributes={}, **_arguments): """update: Update the display of the specified object(s) to match their on-disk representation Required argument: the item to update Keyword argument _attributes: AppleEvent attribute dictionary @@ -470,30 +303,17 @@ class Finder_Suite: _code = 'fndr' _subcode = 'fupd' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] # Class 'accessory process' ('pcda') -- 'A process launched from a desk accessory file' diff --git a/Mac/Lib/toolbox/Metrowerks_Shell_Suite.py b/Mac/Lib/toolbox/Metrowerks_Shell_Suite.py index 6b9439e..b242719 100644 --- a/Mac/Lib/toolbox/Metrowerks_Shell_Suite.py +++ b/Mac/Lib/toolbox/Metrowerks_Shell_Suite.py @@ -54,7 +54,7 @@ class Metrowerks_Shell_Suite: 'Saving' : 'savo', } - def Close_Window(self, object, *arguments): + def Close_Window(self, _object, _attributes={}, **_arguments): """Close Window: Close the windows showing the specified files Required argument: The files to close Keyword argument Saving: Whether to save changes to each file before closing its window @@ -63,38 +63,24 @@ class Metrowerks_Shell_Suite: _code = 'MMPR' _subcode = 'ClsW' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - aetools.keysubst(arguments, self._argmap_Close_Window) - aetools.enumsubst(arguments, 'savo', _Enum_savo) - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + aetools.keysubst(_arguments, self._argmap_Close_Window) + aetools.enumsubst(_arguments, 'savo', _Enum_savo) + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] _argmap_Add_Files = { 'To_Segment' : 'Segm', } - def Add_Files(self, object, *arguments): + def Add_Files(self, _object, _attributes={}, **_arguments): """Add Files: Add the specified file(s) to the current project Required argument: List of files to add Keyword argument To_Segment: Segment number into which to add the file(s) @@ -104,33 +90,19 @@ class Metrowerks_Shell_Suite: _code = 'MMPR' _subcode = 'AddF' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - aetools.keysubst(arguments, self._argmap_Add_Files) - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + aetools.keysubst(_arguments, self._argmap_Add_Files) + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def Remove_Files(self, object, *arguments): + def Remove_Files(self, _object, _attributes={}, **_arguments): """Remove Files: Remove the specified file(s) from the current project Required argument: List of files to remove Keyword argument _attributes: AppleEvent attribute dictionary @@ -139,32 +111,19 @@ class Metrowerks_Shell_Suite: _code = 'MMPR' _subcode = 'RemF' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def Touch(self, object, *arguments): + def Touch(self, _object, _attributes={}, **_arguments): """Touch: Touch the modification date of the specified file(s) Required argument: List of files to compile Keyword argument _attributes: AppleEvent attribute dictionary @@ -173,36 +132,23 @@ class Metrowerks_Shell_Suite: _code = 'MMPR' _subcode = 'Toch' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] _argmap_Check_Syntax = { 'ExternalEditor' : 'Errs', } - def Check_Syntax(self, object, *arguments): + def Check_Syntax(self, _object, _attributes={}, **_arguments): """Check Syntax: Check the syntax of the specified file(s) Required argument: List of files to check the syntax of Keyword argument ExternalEditor: Should the contents of the message window be returned to the caller? @@ -212,37 +158,23 @@ class Metrowerks_Shell_Suite: _code = 'MMPR' _subcode = 'Chek' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - aetools.keysubst(arguments, self._argmap_Check_Syntax) - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + aetools.keysubst(_arguments, self._argmap_Check_Syntax) + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] _argmap_Compile = { 'ExternalEditor' : 'Errs', } - def Compile(self, object, *arguments): + def Compile(self, _object, _attributes={}, **_arguments): """Compile: Compile the specified file(s) Required argument: List of files to compile Keyword argument ExternalEditor: Should the contents of the message window be returned to the caller? @@ -252,38 +184,24 @@ class Metrowerks_Shell_Suite: _code = 'MMPR' _subcode = 'Comp' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - aetools.keysubst(arguments, self._argmap_Compile) - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + aetools.keysubst(_arguments, self._argmap_Compile) + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] _argmap_Precompile = { 'Saving_As' : 'Targ', 'ExternalEditor' : 'Errs', } - def Precompile(self, object, *arguments): + def Precompile(self, _object, _attributes={}, **_arguments): """Precompile: Precompile the specified file to the specified destination file Required argument: File to precompile Keyword argument Saving_As: Destination file for precompiled header @@ -294,37 +212,23 @@ class Metrowerks_Shell_Suite: _code = 'MMPR' _subcode = 'PreC' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - aetools.keysubst(arguments, self._argmap_Precompile) - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + aetools.keysubst(_arguments, self._argmap_Precompile) + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] _argmap_Create_Project = { 'from_stationery' : 'Tmpl', } - def Create_Project(self, object, *arguments): + def Create_Project(self, _object, _attributes={}, **_arguments): """Create Project: Create a new project file Required argument: New project file specifier Keyword argument from_stationery: undocumented, typecode 'alis' @@ -333,99 +237,61 @@ class Metrowerks_Shell_Suite: _code = 'MMPR' _subcode = 'NewP' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - aetools.keysubst(arguments, self._argmap_Create_Project) - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + aetools.keysubst(_arguments, self._argmap_Create_Project) + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def Close_Project(self, *arguments): + def Close_Project(self, _no_object=None, _attributes={}, **_arguments): """Close Project: Close the current project Keyword argument _attributes: AppleEvent attribute dictionary """ _code = 'MMPR' _subcode = 'ClsP' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + if _no_object != None: raise TypeError, 'No direct arg expected' + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def Remove_Binaries(self, *arguments): + def Remove_Binaries(self, _no_object=None, _attributes={}, **_arguments): """Remove Binaries: Remove the binary object code from the current project Keyword argument _attributes: AppleEvent attribute dictionary """ _code = 'MMPR' _subcode = 'RemB' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + if _no_object != None: raise TypeError, 'No direct arg expected' + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] _argmap_Update_Project = { 'ExternalEditor' : 'Errs', } - def Update_Project(self, *arguments): + def Update_Project(self, _no_object=None, _attributes={}, **_arguments): """Update Project: Update the current project Keyword argument ExternalEditor: Should the contents of the message window be returned to the caller? Keyword argument _attributes: AppleEvent attribute dictionary @@ -434,36 +300,23 @@ class Metrowerks_Shell_Suite: _code = 'MMPR' _subcode = 'UpdP' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - aetools.keysubst(arguments, self._argmap_Update_Project) - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + if _no_object != None: raise TypeError, 'No direct arg expected' + + aetools.keysubst(_arguments, self._argmap_Update_Project) + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] _argmap_Make_Project = { 'ExternalEditor' : 'Errs', } - def Make_Project(self, *arguments): + def Make_Project(self, _no_object=None, _attributes={}, **_arguments): """Make Project: Make the current project Keyword argument ExternalEditor: Should the contents of the message window be returned to the caller? Keyword argument _attributes: AppleEvent attribute dictionary @@ -472,37 +325,24 @@ class Metrowerks_Shell_Suite: _code = 'MMPR' _subcode = 'Make' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - aetools.keysubst(arguments, self._argmap_Make_Project) - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + if _no_object != None: raise TypeError, 'No direct arg expected' + + aetools.keysubst(_arguments, self._argmap_Make_Project) + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] _argmap_Run_Project = { 'ExternalEditor' : 'Errs', 'SourceDebugger' : 'DeBg', } - def Run_Project(self, *arguments): + def Run_Project(self, _no_object=None, _attributes={}, **_arguments): """Run Project: Run the current project Keyword argument ExternalEditor: Should the contents of the message window be returned to the caller? Keyword argument SourceDebugger: Run the application under the control of the source-level debugger @@ -512,36 +352,23 @@ class Metrowerks_Shell_Suite: _code = 'MMPR' _subcode = 'RunP' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - aetools.keysubst(arguments, self._argmap_Run_Project) - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + if _no_object != None: raise TypeError, 'No direct arg expected' + + aetools.keysubst(_arguments, self._argmap_Run_Project) + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] _argmap_Set_Preferences = { 'To' : 'PRec', } - def Set_Preferences(self, *arguments): + def Set_Preferences(self, _no_object=None, _attributes={}, **_arguments): """Set Preferences: Set the preferences for the current project Keyword argument To: Preferences settings Keyword argument _attributes: AppleEvent attribute dictionary @@ -549,36 +376,23 @@ class Metrowerks_Shell_Suite: _code = 'MMPR' _subcode = 'Pref' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - aetools.keysubst(arguments, self._argmap_Set_Preferences) - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + if _no_object != None: raise TypeError, 'No direct arg expected' + + aetools.keysubst(_arguments, self._argmap_Set_Preferences) + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] _argmap_Get_Preferences = { 'Of' : 'PRec', } - def Get_Preferences(self, *arguments): + def Get_Preferences(self, _no_object=None, _attributes={}, **_arguments): """Get Preferences: Get the preferences for the current project Keyword argument Of: Preferences settings Keyword argument _attributes: AppleEvent attribute dictionary @@ -587,32 +401,19 @@ class Metrowerks_Shell_Suite: _code = 'MMPR' _subcode = 'Gref' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - aetools.keysubst(arguments, self._argmap_Get_Preferences) - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + if _no_object != None: raise TypeError, 'No direct arg expected' + + aetools.keysubst(_arguments, self._argmap_Get_Preferences) + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def Is_In_Project(self, object, *arguments): + def Is_In_Project(self, _object, _attributes={}, **_arguments): """Is In Project: Whether or not the specified file(s) is in the current project Required argument: List of files to check for project membership Keyword argument _attributes: AppleEvent attribute dictionary @@ -621,32 +422,19 @@ class Metrowerks_Shell_Suite: _code = 'MMPR' _subcode = 'FInP' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def Get_Project_Specifier(self, *arguments): + def Get_Project_Specifier(self, _no_object=None, _attributes={}, **_arguments): """Get Project Specifier: Return the File Specifier for the current project Keyword argument _attributes: AppleEvent attribute dictionary Returns: File Specifier for the current project @@ -654,62 +442,38 @@ class Metrowerks_Shell_Suite: _code = 'MMPR' _subcode = 'GetP' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + if _no_object != None: raise TypeError, 'No direct arg expected' + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def Reset_File_Paths(self, *arguments): + def Reset_File_Paths(self, _no_object=None, _attributes={}, **_arguments): """Reset File Paths: Resets access paths for all files belonging to open project. Keyword argument _attributes: AppleEvent attribute dictionary """ _code = 'MMPR' _subcode = 'ReFP' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + if _no_object != None: raise TypeError, 'No direct arg expected' + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def Goto_Line(self, object, *arguments): + def Goto_Line(self, _object, _attributes={}, **_arguments): """Goto Line: Goto Specified Line Number Required argument: The requested source file line number Keyword argument _attributes: AppleEvent attribute dictionary @@ -717,32 +481,19 @@ class Metrowerks_Shell_Suite: _code = 'MMPR' _subcode = 'GoLn' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def Goto_Function(self, object, *arguments): + def Goto_Function(self, _object, _attributes={}, **_arguments): """Goto Function: Goto Specified Function Name Required argument: undocumented, typecode 'TEXT' Keyword argument _attributes: AppleEvent attribute dictionary @@ -750,32 +501,19 @@ class Metrowerks_Shell_Suite: _code = 'MMPR' _subcode = 'GoFn' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def Save_Message_Window_As(self, object, *arguments): + def Save_Message_Window_As(self, _object, _attributes={}, **_arguments): """Save Message Window As: Saves the message window as a text file Required argument: Destination file for Save Message Window As Keyword argument _attributes: AppleEvent attribute dictionary @@ -783,32 +521,19 @@ class Metrowerks_Shell_Suite: _code = 'MMPR' _subcode = 'SvMs' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def Get_Open_Documents(self, *arguments): + def Get_Open_Documents(self, _no_object=None, _attributes={}, **_arguments): """Get Open Documents: Returns the list of open documents Keyword argument _attributes: AppleEvent attribute dictionary Returns: The list of documents @@ -816,31 +541,19 @@ class Metrowerks_Shell_Suite: _code = 'MMPR' _subcode = 'GDoc' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + if _no_object != None: raise TypeError, 'No direct arg expected' + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def Get_Segments(self, *arguments): + def Get_Segments(self, _no_object=None, _attributes={}, **_arguments): """Get Segments: Returns a description of each segment in the project. Keyword argument _attributes: AppleEvent attribute dictionary Returns: undocumented, typecode 'Seg ' @@ -848,35 +561,23 @@ class Metrowerks_Shell_Suite: _code = 'MMPR' _subcode = 'GSeg' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + if _no_object != None: raise TypeError, 'No direct arg expected' + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] _argmap_Set_Segment = { 'to' : 'Segm', } - def Set_Segment(self, object, *arguments): + def Set_Segment(self, _object, _attributes={}, **_arguments): """Set Segment: Changes the name and attributes of a segment. Required argument: The segment to change Keyword argument to: The new name and attributes for the segment. @@ -885,37 +586,23 @@ class Metrowerks_Shell_Suite: _code = 'MMPR' _subcode = 'SSeg' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - aetools.keysubst(arguments, self._argmap_Set_Segment) - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + aetools.keysubst(_arguments, self._argmap_Set_Segment) + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] _argmap_Get_Project_File = { 'Segment' : 'Segm', } - def Get_Project_File(self, object, *arguments): + def Get_Project_File(self, _object, _attributes={}, **_arguments): """Get Project File: Returns a description of a file in the project window. Required argument: The index of the file within its segment. Keyword argument Segment: The segment containing the file. @@ -925,37 +612,23 @@ class Metrowerks_Shell_Suite: _code = 'MMPR' _subcode = 'GFil' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - aetools.keysubst(arguments, self._argmap_Get_Project_File) - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + aetools.keysubst(_arguments, self._argmap_Get_Project_File) + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] _argmap_Set_Project_File = { 'to' : 'SrcS', } - def Set_Project_File(self, object, *arguments): + def Set_Project_File(self, _object, _attributes={}, **_arguments): """Set Project File: Changes the settings for a given file in the project. Required argument: The name of the file Keyword argument to: The new settings for the file @@ -964,33 +637,19 @@ class Metrowerks_Shell_Suite: _code = 'MMPR' _subcode = 'SFil' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - aetools.keysubst(arguments, self._argmap_Set_Project_File) - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + aetools.keysubst(_arguments, self._argmap_Set_Project_File) + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def Get_Definition(self, object, *arguments): + def Get_Definition(self, _object, _attributes={}, **_arguments): """Get Definition: Returns the location(s) of a globally scoped function or data object. Required argument: undocumented, typecode 'TEXT' Keyword argument _attributes: AppleEvent attribute dictionary @@ -999,30 +658,17 @@ class Metrowerks_Shell_Suite: _code = 'MMPR' _subcode = 'GDef' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] # Class 'C/C++ Language' ('FECP') -- 'C/C++ Language specifics' diff --git a/Mac/Lib/toolbox/Required_Suite.py b/Mac/Lib/toolbox/Required_Suite.py index 4f317c9..9ef255e 100644 --- a/Mac/Lib/toolbox/Required_Suite.py +++ b/Mac/Lib/toolbox/Required_Suite.py @@ -17,7 +17,7 @@ _code = 'reqd' class Required_Suite: - def open(self, object, *arguments): + def open(self, _object, _attributes={}, **_arguments): """open: Open the specified object(s) Required argument: list of objects to open Keyword argument _attributes: AppleEvent attribute dictionary @@ -25,32 +25,19 @@ class Required_Suite: _code = 'aevt' _subcode = 'odoc' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def _print(self, object, *arguments): + def _print(self, _object, _attributes={}, **_arguments): """print: Print the specified object(s) Required argument: list of objects to print Keyword argument _attributes: AppleEvent attribute dictionary @@ -58,90 +45,53 @@ class Required_Suite: _code = 'aevt' _subcode = 'pdoc' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def quit(self, *arguments): + def quit(self, _no_object=None, _attributes={}, **_arguments): """quit: Quit application Keyword argument _attributes: AppleEvent attribute dictionary """ _code = 'aevt' _subcode = 'quit' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + if _no_object != None: raise TypeError, 'No direct arg expected' + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def run(self, *arguments): + def run(self, _no_object=None, _attributes={}, **_arguments): """run: Sent to an application when it is double-clicked Keyword argument _attributes: AppleEvent attribute dictionary """ _code = 'aevt' _subcode = 'oapp' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + if _no_object != None: raise TypeError, 'No direct arg expected' + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] diff --git a/Mac/Lib/toolbox/Standard_Suite.py b/Mac/Lib/toolbox/Standard_Suite.py index ca7908b..678fc8f 100644 --- a/Mac/Lib/toolbox/Standard_Suite.py +++ b/Mac/Lib/toolbox/Standard_Suite.py @@ -1,7 +1,7 @@ """Suite Standard Suite: Common terms for most applications Level 1, version 1 -Generated from Moes:Programma's:Speech Technology:Scriptable Text Editor +Generated from Moes:System folder:Extensions:Scripting Additions:Dialects:English Dialect AETE/AEUT resource version 1/0, language 0, script 0 """ @@ -13,7 +13,7 @@ addpack.addpack('ae') import aetools import MacOS -_code = 'CoRe' +_code = 'core' _Enum_savo = { 'yes' : 'yes ', # Save objects now @@ -24,98 +24,114 @@ _Enum_savo = { _Enum_kfrm = { 'index' : 'indx', # keyform designating indexed access 'named' : 'name', # keyform designating named access - 'id' : 'ID ', # keyform designating identifer access + 'id' : 'ID ', # keyform designating access by unique identifier +} + +_Enum_styl = { + 'plain' : 'plan', # Plain + 'bold' : 'bold', # Bold + 'italic' : 'ital', # Italic + 'outline' : 'outl', # Outline + 'shadow' : 'shad', # Shadow + 'underline' : 'undl', # Underline + 'superscript' : 'spsc', # Superscript + 'subscript' : 'sbsc', # Subscript + 'strikethrough' : 'strk', # Strikethrough + 'small_caps' : 'smcp', # Small caps + 'all_caps' : 'alcp', # All capital letters + 'all_lowercase' : 'lowc', # Lowercase + 'condensed' : 'cond', # Condensed + 'expanded' : 'pexp', # Expanded + 'hidden' : 'hidn', # Hidden } class Standard_Suite: + _argmap_class_info = { + '_in' : 'wrcd', + } + + def class_info(self, _object=None, _attributes={}, **_arguments): + """class info: Get information about an object class + Required argument: the object class about which information is requested + Keyword argument _in: the human language and script system in which to return information + Keyword argument _attributes: AppleEvent attribute dictionary + Returns: a record containing the objectÕs properties and elements + """ + _code = 'core' + _subcode = 'qobj' + + _arguments['----'] = _object + + aetools.keysubst(_arguments, self._argmap_class_info) + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) + # XXXX Optionally decode result + if _arguments.has_key('----'): + return _arguments['----'] + _argmap_close = { 'saving' : 'savo', 'saving_in' : 'kfil', } - def close(self, object, *arguments): + def close(self, _object, _attributes={}, **_arguments): """close: Close an object Required argument: the object to close - Keyword argument saving: Specifies whether or not changes should be saved before closing + Keyword argument saving: specifies whether changes should be saved before closing Keyword argument saving_in: the file in which to save the object Keyword argument _attributes: AppleEvent attribute dictionary """ _code = 'core' _subcode = 'clos' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - aetools.keysubst(arguments, self._argmap_close) - aetools.enumsubst(arguments, 'savo', _Enum_savo) - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + aetools.keysubst(_arguments, self._argmap_close) + aetools.enumsubst(_arguments, 'savo', _Enum_savo) + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] _argmap_count = { 'each' : 'kocl', } - def count(self, object, *arguments): + def count(self, _object, _attributes={}, **_arguments): """count: Return the number of elements of a particular class within an object Required argument: the object whose elements are to be counted - Keyword argument each: the class of the elements to be counted. Keyword 'each' is optional in AppleScript + Keyword argument each: the class of the elements to be counted. Keyword argument _attributes: AppleEvent attribute dictionary Returns: the number of elements """ _code = 'core' _subcode = 'cnte' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - aetools.keysubst(arguments, self._argmap_count) - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + aetools.keysubst(_arguments, self._argmap_count) + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] _argmap_data_size = { 'as' : 'rtyp', } - def data_size(self, object, *arguments): + def data_size(self, _object, _attributes={}, **_arguments): """data size: Return the size in bytes of an object Required argument: the object whose data size is to be returned Keyword argument as: the data type for which the size is calculated @@ -125,33 +141,19 @@ class Standard_Suite: _code = 'core' _subcode = 'dsiz' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - aetools.keysubst(arguments, self._argmap_data_size) - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + aetools.keysubst(_arguments, self._argmap_data_size) + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def delete(self, object, *arguments): + def delete(self, _object, _attributes={}, **_arguments): """delete: Delete an element from an object Required argument: the element to delete Keyword argument _attributes: AppleEvent attribute dictionary @@ -159,36 +161,23 @@ class Standard_Suite: _code = 'core' _subcode = 'delo' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] _argmap_duplicate = { 'to' : 'insh', } - def duplicate(self, object, *arguments): + def duplicate(self, _object, _attributes={}, **_arguments): """duplicate: Duplicate object(s) Required argument: the object(s) to duplicate Keyword argument to: the new location for the object(s) @@ -198,33 +187,45 @@ class Standard_Suite: _code = 'core' _subcode = 'clon' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - aetools.keysubst(arguments, self._argmap_duplicate) - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + aetools.keysubst(_arguments, self._argmap_duplicate) + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] + + _argmap_event_info = { + '_in' : 'wrcd', + } + + def event_info(self, _object, _attributes={}, **_arguments): + """event info: Get information about the Apple events in a suite + Required argument: the event class of the Apple events for which to return information + Keyword argument _in: the human language and script system in which to return information + Keyword argument _attributes: AppleEvent attribute dictionary + Returns: a record containing the events and their parameters + """ + _code = 'core' + _subcode = 'gtei' + + _arguments['----'] = _object - def exists(self, object, *arguments): + aetools.keysubst(_arguments, self._argmap_event_info) + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) + # XXXX Optionally decode result + if _arguments.has_key('----'): + return _arguments['----'] + + def exists(self, _object, _attributes={}, **_arguments): """exists: Verify if an object exists Required argument: the object in question Keyword argument _attributes: AppleEvent attribute dictionary @@ -233,70 +234,17 @@ class Standard_Suite: _code = 'core' _subcode = 'doex' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) - # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + _arguments['----'] = _object - _argmap_get = { - 'as' : 'rtyp', - } + if _arguments: raise TypeError, 'No optional args expected' - def get(self, object, *arguments): - """get: Get the data for an object - Required argument: the object whose data is to be returned - Keyword argument as: the desired types for the data, in order of preference - Keyword argument _attributes: AppleEvent attribute dictionary - Returns: The data from the object - """ - _code = 'core' - _subcode = 'getd' - - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - aetools.keysubst(arguments, self._argmap_get) - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] _argmap_make = { 'new' : 'kocl', @@ -305,9 +253,9 @@ class Standard_Suite: 'with_properties' : 'prdt', } - def make(self, *arguments): + def make(self, _no_object=None, _attributes={}, **_arguments): """make: Make a new element - Keyword argument new: the class of the new element. Keyword 'new' is optional in AppleScript + Keyword argument new: the class of the new element. Keyword argument at: the location at which to insert the element Keyword argument with_data: the initial data for the element Keyword argument with_properties: the initial values for the properties of the element @@ -317,36 +265,23 @@ class Standard_Suite: _code = 'core' _subcode = 'crel' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - aetools.keysubst(arguments, self._argmap_make) - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + if _no_object != None: raise TypeError, 'No direct arg expected' + + aetools.keysubst(_arguments, self._argmap_make) + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] _argmap_move = { 'to' : 'insh', } - def move(self, object, *arguments): + def move(self, _object, _attributes={}, **_arguments): """move: Move object(s) to a new location Required argument: the object(s) to move Keyword argument to: the new location for the object(s) @@ -356,33 +291,19 @@ class Standard_Suite: _code = 'core' _subcode = 'move' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - aetools.keysubst(arguments, self._argmap_move) - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + aetools.keysubst(_arguments, self._argmap_move) + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def open(self, object, *arguments): + def open(self, _object, _attributes={}, **_arguments): """open: Open the specified object(s) Required argument: list of objects to open Keyword argument _attributes: AppleEvent attribute dictionary @@ -390,32 +311,19 @@ class Standard_Suite: _code = 'aevt' _subcode = 'odoc' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - def _print(self, object, *arguments): + def _print(self, _object, _attributes={}, **_arguments): """print: Print the specified object(s) Required argument: list of objects to print Keyword argument _attributes: AppleEvent attribute dictionary @@ -423,75 +331,49 @@ class Standard_Suite: _code = 'aevt' _subcode = 'pdoc' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + if _arguments: raise TypeError, 'No optional args expected' + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] _argmap_quit = { 'saving' : 'savo', } - def quit(self, *arguments): + def quit(self, _no_object=None, _attributes={}, **_arguments): """quit: Quit an application program - Keyword argument saving: Specifies whether or not to save currently open documents + Keyword argument saving: specifies whether to save currently open documents Keyword argument _attributes: AppleEvent attribute dictionary """ _code = 'aevt' _subcode = 'quit' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - aetools.keysubst(arguments, self._argmap_quit) - aetools.enumsubst(arguments, 'savo', _Enum_savo) - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + if _no_object != None: raise TypeError, 'No direct arg expected' + + aetools.keysubst(_arguments, self._argmap_quit) + aetools.enumsubst(_arguments, 'savo', _Enum_savo) + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] _argmap_save = { '_in' : 'kfil', 'as' : 'fltp', } - def save(self, object, *arguments): + def save(self, _object, _attributes={}, **_arguments): """save: Save an object Required argument: the object to save Keyword argument _in: the file in which to save the object @@ -501,141 +383,91 @@ class Standard_Suite: _code = 'core' _subcode = 'save' - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - aetools.keysubst(arguments, self._argmap_save) - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _arguments['----'] = _object + + aetools.keysubst(_arguments, self._argmap_save) + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] - _argmap_set = { - 'to' : 'data', + _argmap_suite_info = { + '_in' : 'wrcd', } - def set(self, object, *arguments): - """set: Set an object's data - Required argument: the object to change - Keyword argument to: the new value + def suite_info(self, _object, _attributes={}, **_arguments): + """suite info: Get information about event suite(s) + Required argument: the suite for which to return information + Keyword argument _in: the human language and script system in which to return information Keyword argument _attributes: AppleEvent attribute dictionary + Returns: a record containing the suites and their versions """ _code = 'core' - _subcode = 'setd' - - if len(arguments) > 1: - raise TypeError, 'Too many arguments' - if arguments: - arguments = arguments[0] - if type(arguments) <> type({}): - raise TypeError, 'Must be a mapping' - else: - arguments = {} - arguments['----'] = object - - if arguments.has_key('_attributes'): - attributes = arguments['_attributes'] - del arguments['_attributes'] - else: - attributes = {} - - aetools.keysubst(arguments, self._argmap_set) - - reply, arguments, attributes = self.send(_code, _subcode, - arguments, attributes) - if arguments.has_key('errn'): - raise MacOS.Error, aetools.decodeerror(arguments) + _subcode = 'gtsi' + + _arguments['----'] = _object + + aetools.keysubst(_arguments, self._argmap_suite_info) + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result - if arguments.has_key('----'): - return arguments['----'] + if _arguments.has_key('----'): + return _arguments['----'] # Class 'application' ('capp') -- 'An application program' -# property 'clipboard' ('pcli') '****' -- 'contents of the clipboard' [mutable list] +# property 'clipboard' ('pcli') '****' -- 'the clipboard' [mutable list] # property 'frontmost' ('pisf') 'bool' -- 'Is this the frontmost application?' [] # property 'name' ('pnam') 'itxt' -- 'the name' [] # property 'selection' ('sele') 'csel' -- 'the selection visible to the user' [mutable] # property 'version' ('vers') 'vers' -- 'the version of the application' [] -# property 'text item delimiters' ('txdl') 'list' -- 'a list of all the text item delimiters' [mutable] -# element 'docu' as ['indx', 'name', 'rang', 'test'] -# element 'cwin' as ['indx', 'name', 'rang', 'test'] # Class 'applications' ('capp') -- 'Every application' -# property 'class attributes' ('c@#!') 'type' -- 'special class attributes' [0] +# property '' ('c@#!') 'type' -- '' [0] + +# Class 'character' ('cha ') -- 'A character' +# property 'color' ('colr') 'cRGB' -- 'the color' [mutable] +# property 'font' ('font') 'ctxt' -- 'the name of the font' [mutable] +# property 'size' ('ptsz') 'fixd' -- 'the size in points' [mutable] +# property 'writing code' ('psct') 'intl' -- 'the script system and language' [] +# property 'style' ('txst') 'tsty' -- 'the text style' [mutable] +# property 'uniform styles' ('ustl') 'tsty' -- 'the text style' [] + +# Class 'characters' ('cha ') -- 'Every character' +# property '' ('c@#!') 'type' -- '' [0] # Class 'document' ('docu') -- 'A document' -# property 'bounds' ('pbnd') 'qdrt' -- 'the boundary rectangle for the document' [mutable] -# property 'closeable' ('hclb') 'bool' -- 'Does the document have a close box?' [] -# property 'titled' ('ptit') 'bool' -- 'Does the document have a title bar?' [] -# property 'index' ('pidx') 'long' -- 'the number of the document' [mutable] -# property 'floating' ('isfl') 'bool' -- 'Does the document float?' [] -# property 'modal' ('pmod') 'bool' -- 'Is the document modal?' [] -# property 'resizable' ('prsz') 'bool' -- 'Is the document resizable?' [] -# property 'zoomable' ('iszm') 'bool' -- 'Is the document zoomable?' [] -# property 'zoomed' ('pzum') 'bool' -- 'Is the document zoomed?' [mutable] -# property 'name' ('pnam') 'itxt' -- 'the title of the document' [mutable] -# property 'selection' ('sele') 'csel' -- 'the selection visible to the user' [mutable] -# property 'visible' ('pvis') 'bool' -- 'Is the document visible?' [] # property 'modified' ('imod') 'bool' -- 'Has the document been modified since the last save?' [] -# property 'position' ('ppos') 'QDpt' -- 'upper left coordinates of the document' [] -# element 'cha ' as ['indx', 'rele', 'rang', 'test'] -# element 'cins' as ['rele'] -# element 'cpar' as ['indx', 'rele', 'rang', 'test'] -# element 'ctxt' as ['rang'] -# element 'citm' as ['indx', 'rele', 'rang', 'test'] -# element 'cwor' as ['indx', 'rele', 'rang', 'test'] # Class 'documents' ('docu') -- 'Every document' -# property 'class attributes' ('c@#!') 'type' -- 'special class attributes' [0] +# property '' ('c@#!') 'type' -- '' [0] # Class 'file' ('file') -- 'A file' +# property 'stationery' ('pspd') 'bool' -- 'Is the file a stationery file?' [mutable] # Class 'files' ('file') -- 'Every file' -# property 'class attributes' ('c@#!') 'type' -- 'special class attributes' [0] +# property '' ('c@#!') 'type' -- '' [0] -# Class 'insertion point' ('cins') -- 'An insertion location between two objects' -# property 'length' ('leng') 'long' -- 'length of text object (in characters)' [] -# property 'offset' ('ofse') 'long' -- 'offset of a text object from the beginning of the document (first char has offset 1)' [] -# property 'font' ('font') 'ctxt' -- 'the name of the font' [mutable] -# property 'size' ('ptsz') 'long' -- 'the size in points' [mutable] -# property 'style' ('txst') 'tsty' -- 'the text style' [mutable] -# property 'uniform styles' ('ustl') 'tsty' -- 'the text style' [] -# property 'writing code' ('psct') 'intl' -- 'the script system and language' [mutable] +# Class 'selection-object' ('csel') -- 'the selection visible to the user' +# property 'contents' ('pcnt') 'type' -- 'the contents of the selection' [] -# Class 'insertion points' ('cins') -- 'Every insertion location' -# property 'class attributes' ('c@#!') 'type' -- 'special class attributes' [0] +# Class 'text' ('ctxt') -- 'Text' +# property '' ('c@#!') 'type' -- '' [0] +# property 'font' ('font') 'ctxt' -- 'the name of the font of the first character' [mutable] -# Class 'selection-object' ('csel') -- 'the selection visible to the user' -# property 'contents' ('pcnt') 'type' -- 'the contents of the selection' [mutable] -# property 'length' ('leng') 'long' -- 'length of text object (in characters)' [] -# property 'offset' ('ofse') 'long' -- 'offset of a text object from the beginning of the document (first char has offset 1)' [] -# property 'font' ('font') 'ctxt' -- 'the name of the font' [mutable] -# property 'size' ('ptsz') 'long' -- 'the size in points' [mutable] -# property 'style' ('txst') 'tsty' -- 'the text style' [mutable] -# property 'uniform styles' ('ustl') 'tsty' -- 'the text style' [] -# property 'writing code' ('psct') 'intl' -- 'the script system and language' [mutable] -# element 'cha ' as ['indx', 'rele', 'rang', 'test'] -# element 'cpar' as ['indx', 'rele', 'rang', 'test'] -# element 'ctxt' as ['rang'] -# element 'citm' as ['indx', 'rele', 'rang', 'test'] -# element 'cwor' as ['indx', 'rele', 'rang', 'test'] +# Class 'text style info' ('tsty') -- 'On and Off styles of text run' +# property 'on styles' ('onst') 'styl' -- 'the styles that are on for the text' [enum list] +# property 'off styles' ('ofst') 'styl' -- 'the styles that are off for the text' [enum list] + +# Class 'text style infos' ('tsty') -- 'every text style info' +# property '' ('c@#!') 'type' -- '' [0] # Class 'window' ('cwin') -- 'A window' # property 'bounds' ('pbnd') 'qdrt' -- 'the boundary rectangle for the window' [mutable] @@ -647,17 +479,20 @@ class Standard_Suite: # property 'resizable' ('prsz') 'bool' -- 'Is the window resizable?' [] # property 'zoomable' ('iszm') 'bool' -- 'Is the window zoomable?' [] # property 'zoomed' ('pzum') 'bool' -- 'Is the window zoomed?' [mutable] -# property 'name' ('pnam') 'itxt' -- 'the title of the window' [mutable] -# property 'selection' ('sele') 'csel' -- 'the selection visible to the user' [mutable] -# property 'visible' ('pvis') 'bool' -- 'is the window visible?' [] -# property 'modified' ('imod') 'bool' -- 'has the window been modified since the last save?' [] -# property 'position' ('ppos') 'QDpt' -- 'upper left coordinates of window' [] -# element 'cha ' as ['indx', 'rele', 'rang', 'test'] -# element 'cins' as ['rele'] -# element 'cpar' as ['indx', 'rele', 'rang', 'test'] -# element 'ctxt' as ['rang'] -# element 'citm' as ['indx', 'rele', 'rang', 'test'] -# element 'cwor' as ['indx', 'rele', 'rang', 'test'] +# property 'visible' ('pvis') 'bool' -- 'Is the window visible?' [mutable] # Class 'windows' ('cwin') -- 'Every window' -# property 'class attributes' ('c@#!') 'type' -- 'special class attributes' [0] +# property '' ('c@#!') 'type' -- '' [0] + +# Class 'insertion point' ('cins') -- 'An insertion location between two objects' + +# Class 'insertion points' ('cins') -- 'Every insertion location' +# property '' ('c@#!') 'type' -- '' [0] +# comparison 'starts with' ('bgwt') -- Starts with +# comparison 'contains' ('cont') -- Contains +# comparison 'ends with' ('ends') -- Ends with +# comparison '=' ('= ') -- Equal +# comparison '>' ('> ') -- Greater than +# comparison '\263' ('>= ') -- Greater than or equal to +# comparison '<' ('< ') -- Less than +# comparison '\262' ('<= ') -- Less than or equal to diff --git a/Mac/Lib/toolbox/aetools.py b/Mac/Lib/toolbox/aetools.py index 53d2cbd..68eb825 100644 --- a/Mac/Lib/toolbox/aetools.py +++ b/Mac/Lib/toolbox/aetools.py @@ -78,6 +78,7 @@ def packevent(ae, parameters = {}, attributes = {}): # # Support routine for automatically generated Suite interfaces +# These routines are also useable for the reverse function. # def keysubst(arguments, keydict): """Replace long name keys by their 4-char counterparts, and check""" diff --git a/Mac/scripts/gensuitemodule.py b/Mac/scripts/gensuitemodule.py index f4ae00c..cd94725 100644 --- a/Mac/scripts/gensuitemodule.py +++ b/Mac/scripts/gensuitemodule.py @@ -281,10 +281,15 @@ def compileevent(fp, event): has_arg = (not is_null(accepts)) opt_arg = (has_arg and is_optional(accepts)) + fp.write("\tdef %s(self, "%funcname) if has_arg: - fp.write("\tdef %s(self, object, *arguments):\n"%funcname) + if not opt_arg: + fp.write("_object, ") # Include direct object, if it has one + else: + fp.write("_object=None, ") # Also include if it is optional else: - fp.write("\tdef %s(self, *arguments):\n"%funcname) + fp.write("_no_object=None, ") # For argument checking + fp.write("_attributes={}, **_arguments):\n") # include attribute dict and args # # Generate doc string (important, since it may be the only # available documentation, due to our name-remaping) @@ -306,65 +311,46 @@ def compileevent(fp, event): # fp.write("\t\t_code = %s\n"% `code`) fp.write("\t\t_subcode = %s\n\n"% `subcode`) - if opt_arg: - fp.write("\t\tif len(arguments):\n") - fp.write("\t\t\tobject = arguments[0]\n") - fp.write("\t\t\targuments = arguments[1:]\n") - fp.write("\t\telse:\n") - fp.write("\t\t\tobject = None\n") - fp.write("\t\tif len(arguments) > 1:\n") - fp.write("\t\t\traise TypeError, 'Too many arguments'\n") - fp.write("\t\tif arguments:\n") - fp.write("\t\t\targuments = arguments[0]\n") - fp.write("\t\t\tif type(arguments) <> type({}):\n") - fp.write("\t\t\t\traise TypeError, 'Must be a mapping'\n") - fp.write("\t\telse:\n") - fp.write("\t\t\targuments = {}\n") if has_arg: - fp.write("\t\targuments['----'] = object\n") + fp.write("\t\t_arguments['----'] = _object\n") elif opt_arg: - fp.write("\t\tif object:\n") - fp.write("\t\t\targuments['----'] = object\n") - fp.write("\n") - # - # Extract attributes - # - fp.write("\t\tif arguments.has_key('_attributes'):\n") - fp.write("\t\t\tattributes = arguments['_attributes']\n") - fp.write("\t\t\tdel arguments['_attributes']\n") - fp.write("\t\telse:\n"); - fp.write("\t\t\tattributes = {}\n") + fp.write("\t\tif _object:\n") + fp.write("\t\t\t_arguments['----'] = _object\n") + else: + fp.write("\t\tif _no_object != None: raise TypeError, 'No direct arg expected'\n") fp.write("\n") # # Do key substitution # if arguments: - fp.write("\t\taetools.keysubst(arguments, self._argmap_%s)\n"%funcname) + fp.write("\t\taetools.keysubst(_arguments, self._argmap_%s)\n"%funcname) + else: + fp.write("\t\tif _arguments: raise TypeError, 'No optional args expected'\n") for a in arguments: if is_enum(a[2]): kname = a[1] ename = a[2][0] - fp.write("\t\taetools.enumsubst(arguments, %s, _Enum_%s)\n" % + fp.write("\t\taetools.enumsubst(_arguments, %s, _Enum_%s)\n" % (`kname`, ename)) fp.write("\n") # # Do the transaction # - fp.write("\t\treply, arguments, attributes = self.send(_code, _subcode,\n") - fp.write("\t\t\t\targuments, attributes)\n") + fp.write("\t\t_reply, _arguments, _attributes = self.send(_code, _subcode,\n") + fp.write("\t\t\t\t_arguments, _attributes)\n") # # Error handling # - fp.write("\t\tif arguments.has_key('errn'):\n") - fp.write("\t\t\traise MacOS.Error, aetools.decodeerror(arguments)\n") + fp.write("\t\tif _arguments.has_key('errn'):\n") + fp.write("\t\t\traise MacOS.Error, aetools.decodeerror(_arguments)\n") fp.write("\t\t# XXXX Optionally decode result\n") # # Decode result # - fp.write("\t\tif arguments.has_key('----'):\n") + fp.write("\t\tif _arguments.has_key('----'):\n") if is_enum(returns): fp.write("\t\t\t# XXXX Should do enum remapping here...\n") - fp.write("\t\t\treturn arguments['----']\n") + fp.write("\t\t\treturn _arguments['----']\n") fp.write("\n") # print "\n# Command %s -- %s (%s, %s)" % (`name`, `desc`, `code`, `subcode`) -- cgit v0.12