コード例 #1
0
def main(action, query):
    # If the configuration file doesn't exist, create an empty one
    if not os.path.isfile(_CONFIG_FILE):
        create_config()
        alfred.write(alfred.xml(config_file_is_empty()))
        return

    try:
        config = get_config()
        if not config.sections() and action != 'add':
            # If the configuration file is empty, tell the user to add secrets to it
            alfred.write(alfred.xml(config_file_is_empty()))
            return
    except Exception as e:
        alfred.write(alfred.xml([alfred.Item({u'uid': alfred.uid(0),
                                              u'arg': '', u'ignore': 'yes'},
                                             "~/.gauth: Invalid syntax",
                                             str(e).replace('\n', ' '),
                                             "error.png")]))
        sys.exit(1)

    if action == 'list' and not is_command(query):
        alfred.write(alfred.xml(list_accounts(config, query), maxresults=_MAX_RESULTS))
    elif action == 'add':
        alfred.write(add_account(config, query))
コード例 #2
0
def process():
    dirname = os.path.dirname(os.path.abspath('.'))

    dirs = [f for f in os.listdir(dirname) if os.path.isdir(os.path.join(dirname, f))]

    results = []

    for (idx,d) in enumerate(dirs):
        try:
            print os.path.join(dirname, d, 'settings.plist')
            plist = plistlib.readPlist(os.path.join(dirname, d, 'info.plist'))
        except:
            continue

        title = plist['name']
        disabled = plist.get('disabled', None)
        createdby = plist['createdby']
        displayTitle = title + (' - disabled' if disabled else '')

        results.append({'title': displayTitle, 'createdby' : createdby, 'disabled' : disabled, 'directory' : d})

    results = sorted(results, key=lambda a: a['title'].lower())

    resultsData = [alfred.Item(title=f['title'], subtitle=' by ' + (f['createdby'] or "[noinfo]"), attributes = {'uid':uuid4(), 'arg':os.path.join(dirname,f['directory'])}, icon=os.path.join(dirname, f['directory'], u"icon.png")) for f in results]

    alfred.write(alfred.xml(resultsData, maxresults=None))
コード例 #3
0
ファイル: actions.py プロジェクト: rbnio/pocket_alfred
def get_actions():
	arr = []
	isChrome = bool(int(applescript("isChrome")))
	isSafari = bool(int(applescript("isSafari")))
	isClipboard = applescript("isClipboard")

	if isChrome:
		chrome_url = applescript("chrome")
		arr.append(alfred.Item(
			attributes={'uid': alfred.uid(0), 'arg': "chrome"},
			title='Pocket - save url from Chrome',
			icon='icon.png',
			subtitle= chrome_url["title"].decode('utf8')
		))
	if isSafari:
		s_url = applescript("safari")
		arr.append(alfred.Item(
			attributes={'uid': alfred.uid(0), 'arg': "safari"},
			title='Pocket - save url from Safari',
			icon='icon.png',
			subtitle=s_url["title"].decode('utf8')
		))
	if isClipboard:
		c_url = applescript("clip")
		arr.append(alfred.Item(
				attributes={'uid': alfred.uid(0), 'arg': "clip"},
				title='Pocket - save url from Clipboard',
				icon='icon.png',
				subtitle=c_url["url"].decode('utf8')
			))
	xml = alfred.xml(arr)
	alfred.write(xml)
コード例 #4
0
def process(query_str):
    """ Entry point """
    value = parse_query_value(query_str)
    if value is not None:
        results = alfred_items_for_value(value)
        xml = alfred.xml(results) # compiles the XML answer
        alfred.write(xml) # writes the XML back to Alfred
コード例 #5
0
ファイル: tagview.py プロジェクト: BenziAhamed/todo
def generate_view(query, entered_tag, info):
    feedback_items = []
    tags = itemlist.get_tags()

    # check if we have any tags
    if len(tags) == 0:
        feedback_items.append(default_no_tags())
        config.update_state(tag='#default')
    else:
        if entered_tag:
            feedback_items.append(itemview.generate_add_feedbackitem(query, info))
        sorted_tags = sorted(tags, key=lambda x: x)
        for tag in sorted_tags:
            if not entered_tag or tag.lower().find(entered_tag.lower()) >= 0:
                count = tags[tag]
                feedback_items.append(
                    alfred.Item(
                        attributes={
                            'uid': uuid4(),
                            'arg': helpers.encode_tag(tag),
                            'autocomplete': "#{0} ".format(tag),
                            'valid': 'yes'
                        },
                        title="#{0}".format(tag),
                        subtitle="{0} item{1}".format(count, ('' if count == 1 else 's')),
                        icon="todo_tag.png"
                    )
                )
    config.update_state(view='tag_view', command='display_tags')
    alfred.write(alfred.xml(feedback_items))
コード例 #6
0
ファイル: think.py プロジェクト: jhalan6/learn-and-think
def main():
    #read
    knowledge_dir = '~/Knowledges'
    query = sys.argv[1:]
    result = "grep -r key %s" % knowledge_dir
    for argu in query:
        if argu:
            result += "| grep " + argu
    (status, output) = commands.getstatusoutput(result)
    result = []

    i = 1
    for line in output.split('\n'):
        if line:
            file_name = line.split(':')[0]
            key_list = line.split(':')[1].decode('utf8')
            preview = commands.getoutput("cat %s | grep title" %
                                         file_name).decode('utf8')
            result.append(
                alfred.Item({
                    "uid": alfred.uid(i),
                    'arg': file_name
                }, key_list, preview, None))
            i = i + 1

    if not result:
        result.append(
            alfred.Item({"uid": alfred.uid(i)}, "nothing find", "", None))

    alfred.write(alfred.xml(result))
コード例 #7
0
def show_recent_list_of_file(target_file):
    '''
    Get the recent list saved by the parameter file.
    '''
    file_path = expanduser('~') + '/Library/Preferences/' + target_file
    feedback = []

    index = 0
    res = True
    while res:
        sub_cmd = 'Print RecentDocuments:CustomListItems:' + str(index) + ':Name'
        cmd = ['/usr/libexec/PlistBuddy', '-c', sub_cmd, file_path]
        p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        out, err = p.communicate()
        res = out != ''
        if res:
            out_arg = unicode(target_file, 'utf-8') + ' ' + unicode(out.strip(), 'utf-8')
            feedback.append(alfred.Item(
                {'arg': out_arg}, # item attribute
                unicode(out.strip(), 'utf-8'), # title
                unicode(target_file, 'utf-8') # subtitle
                )
            )
        index = index + 1
    alfred.write(alfred.xml(feedback))
