def data_generator(pkgname, repos): binpkgs = Binpkgs() source = datasource.factory() fields_dic = defaultdict(list) other_archs = False for row in source.read(pkgname=pkgname): if row.arch not in repos: other_archs = True continue pkg = make_pkg(row) binpkgs.add(pkg['verrev'], iset=pkg['iset'], libc=pkg['libc']) fields_dic_append(fields_dic, pkg) if not binpkgs: return FoundPackages(None, other_archs) fields = combine_fields(fields_dic, binpkgs) separated = separate_fields(fields, SEPARATED_FIELDS) upstreamver = new_versions(binpkgs, separated['upstreamver'].value) subpkgs = source.same_template(pkgname) return FoundPackages( { 'pkgname': pkgname, 'short_desc': separated['short_desc'], 'fields': fields, 'versions': binpkgs, 'mainpkg': { 'pkgname': separated['mainpkgname'] }, 'subpkgs': list(subpkgs), 'upstreamver': upstreamver, }, other_archs)
def longest_names(): source = datasource.factory() packages = source.longest_names(100) parameters = { 'title': 'Packages with longest names', 'packages': packages, } return present.render_template('list.html', **parameters)
def of_day(): source = datasource.factory() packages = source.of_day(datetime.datetime.now().date()) parameters = { 'title': 'Packages of the day', 'packages': packages, 'bullets': True, } return present.render_template('list.html', **parameters)
def newest(): source = datasource.factory() packages = source.newest(70) parameters = { 'title': 'Newest packages', 'subtitle': f'by {_ago(source)}', 'packages': packages, } return present.render_template('list.html', **parameters)
def popular(): source = datasource.factory() packages = source.popular(70) parameters = { 'title': 'Most popular packages', 'subtitle': 'as reported by volunteers running PopCorn', 'packages': packages, 'with_devel_and_so': True, } return present.render_template('list.html', **parameters)
def metapackages(): source = datasource.factory() packages = [Collection(i) for i in source.metapackages()] parameters = { 'title': 'Package sets', 'bullets': True, 'packages': packages, 'with_devel_and_so': True, 'has_featured': any([i.featured for i in packages]), } return present.render_template('list.html', **parameters)
def list_all(): source = datasource.factory() packages = source.list_all() parameters = { 'packages': ({ 'pkgname': i.pkgname, 'short_desc': (datasource.from_json(i.repodata).get('short_desc') or datasource.from_json(i.templatedata).get('short_desc')) } for i in packages), } return present.render_template('all.html', **parameters)
def main_page(): source = datasource.factory() lists = [ { 'title': 'Newest', 'more': 'More newest', 'address': 'newest', 'packages': source.newest(20) }, { 'title': 'Popular', 'more': 'More popular', 'address': 'popular', 'packages': source.popular(20) }, { 'title': 'Of day', 'bullets': True, 'address': 'of_day', 'packages': source.of_day(datetime.datetime.now().date()), }, { 'title': 'Sets', 'more': 'More sets', 'bullets': True, 'address': 'sets', 'packages': [ i['pkgname'] for i in source.metapackages([ Interest.INTERESTING, Interest.NOVEL, ]) ] }, ] parameters = { 'title': 'Packages', 'updated': _update_time(source), 'lists': lists, } return present.render_template('main.html', **parameters)
#!/usr/bin/env python3 # pkgs.void - web catalog of Void Linux packages. # Copyright (C) 2020 Piotr Wójcik <*****@*****.**> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. import sys sys.path.append('.') import datasource # noqa, pylint: disable=wrong-import-position from custom_types import Interest # noqa, pylint: disable=wrong-import-position SOURCE = datasource.factory() COLLECTIONS = SOURCE.metapackages() for i in COLLECTIONS: if Interest(i['classification']) == Interest.NOVEL: print(i['pkgname'])