예제 #1
0
    def _render_main_menu(self):
        self._clear_screen()
        #puts_header("Django Package Manager")

        ascii_art = """\
 ___     _   ___         _
|   \ _ | | | _ \__ _ __| |____ _ __ _ ___
| |) | || | |  _/ _` / _| / / _` / _` / -_)
|___/ \__/  |_| \__,_\__|_\_\__,_\__, \___|
                                 |___/
 __  __
|  \/  |__ _ _ _  __ _ __ _ ___ _ _
| |\/| / _` | ' \/ _` / _` / -_) '_|
|_|  |_\__,_|_||_\__,_\__, \___|_|
                      |___/         """

        with indent(indent=4):
            puts(colored.green(ascii_art))

        puts(colored.green("=" * 80), newline=False)
        puts("    Main menu")
        puts(colored.green("=" * 80))

        for index, option in enumerate(self.menu_view['options'].keys()):
            quote = ""
            if self.menu_view['highlighted_item'] == index + 1:
                quote = "  * "
            with indent(indent=4, quote=quote):
                puts(option)
            puts()

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

        with indent(indent=4):
            puts("https://github.com/jamespacileo/django-package-manager")
예제 #2
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_main_menu(self):
        self._clear_screen()
        #puts_header("Django Package Manager")

        ascii_art = """\
 ___     _   ___         _
|   \ _ | | | _ \__ _ __| |____ _ __ _ ___
| |) | || | |  _/ _` / _| / / _` / _` / -_)
|___/ \__/  |_| \__,_\__|_\_\__,_\__, \___|
                                 |___/
 __  __
|  \/  |__ _ _ _  __ _ __ _ ___ _ _
| |\/| / _` | ' \/ _` / _` / -_) '_|
|_|  |_\__,_|_||_\__,_\__, \___|_|
                      |___/         """

        with indent(indent=4):
            puts(colored.green(ascii_art))

        puts(colored.green("="*80), newline=False)
        puts("    Main menu")
        puts(colored.green("="*80))


        for index, option in enumerate(self.menu_view['options'].keys()):
            quote = ""
            if self.menu_view['highlighted_item'] == index+1:
                quote = "  * "
            with indent(indent=4, quote=quote):
                puts(option)
            puts()

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

        with indent(indent=4):
            puts("https://github.com/jamespacileo/django-package-manager")
def main():
    with clint_core.indent(4):
        print('\n')
        title = (' ' * 24) + ('<' * 3) + (' CLI CALCULATOR ') + ('>' * 3)
        clint_ui.puts(clint_ui.colored.cyan(title))
        print('\n\n')
        line_no = 0
        global calculation_history
        calculation_history = []
        while True:
            line_no += 1
            try:
                formula = input('<' + str(line_no) + '> ')
                if formula == '..' or formula.lower() == 'exit':
                    break

                if (formula.lower() == 'help') or (formula == '?'):
                    #use input() to stall the program while displaying help
                    input(const.HELP_TEXT)
                    line_data = {
                        'line': line_no,
                        'operation': 'help',
                        'operation_result': calc,
                        'err': False
                    }
                    calculation_history.append(line_data)
                else:
                    calc = evaluate(formula)
                    clint_ui.puts(clint_ui.colored.yellow('= ' + str(calc)))
                    line_data = {
                        'line': line_no,
                        'operation': 'calc',
                        'operation_result': calc,
                        'err': False
                    }
                    calculation_history.append(line_data)
            except Exception as err:
                line_data = {
                    'line': line_no,
                    'operation': 'calc',
                    'operation_result': 0,
                    'err': True
                }
                calculation_history.append(line_data)
                clint_core.puts_err(
                    clint_ui.colored.red('Error: {}'.format(err)))
    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))
예제 #6
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_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))