コード例 #8
0
ファイル: main.py プロジェクト: CreSeed/alfred-extension
def main():
    try:
        q = unicode(sys.argv[1])
        q = unicodedata.normalize('NFC', q).lower().replace(' ','')
    except:
        q = ""
        
    rss = rss_data()
    config = config_data()
    try:
        max_results = config['max_results']
    except:
        max_results = None

    results = []
    for e in itertools.islice(rss,max_results):
        if not q or q in e['title'].lower().replace(' ',''):
            results.append(alfred.Item(title=e['title'],subtitle=e['published'],attributes={'arg':e['link']},icon=e['image']))

    try:
        last_updated = config['last_updated']
    except:
        last_updated = 0
    subtitle = "Last updated: "+(last_updated and util.pretty_date(config['last_updated']) or "no info")
    
    diff = int(time.time())-last_updated
    if diff > RELOAD_ASK_THRESHOLD or len(rss) == 0:
        results.insert(0,alfred.Item(title="BackToTheMac - Reload Data?", subtitle=subtitle,
                                     attributes={'arg':'reload','uid':alfred.uid('t')}, icon="icon.png"))
    else:
        results.insert(0,alfred.Item(title="BackToTheMac", subtitle=subtitle,
                                     attributes={'arg':'http://macnews.tistory.com','uid':alfred.uid('t')}, icon="icon.png"))
    
    alfred.write(alfred.xml(results, maxresults=None))
コード例 #9
0
ファイル: itemview.py プロジェクト: 00zl00/AlfredWorkflow.com
def generate_view(query):
	if len(query) == 0  and config.get('todo.command.last') == 'quick_create':
		add_query = config.get('todo.user.query')
		add_tag = config.get('todo.tag.recent')
		itemlist.save_todo(add_query,silent=True)
		config.update_state(command='', query='')

	info = parser.parse(query)
	tag = info['tag']
	q = info['task']
	
	todos = itemlist.get_todo_list()

	# view for pinned items
	# pinned items should have unique uuid and different logo
	pinned = [t for t in todos if itemlist.feature(t,'pinned') == True]
	pinned = [t for t in pinned if (tag is None or t['group'] == tag)]
	pinned = [t for t in pinned if (q is None or t['title'].lower().find(q.lower()) >= 0)] 
	pinned = pinned[::-1]
	# view for non-pinned items
	normal = [t for t in todos if itemlist.feature(t,'pinned') == False]
	normal = [t for t in normal if (tag is None or t['group'] == tag)]
	normal = [t for t in normal if (q is None or t['title'].lower().find(q.lower()) >= 0)] 
	normal = normal[::-1]

	feedback_items = []
	if len(normal) == 0 and len(pinned) == 0:
		feedback_items.append( generate_add_feedbackitem(query, info) )
	else:
		pinned = map(lambda x: generate_pinned_feedbackitem(x), pinned)
		normal = map(lambda x: generate_todo_feedbackitem(x), normal)
		feedback_items = pinned + normal
	
	alfred.write(alfred.xml(feedback_items))
コード例 #10
0
def alfred_search(keyword, query):

    infos = []

    strings = keyword.split(".")

    # Include extension
    if len(strings) > 1:
        result = domainsearch(keyword)
        show_result(infos, keyword, result)

        alfred.write(alfred.xml(infos, maxresults=10))

        return

    # No extension
    base_exts = [".com", ".cn", ".net", ".me"]
    advanced_exts = [".org", ".tv", ".cc"]

    final_exts = base_exts
    if query == "all":
        final_exts = base_exts + advanced_exts

    for ext in final_exts:
        domain = keyword + ext
        result = domainsearch(domain)
        show_result(infos, domain, result)

    alfred.write(alfred.xml(infos, maxresults=10))
コード例 #11
0
ファイル: futhead.py プロジェクト: dpsk/FutHeadWorkFlow
def getPlayerInfo(value):
	selectItem = None
	for item in value:
		if item['rating'] == rating:
			selectItem = item
			break
	statusDic = {
	u'PACE(速度)': selectItem['attr1'],
	u'SHOOTING(射门)': selectItem['attr2'],
	u'PASSING(传球)': selectItem['attr3'],
	u'DRIBBLING(盘带)': selectItem['attr4'],
	u'DEFENDING(防守)': selectItem['attr5'],
	u'PHYSICAL(身体)': selectItem['attr6']
	}
	results = []
	index = 0

	for (key, value) in statusDic.items():
		# print key, value
		results.append(alfred.Item(
            title= key,
            subtitle=value,
            attributes={
                'uid': alfred.uid(index), 
                'arg': u'%s\'s %s is %d' % (selectItem['full_name'], key , value),
            },
        	icon='icon.png',
        ))
		index += 1
	xml = alfred.xml(results)
	alfred.write(xml)
コード例 #12
0
ファイル: commend.py プロジェクト: 00zl00/AlfredWorkflow.com
def main():
    reload(sys)                         # reload unicode decoder
    sys.setdefaultencoding('utf-8')     # use utf-8
    (param, word) = alfred.args()
    cityCode = '100010000' # Beijing

    if word.isspace():
        url = "http://m.nuomi.com/client/gethotkeyword?cityid=%s&limit=20&client=ios&version=3.2.0" % (cityCode)
    else:
        word = OnlyCharNum(word)
        url = "http://m.nuomi.com/client/searchsuggest?k=%s&cityid=%s" % (word, cityCode)
    req = urllib2.Request(url)
    response = urllib2.urlopen(req)
    data = json.loads(response.read())
    results = []
    if word.isspace():
        if len(data['keywords']) == 0:
            results.append(alfred.Item({'uid': 0, 'arg': word}, word, '', 'icon.png'))
        else:
            for i in range(0, len(data['keywords'])):
                results.append(alfred.Item({'uid': i, 'arg': data['keywords'][i]['keyword']}, data['keywords'][i]['keyword'], '', 'icon.png'))
    else:
        if len(data['data']) == 0:
            results.append(alfred.Item({'uid': 0, 'arg': word}, word, '', 'icon.png'))
        else:
            for i in range(0, len(data['data'])):
                results.append(alfred.Item({'uid': i, 'arg': data['data'][i]['t']}, data['data'][i]['t'], '', 'icon.png'))
    xml = alfred.xml(results) # compiles the XML answer
    alfred.write(xml)
