Skip to content

Instantly share code, notes, and snippets.

@fractaledmind
Created May 19, 2014 18:02
Show Gist options
  • Save fractaledmind/b58ff306a75a62e2af11 to your computer and use it in GitHub Desktop.
Save fractaledmind/b58ff306a75a62e2af11 to your computer and use it in GitHub Desktop.
Alfred, check for workflow by name
#!/usr/bin/python
# encoding: utf-8
import os
import plistlib
def check_for_workflow(name):
"""Check if specified workflow name exists"""
workflows_dir = os.path.dirname(os.getcwd())
all_wfs = os.walk(workflows_dir).next()[1]
found = False
for wf in all_wfs:
plist = workflows_dir + "/" + wf + "/info.plist"
if os.path.isfile(plist):
plist_info = plistlib.readPlist(plist)
wf_name = plist_info['name'].lower()
if wf_name == name.lower():
found = True
break
return found
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment