Skip to content

Commit

Permalink
Update AW to v1.28
Browse files Browse the repository at this point in the history
  • Loading branch information
deanishe committed Sep 17, 2017
1 parent 6ed10fa commit 0557322
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 63 deletions.
Binary file not shown.
94 changes: 48 additions & 46 deletions src/info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -48,50 +48,31 @@
<dict>
<key>config</key>
<dict>
<key>concurrently</key>
<key>lastpathcomponent</key>
<false/>
<key>escaping</key>
<integer>102</integer>
<key>script</key>
<string>mode=$1
datadir="$alfred_workflow_data"
cachedir="$alfred_workflow_cache"
blacklist="${datadir}/blacklist.txt"
logfile="${cachedir}/net.deanishe.alfred.fixum.log"
# create data &amp; cache directories, logfile and blacklist
test -d "$cachedir" || mkdir -p "$cachedir"
test -f "$logfile" || touch "$logfile"
test -d "$datadir" || mkdir -p "$datadir"
test -f "$blacklist" || cp blacklist.default.txt "$blacklist"
# script actions
[[ "$mode" = dryrun ]] &amp;&amp; /usr/bin/python fixum.py --nothing
[[ "$mode" = fix ]] &amp;&amp; /usr/bin/python fixum.py
[[ "$mode" = blacklist ]] &amp;&amp; open "$blacklist"
[[ "$mode" = log ]] &amp;&amp; open -a Console "$logfile"
exit 0</string>
<key>scriptargtype</key>
<integer>1</integer>
<key>scriptfile</key>
<string></string>
<key>type</key>
<integer>5</integer>
<key>onlyshowifquerypopulated</key>
<true/>
<key>removeextension</key>
<false/>
<key>text</key>
<string>{query}</string>
<key>title</key>
<string>Fixum</string>
</dict>
<key>type</key>
<string>alfred.workflow.action.script</string>
<string>alfred.workflow.output.notification</string>
<key>uid</key>
<string>97033D94-9B6F-446C-94E5-AB677B5ABB4F</string>
<string>90302262-60E4-4C1C-AAEA-2A5C3F4C025A</string>
<key>version</key>
<integer>2</integer>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>alfredfiltersresults</key>
<false/>
<key>alfredfiltersresultsmatchmode</key>
<integer>0</integer>
<key>argumenttrimmode</key>
<integer>0</integer>
<key>argumenttype</key>
Expand Down Expand Up @@ -135,23 +116,44 @@ exit 0</string>
<dict>
<key>config</key>
<dict>
<key>lastpathcomponent</key>
<false/>
<key>onlyshowifquerypopulated</key>
<true/>
<key>removeextension</key>
<key>concurrently</key>
<false/>
<key>text</key>
<string>{query}</string>
<key>title</key>
<string>Fixum</string>
<key>escaping</key>
<integer>102</integer>
<key>script</key>
<string>mode=$1
datadir="$alfred_workflow_data"
cachedir="$alfred_workflow_cache"
blacklist="${datadir}/blacklist.txt"
logfile="${cachedir}/net.deanishe.alfred.fixum.log"
# create data &amp; cache directories, logfile and blacklist
test -d "$cachedir" || mkdir -p "$cachedir"
test -f "$logfile" || touch "$logfile"
test -d "$datadir" || mkdir -p "$datadir"
test -f "$blacklist" || cp blacklist.default.txt "$blacklist"
# script actions
[[ "$mode" = dryrun ]] &amp;&amp; /usr/bin/python fixum.py --nothing
[[ "$mode" = fix ]] &amp;&amp; /usr/bin/python fixum.py
[[ "$mode" = blacklist ]] &amp;&amp; open "$blacklist"
[[ "$mode" = log ]] &amp;&amp; open -a Console "$logfile"
exit 0</string>
<key>scriptargtype</key>
<integer>1</integer>
<key>scriptfile</key>
<string></string>
<key>type</key>
<integer>5</integer>
</dict>
<key>type</key>
<string>alfred.workflow.output.notification</string>
<string>alfred.workflow.action.script</string>
<key>uid</key>
<string>90302262-60E4-4C1C-AAEA-2A5C3F4C025A</string>
<string>97033D94-9B6F-446C-94E5-AB677B5ABB4F</string>
<key>version</key>
<integer>1</integer>
<integer>2</integer>
</dict>
</array>
<key>readme</key>
Expand Down Expand Up @@ -183,7 +185,7 @@ It is primarily a workaround to fix bugs that are preventing the workflows from
</dict>
</dict>
<key>version</key>
<string>0.4</string>
<string>0.5</string>
<key>webaddress</key>
<string></string>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion src/workflow/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.27
1.28
12 changes: 5 additions & 7 deletions src/workflow/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1959,10 +1959,8 @@ def filter(self, query, items, key=lambda x: x, ascending=False,
``query`` is case-insensitive. Any item that does not contain the
entirety of ``query`` is rejected.
.. warning::
If ``query`` is an empty string or contains only whitespace,
a :class:`ValueError` will be raised.
If ``query`` is an empty string or contains only whitespace,
all items will match.
:param query: query to test items against
:type query: ``unicode``
Expand Down Expand Up @@ -2055,13 +2053,13 @@ def filter(self, query, items, key=lambda x: x, ascending=False,
"""
if not query:
raise ValueError('Empty `query`')
return items

# Remove preceding/trailing spaces
query = query.strip()

if not query:
raise ValueError('`query` contains only whitespace')
return items

# Use user override if there is one
fold_diacritics = self.settings.get('__workflow_diacritic_folding',
Expand Down Expand Up @@ -2773,7 +2771,7 @@ def list_magic():
for name in sorted(self.magic_arguments.keys()):
if name == 'magic':
continue
arg = '{0}{1}'.format(self.magic_prefix, name)
arg = self.magic_prefix + name
self.logger.debug(arg)

if not isatty:
Expand Down
27 changes: 18 additions & 9 deletions src/workflow/workflow3.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,14 @@ class Item3(object):
Generates Alfred-compliant JSON for a single item.
Don't use this class directly (as it then won't be associated with
any :class:`Workflow3` object), but rather use
any :class:`Workflow3 <workflow.Workflow3>` object), but rather use
:meth:`Workflow3.add_item() <workflow.Workflow3.add_item>`.
See :meth:`~workflow.Workflow3.add_item` for details of arguments.
"""

def __init__(self, title, subtitle='', arg=None, autocomplete=None,
valid=False, uid=None, icon=None, icontype=None,
match=None, valid=False, uid=None, icon=None, icontype=None,
type=None, largetext=None, copytext=None, quicklookurl=None):
"""Create a new :class:`Item3` object.
Expand All @@ -276,6 +276,7 @@ def __init__(self, title, subtitle='', arg=None, autocomplete=None,
self.subtitle = subtitle
self.arg = arg
self.autocomplete = autocomplete
self.match = match
self.valid = valid
self.uid = uid
self.icon = icon
Expand Down Expand Up @@ -362,6 +363,9 @@ def obj(self):
if self.autocomplete is not None:
o['autocomplete'] = self.autocomplete

if self.match is not None:
o['match'] = self.match

if self.uid is not None:
o['uid'] = self.uid

Expand Down Expand Up @@ -548,12 +552,17 @@ def getvar(self, name, default=None):
return self.variables.get(name, default)

def add_item(self, title, subtitle='', arg=None, autocomplete=None,
valid=False, uid=None, icon=None, icontype=None,
type=None, largetext=None, copytext=None, quicklookurl=None):
valid=False, uid=None, icon=None, icontype=None, type=None,
largetext=None, copytext=None, quicklookurl=None, match=None):
"""Add an item to be output to Alfred.
See :meth:`Workflow.add_item() <workflow.Workflow.add_item>` for the
main documentation.
Args:
match (unicode, optional): If you have "Alfred filters results"
turned on for your Script Filter, Alfred (version 3.5 and
above) will filter against this field, not ``title``.
See :meth:`Workflow.add_item() <workflow.Workflow.add_item>` for
the main documentation and other parameters.
The key difference is that this method does not support the
``modifier_subtitles`` argument. Use the :meth:`~Item3.add_modifier()`
Expand All @@ -563,8 +572,8 @@ def add_item(self, title, subtitle='', arg=None, autocomplete=None,
Item3: Alfred feedback item.
"""
item = self.item_class(title, subtitle, arg,
autocomplete, valid, uid, icon, icontype, type,
item = self.item_class(title, subtitle, arg, autocomplete,
match, valid, uid, icon, icontype, type,
largetext, copytext, quicklookurl)

self._items.append(item)
Expand All @@ -577,7 +586,7 @@ def _session_prefix(self):

def _mk_session_name(self, name):
"""New cache name/key based on session ID."""
return '{0}{1}'.format(self._session_prefix, name)
return self._session_prefix + name

def cache_data(self, name, data, session=False):
"""Cache API with session-scoped expiry.
Expand Down

0 comments on commit 0557322

Please sign in to comment.