コード例 #1
0
def puts_package_list(paginator, current_page, highlighted_item):



    packages = 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, package in enumerate(packages):
        #if package.check_installed:
        #    puts('* ' + colored.green(package.title) + ' [Installed] ' + colored.yellow(package.pypi_package_name) + ' ' + colored.yellow(package.repo_name))
        #else:
        #    puts('* ' + colored.green(package.title) + ' ' + colored.yellow(package.pypi_package_name) + ' ' + colored.yellow(package.repo_name))

        #STREAM.write(package.title+"\r\n")

        #STREAM.write("\r")

        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 = {
            "using": package.usage_count,
            "PYPI dl": package.pypi_downloads,
            #"forks": package.repo_forks,
            "watching": package.repo_watchers,
        }
        cols = [["%s: %s" %(key, value), 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))
コード例 #2
0
ファイル: models.py プロジェクト: jefftriplett/opencomparison
 def pypi_version(self):
     string_ver_list = self.version_set.values_list('number', flat=True)
     if string_ver_list:
         vers_list = [versioner(v) for v in string_ver_list]
         latest = sorted(vers_list)[-1]
         return str(latest)
     return ''
コード例 #3
0
ファイル: models.py プロジェクト: encorehu/opencomparison
 def pypi_version(self):
     string_ver_list = self.version_set.values_list('number', flat=True)
     if string_ver_list:
         vers_list = [versioner(v) for v in string_ver_list]
         latest = sorted(vers_list)[-1]
         return str(latest)
     return ''
コード例 #4
0
ファイル: utils.py プロジェクト: mshamber/opencomparison
def get_pypi_version(package):
    string_ver_list = package.version_set.values_list('number', flat=True)
    if string_ver_list:
        vers_list = [versioner(v) for v in string_ver_list]
        latest = sorted(vers_list)[-1]
        return str(latest)
    return ''
コード例 #5
0
def get_pypi_version(package):
    string_ver_list = package.version_set.values_list('number', flat=True)
    if string_ver_list:
        vers_list = [versioner(v) for v in string_ver_list]
        latest = sorted(vers_list)[-1]
        return str(latest)
    return ''
コード例 #6
0
ファイル: models.py プロジェクト: zinovi/steemprojects.com
 def generate_valid_versions(qs):
     for item in qs:
         v = versioner(item.number)
         comparable = True
         for elem in v.version:
             if isinstance(elem, str):
                 comparable = False
         if comparable:
             yield item
コード例 #7
0
ファイル: utils.py プロジェクト: perduta/steemprojects.com
def get_pypi_version(package):
    versions = []
    for v_str in package.version_set.values_list('number', flat=True):
        v = versioner(v_str)
        comparable = True
        for elem in v.version:
            if isinstance(elem, str):
                comparable = False
        if comparable:
            versions.append(v)
    if versions:
        return str(sorted(versions)[-1])
    return ''
コード例 #8
0
    def by_version(self, visible=False, *args, **kwargs):
        qs = self.get_queryset().filter(*args, **kwargs)

        if visible:
            qs = qs.filter(hidden=False)

        def generate_valid_versions(qs):
            for item in qs:
                v = versioner(item.number)
                comparable = True
                for elem in v.version:
                    if isinstance(elem, str):
                        comparable = False
                if comparable:
                    yield item

        return sorted(list(generate_valid_versions(qs)), key=lambda v: versioner(v.number))
コード例 #9
0
ファイル: models.py プロジェクト: jefftriplett/opencomparison
 def by_version_not_hidden(self, *args, **kwargs):
     qs = self.get_query_set().filter(*args, **kwargs)
     qs = qs.filter(hidden=False)
     return sorted(qs, key=lambda v: versioner(v.number))
コード例 #10
0
ファイル: models.py プロジェクト: jefftriplett/opencomparison
 def by_version(self, *args, **kwargs):
     qs = self.get_query_set().filter(*args, **kwargs)
     return sorted(qs, key=lambda v: versioner(v.number))
コード例 #11
0
ファイル: models.py プロジェクト: encorehu/opencomparison
 def by_version_not_hidden(self, *args, **kwargs):
     qs = self.get_query_set().filter(*args, **kwargs)
     qs = qs.filter(hidden=False)
     return sorted(qs, key=lambda v: versioner(v.number))
コード例 #12
0
ファイル: models.py プロジェクト: encorehu/opencomparison
 def by_version(self, *args, **kwargs):
     qs = self.get_query_set().filter(*args, **kwargs)
     return sorted(qs, key=lambda v: versioner(v.number))
コード例 #13
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))
コード例 #14
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))