コード例 #1
0
    def on_enter(self, query):
        action_list = ActionList()
        if query.get_keyword() == self.keyword and query.get_argument():
            argument = query.get_argument()
        elif self.is_default_search:
            argument = query
        else:
            argument = None

        if self.run_without_argument:
            if self._is_url():
                action = OpenUrlAction(self.cmd.strip())
            else:
                action = RunScriptAction(self.cmd)
            action_list.append(action)
        elif argument:
            if self._is_url():
                command = self.cmd.strip().replace('%s', argument)
                action = OpenUrlAction(command)
            else:
                action = RunScriptAction(self.cmd, argument)
            action_list.append(action)
        else:
            action_list.append(SetUserQueryAction('%s ' % self.keyword))

        self._query_history.save_query(query, self.get_name())

        return action_list
コード例 #2
0
 def on_event(self, event, extension):
     items = []
     logger.info(event.get_argument())
     logger.info(extension.preferences['redmine_url'])
     logger.info(extension.preferences['redmine_api_key'])
     redmine = Redmine(extension.preferences['redmine_url'], version=extension.preferences['redmine_version'], key=extension.preferences['redmine_api_key'])
     query = str(event.get_argument()) or str()
     if len(query) != 0:
         issue = None
         try:
             issue = redmine.issue.get(query)
         except:
             issue = None
         if issue == None:
             issue_list = list(redmine.issue.search(event.get_argument(), limit=15))
             for issue in itertools.islice(issue_list, 15):
                 issue_url = build_issue_url(extension.preferences['redmine_url'], issue)
                 items.append(ExtensionResultItem(icon='images/icon.png',
                                             name= issue.title,
                                             description='',
                                             on_enter=OpenUrlAction(issue_url)))
         else:
             issue_url = build_issue_url(extension.preferences['redmine_url'], issue)
             items.append(ExtensionResultItem(icon='images/icon.png',
                         name= '#' + query + ': ' + issue.subject,
                         description='',
                         on_enter=OpenUrlAction(issue_url)))
     return RenderResultListAction(items)
コード例 #3
0
    def on_event(self, event, extension):
        """ Handles the event """
        items = []

        query = event.get_argument()

        # filter and sort array of languages.
        langs = LANGUAGES
        if query:
            langs = [
                x for x in LANGUAGES if query.lower() in x['name'].lower()
            ]

        items.append(
            ExtensionResultItem(icon='images/icon.png',
                                name='Repl.it',
                                description='Select to open repl.it',
                                on_enter=OpenUrlAction('https://repl.it/')))

        for l in langs:  # pylint: disable=invalid-name
            items.append(
                ExtensionResultItem(
                    icon=l['icon'],
                    name=l['name'],
                    description='Open Repl.it for %s language' % l['name'],
                    on_enter=OpenUrlAction("https://repl.it/languages/%s" %
                                           l['key'])))

        return RenderResultListAction(items)
コード例 #4
0
ファイル: main.py プロジェクト: brpaz/ulauncher-circleci
 def show_menu(self):
     """ Shoe available extension options """
     return RenderResultListAction([
         ExtensionResultItem(
             icon=ICON_DEFAULT,
             name='Recent Builds',
             description='Lists the latest builds on Circle CI',
             on_enter=SetUserQueryAction(KEYWORD_RECENT_BUILDS + ' ')),
         ExtensionResultItem(icon=ICON_DEFAULT,
                             name='Projects',
                             description='Projects',
                             on_enter=SetUserQueryAction(KEYWORD_PROJECTS +
                                                         ' ')),
         ExtensionResultItem(
             icon=ICON_DEFAULT,
             name='Dashboard',
             description='Open the Circle CI dashboard page',
             on_enter=OpenUrlAction("https://circleci.com/dashboard")),
         ExtensionResultItem(
             icon=ICON_DEFAULT,
             name='Account Settings',
             description='Open the Circle CI account settings page',
             on_enter=OpenUrlAction("https://circleci.com/dashboard")),
         ExtensionResultItem(
             icon=ICON_DEFAULT,
             name='Status',
             description='Open the Circle CI status page',
             on_enter=OpenUrlAction("https://status.circleci.com/account")),
     ])