コード例 #13
0
ファイル: editview.py プロジェクト: BenziAhamed/todo
def generate_view_tagedit(old_tag, query):
    info = parser.parse(query)
    new_tag = info['tag']
    new_text = info['task']
    tag_changed = new_tag and new_tag != old_tag
    only_tag_changed = tag_changed and len(new_text) == 0

    feedback_items = []
    # action item
    feedback_items.append(alfred.Item(
        attributes={
        'uid': uuid4(),
        'arg': query + "  ",
        'valid': 'yes' if only_tag_changed else 'no'
        },
        title="Update tag" if only_tag_changed else "Nothing to update",
        subtitle="Enter a new tag name" if not only_tag_changed else "",
        icon="todo_edit.png"
    ))
    # tag info item
    feedback_items.append(alfred.Item(
        attributes={
        'uid': uuid4(),
        'arg': "",
        'valid': 'no',
        'autocomplete': "#"+old_tag
        },
        title="#"+old_tag,
        subtitle="Change to #" + new_tag if only_tag_changed else "",
        icon="todo_tag.png"
    ))
    alfred.write(alfred.xml(feedback_items))
コード例 #14
0
def process_tag(pins, deleted_url, q, prefix):
    tag_list = {}

    for p in pins:
        url = p['href']
        if url in map(lambda x: x.lower(), deleted_url): continue
        try:
            tags = p['tags'].encode('utf-8').split(' ')
        except:
            tags = []
        for t in tags:
            if t in tag_list:
                tag_list[t] += 1
            else:
                tag_list[t] = 1
    resultData = []
    tag_list_key = sorted(tag_list.keys(), key=str.lower)
    for (idx, i) in enumerate(tag_list_key):
        if not q or q in i.lower():
            expand_str = prefix + (prefix and " " or "") + "#" + i + " : "
            resultData.append(
                alfred.Item(title=(i and i or "untagged") + " (" +
                            str(tag_list[i]) + ")",
                            subtitle='',
                            attributes={
                                'autocomplete': expand_str,
                                'valid': 'no',
                                'uid': alfred.uid(idx)
                            },
                            icon='tag.png'))
    alfred.write(alfred.xml(resultData, maxresults=None))
    return
コード例 #15
0
ファイル: export.py プロジェクト: LiuFang816/SALSTM_py_data
def generate_export_view():
    feedback_items = []
    todos = itemlist.get_todo_list()
    if len(todos) == 0:
        feedback_items.append(generate_noitems())
    else:
        items = []
        items.append({
            'title': 'Export all items as plain text',
            'subtitle': 'Will be copied to your clipboard',
            'arg': 'txt',
            'icon': 'export_txt.png'
        })
        todos = itemlist.get_todo_list()
        tags = defaultdict(list)
        for i in todos:
            tags[i['group']].append(1)
        for tag in tags:
            if tag != 'default':
                items.append({
                    'title': 'Export #' + tag,
                    'subtitle': 'Will be copied to your clipboard',
                    'arg': 'txt ' + tag,
                    'icon': 'export_txt.png'
                })
        feedback_items = map(lambda x: generate_feedbackitem(x), items)
    alfred.write(alfred.xml(feedback_items))
コード例 #16
0
def process(query_str):
    """ Entry point """
    value = parse_query_value(query_str)
    if value is not None:
        results = alfred_items_for_value(value)
        xml = alfred.xml(results)  # compiles the XML answer
        alfred.write(xml)  # writes the XML back to Alfred
コード例 #17
0
def main(action, query):
    # If the configuration file doesn't exist, create an empty one
    if not os.path.isfile(_CONFIG_FILE):
        create_config()
        alfred.write(alfred.xml(config_file_is_empty()))
        return

    try:
        config = get_config()
        if not config.sections() and action != 'add':
            # If the configuration file is empty, tell the user to add secrets to it
            alfred.write(alfred.xml(config_file_is_empty()))
            return
    except Exception as e:
        alfred.write(alfred.xml([alfred.Item({u'uid': alfred.uid(0),
                                              u'arg': '', u'ignore': 'yes'},
                                             "~/.gauth: Invalid syntax",
                                             str(e).replace('\n', ' '),
                                             "error.png")]))
        sys.exit(1)

    if action == 'list' and not is_command(query):
        alfred.write(alfred.xml(list_accounts(config, query), maxresults=_MAX_RESULTS))
    elif action == 'add':
        alfred.write(add_account(config, query))
コード例 #18
0
 def process(self, query_str):
     """ Entry point """
     results = self.get_items_for_query(query_str)
     if results:
         xml = alfred.xml(results,
                          self.max_results)  # compiles the XML answer
         alfred.write(xml)  # writes the XML back to Alfred
コード例 #19
0
ファイル: domain.py プロジェクト: Lings/AlfredDomainSearcher
def alfred_search(keyword, query):

    infos = []

    strings = keyword.split(".")

    # Include extension
    if len(strings) > 1:
        result = domainsearch(keyword)
        show_result(infos, keyword, result)

        alfred.write(alfred.xml(infos, maxresults=10))

        return

    # No extension
    base_exts = [".com", ".cn", ".net", ".me"]
    advanced_exts = [".org", ".tv", ".cc"]

    final_exts = base_exts
    if query == "all":
        final_exts = base_exts+advanced_exts

    for ext in final_exts:
        domain = keyword+ext
        result = domainsearch(domain)
        show_result(infos, domain, result)

    alfred.write(alfred.xml(infos, maxresults=10))
コード例 #20
0
ファイル: main.py プロジェクト: CreSeed/alfred-extension
def process_tag(pins,deleted_url,q,prefix):
    tag_list = {}
    
    for p in pins:
        url = p['href']
        if url in map(lambda x:x.lower(), deleted_url): continue
        try:
            tags = p['tags'].encode('utf-8').split(' ')
        except:
            tags = []
        for t in tags:
            if t in tag_list:
                tag_list[t] += 1
            else:
                tag_list[t] = 1
    resultData = []
    tag_list_key = sorted(tag_list.keys(),key=str.lower)
    for (idx,i) in enumerate(tag_list_key):
        if not q or q in i.lower():
            expand_str = prefix+(prefix and " " or "")+"#"+i+" : "
            resultData.append(alfred.Item(title=(i and i or "untagged")+" ("+str(tag_list[i])+")", subtitle='',
                                          attributes={'autocomplete':expand_str,
                                                      'valid':'no',
                                                      'uid':alfred.uid(idx)}, icon='tag.png'))
    alfred.write(alfred.xml(resultData,maxresults=None))
    return
コード例 #21
0
 def process(self, query_str):
     """ Entry point """
     results = self.get_items_for_query(query_str)
     if results:
         xml = alfred.xml(results,
                          self.max_results)  # compiles the XML answer
         alfred.write(xml)  # writes the XML back to Alfred
