forked from deanishe/awgo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add better example for customised fuzzy search
- Loading branch information
Showing
20 changed files
with
4,557 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// Copyright (c) 2017 Dean Jackson <[email protected]> | ||
// | ||
// MIT Licence. See http://opensource.org/licenses/MIT | ||
// | ||
// Created on 2017-09-08 | ||
// | ||
|
||
/* | ||
Each subdirectory contains a complete, but trivial, Alfred workflow | ||
demonstrating a feature of AwGo. | ||
After building the executable, copy or symlink the directory to Alfred's | ||
workflow directory to try it out. | ||
You can use the following script to simplify installing/symlinking workflows | ||
that are still in development: | ||
https://gist.github.com/deanishe/35faae3e7f89f629a94e | ||
If you've installed that script on your $PATH, you can try out the examples by | ||
running: | ||
workflow-install -s /path/to/example | ||
which will symlink the workflow to Alfred's workflow directory. | ||
*/ | ||
package examples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# ignore binary | ||
/fuzzy-custom |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#!/usr/bin/env python | ||
# encoding: utf-8 | ||
# | ||
# Copyright (c) 2017 Dean Jackson <[email protected]> | ||
# | ||
# MIT Licence. See http://opensource.org/licenses/MIT | ||
# | ||
# Created on 2017-09-12 | ||
# | ||
|
||
"""Fetch list of Alfred workflows on GitHub.""" | ||
|
||
from __future__ import print_function, absolute_import | ||
|
||
import json | ||
import os | ||
import sys | ||
|
||
import requests | ||
|
||
# Base search URL | ||
API_URL = 'https://api.github.com/search/repositories?per_page=100' | ||
# What to search for | ||
QUERY = 'topic:alfred-workflow' | ||
# Where to save results | ||
OUTPUT = os.path.join(os.path.dirname(__file__), 'workflows.json') | ||
# Enable beta API features (needed for topics) | ||
HEADERS = {'Accept': 'application/vnd.github.mercy-preview+json'} | ||
|
||
|
||
def log(s, *args): | ||
"""Simple STDERR logger.""" | ||
if args: | ||
s = s % args | ||
print(s, file=sys.stderr) | ||
|
||
|
||
def fetch(): | ||
"""Retrieve search results from GitHub.""" | ||
results = [] | ||
page_count = 0 | ||
page_number = 1 | ||
while True: | ||
if page_count and page_number > page_count: | ||
break | ||
|
||
log('fetching page %d ...', page_number) | ||
|
||
r = requests.get(API_URL, {'q': QUERY, 'page': page_number}, | ||
headers=HEADERS) | ||
log('[%s] %s', r.status_code, r.url) | ||
r.raise_for_status() | ||
|
||
data = r.json() | ||
page_number += 1 | ||
|
||
# populate page_count | ||
if not page_count: | ||
total_results = data.get('total_count', 100) | ||
page_count = total_results / 100 | ||
if total_results % 100: | ||
page_count += 1 | ||
|
||
log('%d results on %d pages', total_results, page_count) | ||
|
||
# extract workflows | ||
for d in data.get('items', []): | ||
results.append(dict( | ||
name=d['name'], | ||
description=d['description'], | ||
owner=d['owner']['login'], | ||
url=d['html_url'], | ||
stars=d['stargazers_count'], | ||
topics=d.get('topics', []), | ||
lang=d.get('language') or '', | ||
)) | ||
|
||
return results | ||
|
||
|
||
def main(): | ||
"""Fetch Alfred workflows from GitHub.""" | ||
results = fetch() | ||
with open(OUTPUT, 'wb') as fp: | ||
json.dump(results, fp, indent=2, sort_keys=True) | ||
|
||
log('saved %d workflows to %s', len(results), OUTPUT) | ||
|
||
if __name__ == '__main__': | ||
main() |
Oops, something went wrong.