Esempio n. 1
0
    def _render_category_choice_view(self, paginator, current_page, info,
                                     highlighted_item):
        self._clear_screen()

        puts_header("Choose a category")

        puts_key_value("Current category", colored.yellow(info['Category']))

        puts(colored.green("-" * 80))

        puts_key_value("Main categories", "[A]ll, [I]nstalled")
        puts_key_value("Order by", "Na[m]e, Pac[K]ages")

        categories = paginator.page(current_page)
        starting_index = paginator.pagination * (current_page - 1)

        pagination_tpl = "Page %s of %s" % (current_page, paginator.num_pages)

        puts(colored.green("-" * 80), newline=False)
        puts(pagination_tpl)
        puts(colored.green("-" * 80))

        for index, category in enumerate(categories):

            quote = "%s)" % str(starting_index + index + 1)
            if index + 1 == highlighted_item:
                quote += " * "

            with indent(indent=6, quote=quote):
                title = colored.green(category.title)

                #title += "[%s]" %len(category.packages)

                puts(columns([title, 40], [
                    colored.yellow("[%s packages]" % len(category.packages)),
                    40
                ]),
                     newline=False)

            #puts("%s" %category.description or "")

            puts()

            #with indent(indent=6):
            #    puts_key_value("Packages", "%s" %len(category.packages))
            #puts("%s" %category.description)

        puts(colored.green("-" * 80), newline=False)
        puts(pagination_tpl)
        puts(colored.green("-" * 80))
    def _render_category_choice_view(self, paginator, current_page, info, highlighted_item):
        self._clear_screen()

        puts_header("Choose a category")

        puts_key_value("Current category", colored.yellow(info['Category']))

        puts(colored.green("-"*80))

        puts_key_value("Main categories", "[A]ll, [I]nstalled")
        puts_key_value("Order by","Na[m]e, Pac[K]ages")


        categories = paginator.page(current_page)
        starting_index = paginator.pagination*(current_page-1)

        pagination_tpl = "Page %s of %s" %(current_page, paginator.num_pages)

        puts(colored.green("-"*80), newline=False)
        puts(pagination_tpl)
        puts(colored.green("-"*80))

        for index, category in enumerate(categories):

            quote = "%s)" %str(starting_index+index+1)
            if index+1 == highlighted_item:
                quote += " * "

            with indent(indent=6, quote=quote):
                title = colored.green(category.title)

                #title += "[%s]" %len(category.packages)

                puts(columns([title, 40], [colored.yellow("[%s packages]" %len(category.packages)), 40]), newline=False)

            #puts("%s" %category.description or "")

            puts()

            #with indent(indent=6):
            #    puts_key_value("Packages", "%s" %len(category.packages))
                #puts("%s" %category.description)

        puts(colored.green("-"*80), newline=False)
        puts(pagination_tpl)
        puts(colored.green("-"*80))
Esempio n. 3
0
    def _render_package_info(self, package, docs=None):
        # CLEAR CLI
        self._clear_screen()

        puts_header("Package information")

        puts_key_value("Package name", colored.yellow(package.title))
        puts_key_value("Latest version", colored.yellow(package.pypi_version))
        puts_key_value("Repo url", colored.yellow(package.repo_url))
        puts_key_value("PYPI url", colored.yellow(package.pypi_url))
        if package.installed:
            puts_key_value("Installed version",
                           colored.yellow(package.installed_version or "N\A"))
        puts_key_value(
            "Categories",
            colored.yellow(', '.join(
                [category.title for category in package.categories])))
        if docs:
            puts_key_value("ReadTheDocs", colored.magenta(docs))
        # DESCRIPTION

        puts('-' * 80, newline=False)
        puts("Description:")
        puts()
        puts(colored.yellow(package.repo_description))
        puts('-' * 80)

        # COMMANDS
        puts("Commands:")
        puts()
        if not package.installed:
            puts("[i] install")
        else:
            puts("[o] upgrade install")
            puts("[u] uninstall")
        puts()
        puts("[p] open pypi page")
        if docs:
            puts("[d] open docs page")
        puts("[r] open repository url")
        puts()
        puts("[backspace] return to previous screen")