コード例 #5
0
ファイル: main.py プロジェクト: Tikotik/ulauncher-mailinator
    def on_event(self, event, extension):
        items = []

        if (event.get_argument() is not None):
            items.append(
                ExtensionResultItem(
                    icon='images/icon.png',
                    name=event.get_argument(),
                    description="Press enter to open on mailinator.com",
                    on_enter=OpenUrlAction('{}{}'.format(
                        MAILINATOR_URL, event.get_argument()))))
        else:
            email = '{}{}{}'.format(extension.preferences.get("prefix"),
                                    fake.user_name(),
                                    str(random.randint(1000, 9999)))

            items.append(
                ExtensionResultItem(
                    icon='images/icon.png',
                    name='{}@mailinator.com'.format(email),
                    description=
                    "Press enter to copy to the cliboard. Alt+Enter to open",
                    highlightable=False,
                    on_enter=CopyToClipboardAction(email),
                    on_alt_enter=OpenUrlAction('{}{}'.format(
                        MAILINATOR_URL, email))))

        return RenderResultListAction(items)
コード例 #6
0
ファイル: main.py プロジェクト: mabasic/ulauncher-laravel
    def on_event(self, event, extension):
        description = "Type in your query and press Enter..."

        url = "https://laravel.com/docs/"
        extension_results = []
        if event.get_argument() is not None:
            results = extension.index.search(event.get_argument(), {
                "tagFilters": "master",
                "hitsPerPage": 5
            })

            for hit in results["hits"]:
                extension_results.append(
                    ExtensionResultItem(icon='icons/laravel.svg',
                                        name=hit["h1"],
                                        description=get_subtitle(hit),
                                        on_enter=OpenUrlAction(url +
                                                               hit["link"])))
        if len(extension_results) == 0:
            extension_results.append(
                ExtensionResultItem(icon='icons/laravel.svg',
                                    name="Search Laravel docs",
                                    description=description,
                                    on_enter=OpenUrlAction(url)))

        return RenderResultListAction(extension_results)
コード例 #7
0
ファイル: main.py プロジェクト: zoni/ulauncher-meet
    def on_event(self, event, extension):
        items = []

        user_inputs = event.get_query().split()

        items = []

        if len(user_inputs) == 1 or user_inputs[1] in 'new':
            items.append(
                ExtensionResultItem(
                    icon='images/icon.png',
                    name='New',
                    description='Start new meeting',
                    on_enter=OpenUrlAction('https://meet.google.com/new')))
        if len(user_inputs) == 1:
            for meeting in saved_meetings:
                items.append(
                    ExtensionResultItem(
                        icon='images/icon.png',
                        name='Join %s' % meeting.name,
                        description='Join https://meet.google.com/%s' %
                        meeting.id,
                        on_enter=OpenUrlAction('https://meet.google.com/%s' %
                                               meeting.id)))
        if len(user_inputs) > 1:
            meet_id = user_inputs[1]
            if saved_meetings is None:
                items.append(
                    ExtensionResultItem(
                        icon='images/icon.png',
                        name='Saved meetings misformed',
                        description=
                        'Please fix saved meetings in extension properties',
                        on_enter=DoNothingAction()))
            else:
                for meeting in saved_meetings:
                    if in_saved_meeting(meet_id, meeting):
                        items.append(
                            ExtensionResultItem(
                                icon='images/icon.png',
                                name='Join %s' % meeting.name,
                                description='Join https://meet.google.com/%s' %
                                meeting.id,
                                on_enter=OpenUrlAction(
                                    'https://meet.google.com/%s' %
                                    meeting.id)))

            items.append(
                ExtensionResultItem(
                    icon='images/icon.png',
                    name='Join meeting',
                    description='Join https://meet.google.com/%s' % meet_id,
                    on_enter=OpenUrlAction('https://meet.google.com/%s' %
                                           meet_id)))

        return RenderResultListAction(items)
