[Pythonmac-SIG] [ann] AppScripting 0.1.0
has
hengist.podd at virgin.net
Wed Nov 19 12:10:13 EST 2003
Jack wrote:
>On 19 Nov 2003, at 10:11, has wrote:
>>More important stuff includes figuring out how to create
>>typeAppSignature AEDescs (or equivalent) for apps like Address Book
>>that don't have creator codes, and how best to implement the user
>>interface for the by-test reference form (aka 'whose clauses').
>
>Assume that a LaunchServices or ApplicationServices or whatever
>module will be available soon. That'll solve the first problem,
>right?
Afraid I'm too ignorant of the lower workings of MacOS to give an
answer. Must defer to smarter minds for that.
>The second problem is more of a design problem, Python has no
>language construct for this that we could use. But the bad news is
>that I don't have an easy solution either:-(
The options I can think of are:
1. Let users work directly with the various test-related classes, eg:
imagesRef = blah.blah.blah.whose(AS.is_in(AS.ref.name_extension,
['gif', 'jpg', 'png']))
(This'd be simple to implement, but also the least pleasant to use.)
2. Let users express the test as an interpolated string that's parsed
for meaning internally, eg:
imagesRef = blah.blah.blah.whose('name_extension is in $', ['gif',
'jpg', 'png'])
(This'd require a basic parser, but nothing I couldn't write myself.
And Python folk are already used to %-interpolated strings so
shouldn't find this variant too tedious.)
3. Let users express the test as a series of attribute accesses and
method calls:
imagesRef = blah.blah.blah.whose.name_extension.is_in(['gif', 'jpg', 'png'])
(This is just an extension of the approach ScriptingInterface uses to
build OSA object specifiers - a series of chained __getattr__ calls
hanging off a smart 'whose' object that assembles the OSA expression.)
Any thoughts?
has
--
http://freespace.virgin.net/hamish.sanderson/
More information about the Pythonmac-SIG
mailing list