コード例 #22
0
ファイル: comics.py プロジェクト: 00zl00/AlfredWorkflow.com
def searchComics(search_term):
	feedback_items = []
	for i in getPlugins():
		plugin = loadPlugin(i)
		title = plugin.title()
		subtitle = plugin.subtitle()
		should_add = (plugin.enabled() 
			and (search_term == None 
				or title.lower().find(search_term.lower()) >= 0 
				or subtitle.lower().find(search_term.lower()) >= 0)
			)
		if should_add:	
			feedback_items.append(
				alfred.Item(
					attributes = { 
					'uid' : alfred.uid(i["name"]),
					'arg' : i["name"]
					},
					title = title,
					subtitle = subtitle,
					icon = os.path.join(i["location"], "icon.png")
				)
			)
	xml = alfred.xml(feedback_items)
	alfred.write(xml)
コード例 #23
0
def convert(query):
    #Input data
    query2 = unicodedata.normalize('NFC', query)

    parsed_data = string_div(query2)
    #	print(parsed_data)
    unit = parsed_data['unit']
    number = parsed_data['number']

    #Load convert data file
    try:
        f = open("unit.json", 'r')
    except:
        print("ERROR:can't create file")

    unit_data = json.load(f, encoding='utf-8')

    #print(unit_data['inch'])

    #Data check & convert
    output_list = []
    #	item = alfred.Item({'uid': alfred.uid(1), 'arg': 'some arg', 'valid': 'no'}, unit, number, ('someicon.png', {'type': 'filetype'}))
    #	output_list.append(item)

    for unit_group in unit_data:
        inputs = unit_data[unit_group]['input']
        outputs = unit_data[unit_group]['output']

        for input_keyword in inputs:
            if input_keyword == unit:
                for output_unit in outputs:

                    #convert calc type check
                    find_index = outputs[output_unit].find("?")
                    if find_index >= 0:
                        #special pattern
                        float_str = eval(outputs[output_unit].replace(
                            '?', number))
                        float_data = float(float_str)
                    else:
                        #normal pattern
                        float_data = float(
                            outputs[output_unit]) * float(number)

                    #output_data = {'number':str(float_data),'unit':output_unit}
                    output_str = str(float_data) + output_unit
                    item = alfred.Item(
                        {
                            'uid': alfred.uid(len(output_list) + 1),
                            'arg': output_str,
                            'valid': 'yes'
                        }, output_str, query, ('icon.png', {
                            'type': 'png'
                        }))
                    output_list.append(item)
#	print(output_list)

    xml = alfred.xml(output_list)
    alfred.write(xml)
コード例 #24
0
def process(query_str):
    query_str = str(query_str).strip('"\' ')
    timestamp = parse_query_str(query_str)
    if timestamp is None:
        return
    results = gen_alfred_items(timestamp)
    xml = alfred.xml(results)
    alfred.write(xml)
コード例 #25
0
ファイル: oj.py プロジェクト: Eronana/OJOJO
	def search(this,kw):
		html=this.getSearchHTML(kw)
		problems=re.compile(this.RE_SEARCH,re.DOTALL).findall(html)
		result=[]
		for p in problems:
			this.ad_prob(result,this.getSearchResult(p))
		this.checkresult(result,"No result found")
		alfred.write(alfred.xml(result))
コード例 #26
0
def process(query_str):
    """ Entry point """
    if query_str and len(query_str) > 2:
        results = get_results(query_str)
        if results is not None:
            response = alfred_items_for_results(results)
            xml = alfred.xml(response) # compiles the XML answer
            alfred.write(xml) # writes the XML back to Alfred
コード例 #27
0
def process(query):
    """ Entry point
    :param query: query string
    :return:
    """
    if query:
        results = alfred_items_for_query(query)
        xml = alfred.xml(results)
        alfred.write(xml)
コード例 #28
0
ファイル: oj.py プロジェクト: Eronana/OJOJO
	def query(this,pid):
		if pid==0:
			return
		result=[]
		isget=True
		for p in this.getProblemList(pid):
			isget=this.add_problem(result,p,isget)
		this.checkresult(result,"No this problem %d"%pid)
		alfred.write(alfred.xml(result))
コード例 #29
0
def process(query):
    """ Entry point
    :param query: query string
    :return:
    """
    if query:
        results = alfred_items_for_query(query)
        xml = alfred.xml(results)
        alfred.write(xml)
コード例 #30
0
ファイル: features.py プロジェクト: BenziAhamed/todo
def generate_view():
    feedback_items = []
    if not all_enabled():
        feedback_items.append(feedback_item("Enable all", '', 'special_enable'))
    else:
        feedback_items.append(feedback_item("Disable all", '', 'special_disable'))

    feedback_items = feedback_items + map(lambda f: feedback_item(f['title'], f['subtitle'], f['id']), features)
    alfred.write(alfred.xml(feedback_items))
コード例 #31
0
ファイル: listmanager.py プロジェクト: BenziAhamed/todo
def generate_view(query):
    feedback_items = []
    special_added = generate_view_rtm(feedback_items)

    lists, active = get_todo_lists()
    (path, db) = os.path.split(config.get(ck.KEY_TODO))
    lists = [f for f in lists if len(query) == 0 or friendly_file(f).lower().find(query.lower()) >= 0]
    feedback_items = feedback_items + map(lambda x: generate_feedback(path, x, x == active), lists)
    if len(feedback_items) == 0 or (special_added and len(feedback_items) == 1):
        feedback_items.append(generate_add_feedback(path, query))
    alfred.write(alfred.xml(feedback_items))
コード例 #32
0
def pbauthpocket(q):
    ret = pocket.getRequestCode()
    
    config = config_data()
    config['pocket_request_code'] = ret['code']
    
    with open(os.path.join(alfred.work(False), 'config.json'), 'w+') as myFile:
        myFile.write(json.dumps(config))
    
    result = [alfred.Item(title='Login!', subtitle='Login with Pocket.com (you will be taken to pocket.com)', attributes={'arg':ret['code'],'uid':alfred.uid(0)}, icon="icon.png")]
    alfred.write(alfred.xml(result))
