[Pythonmac-SIG] Help getting properties in py-appscript?

Charles Turner vze26m98 at optonline.net
Tue Apr 13 15:25:33 CEST 2010


Hi all-

Having some trouble getting my head around this, and wonder if someone  
could shed some light.

I'm using py-appscript to get the properties of a record in DEVONthink  
Pro:

from appscript import *

dtpo = app('DEVONthink Pro.app')
i = dtpo.selection.get()
props = i[0].properties.get()

print props[k.uuid]
print props[k.name]
print props[k.type]
print props[k.tags]
print props[k.plain_text]

This works just fine at the top level of the script, but when I get()  
and reference props inside a function definition, Python complains  
about the dot in k-dot-name, for example:

"UnboundLocalError: "local variable 'k' referenced before assignment""

If I ask for the keys inside the function I get the following array of  
type:

<class 'appscript.keywordwrapper.Keyword'>

[k.comment, k.exclude_from_search, k.duplicates, k.image,  
k.page_count, k.word_count, k.height, k.thumbnail, k.opening_date,  
k.number_of_duplicates, k.filename, k.attached_script, k.size,  
k.exclude_from_tagging, k.dimensions, k.modification_date, k.width,  
k.locking, k.id, k.source, k.state, k.score, k.location,  
k.addition_date, k.indexed, k.character_count, k.aliases, k.type,  
k.rich_text, k.columns, k.tags, k.URL, k.plain_text, k.date_,  
k.class_, k.meta_data, k.exclude_from_classification, k.path,  
k.creation_date, k.data, k.uuid, k.kind, k.name, k.database,  
k.state_visibility, k.interval, k.label, k.number_of_replicants,  
k.exclude_from_see_also, k.MIME_type, k.unread, k.cells, k.dpi]

So how can I approach this?

Using System Python (2.5.1) on Leopard

Thanks in advance!

Best wishes,

Charles




More information about the Pythonmac-SIG mailing list