Skip to content

Commit

Permalink
python 2.6 support
Browse files Browse the repository at this point in the history
  • Loading branch information
pochemuto committed Aug 26, 2015
1 parent 6e07600 commit b435371
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
19 changes: 12 additions & 7 deletions src/alfredhelp.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#coding: utf
__author__ = u'pochemuto'
import sys, plistlib, os, argparse
import sys, plistlib, os
from os import path
from workflow import Workflow, ICON_HELP, ICON_INFO
from workflow.background import run_in_background, is_running
Expand All @@ -10,11 +10,7 @@


def main(wf):
argparser = argparse.ArgumentParser()
argparser.add_argument('--keywords', dest='show_keywords', action='store_true')
argparser.add_argument('--scan', action='store_true')
argparser.add_argument('query', nargs='?', default=None)
args = argparser.parse_args(wf.args)
args = Args(wf.args)

actions = wf.cached_data('actions', None, max_age=0)

Expand Down Expand Up @@ -45,7 +41,7 @@ def main(wf):
if action.add_space:
argument += u' '
wf.add_item(
title=u'{} - {}'.format(action.keyword, action.title),
title=u'{keyword} - {title}'.format(keyword=action.keyword, title=action.title),
subtitle=action.subtitle,
icon=action.icon,
arg=argument,
Expand All @@ -72,6 +68,15 @@ def __init__(self):
self.workflow_name = None
self.add_space = False

class Args:
def __init__(self, args):
self.show_keywords = self.get_arg(args, 0) == '--keywords'
self.scan = self.get_arg(args, 0) == '--scan'
self.query = self.get_arg(args, 1)

@staticmethod
def get_arg(args, n, default=None):
return args[n] if len(args) > n else default

def search_key(action):
elements = [action.keyword, action.title, action.subtitle]
Expand Down
2 changes: 1 addition & 1 deletion src/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.0
1.0.1

0 comments on commit b435371

Please sign in to comment.