コード例 #33
0
ファイル: main.py プロジェクト: CreSeed/alfred-extension
def process_sortoption(q):
    result = []
    result.append(alfred.Item(title='last accessed time', subtitle='^l ',
                              attributes={'valid':'no','autocomplete':q+(q and " " or "")+'^l ','uid':alfred.uid(4)}, icon="num-des.png"))
    result.append(alfred.Item(title='time ascending', subtitle='^d ',
                              attributes={'valid':'no','autocomplete':q+(q and " " or "")+'^d ','uid':alfred.uid(1)}, icon="general-des.png"))
    result.append(alfred.Item(title='title ascending', subtitle='^a ',
                              attributes={'valid':'no','autocomplete':q+(q and " " or "")+'^a ','uid':alfred.uid(2)}, icon="alpha-asc.png"))
    result.append(alfred.Item(title='title descending', subtitle='^z ',
                              attributes={'valid':'no','autocomplete':q+(q and " " or "")+'^z ','uid':alfred.uid(3)}, icon="alpha-des.png"))
    alfred.write(alfred.xml(result,maxresults=None))
コード例 #34
0
ファイル: main.py プロジェクト: CreSeed/alfred-extension
def pbauthpocket(q):
    ret = pocket.getRequestCode()
    
    config = config_data()
    config['pocket_request_code'] = ret['code']
    
    with open(os.path.join(alfred.work(False), 'config.json'), 'w+') as myFile:
        myFile.write(json.dumps(config))
    
    result = [alfred.Item(title='Login!', subtitle='Login with Pocket.com (you will be taken to pocket.com)', attributes={'arg':ret['code'],'uid':alfred.uid(0)}, icon="icon.png")]
    alfred.write(alfred.xml(result))
コード例 #35
0
def process_sortoption(q):
    result = []
    result.append(alfred.Item(title='last accessed time', subtitle='^l ',
                              attributes={'valid':'no','autocomplete':q+(q and " " or "")+'^l ','uid':alfred.uid(4)}, icon="num-des.png"))
    result.append(alfred.Item(title='time ascending', subtitle='^d ',
                              attributes={'valid':'no','autocomplete':q+(q and " " or "")+'^d ','uid':alfred.uid(1)}, icon="general-des.png"))
    result.append(alfred.Item(title='title ascending', subtitle='^a ',
                              attributes={'valid':'no','autocomplete':q+(q and " " or "")+'^a ','uid':alfred.uid(2)}, icon="alpha-asc.png"))
    result.append(alfred.Item(title='title descending', subtitle='^z ',
                              attributes={'valid':'no','autocomplete':q+(q and " " or "")+'^z ','uid':alfred.uid(3)}, icon="alpha-des.png"))
    alfred.write(alfred.xml(result,maxresults=None))
コード例 #36
0
ファイル: main.py プロジェクト: softdevstory/alfred-extension
def main():
    try:
        q = unicode(sys.argv[1])
        q = unicodedata.normalize('NFC', q).lower().replace(' ', '')
    except:
        q = ""

    rss = rss_data()
    config = config_data()
    try:
        max_results = config['max_results']
    except:
        max_results = None

    results = []
    for e in itertools.islice(rss, max_results):
        if not q or q in e['title'].lower().replace(' ', ''):
            results.append(
                alfred.Item(title=e['title'],
                            subtitle=e['published'],
                            attributes={'arg': e['link']},
                            icon=e['image']))

    try:
        last_updated = config['last_updated']
    except:
        last_updated = 0
    subtitle = "Last updated: " + (
        last_updated and util.pretty_date(config['last_updated']) or "no info")

    diff = int(time.time()) - last_updated
    if diff > RELOAD_ASK_THRESHOLD or len(rss) == 0:
        results.insert(
            0,
            alfred.Item(title="BackToTheMac - Reload Data?",
                        subtitle=subtitle,
                        attributes={
                            'arg': 'reload',
                            'uid': alfred.uid('t')
                        },
                        icon="icon.png"))
    else:
        results.insert(
            0,
            alfred.Item(title="BackToTheMac",
                        subtitle=subtitle,
                        attributes={
                            'arg': 'http://macnews.tistory.com',
                            'uid': alfred.uid('t')
                        },
                        icon="icon.png"))

    alfred.write(alfred.xml(results, maxresults=None))
コード例 #37
0
def list_apps(arg):
    apps = subprocess.check_output("ios-deploy -B | sort",
                                   stderr=subprocess.STDOUT,
                                   shell=True)
    apps = apps.rstrip().split('\n')

    items = []
    for app in apps:
        if arg is '' or app.startswith(arg):
            items.append(alfred.Item({'arg': app}, app, ''))

    alfred.write(alfred.xml(items))
コード例 #38
0
ファイル: homefolder.py プロジェクト: BenziAhamed/todo
def generate_no_conflict_feedbackitem(destination_path):
    feedback_items = []
    feedback_items.append(alfred.Item(
        attributes={
            'uid': uuid4(),
            'arg': 'no_conflict'
        },
        title="Move your Todo database",
        subtitle="Move it to '{0}'".format(destination_path),
        icon="5942F024-8248-41C6-8D33-422F4BFC7408.png"
    ))
    alfred.write(alfred.xml(feedback_items))
コード例 #39
0
ファイル: editview.py プロジェクト: BenziAhamed/todo
def generate_select_item():
    feedback_items = []
    feedback_items.append(alfred.Item(
        attributes={
        'uid': uuid4(),
        'arg': '',
        'valid': 'no'
        },
        title="Nothing to edit",
        subtitle="Select an item to edit first",
        icon="todo_edit.png"
    ))
    alfred.write(alfred.xml(feedback_items))
コード例 #40
0
ファイル: main.py プロジェクト: boehle/alfred-extension
def help():
    result = []
    result.append(alfred.Item(title='Look up Documentation', subtitle='Goto project site', attributes={'arg':'http://j.mp/1c4E6Q2','uid':alfred.uid(0)}, icon="icon.png"))
    result.append(alfred.Item(title='pbauth username:token', subtitle='set pinboard authentication token', attributes={'valid':'no','uid':alfred.uid(1)}, icon="icon.png"))
    result.append(alfred.Item(title='pbreload', subtitle='load latest bookmarks from pinboard.in', attributes={'valid':'no','uid':alfred.uid(2)}, icon="icon.png"))
    result.append(alfred.Item(title='pba query', subtitle='search all fields of bookmarks', attributes={'valid':'no','uid':alfred.uid(3)}, icon="icon.png"))
    result.append(alfred.Item(title='pbt query', subtitle='search description of bookmarks', attributes={'valid':'no','uid':alfred.uid(4)}, icon="icon.png"))
    result.append(alfred.Item(title='pbl query', subtitle='search link of bookmarks', attributes={'valid':'no','uid':alfred.uid(5)}, icon="icon.png"))
    result.append(alfred.Item(title='pbd query', subtitle='search extended field of bookmarks', attributes={'valid':'no','uid':alfred.uid(6)}, icon="icon.png"))
    result.append(alfred.Item(title='pbtag tag query', subtitle='display tags list', attributes={'valid':'no','uid':alfred.uid(7)}, icon="icon.png"))
    result.append(alfred.Item(title='pbu query', subtitle='search title of toread bookmarks', attributes={'valid':'no','uid':alfred.uid(8)}, icon="icon.png"))
    result.append(alfred.Item(title='To selected bookmark', subtitle='enter:goto site, cmd:copy url, alt:delete bookmark, tab:expand', attributes={'valid':'no','uid':alfred.uid(9)}, icon="icon.png"))
    alfred.write(alfred.xml(result))
