コード例 #1
0
        def callback():
            this = yield

            # Setup the loading notice
            frames = ['Loading package list' + f for f in busy_frames]
            stop_status_loop = loop_status_msg(frames, 0.15)

            # Run the search/list command
            output, return_code = yield Thread(target=run_nimble,
                                               args=('-y list -i',
                                                     this.send)).start()

            # Set the status to show we've finished searching
            yield stop_status_loop(get_next_method(this))

            if return_code != 0:
                sublime.status_message(
                    "Nimble Installed Package Listing Failed")
            else:
                items = []
                packages = parse_package_descriptions(output)

                if len(packages) == 0:
                    sublime.status_message("No Installed Packages Found")
                else:
                    for package in packages:
                        items.append([
                            package['name'],
                            package.get('description', ''),
                            package.get('url', '')
                        ])

                    selection = yield window.show_quick_panel(items, this.send)

                    if selection != -1:
                        target_name = items[selection][0]
                        # Setup the loading notice
                        loading_notice = "Uninstalling package"
                        frames = [loading_notice + f for f in busy_frames]
                        stop_status_loop = loop_status_msg(frames, 0.15)

                        # Run the install command
                        output, return_code = yield Thread(
                            target=run_nimble,
                            args=('-y uninstall ' + escape_shell(target_name),
                                  this.send)).start()

                        yield stop_status_loop(get_next_method(this))

                        self.output_content(output, window)
                        if return_code == 0:
                            sublime.status_message(
                                "Uninstalled Nimble Package")
                        else:
                            sublime.status_message(
                                'Nimble Package Uninstallation Failed')
            yield
コード例 #2
0
    def run(self):
        this = yield

        window = sublime.active_window()

        # Setup the loading notice
        frames = ['Updating Nimble package list' + f for f in busy_frames]
        stop_status_loop = loop_status_msg(frames, 0.15)

        # Run the main command
        output, return_code = yield Thread(target=run_nimble,
                                           args=('-y update',
                                                 this.send)).start()

        # Set the status to show we've finished
        yield stop_status_loop(get_next_method(this))

        # Show output
        self.output_content(output, window)

        if return_code == 0:
            sublime.status_message("Nimble Package List Updated")
        else:
            sublime.status_message('Updating Nimble Package List Failed')

        yield
コード例 #3
0
ファイル: Nimble.py プロジェクト: enjoysmath/NimLime
    def run(self):
        this = yield

        window = sublime.active_window()

        # Setup the loading notice
        frames = ['Updating Nimble package list' + f for f in busy_frames]
        stop_status_loop = loop_status_msg(frames, 0.15)

        # Run the main command
        output, return_code = yield Thread(
            target=run_nimble,
            args=('-y update', this.send)
        ).start()

        # Set the status to show we've finished
        yield stop_status_loop(get_next_method(this))

        # Show output
        self.output_content(output, window)

        if return_code == 0:
            sublime.status_message("Nimble Package List Updated")
        else:
            sublime.status_message('Updating Nimble Package List Failed')

        yield
コード例 #4
0
    def run(self):
        this = yield

        window = sublime.active_window()

        # Setup the loading notice
        frames = ['Retrieving package list' + f for f in busy_frames]
        stop_status_loop = loop_status_msg(frames, 0.15)

        # Run the main command
        output, returncode = yield Thread(target=run_nimble,
                                          args=('-y list', this.send)).start()

        # Set the status to show we've finished
        yield stop_status_loop(get_next_method(this))

        # Show output
        self.output_content(output, window)

        if self.send_to_quickpanel:
            items = []
            packages = parse_package_descriptions(output)
            for package in packages:
                items.append([
                    package['name'],
                    package.get('description', ''),
                    package.get('url', '')
                ])
            window.show_quick_panel(items, None)

        if returncode == 0:
            sublime.status_message("Listing Nimble Packages")
        else:
            sublime.status_message('Nimble Package List Retrieval Failed')
        yield
コード例 #5
0
ファイル: NimCheck.py プロジェクト: enjoysmath/NimLime
    def run(self, show_error_list=True):
        this = yield

        frames = ["Running Nim Check" + f for f in busy_frames]
        stop_status_loop = loop_status_msg(frames, 0.15)

        window = sublime.active_window()
        view = window.active_view()
        view_name = os.path.split(view.file_name() or view.name())[1]

        # Save view text
        if view.is_dirty():
            view.run_command('save')

        # Run 'nim check' on the current view and retrieve the output.
        output, returncode = yield Thread(
            target=run_nimcheck,
            args=(view.file_name(), this.send, self.verbosity)
        ).start()

        messages = parse_nimcheck_output(output)

        yield stop_status_loop(get_next_method(this))
        sublime.status_message("Nim Check Finished.")

        self.highlight_and_list_messages(messages, window, view)

        if self.send_output:
            if self.raw_output:
                content = output
            else:
                gen = (m[5] for m in messages if view_name == m[0])
                content = "\n".join(gen)
            self.write_to_output(content, window, view)
        yield