コード例 #8
0
    def show_menu(self):
        """
        Show the main extension menu
        when the user types the extension keyword without arguments
        """
        keyword = self.preferences["kw"]

        menu = [
            ExtensionResultItem(
                icon='images/icon.png',
                name="My",
                description=
                "Your personal menu with shortcuts for your Issues, Merge Requests and more",
                highlightable=False,
                on_enter=SetUserQueryAction("%s my" % keyword)),
            ExtensionResultItem(
                icon='images/icon.png',
                name="Project Search",
                description=
                "Search public projects in the entire GitLab platform",
                highlightable=False,
                on_enter=SetUserQueryAction("%s search " % keyword)),
            ExtensionResultItem(
                icon='images/icon.png',
                name="My Projects",
                description="List the projects you are a member of",
                highlightable=False,
                on_enter=SetUserQueryAction("%s projects " % keyword)),
            ExtensionResultItem(icon='images/icon.png',
                                name="My Projects (Starred)",
                                description="List your starred projects",
                                highlightable=False,
                                on_enter=SetUserQueryAction("%s starred " %
                                                            keyword)),
            ExtensionResultItem(icon='images/icon.png',
                                name="My Groups",
                                description="List the groups you belong",
                                highlightable=False,
                                on_enter=SetUserQueryAction("%s groups " %
                                                            keyword)),
            ExtensionResultItem(icon='images/icon.png',
                                name="GitLab Website",
                                description="Opens the GitLab website",
                                highlightable=False,
                                on_enter=OpenUrlAction(self.gitlab.url)),
            ExtensionResultItem(
                icon='images/icon.png',
                name="GitLab Status",
                description="Opens the GitLab status page",
                highlightable=False,
                on_enter=OpenUrlAction("https://status.gitlab.com"))
        ]

        return RenderResultListAction(menu)
コード例 #9
0
    def account_menu(self):
        """ Show your menu with links for GitHub pages """

        # Authenticate the user, if its not already authenticated.
        if self.user is None:
            self.user = self.github.get_user()

        return RenderResultListAction([
            ExtensionResultItem(icon='images/icon.png',
                                name="Logged in as %s (%s)" %
                                (self.user.name, self.user.login),
                                highlightable=False,
                                on_enter=OpenUrlAction(self.user.html_url)),
            ExtensionResultItem(
                icon='images/icon.png',
                name="Profile",
                description="Open your User Profile page on GitHub website",
                highlightable=False,
                on_enter=OpenUrlAction("https://github.com/%s" %
                                       self.user.login)),
            ExtensionResultItem(
                icon='images/icon.png',
                name="Repos",
                description="Open your Repositories page on GitHub website",
                highlightable=False,
                on_enter=OpenUrlAction(
                    "https://github.com/%s?tab=repositories" %
                    self.user.login)),
            ExtensionResultItem(
                icon='images/icon.png',
                name="Starred Repos",
                description="Open your Starred repositories page on GitHub website",
                highlightable=False,
                on_enter=OpenUrlAction("https://github.com/%s?tab=stars" %
                                       self.user.login)),
            ExtensionResultItem(
                icon='images/icon.png',
                name="Gists",
                description="Open your Gists",
                highlightable=False,
                on_enter=OpenUrlAction("https://gist.github.com")),
            ExtensionResultItem(
                icon='images/icon.png',
                name="Pull Requests",
                description="Open your Pull requests page on GitHub website",
                highlightable=False,
                on_enter=OpenUrlAction("https://github.com/pulls")),
            ExtensionResultItem(
                icon='images/icon.png',
                name="Issues",
                description="Open your Issues page on GitHub website",
                highlightable=False,
                on_enter=OpenUrlAction("https://github.com/issues")),
            ExtensionResultItem(
                icon='images/icon.png',
                name="Access tokens",
                description="Manage your personal access tokens",
                highlightable=False,
                on_enter=OpenUrlAction("https://github.com/settings/tokens")),
        ])