コード例 #41
0
def main(query):
    results = []
    json_ = json.load(file(BOOKMARK_PATH))
    uid = uid_generator()
    for entry in jsonpath.jsonpath(json_, '''$..?(@.url and @.type=='url')'''):
        if not query in entry['name'].lower() and not query in entry['url']:
            continue
        results.append(alfred.Item(
            attributes = { 'uid': uid.next(), 'arg': entry['url'] }, 
            title = entry['name'], 
            subtitle = entry['url'], 
            icon = 'icon.png'))
    alfred.write(alfred.xml(results))
コード例 #42
0
def help():
    result = []
    result.append(alfred.Item(title='Look up Documentation', subtitle='Goto project site', attributes={'arg':'https://github.com/jmjeong/alfred-extension/blob/master/alfred-pinboard/README.md','uid':alfred.uid(0)}, icon="icon.png"))
    result.append(alfred.Item(title='pbauth username:token', subtitle='set pinboard authentication token', attributes={'valid':'no','uid':alfred.uid(1)}, icon="icon.png"))
    result.append(alfred.Item(title='pbreload', subtitle='load latest bookmarks from pinboard.in', attributes={'valid':'no','uid':alfred.uid(2)}, icon="icon.png"))
    result.append(alfred.Item(title='pba query', subtitle='search all fields of bookmarks', attributes={'valid':'no','uid':alfred.uid(3)}, icon="icon.png"))
    result.append(alfred.Item(title='pbtag', subtitle='display tags list', attributes={'valid':'no','uid':alfred.uid(7)}, icon="icon.png"))
    result.append(alfred.Item(title='pbnote query', subtitle='display note list', attributes={'valid':'no','uid':alfred.uid(10)}, icon="icon.png"))
    result.append(alfred.Item(title='pbl query', subtitle='search link of bookmarks', attributes={'valid':'no','uid':alfred.uid(5)}, icon="icon.png"))
    result.append(alfred.Item(title='pbu query', subtitle='search title of toread bookmarks', attributes={'valid':'no','uid':alfred.uid(8)}, icon="icon.png"))
    result.append(alfred.Item(title='pbauthpocket', subtitle='Login with Pocket!', attributes={'valid':'no','uid':alfred.uid(1)}, icon="icon.png"))
    result.append(alfred.Item(title='To selected bookmark', subtitle='enter:goto site, cmd:copy url, alt:delete bookmark, tab:expand', attributes={'valid':'no','uid':alfred.uid(9)}, icon="icon.png"))
    alfred.write(alfred.xml(result,maxresults=None))
コード例 #43
0
ファイル: homefolder.py プロジェクト: BenziAhamed/todo
def generate_conflict_feedbackitem(destination_path):
    feedback_items = []
    feedback_items.append(alfred.Item(
        attributes={
            'uid': uuid4(),
            'arg': '',
            'valid': 'no'
        },
        title="Please choose an option from below",
        subtitle="Folder already has a Todo database: '{0}'".format(destination_path),
        icon="5942F024-8248-41C6-8D33-422F4BFC7408.png"
    ))
    alfred.write(alfred.xml(feedback_items))
コード例 #44
0
ファイル: actions.py プロジェクト: rbnio/pocket_alfred
def login():
	code = pocket.getRequestCode()
	with open('code.json', 'w') as myFile:
		myFile.write(json.dumps(code))

	results = [alfred.Item(
		attributes={'uid': alfred.uid(0), 'arg': code["code"]},
		title='Login!',
		icon='icon.png',
		subtitle=u'Login with Pocket.com (you will be taken to pocket.com)'
	)] # a single Alfred result
	xml = alfred.xml(results) # compiles the XML answer
	alfred.write(xml) # writes the XML back to Alfred
コード例 #45
0
ファイル: main.py プロジェクト: CreSeed/alfred-extension
def help():
    result = []
    result.append(alfred.Item(title='Look up Documentation', subtitle='Goto project site', attributes={'arg':'https://github.com/jmjeong/alfred-extension/blob/master/alfred-pinboard/README.md','uid':alfred.uid(0)}, icon="icon.png"))
    result.append(alfred.Item(title='pbauth username:token', subtitle='set pinboard authentication token', attributes={'valid':'no','uid':alfred.uid(1)}, icon="icon.png"))
    result.append(alfred.Item(title='pbreload', subtitle='load latest bookmarks from pinboard.in', attributes={'valid':'no','uid':alfred.uid(2)}, icon="icon.png"))
    result.append(alfred.Item(title='pba query', subtitle='search all fields of bookmarks', attributes={'valid':'no','uid':alfred.uid(3)}, icon="icon.png"))
    result.append(alfred.Item(title='pbtag', subtitle='display tags list', attributes={'valid':'no','uid':alfred.uid(7)}, icon="icon.png"))
    result.append(alfred.Item(title='pbnote query', subtitle='display note list', attributes={'valid':'no','uid':alfred.uid(10)}, icon="icon.png"))
    result.append(alfred.Item(title='pbl query', subtitle='search link of bookmarks', attributes={'valid':'no','uid':alfred.uid(5)}, icon="icon.png"))
    result.append(alfred.Item(title='pbu query', subtitle='search title of toread bookmarks', attributes={'valid':'no','uid':alfred.uid(8)}, icon="icon.png"))
    result.append(alfred.Item(title='pbauthpocket', subtitle='Login with Pocket!', attributes={'valid':'no','uid':alfred.uid(1)}, icon="icon.png"))
    result.append(alfred.Item(title='To selected bookmark', subtitle='enter:goto site, cmd:copy url, alt:delete bookmark, tab:expand', attributes={'valid':'no','uid':alfred.uid(9)}, icon="icon.png"))
    alfred.write(alfred.xml(result,maxresults=None))