コード例 #6
0
ファイル: NimCheck.py プロジェクト: chel-man/NimLime
    def run(self, show_error_list=True):
        this = yield

        frames = ["Running Nim Check" + f for f in busy_frames]
        stop_status_loop = loop_status_msg(frames, 0.15)

        window = sublime.active_window()
        view = window.active_view()
        view_name = os.path.split(view.file_name() or view.name())[1]

        # Save view text
        if view.is_dirty():
            view.run_command('save')

        # Run 'nim check' on the current view and retrieve the output.
        output, returncode = yield Thread(target=run_nimcheck,
                                          args=(view.file_name(),
                                                this.send)).start()

        messages = parse_nimcheck_output(output)

        yield stop_status_loop(get_next_method(this))
        sublime.status_message("Nim Check Finished.")

        self.highlight_and_list_messages(messages, window, view)

        if self.send_output:
            if self.raw_output:
                content = output
            else:
                gen = (m[5] for m in messages if view_name == m[0])
                content = "\n".join(gen)
            self.write_to_output(content, window, view)
        yield
コード例 #7
0
ファイル: NimCheck.py プロジェクト: enjoysmath/NimLime
    def run(self):
        this = yield

        active_window = sublime.active_window()
        active_view = active_window.active_view()

        # Retrieve user input
        initial_text = ''
        if self.remember_input:
            initial_text = self.last_entry

        path = yield active_window.show_input_panel(
            "File to check?", initial_text, this.send, None, None
        )
        self.last_entry = path

        # Run 'nim check' on the external file.
        if os.path.isfile(path):
            frames = ['Checking external file' + f for f in busy_frames]
            stop_status_loop = loop_status_msg(frames, 0.25)

            output, returncode = yield Thread(
                target=run_nimcheck,
                args=(path, this.send)
            ).start()

        else:
            sublime.error_message(
                "File '{0}' does not exist, or isn't a file.".format(path)
            )
            yield

        error_list = parse_nimcheck_output(output)
        # Prepare output
        error_output = '\n'.join(
            [error[4] for error in error_list]
        )

        # Stop the status loop
        yield stop_status_loop(get_next_method(this))
        sublime.status_message("External file checked.")

        # Print to the output view
        fallback_view_name = path + " - Nim Check Output"
        self.write_to_output(
            error_output, active_window, active_view
        )

        yield
コード例 #8
0
ファイル: NimCheck.py プロジェクト: chel-man/NimLime
    def run(self):
        this = yield

        active_window = sublime.active_window()
        active_view = active_window.active_view()

        # Retrieve user input
        initial_text = ''
        if self.remember_input:
            initial_text = self.last_entry

        path = yield active_window.show_input_panel("File to check?",
                                                    initial_text, this.send,
                                                    None, None)
        self.last_entry = path

        # Run 'nim check' on the external file.
        if os.path.isfile(path):
            frames = ['Checking external file' + f for f in busy_frames]
            stop_status_loop = loop_status_msg(frames, 0.25)

            output, returncode = yield Thread(target=run_nimcheck,
                                              args=(path, this.send)).start()

        else:
            sublime.error_message(
                "File '{0}' does not exist, or isn't a file.".format(path))
            yield

        error_list = parse_nimcheck_output(output)
        # Prepare output
        error_output = '\n'.join([error[4] for error in error_list])

        # Stop the status loop
        yield stop_status_loop(get_next_method(this))
        sublime.status_message("External file checked.")

        # Print to the output view
        fallback_view_name = path + " - Nim Check Output"
        self.write_to_output(error_output, active_window, active_view)

        yield
コード例 #9
0
ファイル: Nimble.py プロジェクト: enjoysmath/NimLime
        def callback():
            this = yield

            # Get user input
            search_term = yield window.show_input_panel(
                "Package Search Term?", '', this.send, None, None
            )

            # Setup the loading notice
            frames = ['Searching package list' + f for f in busy_frames]
            stop_status_loop = loop_status_msg(frames, 0.15)

            # Run the main command
            output, return_code = yield Thread(
                target=run_nimble,
                args=('-y search ' + escape_shell(search_term), this.send)
            ).start()

            # Set the status to show we've finished
            yield stop_status_loop(get_next_method(this))

            # List output
            if self.send_to_quickpanel:
                items = []
                packages = parse_package_descriptions(output)
                for package in packages:
                    items.append([
                        package['name'],
                        package.get('description', ''),
                        package.get('url', '')
                    ])
                window.show_quick_panel(items, None)

            # Show output
            self.output_content(output, window)

            if return_code == 0:
                sublime.status_message("Listing Nimble Packages")
            else:
                sublime.status_message('Nimble Package List Retrieval Failed')
            yield