コード例 #10
0
    def build_results_list(self, apps):
        """ Build sites list """
        items = []
        LOGGER.debug(apps)

        for app in apps:
            app_url = self.heroku_client.DASHBOARD_URL + "/apps/" + app['name']
            items.append(
                ExtensionResultItem(icon='images/icon.png',
                                    name=app["name"],
                                    on_enter=OpenUrlAction(app_url),
                                    on_alt_enter=OpenUrlAction(
                                        app['web_url'])))

        return items
コード例 #11
0
    def on_event(self, event, extension):
        keyword = event.get_keyword()

        if keyword == extension.preferences["github"]:
            hostname = "github.com"
            gh = GithubQuery("https://api.github.com/graphql",
                             extension.preferences["github_token"])
        else:
            hostname = extension.preferences["ghe_hostname"]
            url = "https://%s/api/graphql" % hostname
            gh = GithubQuery(url, extension.preferences["ghe_token"])

        items = []
        argument = event.get_argument() or ""
        arguments = argument.split(" ", 1)
        command = arguments[0]
        query = arguments[1] if len(arguments) > 1 else ''

        if command == "my":
            my_pages = [
                "dashboard", "notifications", "issues", "pulls", "settings",
                "stars", "gist"
            ]
            for page in my_pages:
                if query != '' and re.search("^%s" % query, page) is None:
                    continue
                url = "https://%s/%s" % (hostname, page)
                items.append(
                    ExtensionResultItem(icon='images/repo.png',
                                        name=page,
                                        description="Open %s page" % page,
                                        on_enter=OpenUrlAction(url)))
        else:
            argument += " in:name,org"

            repos = gh.repos(argument)
            for r in sorted(repos, key=lambda r: r["nameWithOwner"]):
                name = r["nameWithOwner"]
                desc = r["description"]

                url = "https://%s/%s" % (hostname, name)
                items.append(
                    ExtensionResultItem(icon='images/repo.png',
                                        name=name,
                                        description=desc,
                                        on_enter=OpenUrlAction(url)))

        return RenderResultListAction(items)
コード例 #12
0
ファイル: main.py プロジェクト: brpaz/ulauncher-open-docs
    def on_event(self, event, extension):
        """ Handles the event """

        script_dir = os.path.dirname(__file__)
        file_path = os.path.join(script_dir, 'data', 'docs.json')

        with open(file_path) as f_data:
            docs = json.load(f_data)

        query = event.get_argument() or ""

        if query:
            docs = [x for x in docs if query.lower() in x['name'].lower()]

        docs = sorted(docs, key=lambda k: k['name'])
        items = []

        for doc in docs[:8]:

            icon = extension.get_doc_icon(doc['key'])

            items.append(ExtensionResultItem(
                icon=icon,
                name=doc['name'],
                description=doc['description'],
                on_enter=OpenUrlAction(doc['url']),
                on_alt_enter=CopyToClipboardAction(doc['url'])
            ))

        return RenderResultListAction(items)
