Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d50c66b

Browse files
committed
A "magic" suite that is the base suite for StdSuites. This solves a problem with the required events open/openapp/reopen/print/quit officially being part of Required but being defined (by Apple) in Standard.
Most of the code and ideas contributed by Michael j. Barber.
1 parent bbf5ef5 commit d50c66b

2 files changed

Lines changed: 168 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""
2+
Manually generated suite used as base class for StdSuites Required and Standard
3+
suites. This is needed because the events and enums in this suite belong
4+
in the Required suite according to the Apple docs, but they often seem to be
5+
in the Standard suite.
6+
"""
7+
import aetools
8+
import builtin_Suite
9+
10+
11+
_code_to_module = {
12+
'reqd' : builtin_Suite,
13+
'core' : builtin_Suite,
14+
}
15+
16+
17+
18+
_code_to_fullname = {
19+
'reqd' : ('_builtinSuites.builtin_Suite', 'builtin_Suite'),
20+
'core' : ('_builtinSuites.builtin_Suite', 'builtin_Suite'),
21+
}
22+
23+
from builtin_Suite import *
24+
25+
class _builtinSuites(builtin_Suite_Events,
26+
aetools.TalkTo):
27+
_signature = 'ascr'
28+
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
"""Suite builtin_Suite: Every application supports open, reopen, print, run, and quit
2+
Level 1, version 1
3+
"""
4+
5+
import aetools
6+
import MacOS
7+
8+
_code = 'aevt'
9+
10+
class builtin_Suite_Events:
11+
12+
def open(self, _object, _attributes={}, **_arguments):
13+
"""open: Open the specified object(s)
14+
Required argument: list of objects to open
15+
Keyword argument _attributes: AppleEvent attribute dictionary
16+
"""
17+
_code = 'aevt'
18+
_subcode = 'odoc'
19+
20+
if _arguments: raise TypeError, 'No optional args expected'
21+
_arguments['----'] = _object
22+
23+
24+
_reply, _arguments, _attributes = self.send(_code, _subcode,
25+
_arguments, _attributes)
26+
if _arguments.has_key('errn'):
27+
raise aetools.Error, aetools.decodeerror(_arguments)
28+
# XXXX Optionally decode result
29+
if _arguments.has_key('----'):
30+
return _arguments['----']
31+
32+
def run(self, _no_object=None, _attributes={}, **_arguments):
33+
"""run: Run an application. Most applications will open an empty, untitled window.
34+
Keyword argument _attributes: AppleEvent attribute dictionary
35+
"""
36+
_code = 'aevt'
37+
_subcode = 'oapp'
38+
39+
if _arguments: raise TypeError, 'No optional args expected'
40+
if _no_object != None: raise TypeError, 'No direct arg expected'
41+
42+
43+
_reply, _arguments, _attributes = self.send(_code, _subcode,
44+
_arguments, _attributes)
45+
if _arguments.has_key('errn'):
46+
raise aetools.Error, aetools.decodeerror(_arguments)
47+
# XXXX Optionally decode result
48+
if _arguments.has_key('----'):
49+
return _arguments['----']
50+
51+
def reopen(self, _no_object=None, _attributes={}, **_arguments):
52+
"""reopen: Reactivate a running application. Some applications will open a new untitled window if no window is open.
53+
Keyword argument _attributes: AppleEvent attribute dictionary
54+
"""
55+
_code = 'aevt'
56+
_subcode = 'rapp'
57+
58+
if _arguments: raise TypeError, 'No optional args expected'
59+
if _no_object != None: raise TypeError, 'No direct arg expected'
60+
61+
62+
_reply, _arguments, _attributes = self.send(_code, _subcode,
63+
_arguments, _attributes)
64+
if _arguments.has_key('errn'):
65+
raise aetools.Error, aetools.decodeerror(_arguments)
66+
# XXXX Optionally decode result
67+
if _arguments.has_key('----'):
68+
return _arguments['----']
69+
70+
def _print(self, _object, _attributes={}, **_arguments):
71+
"""print: Print the specified object(s)
72+
Required argument: list of objects to print
73+
Keyword argument _attributes: AppleEvent attribute dictionary
74+
"""
75+
_code = 'aevt'
76+
_subcode = 'pdoc'
77+
78+
if _arguments: raise TypeError, 'No optional args expected'
79+
_arguments['----'] = _object
80+
81+
82+
_reply, _arguments, _attributes = self.send(_code, _subcode,
83+
_arguments, _attributes)
84+
if _arguments.has_key('errn'):
85+
raise aetools.Error, aetools.decodeerror(_arguments)
86+
# XXXX Optionally decode result
87+
if _arguments.has_key('----'):
88+
return _arguments['----']
89+
90+
_argmap_quit = {
91+
'saving' : 'savo',
92+
}
93+
94+
def quit(self, _no_object=None, _attributes={}, **_arguments):
95+
"""quit: Quit an application
96+
Keyword argument saving: specifies whether to save currently open documents
97+
Keyword argument _attributes: AppleEvent attribute dictionary
98+
"""
99+
_code = 'aevt'
100+
_subcode = 'quit'
101+
102+
aetools.keysubst(_arguments, self._argmap_quit)
103+
if _no_object != None: raise TypeError, 'No direct arg expected'
104+
105+
aetools.enumsubst(_arguments, 'savo', _Enum_savo)
106+
107+
_reply, _arguments, _attributes = self.send(_code, _subcode,
108+
_arguments, _attributes)
109+
if _arguments.has_key('errn'):
110+
raise aetools.Error, aetools.decodeerror(_arguments)
111+
# XXXX Optionally decode result
112+
if _arguments.has_key('----'):
113+
return _arguments['----']
114+
115+
_argmap_close = {
116+
'saving' : 'savo',
117+
'saving_in' : 'kfil',
118+
}
119+
120+
_Enum_savo = {
121+
'yes' : 'yes ', # Save objects now
122+
'no' : 'no ', # Do not save objects
123+
'ask' : 'ask ', # Ask the user whether to save
124+
}
125+
126+
#
127+
# Indices of types declared in this module
128+
#
129+
_classdeclarations = {
130+
}
131+
132+
_propdeclarations = {
133+
}
134+
135+
_compdeclarations = {
136+
}
137+
138+
_enumdeclarations = {
139+
'savo' : _Enum_savo,
140+
}

0 commit comments

Comments
 (0)