summaryrefslogtreecommitdiffstats
path: root/Mac/Lib/aetools.py
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2002-08-07 14:49:00 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>2002-08-07 14:49:00 (GMT)
commit8b77767094ba4bf3fb497ce974261366470d6aa3 (patch)
treee4283696eb5272d0aaff19cf4c0832bc57321575 /Mac/Lib/aetools.py
parentb2bb87300bd5db23216d5f339e1cdb6e4c613b42 (diff)
downloadcpython-8b77767094ba4bf3fb497ce974261366470d6aa3.zip
cpython-8b77767094ba4bf3fb497ce974261366470d6aa3.tar.gz
cpython-8b77767094ba4bf3fb497ce974261366470d6aa3.tar.bz2
Donovan Preston's patch #538395, with some mods by me.
This patch makes inheritance for OSA classes work. The implementation is a bit convoluted, but I don't immedeately see a simpler way of doing it. I added calls to ascii() everywhere we output strings that may contain non-ascii characters (Python has gotten very picky since the encoding patch:-). I also removed Donovan's different way of opening resource files: I don't seem to need it.
Diffstat (limited to 'Mac/Lib/aetools.py')
-rw-r--r--Mac/Lib/aetools.py40
1 files changed, 32 insertions, 8 deletions
diff --git a/Mac/Lib/aetools.py b/Mac/Lib/aetools.py
index ba42f03..5495dfa 100644
--- a/Mac/Lib/aetools.py
+++ b/Mac/Lib/aetools.py
@@ -28,7 +28,7 @@ import MacOS
import sys
from aetypes import *
-from aepack import pack, unpack, coerce, AEDescType
+from aepack import packkey, pack, unpack, coerce, AEDescType
Error = 'aetools.Error'
@@ -56,19 +56,19 @@ def missed(ae):
return None
return desc.data
-def unpackevent(ae):
+def unpackevent(ae, formodulename=""):
parameters = {}
try:
dirobj = ae.AEGetParamDesc('----', '****')
except AE.Error:
pass
else:
- parameters['----'] = unpack(dirobj)
+ parameters['----'] = unpack(dirobj, formodulename)
del dirobj
while 1:
key = missed(ae)
if not key: break
- parameters[key] = unpack(ae.AEGetParamDesc(key, '****'))
+ parameters[key] = unpack(ae.AEGetParamDesc(key, '****'), formodulename)
attributes = {}
for key in aekeywords:
try:
@@ -77,14 +77,14 @@ def unpackevent(ae):
if msg[0] != -1701 and msg[0] != -1704:
raise sys.exc_type, sys.exc_value
continue
- attributes[key] = unpack(desc)
+ attributes[key] = unpack(desc, formodulename)
return parameters, attributes
def packevent(ae, parameters = {}, attributes = {}):
for key, value in parameters.items():
- ae.AEPutParamDesc(key, pack(value))
+ packkey(ae, key, value)
for key, value in attributes.items():
- ae.AEPutAttributeDesc(key, pack(value))
+ packkey(ae, key, value)
#
# Support routine for automatically generated Suite interfaces
@@ -130,6 +130,7 @@ def decodeerror(arguments):
class TalkTo:
"""An AE connection to an application"""
_signature = None # Can be overridden by subclasses
+ _moduleName = None # Can be overridden by subclasses
def __init__(self, signature=None, start=0, timeout=0):
"""Create a communication channel with a particular application.
@@ -183,7 +184,7 @@ class TalkTo:
reply = event.AESend(self.send_flags, self.send_priority,
self.send_timeout)
- parameters, attributes = unpackevent(reply)
+ parameters, attributes = unpackevent(reply, self._moduleName)
return reply, parameters, attributes
def send(self, code, subcode, parameters = {}, attributes = {}):
@@ -218,6 +219,29 @@ class TalkTo:
if _arguments.has_key('----'):
return _arguments['----']
+ if as:
+ item.__class__ = as
+ return item
+
+ def _set(self, _object, _arguments = {}, _attributes = {}):
+ """ _set: set data for an object
+ Required argument: the object
+ Keyword argument _parameters: Parameter dictionary for the set operation
+ Keyword argument _attributes: AppleEvent attribute dictionary
+ Returns: the data
+ """
+ _code = 'core'
+ _subcode = 'setd'
+
+ _arguments['----'] = _object
+
+ _reply, _arguments, _attributes = self.send(_code, _subcode,
+ _arguments, _attributes)
+ if _arguments.has_key('errn'):
+ raise Error, decodeerror(_arguments)
+
+ if _arguments.has_key('----'):
+ return _arguments['----']
# Tiny Finder class, for local use only