コード例 #13
0
    def build_result_item(self, page):
        """ Builds a result item object """

        browser_action = OpenUrlAction(page['url'])
        hawkeye_action = RunScriptAction('hawkeye --uri="%s"' % page['url'],
                                         [])

        epiphany_action = RunScriptAction(
            'epiphany-browser "%s"' % page['url'], [])

        if self.preferences['primary_action'] == "Hawkeye Quicklook":
            on_enter = hawkeye_action
        elif self.preferences['primary_action'] == "Gnome Web":
            on_enter = epiphany_action
        else:
            on_enter = browser_action

        if self.preferences['secondary_action'] == "None":
            on_alt_enter = DoNothingAction()
        elif self.preferences['secondary_action'] == "Hawkeye Quicklook":
            on_alt_enter = hawkeye_action
        elif self.preferences['secondary_action'] == "Gnome Web":
            on_alt_enter = epiphany_action
        else:
            on_alt_enter = browser_action

        return ExtensionResultItem(icon='images/icon.png',
                                   name=page['name'],
                                   description=page['category'],
                                   on_enter=on_enter,
                                   on_alt_enter=on_alt_enter)
コード例 #14
0
    def list_groups(self, query):
        """ Lists the groups the user belongs to """

        items = []
        groups = self.gitlab.groups.list(archived=0,
                                         search=query,
                                         order_by='name',
                                         sort='asc',
                                         page=1,
                                         per_page=10)

        if not groups:
            return RenderResultListAction([
                ExtensionResultItem(
                    icon='images/icon.png',
                    name="No groups found matching your search criteria",
                    highlightable=False,
                    on_enter=HideWindowAction())
            ])

        for group in groups:
            if group.description is not None:
                description = group.description
            else:
                description = ''

            items.append(
                ExtensionResultItem(icon='images/icon.png',
                                    name=group.name,
                                    description=description,
                                    highlightable=False,
                                    on_enter=OpenUrlAction(group.web_url)))

        return RenderResultListAction(items)
コード例 #15
0
    def show_docs_for_docset(self, docset, query):
        """ Show documentation for a specific Docset """
        if len(query.strip()) < 3:
            return RenderResultListAction([
                ExtensionResultItem(icon='images/icon.png',
                                    name='please keep typing ...',
                                    description='searching %s documentation' %
                                    docset,
                                    highlightable=False,
                                    on_enter=HideWindowAction())
            ])

        results = self.searcher.search(docset, query)

        items = []

        if not results:
            return RenderResultListAction([
                ExtensionResultItem(icon='images/icon.png',
                                    name='No results matching your criteria',
                                    highlightable=False,
                                    on_enter=HideWindowAction())
            ])

        for result in results[:8]:
            items.append(
                ExtensionResultItem(icon=result['icon'],
                                    name=result['title'],
                                    description=result['category'],
                                    highlightable=False,
                                    on_enter=OpenUrlAction(result['url'])))

        return RenderResultListAction(items)
コード例 #16
0
    def search_public_repos(self, query):
        """ Search public repos """

        if not query or len(query) < 3:
            return RenderResultListAction([
                ExtensionResultItem(
                    icon='images/icon.png',
                    name='Please keep typing your search query',
                    description='Minimum 3 chars',
                    highlightable=False,
                    on_enter=HideWindowAction())
            ])

        repos = self.github.search_repositories(query=query)[:8]

        items = []

        for repo in repos:
            items.append(
                ExtensionResultItem(
                    icon='images/icon.png',
                    name="%s (%s stars)" %
                    (repo.name.encode('utf-8'), repo.stargazers_count),
                    description=repo.description.encode('utf-8'),
                    on_enter=OpenUrlAction(repo.html_url),
                    on_alt_enter=CopyToClipboardAction(repo.html_url)))

        return RenderResultListAction(items)
コード例 #17
0
    def search_users(self, query):
        """ Search GitHub users """

        if not query or len(query) < 3:
            return RenderResultListAction([
                ExtensionResultItem(
                    icon='images/icon.png',
                    name='Please keep typing your search query',
                    description='Minimum 3 chars',
                    highlightable=False,
                    on_enter=HideWindowAction())
            ])

        users = self.github.search_users(query=query,
                                         sort="followers",
                                         order="desc")[:8]

        items = []

        for user in users:
            items.append(
                ExtensionResultItem(icon='images/icon.png',
                                    name=user.name,
                                    on_enter=OpenUrlAction(user.html_url),
                                    on_alt_enter=CopyToClipboardAction(
                                        user.html_url)))

        return RenderResultListAction(items)
