Python workflow 模块,ICON_INFO 实例源码

我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用workflow.ICON_INFO

项目:Alfred-Workflow    作者:stidio    | 项目源码 | 文件源码
def main(wf):
    # ?????????
    param = (wf.args[0] if len(wf.args) else '').strip()
    if param:
        title, ip = resolve_ip_from_dns(param)
    else:
        title = get_local_ip()
        ip = get_public_ip()

    if ip:
        location = get_location_information(ip)
        wf.add_item(title=title, 
                    subtitle=ip + ' ' + location if location else '', 
                    arg=ip,
                    valid=True,
                    icon=ICON_INFO)
    else:
        wf.add_item(title=title, subtitle='...', icon=ICON_ERROR)

    # Send the results to Alfred as XML
    wf.send_feedback()
项目:alfred_reviewboard    作者:lydian    | 项目源码 | 文件源码
def search_user_name(self, prefix, limit=LIMIT):
        user_search_history = self.wf.stored_data('recent_users') or []
        if prefix.strip() != '':
            matched_recent_users = self.wf.filter(prefix, user_search_history)
        else:
            matched_recent_users = user_search_history

        if not self.wf.cached_data_fresh('users_list', 86400):
            run_in_background(
                'update_users', [
                    '/usr/bin/python',
                    self.wf.workflowfile('reviewboard.py'),
                    'update_users'])

        # if is_running('update_users'):
        #    self.wf.add_item('Updating users', icon=ICON_INFO)
        user_caches = self.wf.cached_data('users', max_age=0) or dict()
        users_list = self.wf.cached_data('users_list', max_age=0) or set()

        if prefix.strip() != '':
            matched_cached_users = self.wf.filter(
                prefix,
                users_list)
        else:
            matched_cached_users = users_list

        # remove duplicated
        matched_users = matched_recent_users + [
            user
            for user in matched_cached_users
            if user not in set(matched_recent_users)]

        return [
            user_caches[user] for user in matched_users[:limit]
        ]
项目:jisho-alfred-workflow    作者:janclarin    | 项目源码 | 文件源码
def main(wf):
    """Main function to handle query and request info from Jisho.org.
    Args:
        wf: An instance of Workflow.
    """
    # Get query from Alfred.
    query = wf.args[0] if len(wf.args) else None

    # Add query result if there is an update.
    if wf.update_available:
        wf.add_item('A newer version of Jisho Alfred Workflow is available',
                    'Action this item to download and install the new version',
                    autocomplete='workflow:update',
                    icon=ICON_INFO)

    try:
        # Only fetch results from Jisho.org if it is a valid query.
        results = get_results(query) if is_valid_query(query) else []

        if results:
            # Add results to Alfred, up to the maximum number of results.
            for i in range(min(len(results), MAX_NUM_RESULTS)):
                add_alfred_result(wf, results[i])
        else:
            # Add an error result if there was an issue getting results.
            error_msg = "Could not find anything matching '%s'" % (query)
            wf.add_item(error_msg, arg=query, valid=True, icon=ICON_NOTE)
    except:
        # Add an error result if there was an issue getting results.
        error_msg = "There was an issue retrieving Jisho results"
        wf.add_item(error_msg, arg=query, valid=True, icon=ICON_ERROR)

    # Send the results to Alfred as XML.
    wf.send_feedback()
项目:Quiver-alfred    作者:danielecook    | 项目源码 | 文件源码
def main(wf):
    wf.add_item("To ensure your file is found, make sure it ends in '.qvlibrary'", icon=ICON_INFO)
    out, err = Popen(["mdfind","-name",".qvlibrary"], stdout=PIPE, stderr=PIPE).communicate()
    out = out.split("\n")
    for i in out:
        wf.add_item(os.path.split(i)[1],i, arg=i, valid=True, icon="icons/lib.icns")

    wf.send_feedback()
项目:Alfred-Workflow    作者:noogel    | 项目源码 | 文件源码
def main(wf):
    # ?????????
    params = (wf.args or [""])[0].strip().split(" ")
    optype, param = params[0].strip(), " ".join(params[1:]).strip()
    if not param:
        wf.add_item(title=u"?????", subtitle="Cant\'t Empty!", icon=ICON_ERROR)
    elif optype in CATEGORY_MAP:
        conf = CATEGORY_MAP[optype]
        try:
            result = globals()[conf["func"]](param)
        except Exception as ex:
            result = ex.message
        if isinstance(result, basestring):
            wf.add_item(
                title=u"{} ?{}?".format(conf["title"], param),
                subtitle=result,
                arg=result,
                valid=True,
                icon=ICON_INFO)
        elif isinstance(result, list):
            for item in result:
                wf.add_item(
                    title=item["title"],
                    subtitle=item["cmd"],
                    arg=param,
                    valid=True,
                    icon=ICON_INFO)
        else:
            wf.add_item(title=u"?????????", subtitle="...", icon=ICON_ERROR)
    else:
        wf.add_item(title=u"????", subtitle="...", icon=ICON_ERROR)

    wf.send_feedback()