コード例 #46
0
def showFileList(query):
    result = []
    filetypes = []
    count = 1
    filetype = ''
    pos = query.find('.')
    if pos != -1:
        filetype = query[pos + 1:]
        query = query[:query.index('.')]
        filetypes = [tp for tp in alltypes if tp.startswith(filetype)]
        if filetype not in filetypes and filetype != '':
            filetypes.insert(0, filetype)

    elif query != '':
        result.append(
            alfred.Item({
                'uid': count,
                'arg': query
            }, 'Make new file..', 'file name "' + query + '"', 'default.png'))
        count += 1
        if 'Makefile'.startswith(query):
            result.append(
                alfred.Item({
                    'uid': count,
                    'arg': 'Makefile'
                }, 'Make new file..', 'file name "Makefile"', 'make.png'))
            count += 1
        if 'makefile'.startswith(query):
            result.append(
                alfred.Item({
                    'uid': count,
                    'arg': 'makefile'
                }, 'Make new file..', 'file name "makefile"', 'make.png'))
            count += 1

        filetypes = alltypes

    for ch in filetypes:
        filename = query + '.' + ch
        result.append(
            alfred.Item({
                'uid': count,
                'arg': filename
            }, 'Make new file..', 'file name "' + filename + '"',
                        (ch, {
                            'type': 'filetype'
                        })))
        count += 1

    xml = alfred.xml(result)
    alfred.write(xml)
コード例 #47
0
def main(query):
    suggested_items = []
    uid = uid_generator()
    suggested_items.append(alfred.Item(
        attributes = { 'uid': uid.next(), 'arg': query },
        title = 'Execute following commands', subtitle = '', 
        icon = 'icon.png'))
    for command, script in keymacro.generate_applescripts(query):
        script = script.replace('''tell application "System Events" to ''', '')
        suggested_items.append(alfred.Item(
            attributes = { 'uid': uid.next(), 'arg': command },
            title = script, subtitle = '', 
            icon = 'icon.png'))
    alfred.write(alfred.xml(suggested_items))
コード例 #48
0
def list_apps(arg):
    apps = subprocess.check_output(
        "{0} shell 'pm list packages -f' | sed -e 's/.*=//' | sed 's/\r//g' | sort"
        .format(adb_path),
        stderr=subprocess.STDOUT,
        shell=True)
    apps = apps.rstrip().split('\n')

    items = []
    for app in apps:
        if arg is '' or app.startswith(arg):
            items.append(alfred.Item({'arg': app}, app, ''))

    alfred.write(alfred.xml(items))
コード例 #49
0
ファイル: futhead.py プロジェクト: dpsk/FutHeadWorkFlow
def error(title="errorTitle", subtitle='i.e Ronald', arg=None):
	results = []
	results.append(alfred.Item(
		attributes = {
		'uid': 1,
		'arg': arg,
		}, 
		title = title, 
		subtitle = subtitle, 
		icon = 'icon.png'
		))
	# print(results)
	xml = alfred.xml(results)
	alfred.write(xml)
コード例 #50
0
ファイル: w.py プロジェクト: trunda/my-mac
def wSearch():
    if len(sys.argv) <= 2:
        alfred.write(alfred.xml([default()]))
        return

    (lang, query) = alfred.args2()

    feedback_items = map(lambda x: parse(lang, x), search_for(lang, query))

    # opensearch is used to autocomplete, which means
    # it searches based on the starting of the text that entered
    # feedback_items = map(lambda x: opensearch_parse(lang, x), opensearch_for(lang, query))

    xml = alfred.xml(feedback_items, results=100)
    alfred.write(xml)
コード例 #51
0
def main():
    reload(sys)  # reload unicode decoder
    sys.setdefaultencoding('utf-8')  # use utf-8
    (param, word) = alfred.args()
    cityCode = '100010000'  # Beijing

    if word.isspace():
        url = "http://m.nuomi.com/client/gethotkeyword?cityid=%s&limit=20&client=ios&version=3.2.0" % (
            cityCode)
    else:
        word = OnlyCharNum(word)
        url = "http://m.nuomi.com/client/searchsuggest?k=%s&cityid=%s" % (
            word, cityCode)
    req = urllib2.Request(url)
    response = urllib2.urlopen(req)
    data = json.loads(response.read())
    results = []
    if word.isspace():
        if len(data['keywords']) == 0:
            results.append(
                alfred.Item({
                    'uid': 0,
                    'arg': word
                }, word, '', 'icon.png'))
        else:
            for i in range(0, len(data['keywords'])):
                results.append(
                    alfred.Item(
                        {
                            'uid': i,
                            'arg': data['keywords'][i]['keyword']
                        }, data['keywords'][i]['keyword'], '', 'icon.png'))
    else:
        if len(data['data']) == 0:
            results.append(
                alfred.Item({
                    'uid': 0,
                    'arg': word
                }, word, '', 'icon.png'))
        else:
            for i in range(0, len(data['data'])):
                results.append(
                    alfred.Item({
                        'uid': i,
                        'arg': data['data'][i]['t']
                    }, data['data'][i]['t'], '', 'icon.png'))
    xml = alfred.xml(results)  # compiles the XML answer
    alfred.write(xml)
コード例 #52
0
def pbsearch(pins, config, deleted_url, starred_url, launch_hist_url, q,
             category):
    logger.info('query string = [%s]', q)

    sort_option = ""
    full_query = q
    sort_re = re.compile(r'[\^|!](\w+)\b', flags=re.U)
    if sort_re.findall(q):  # exists sort option?
        sort_option = sort_re.findall(q)[-1]
        q = sort_re.sub('', q)
    elif category == 'log':
        sort_option = 'l'

    last_q = q.split(' ')[-1]
    if last_q.startswith('^') or last_q.startswith('!'):  # sort option
        process_sortoption(" ".join(q.split(' ')[:-1]))
    elif last_q.startswith('#'):  # tag expansion
        process_tag(pins, deleted_url,
                    last_q.lower()[1:], " ".join(q.split(' ')[:-1]))
    elif ':' in q:
        qq = q.split(':')
        query = qq[-1]
        tags = ':'.join(qq[:-1])
        tag_list = [
            t[1:].lower() for t in tags.split(' ') if t.startswith('#')
        ]
        # logger.error('taglist = %s, query=[%s]', tag_list,query)
        process_search(pins, config,
                       deleted_url, starred_url, launch_hist_url, tag_list,
                       query.strip(), full_query, category, sort_option)
    elif '#' in q and ':' not in q:
        expand_str = q.strip() + ' : '
        tag_list = [t[1:].lower() for t in q.split(' ') if t.startswith('#')]
        resultData = [
            alfred.Item(title="Selected Category (" +
                        total_num(pins, deleted_url, tag_list, category) + ")",
                        subtitle="# or : or Enter",
                        attributes={
                            'uid': alfred.uid(0),
                            'autocomplete': expand_str,
                            'valid': 'no'
                        },
                        icon="item.png")
        ]
        alfred.write(alfred.xml(resultData, maxresults=None))
    else:
        process_search(pins, config, deleted_url, starred_url, launch_hist_url,
                       [], q.strip(), full_query, category, sort_option)