コード例 #18
0
    def on_event(self, event, extension):
        data = event.get_argument()
        language_pref = extension.preferences['language']

        searched_string = data.replace(" ", "%20")

        items = []

        if data:
            response = urllib2.urlopen(
                "http://%s.wiktionary.org/w/api.php?action=opensearch&search=%s&limit=5"
                % (language_pref, searched_string)).read()
            response_array = eval(response)

            if not response_array[1]:
                items.append(
                    self.get_action_to_render(
                        name="Something went terribly wrong !",
                        description="check the typo of your word maybe ?"))
            else:
                for i in range(0, 4):
                    items.append(
                        self.get_action_to_render(
                            name=response_array[1][i],
                            description=response_array[2][i],
                            on_enter=OpenUrlAction(response_array[3][i])))
        else:
            items.append(
                self.get_action_to_render(
                    name="Type in your query",
                    description="Example: def hurluberlu"))

        return RenderResultListAction(items)
コード例 #19
0
    def search_tabs(self, event):
        """ Search tabs """

        if not self.brotab_client.is_installed():
            return RenderResultListAction([
                ExtensionResultItem(
                    icon="images/icon.png",
                    name="Brotab is not installed on your system",
                    description="Press enter to open install instructions.",
                    highlightable=False,
                    on_enter=OpenUrlAction("https://github.com/balta2ar/brotab#installation"),
                )
            ])

        items = []
        tabs = self.brotab_client.search_tabs(event.get_argument())

        for tab in tabs[:DISPLAY_MAX_RESULTS]:
            data = {"tab": tab["prefix"], "mode": self.mode}

            items.append(
                ExtensionSmallResultItem(
                    icon="images/%s" % tab["icon"],
                    name=tab["name"],
                    description=tab["url"],
                    on_enter=ExtensionCustomAction(data),
                    on_alt_enter=CopyToClipboardAction(tab["url"]),
                ))

        if not items:
            return self.show_no_results_message()

        return RenderResultListAction(items)
コード例 #20
0
ファイル: main.py プロジェクト: therj/ulauncher-devdocs
    def open_in_devdocs(self, doc, entry=None):
        """
        Opens a documentation page in DevDocs.
        :param str doc: The documentation slug
        :param str entry: The entry slug.
        Depending of the extension configurations it might open in:
            - DevDocs website
            - Devdocs desktop (devdocs protocol)
            - HawkHeye
        """

        open_result_in = self.preferences['open_doc_in']

        doc_path = doc

        if entry:
            doc_path = doc_path + "/" + entry

        doc_url = "https://devdocs.io/%s" % doc_path

        if open_result_in == "Hawkeye":
            return RunScriptAction('hawkeye --uri="%s"' % doc_url, [])
        elif open_result_in == "DevDocs Protocol":
            return OpenAction("devdocs://%s" % doc_path)

        return OpenUrlAction(doc_url)
コード例 #21
0
    def list_repos(self, query):
        """ Lists the Repositories from the user """

        try:
            repos = self.travis_client.get_repos(query)
        except Exception as e:
            return self.handle_errors(e)

        if not repos:
            return RenderResultListAction([
                ExtensionResultItem(icon='images/icon.png',
                                    name='No Repositories found',
                                    on_enter=HideWindowAction())
            ])

        items = []
        for repo in repos[:8]:
            desc = ''
            if repo['description']:
                desc = repo['description']

            items.append(
                ExtensionResultItem(
                    icon='images/icon.png',
                    name=repo['name'],
                    description=desc,
                    on_enter=SetUserQueryAction(
                        "%s %s builds" % (self.preferences["kw"], repo['id'])),
                    on_alt_enter=OpenUrlAction(repo['url'])))

        return RenderResultListAction(items)