コード例 #10
0
        def callback():
            this = yield

            if self.preemptive_search:
                # Get user input
                search_term = yield window.show_input_panel(
                    "Package to install?", '', this.send, None, None)

                loading_notice = 'Searching package list'
                process_args = ('-y search ' + escape_shell(search_term),
                                this.send)
            else:
                loading_notice = 'Loading package list'
                process_args = ('-y list ', this.send)

            # Setup the loading notice
            frames = [loading_notice + f for f in busy_frames]
            stop_status_loop = loop_status_msg(frames, 0.15)

            # Run the search/list command
            output, return_code = yield Thread(target=run_nimble,
                                               args=process_args).start()

            # Set the status to show we've finished searching
            yield stop_status_loop(get_next_method(this))

            if return_code != 0:
                sublime.status_message("Nimble Package Load Failed")
            else:
                items = []
                packages = parse_package_descriptions(output)

                if len(packages) == 0:
                    sublime.status_message("No Matching Packages Found")
                else:
                    for package in packages:
                        items.append([
                            package['name'],
                            package.get('description', ''),
                            package.get('url', '')
                        ])

                    selection = yield window.show_quick_panel(items, this.send)

                    if selection != -1:
                        target_name = items[selection][0]
                        # Setup the loading notice
                        loading_notice = "Installing package"
                        frames = [loading_notice + f for f in busy_frames]
                        stop_status_loop = loop_status_msg(frames, 0.15)

                        # Run the install command
                        output, return_code = yield Thread(
                            target=run_nimble,
                            args=('-y install ' + escape_shell(target_name),
                                  this.send)).start()

                        yield stop_status_loop(get_next_method(this))

                        self.output_content(output, window)
                        if return_code == 0:
                            sublime.status_message("Installed Nimble Package")
                        else:
                            sublime.status_message(
                                'Nimble Package Installation Failed')
            yield
コード例 #11
0
ファイル: Nimble.py プロジェクト: enjoysmath/NimLime
        def callback():
            this = yield

            # Setup the loading notice
            frames = ['Loading package list' + f for f in busy_frames]
            stop_status_loop = loop_status_msg(frames, 0.15)

            # Run the search/list command
            output, return_code = yield Thread(
                target=run_nimble,
                args=('-y list -i', this.send)
            ).start()

            # Set the status to show we've finished searching
            yield stop_status_loop(get_next_method(this))

            if return_code != 0:
                sublime.status_message(
                    "Nimble Installed Package Listing Failed")
            else:
                items = []
                packages = parse_package_descriptions(output)

                if len(packages) == 0:
                    sublime.status_message("No Installed Packages Found")
                else:
                    for package in packages:
                        items.append([
                            package['name'],
                            package.get('description', ''),
                            package.get('url', '')
                        ])

                    selection = yield window.show_quick_panel(items, this.send)

                    if selection != -1:
                        target_name = items[selection][0]
                        # Setup the loading notice
                        loading_notice = "Uninstalling package"
                        frames = [loading_notice + f for f in busy_frames]
                        stop_status_loop = loop_status_msg(frames, 0.15)

                        # Run the install command
                        output, return_code = yield Thread(
                            target=run_nimble,
                            args=(
                                '-y uninstall ' + escape_shell(target_name),
                                this.send
                            )
                        ).start()

                        yield stop_status_loop(get_next_method(this))

                        self.output_content(output, window)
                        if return_code == 0:
                            sublime.status_message(
                                "Uninstalled Nimble Package")
                        else:
                            sublime.status_message(
                                'Nimble Package Uninstallation Failed'
                            )
            yield
コード例 #12
0
ファイル: Nimble.py プロジェクト: enjoysmath/NimLime
        def callback():
            this = yield

            if self.preemptive_search:
                # Get user input
                search_term = yield window.show_input_panel(
                    "Package to install?", '', this.send, None, None
                )

                loading_notice = 'Searching package list'
                process_args = (
                    '-y search ' + escape_shell(search_term),
                    this.send
                )
            else:
                loading_notice = 'Loading package list'
                process_args = ('-y list ', this.send)

            # Setup the loading notice
            frames = [loading_notice + f for f in busy_frames]
            stop_status_loop = loop_status_msg(frames, 0.15)

            # Run the search/list command
            output, return_code = yield Thread(
                target=run_nimble,
                args=process_args
            ).start()

            # Set the status to show we've finished searching
            yield stop_status_loop(get_next_method(this))

            if return_code != 0:
                sublime.status_message("Nimble Package Load Failed")
            else:
                items = []
                packages = parse_package_descriptions(output)

                if len(packages) == 0:
                    sublime.status_message("No Matching Packages Found")
                else:
                    for package in packages:
                        items.append([
                            package['name'],
                            package.get('description', ''),
                            package.get('url', '')
                        ])

                    selection = yield window.show_quick_panel(items, this.send)

                    if selection != -1:
                        target_name = items[selection][0]
                        # Setup the loading notice
                        loading_notice = "Installing package"
                        frames = [loading_notice + f for f in busy_frames]
                        stop_status_loop = loop_status_msg(frames, 0.15)

                        # Run the install command
                        output, return_code = yield Thread(
                            target=run_nimble,
                            args=(
                                '-y install ' + escape_shell(target_name),
                                this.send
                            )
                        ).start()

                        yield stop_status_loop(get_next_method(this))

                        self.output_content(output, window)
                        if return_code == 0:
                            sublime.status_message("Installed Nimble Package")
                        else:
                            sublime.status_message(
                                'Nimble Package Installation Failed'
                            )
            yield