Jump to content

Jenner36

Member
  • Posts

    6
  • Joined

  • Last visited

Reputation Activity

  1. Thanks
    Jenner36 reacted to deanishe in Using Query in Python file and setting Clipboard after   
    I’ve rewritten the workflow to show you how to handle input and output. The workflow only shows the generated reference in a Large Type output because I wasn't sure what you want to do with it. That's trivial to replace, though.
     
    Basically, you print to STDOUT to pass output to the next action, and to STDERR to write to Alfred's debugger.
     
    I've tidied up your parsing code a bit (the author name handling is a lot cleaner), but mostly I've added a bunch of "features" to show you how to handle various kinds of input and output. There's now a Script Filter to show you live feedback on the validity of your input (i.e. you have to enter a valid DOI, or it won't proceed). And if there's no input, it will check if there's a DOI on the clipboard and use that instead.
     
    The script_filter.py file shows how to send results for Alfred to show, and how to pass input to following elements. And the lookup.py file also shows how to set workflow variables to pass to downstream elements (see the notify() function).
     
    Both scripts log to Alfred's debugger (via STDERR), and they both catch errors and show them to the user instead of dying silently (which is Alfred's default behaviour). That’s important because urlopen raises an exception if you get a 404, so checking the response code isn’t enough (that code will never run).
×
×
  • Create New...