コード例 #22
0
    def show_docsets_list(self, event, query):
        """ Displays a list of available docs """

        docs = self.searcher.get_available_docs(query)

        items = []

        if not docs:
            return RenderResultListAction([
                ExtensionResultItem(
                    icon='images/icon.png',
                    name='No docsets found matching your criteria',
                    on_enter=HideWindowAction())
            ])

        for doc in docs[:8]:
            items.append(
                ExtensionResultItem(
                    icon=doc['icon'],
                    name=doc['name'],
                    description=doc['description'],
                    on_alt_enter=OpenUrlAction(doc['url']),
                    on_enter=SetUserQueryAction(
                        "%s %s " % (event.get_keyword(), doc['key']))))

        return RenderResultListAction(items)
コード例 #23
0
    def show_builds_for_repo(self, repo_id):
        """ Show the latest build results for the specified repository """

        try:
            builds = self.travis_client.get_builds_for_repo(repo_id)
        except Exception as e:
            return self.handle_errors(e)

        if not builds:
            return RenderResultListAction([
                ExtensionResultItem(
                    icon='images/icon.png',
                    name='No builds found for the specified repository',
                    highlightable=False,
                    on_enter=HideWindowAction())
            ])

        items = []
        for build in builds:

            items.append(
                ExtensionResultItem(
                    icon=self.get_icon_for_build(build['state']),
                    name='#%s - %s' %
                    (build['number'], build['commit_message']),
                    description='Branch: %s | Started by: %s | Updated: %s' %
                    (build['branch'], build['triggered_by'],
                     build['updated_at']),
                    on_enter=OpenUrlAction(build['url']),
                    highlightable=False,
                ))

        return RenderResultListAction(items)
コード例 #24
0
    def get_items(self, query):

        items = []
        self.matches_len = 0

        if query is None:
            query = ''

        for bookmarks_path, browser in self.bookmarks_paths:
            matches = []
            with open(bookmarks_path) as data_file:
                data = json.load(data_file)
                bookmark_bar = data['roots']['bookmark_bar']
                matches = self.find_rec(bookmark_bar, query, matches)

            for bookmark in matches:
                bookmark_name = bookmark['name'].encode('utf-8')
                bookmark_url = bookmark['url'].encode('utf-8')
                item = ExtensionResultItem(
                    icon=browser_imgs.get(browser),
                    name='%s' % bookmark_name.decode('utf-8'),
                    description='%s' % bookmark_url.decode('utf-8'),
                    on_enter=OpenUrlAction(bookmark_url.decode('utf-8')))
                items.append(item)

        return items
コード例 #25
0
ファイル: main.py プロジェクト: brpaz/ulauncher-cloudflare
    def get_zones(self, event):
        """ Returns the list of Zones from Cloudflare """
        items = []

        query = event.get_argument() or ""

        zones = self.cf_client.zones.get()

        for zone in zones:

            if query.lower() not in zone["name"].lower():
                continue

            url = "https://dash.cloudflare.com/%s/%s" % (zone["account"]['id'],
                                                         zone["name"])
            items.append(
                ExtensionResultItem(icon='images/icon.png',
                                    name=zone["name"],
                                    description=zone["status"],
                                    on_enter=OpenUrlAction(url)))

        if not items:
            items.append(
                ExtensionResultItem(
                    icon='images/icon.png',
                    name='No results found matching your criteria',
                    highlightable=False))

        return items
コード例 #26
0
    def user_gists(self, query):
        """ List user gists"""

        query = query.lower()
        gists = []
        with open(self.gists_cache_file) as f:
            gists = json.load(f)

        items = []
        for gist in gists:

            desc = gist['description'] or ""

            if query and query not in desc.lower(
            ) or query not in gist['filename'].lower():
                continue

            items.append(
                ExtensionResultItem(icon='images/icon.png',
                                    name=gist['filename'].encode('utf-8'),
                                    description=desc,
                                    highlightable=False if not query else True,
                                    on_enter=OpenUrlAction(gist['url']),
                                    on_alt_enter=CopyToClipboardAction(
                                        gist['url'])))

        return RenderResultListAction(items[:8])