Esempio n. 4
0
    def _render_package_list(self, paginator, current_page, info,
                             highlighted_item):
        self._clear_screen()

        puts_header("Listing packages")
        for key, val in info.items():
            if key == 'Category':
                puts_key_value(key, colored.magenta(str(val)))
            else:
                puts_key_value(key, str(val))

        puts(colored.green("-" * 80))

        #puts_key_value("Main categories", "[A]ll, [I]nstalled")
        puts_key_value("Order by", "Na[m]e, [I]nstalled, [U]sage, [W]atchers")

        packages = paginator.page(current_page)
        starting_index = paginator.pagination * (current_page - 1)

        pagination_tpl = "Page " + colored.yellow(
            "%s" % current_page) + " of %s" % paginator.num_pages

        if self.main_view.get('ordering'):
            pagination_tpl += " - Ordering by: " + colored.yellow(
                self.main_view.get('ordering'))

        puts(colored.green('-' * 80), newline=False)
        puts(pagination_tpl)
        puts(colored.green('-' * 80))

        for index, package in enumerate(packages):

            with indent(indent=6,
                        quote="%s)" % str(starting_index + index + 1)):
                title = colored.green(package.title)

                if index + 1 == highlighted_item:
                    title = " * " + title

                if package.installed:
                    if not package.installed_version:
                        # There is no package version! We can't deduce if a new version is really available.
                        title += colored.yellow(" [Installed] ")
                    else:
                        # Package version is there. Everything normal and good!
                        title += colored.yellow(" [Installed %s] " %
                                                package.installed_version)
                        if versioner(package.installed_version) < versioner(
                                package.pypi_version):
                            title += colored.red(" [New version %s] " %
                                                 package.pypi_version)
                puts(title)

            info = {
                "downloads": package.pypi_downloads,
                #"forks": package.repo_forks,
                "watching": package.repo_watchers,
                "using": package.usage_count,
            }
            cols = [[colored.white("%s %s" % (value, key)), 20]
                    for key, value in info.items()]

            with indent(indent=6):
                #puts()
                puts(columns(*cols))

            puts()

        puts(colored.green('-' * 80), newline=False)
        puts(pagination_tpl)
        puts(colored.green('-' * 80))
    def _render_package_info(self, package, docs=None):
        # CLEAR CLI
        self._clear_screen()

        puts_header("Package information")

        puts_key_value("Package name", colored.yellow( package.title))
        puts_key_value("Latest version", colored.yellow( package.pypi_version))
        puts_key_value("Repo url", colored.yellow( package.repo_url))
        puts_key_value("PYPI url", colored.yellow( package.pypi_url))
        if package.installed:
            puts_key_value("Installed version", colored.yellow( package.installed_version or "N\A" ))
        puts_key_value("Categories", colored.yellow( ', '.join([category.title for category in package.categories]) ))
        if docs:
            puts_key_value("ReadTheDocs", colored.magenta( docs ))
        # DESCRIPTION

        puts('-'*80, newline=False)
        puts("Description:")
        puts()
        puts(colored.yellow( package.repo_description))
        puts('-'*80)

        # COMMANDS
        puts("Commands:")
        puts()
        if not package.installed:
            puts("[i] install")
        else:
            puts("[o] upgrade install")
            puts("[u] uninstall")
        puts()
        puts("[p] open pypi page")
        if docs:
            puts("[d] open docs page")
        puts("[r] open repository url")
        puts()
        puts("[backspace] return to previous screen")
    def _render_package_list(self, paginator, current_page, info, highlighted_item):
        self._clear_screen()

        puts_header("Listing packages")
        for key,val in info.items():
            if key == 'Category':
                puts_key_value(key, colored.magenta(str(val)))
            else:
                puts_key_value(key, str(val))

        puts(colored.green("-"*80))

        #puts_key_value("Main categories", "[A]ll, [I]nstalled")
        puts_key_value("Order by","Na[m]e, [I]nstalled, [U]sage, [W]atchers")


        packages = paginator.page(current_page)
        starting_index = paginator.pagination*(current_page-1)

        pagination_tpl = "Page " + colored.yellow("%s" %current_page) + " of %s" %paginator.num_pages

        if self.main_view.get('ordering'):
            pagination_tpl += " - Ordering by: " + colored.yellow(self.main_view.get('ordering'))

        puts(colored.green('-'*80), newline=False)
        puts(pagination_tpl)
        puts(colored.green('-'*80))

        for index, package in enumerate(packages):

            with indent(indent=6, quote="%s)" %str(starting_index+index+1)):
                title = colored.green(package.title)

                if index+1 == highlighted_item:
                    title = " * " + title


                if package.installed:
                    if not package.installed_version:
                        # There is no package version! We can't deduce if a new version is really available.
                        title += colored.yellow(" [Installed] ")
                    else:
                        # Package version is there. Everything normal and good!
                        title += colored.yellow(" [Installed %s] " %package.installed_version)
                        if versioner(package.installed_version) < versioner(package.pypi_version):
                            title += colored.red(" [New version %s] " %package.pypi_version)
                puts(title)

            info = {
                "downloads": package.pypi_downloads,
                #"forks": package.repo_forks,
                "watching": package.repo_watchers,
                "using": package.usage_count,
                }
            cols = [[colored.white("%s %s" %(value, key)), 20] for key,value in info.items()]

            with indent(indent=6):
                #puts()
                puts(columns(*cols))

            puts()


        puts(colored.green('-'*80), newline=False)
        puts(pagination_tpl)
        puts(colored.green('-'*80))