talonvoice / talon

Issue Tracker for the main Talon app
85 stars 0 forks source link

appscript help doesn't work #334

Open nriley opened 3 years ago

nriley commented 3 years ago

py-appscript has a nice help feature (kinda like python's builtin help) which requires building the ASDictionary app.

ASDictionary does build (sort of), but:

Aside from installing a backrev HTMLParser from PyPI I just had to build and install the other components of https://github.com/hhas/appscript in a virtualenv:

% pwd
/Users/nicholas/src/appscript/ASDictionary/trunk/src
% pip freeze -l
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
aemreceive==0.4.0
altgraph==0.17
appscript==1.1.2
HTMLTemplate==1.5.0
macholib==1.14
modulegraph==0.18
osaterminology==0.14.6
py2app==0.24
pyobjc==5.3
[...]
% python setup.py py2app -A               
[...]
% dist/ASDictionary.app/Contents/MacOS/ASDictionary

In Talon's REPL:

>>> ui.apps(bundle='com.apple.finder')[0].appscript().help()
No help available: ASDictionary raised an error: Command failed: An internal error occurred: untrapped exception in AE handler 'AppSHelp'.
Traceback (most recent call last):
  File "build/bdist.macosx-10.15-x86_64/egg/aemreceive/main.py", line 152, in wrapper
    reply = callback(**kargs)
  File "/Users/nicholas/src/appscript/ASDictionary/trunk/src/appscriptsupport.py", line 462, in help
    helpobj = Help(appobj, style, output)
  File "/Users/nicholas/src/appscript/ASDictionary/trunk/src/appscriptsupport.py", line 186, in __init__
    aetes, appname, style)
  File "build/bdist.macosx-10.15-x86_64/egg/osaterminology/dom/aeteparser.py", line 252, in parseaetes
    p = _parsers[style](path)
  File "build/bdist.macosx-10.15-x86_64/egg/osaterminology/dom/aeteparser.py", line 43, in __init__
    name = '/' in path and (path.split('/')[-1] or path.split('/')[-2]) or path
TypeError: argument of type 'int' is not iterable
 (-10000)
app(pid=612)
>>> app('/System/Library/CoreServices/Finder.app').help()
==============================================================================
Help (-t)

Reference: app(u'/System/Library/CoreServices/Finder.app')

------------------------------------------------------------------------------
Description of reference

Terminology for application class

Class: application -- The Finder
  Plural:
    applications
  Properties:
    clipboard (r/o) : reference -- (NOT AVAILABLE YET) the Finder’s clipboard window
    name (r/o) : AEType("ctxt") -- the Finder’s name
    visible : boolean -- Is the Finder’s layer visible?
    frontmost : boolean -- Is the Finder the frontmost process?
    selection : reference -- the selection in the frontmost Finder window
    insertion_location (r/o) : reference -- the container in which a new folder would appear if “New Folder” was selected
[...]
nriley commented 2 years ago

If you build ASDictionary from source then Talon appscript's help system starts working successfully. Both @phillco and I have done this; will post instructions somewhere if others want to try.