コード例 #53
0
def list_apps(args):
    apps = subprocess.check_output(adb_path +
                                   " devices -l | sed -n '1!p' | tr -s ' '",
                                   stderr=subprocess.STDOUT,
                                   shell=True)
    apps = apps.rstrip().split('\n')

    items = []
    for app in apps:
        arg = args[0] if args else ''
        if arg == '' or arg in app:
            values = app.split(' ')
            name = values[0]
            items.append(alfred.Item({'arg': name}, name, ''))

    alfred.write(alfred.xml(items))
コード例 #54
0
ファイル: r2r.py プロジェクト: LiuFang816/SALSTM_py_data
def main():
    command, query = sys.argv[1].decode('utf-8'), ' '.join(sys.argv[2:]).decode('utf-8')

    autocomplete_enabled = False
    if command == "--query-autocomplete":
        autocomplete_enabled = True
        command = "--query"

    if command == "--reset":
        reset()
        show_alfred()

    elif command == "--search":
        if query.startswith('http://'):
            subprocess.call(["open", query])
        else:
            query_info = query.split(" to ")
            success = do_search(query_info[0], query_info[1])
            if success:
                show_alfred()
            else:
                print query

    elif command == "--query":
        items = []
        result = load_search()
        if re.match(r'^route \d+$', query):
            display_route(result, int(query.replace('route ', '')), items)
        elif len(query) > 0 and query.find(' to ') < 0:
            origin = query
            items.append(item(title='Find routes', subtitle=origin + u" ➡ ?", arg=query, valid='no', autocomplete=origin))
            if len(query) > 3 and autocomplete_enabled:
                autocomplete(items, origin, origin=True, origin_input=query)
        elif re.match(r'.+? to .*', query):
            query_info = query.split(" to ")
            origin = query_info[0]
            destination = "?" if len(query_info[1]) == 0 else query_info[1]
            items.append(item(title='Find routes', subtitle=origin + u" ➡ " + destination, arg=query, valid='yes' if destination != '?' else 'no'))
            if len(destination) > 3 and autocomplete_enabled:
                autocomplete(items, destination, origin=False, origin_input=origin)
        else:
            if result is not None and len(query) == 0:
                display_route(result, 1, items)
            else:
                items.append(item(title='Type a search query', subtitle='E.g. New York to London', valid='no', autocomplete='New York to London'))
        alfred.write(alfred.xml(items))
コード例 #55
0
def login():
    code = pocket.getRequestCode()
    with open('code.json', 'w') as myFile:
        myFile.write(json.dumps(code))

    results = [
        alfred.Item(
            attributes={
                'uid': alfred.uid(0),
                'arg': code["code"]
            },
            title='Login!',
            icon='icon.png',
            subtitle=u'Login with Pocket.com (you will be taken to pocket.com)'
        )
    ]  # a single Alfred result
    xml = alfred.xml(results)  # compiles the XML answer
    alfred.write(xml)  # writes the XML back to Alfred
コード例 #56
0
 def display_message(self, message, subtitle=None, arg=None):
     """ Inform them that something's wrong """
     if message is None:
         # Display same message as the placeholder
         message = self.placeholder
     xml = alfred.xml([
         alfred.Item(
             title=message,
             subtitle=subtitle,
             attributes={
                 'uid': alfred.uid(0),
                 'arg': arg
             },
             icon='icon.png',
         )
     ])  # compiles the XML answer
     alfred.write(xml)  # writes the XML back to Alfred
     exit()
コード例 #57
0
def list_apps(arg):
    pattern = '{ print $1 " " $7 " " substr($8, 1, length($8)-2) }'
    apps = subprocess.check_output(
        "{0} shell dumpsys alarm | awk '/^ +(RTC_WAKEUP|ELAPSED_WAKEUP|RTC|ELAPSED)/ {1}'"
        .format(adb_path, pattern),
        stderr=subprocess.STDOUT,
        shell=True)
    apps = apps.rstrip().split('\n')

    items = []
    for app in apps:
        values = app.split(' ')
        if arg is '' or values[2].startswith(arg):
            type = values[0]
            time = timestamp_to_time(type, float(values[1]))
            item = "{0} {1} {2}".format(type, time, values[2])
            items.append(alfred.Item({'arg': time}, item, ''))

    alfred.write(alfred.xml(items))
コード例 #58
0
def process():
    dirname = os.path.dirname(os.path.abspath('.'))

    dirs = [
        f for f in os.listdir(dirname)
        if os.path.isdir(os.path.join(dirname, f))
    ]

    results = []

    for (idx, d) in enumerate(dirs):
        try:
            print os.path.join(dirname, d, 'settings.plist')
            plist = plistlib.readPlist(os.path.join(dirname, d, 'info.plist'))
        except:
            continue

        title = plist['name']
        disabled = plist.get('disabled', None)
        createdby = plist['createdby']
        displayTitle = title + (' - disabled' if disabled else '')

        results.append({
            'title': displayTitle,
            'createdby': createdby,
            'disabled': disabled,
            'directory': d
        })

    results = sorted(results, key=lambda a: a['title'].lower())

    resultsData = [
        alfred.Item(title=f['title'],
                    subtitle=' by ' + (f['createdby'] or "[noinfo]"),
                    attributes={
                        'uid': uuid4(),
                        'arg': os.path.join(dirname, f['directory'])
                    },
                    icon=os.path.join(dirname, f['directory'], u"icon.png"))
        for f in results
    ]

    alfred.write(alfred.xml(resultsData, maxresults=None))
コード例 #59
0
def write_output(appnames, query):
    results = [
        alfred.Item(title=f,
                    subtitle="",
                    attributes={
                        'arg': f,
                        'autocomplete': f
                    },
                    icon=u"icon.png") for f in appnames if query in f.lower()
    ]
    results.insert(
        0,
        alfred.Item(
            title=u"Tidy up LaunchPad : tdl [appname]",
            subtitle=
            "Hide app icon from LaunchPad. It wouldn't delete App itself.",
            attributes={'valid': "no"},
            icon=u"icon.png"))

    alfred.write(alfred.xml(results, maxresults=None))