コード例 #27
0
def show_instant_answer(instant_item, instant_answer, instant_url):
    if instant_item == "" or instant_answer == "" or instant_url == "":
        return None

    # add line breaks to answer
    max_chars = 75
    answer_chunk = []
    words = instant_answer.split(" ")
    index, anchor = 1, 0
    while anchor <= len(words):
        partial = " ".join(words[anchor:anchor + index])
        if len(partial) > max_chars:
            answer_chunk.append(" ".join(words[anchor:anchor + index - 1]))
            anchor += index - 1
            index = 1
            continue
        if anchor + index == len(words):
            answer_chunk.append(partial)
            break
        index += 1

    return ExtensionResultItem(
        icon=ICON_FILE,
        name=instant_item,
        description="\n".join(answer_chunk),
        on_enter=OpenUrlAction(instant_url),
    )
コード例 #28
0
    def on_event(self, event, extension):
        """ Handles the event """
        items = []

        try:
            boards = extension.trello_client.get_boards(event.get_argument())

            if not boards:
                return [
                    ExtensionResultItem(icon='images/icon.png',
                                        name='No boards found with name %s' %
                                        event.get_argument(),
                                        on_enter=HideWindowAction())
                ]

            for board in boards[:25]:
                items.append(
                    ExtensionSmallResultItem(
                        icon='images/icon.png',
                        name=board['name'],
                        description=board['description'],
                        on_enter=RunScriptAction(board['script']) if bool(
                            board['script']) else OpenUrlAction(board['url'])))

        except TrelloApiException as e:  # pylint: disable=invalid-name
            LOGGER.error(e)
            items.append(
                ExtensionResultItem(
                    icon='images/icon.png',
                    name=
                    'Error when connecting to Trello API ( status code : %s )'
                    % e.get_status_code(),
                    on_enter=HideWindowAction()))

        return RenderResultListAction(items)
コード例 #29
0
ファイル: main.py プロジェクト: brpaz/ulauncher-shortcuts
    def show_applications(self, query):
        """ shows the list of available applications known by the extension """
        apps = self.shortcuts_service.get_applications(query)

        if not apps:
            return RenderResultListAction([
                ExtensionSmallResultItem(
                    icon='images/icon.png',
                    name='No applications found matching your criteria',
                    highlightable=False,
                    on_enter=HideWindowAction())
            ])

        items = []
        for app in apps[:15]:
            items.append(
                ExtensionSmallResultItem(icon=app['icon'],
                                         name=app['name'],
                                         on_enter=ExtensionCustomAction({
                                             "action":
                                             "show",
                                             "app":
                                             app,
                                         }),
                                         on_alt_enter=OpenUrlAction(
                                             app['reference_url'])))
        return RenderResultListAction(items)
コード例 #30
0
ファイル: main.py プロジェクト: therj/ulauncher-devdocs
    def show_options_menu(self, query):
        """ Shoe some general configuration options for the extension """
        items = [
            ExtensionResultItem(
                icon='images/icon.png',
                name='Open DevDocs.io',
                description='Opens DevDocs on your default browser',
                highlightable=False,
                on_enter=OpenUrlAction("https://devdocs.io/")),
            ExtensionResultItem(
                icon='images/icon.png',
                name='Open cache folder',
                description=
                "Opens the folder where the documentation cache is stored",
                highlightable=False,
                on_enter=OpenAction(self.devdocs_svc.cache_dir)),
            ExtensionResultItem(
                icon='images/icon.png',
                name='Index Documentation',
                description=
                "This process might take a while. You will receive a notification when finished.",
                highlightable=False,
                on_enter=ExtensionCustomAction([]))
        ]

        return RenderResultListAction(items)