From 31fbf0ae13b2faba1df22385862eabb2a4947eb6 Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Wed, 3 Jan 2024 19:25:32 +0000 Subject: Factor out writing the details in the package summary page Contain the details in a table of class 'pkgdetails' for more layout control. --- calm/pkg2html.py | 41 ++++++++++++---------- test/testdata/htdocs.expected/summary/arc-src.html | 17 ++++----- test/testdata/htdocs.expected/summary/arc.html | 17 ++++----- .../htdocs.expected/summary/base-cygwin.html | 17 ++++----- .../htdocs.expected/summary/corrupt-src.html | 15 ++++---- test/testdata/htdocs.expected/summary/corrupt.html | 15 ++++---- .../htdocs.expected/summary/cygwin-debuginfo.html | 19 +++++----- .../htdocs.expected/summary/cygwin-devel.html | 15 ++++---- .../htdocs.expected/summary/cygwin-src.html | 21 ++++++----- test/testdata/htdocs.expected/summary/cygwin.html | 17 ++++----- .../htdocs.expected/summary/keychain-src.html | 17 ++++----- .../testdata/htdocs.expected/summary/keychain.html | 19 +++++----- .../htdocs.expected/summary/libdns_sd-devel.html | 19 +++++----- .../htdocs.expected/summary/libdns_sd1.html | 17 ++++----- .../htdocs.expected/summary/mDNSResponder-src.html | 17 ++++----- .../htdocs.expected/summary/mDNSResponder.html | 19 +++++----- .../htdocs.expected/summary/obs-a-src.html | 15 ++++---- test/testdata/htdocs.expected/summary/obs-a.html | 17 ++++----- .../htdocs.expected/summary/obs-b-src.html | 15 ++++---- test/testdata/htdocs.expected/summary/obs-b.html | 17 ++++----- .../htdocs.expected/summary/openssh-src.html | 17 ++++----- test/testdata/htdocs.expected/summary/openssh.html | 17 ++++----- .../per-version-replacement-hint-only-src.html | 15 ++++---- .../summary/per-version-replacement-hint-only.html | 17 ++++----- .../htdocs.expected/summary/per-version-src.html | 15 ++++---- .../htdocs.expected/summary/per-version.html | 17 ++++----- .../summary/perl-Net-SMTP-SSL-src.html | 17 ++++----- .../htdocs.expected/summary/perl-Net-SMTP-SSL.html | 17 ++++----- .../htdocs.expected/summary/rpm-doc-src.html | 10 +++--- test/testdata/htdocs.expected/summary/rpm-doc.html | 10 +++--- .../htdocs.expected/summary/staleversion-src.html | 15 ++++---- .../htdocs.expected/summary/staleversion.html | 15 ++++---- .../htdocs.expected/summary/test-c-src.html | 15 ++++---- test/testdata/htdocs.expected/summary/test-c.html | 19 +++++----- .../htdocs.expected/summary/test-d-src.html | 15 ++++---- test/testdata/htdocs.expected/summary/test-d.html | 15 ++++---- .../htdocs.expected/summary/test-e-src.html | 17 ++++----- test/testdata/htdocs.expected/summary/test-e.html | 15 ++++---- .../htdocs.expected/summary/testpackage-src.html | 15 ++++---- .../htdocs.expected/summary/testpackage.html | 15 ++++---- 40 files changed, 359 insertions(+), 315 deletions(-) diff --git a/calm/pkg2html.py b/calm/pkg2html.py index 5a3f4ac..2d6930e 100755 --- a/calm/pkg2html.py +++ b/calm/pkg2html.py @@ -205,9 +205,10 @@ def update_package_listings(args, packages):

%s: %s

''' % (title, kind, pn)), file=f) - print('summary: %s

' % sdesc(po, bv), file=f) - print('description: %s

' % ldesc(po, bv), file=f) - print('categories: %s

' % po.version_hints[bv].get('category', ''), file=f) + details_table = {} + details_table['summary'] = sdesc(po, bv) + details_table['description'] = ldesc(po, bv) + details_table['categories'] = po.version_hints[bv].get('category', '') if po.kind == package.Kind.source: details = ['build-depends'] @@ -242,7 +243,7 @@ def update_package_listings(args, packages): else: detail.append(linkify_package(detail_pkg) + ' (%s)' % (','.join([arch for arch in pos if detail_pkg in value[arch]]))) - print('%s: %s

' % (key, ', '.join(detail)), file=f) + details_table[key] = ', '.join(detail) if po.kind == package.Kind.source: es = p @@ -250,19 +251,18 @@ def update_package_listings(args, packages): install_packages = set() for arch in pos: install_packages.update(pos[arch].is_used_by) - print('install package(s): %s

' % ', '.join([linkify_package(p) for p in sorted(install_packages)]), file=f) + details_table['install package(s)'] = ', '.join([linkify_package(p) for p in sorted(install_packages)]) homepage = po.version_hints[po.best_version].get('homepage', None) if homepage: - print('homepage: %s

' % (homepage, homepage), file=f) + details_table['homepage'] = '%s' % (homepage, homepage) + lic = po.version_hints[po.best_version].get('license', None) if lic: - print('license: %s' % (lic), file=f) - print('(SPDX)', file=f) - print('

', file=f) + details_table['license'] = '%s (SPDX)' % (lic) else: es = po.srcpackage(bv) - print('source package: %s

' % linkify_package(es), file=f) + details_table['source package'] = linkify_package(es) es_po = arch_package(packages, es) if not es_po: @@ -281,24 +281,29 @@ def update_package_listings(args, packages): pkg_groups = pkg_maintainers[m_pn].groups() if m: - print('maintainer(s): %s ' % m, file=f) - - print(textwrap.dedent('''\ + details_table['maintainer(s)'] = m + textwrap.dedent(''' (Use the mailing list to report bugs or ask questions. - Do not contact the maintainer(s) directly.)'''), file=f) - print('

', file=f) + Do not contact the maintainer(s) directly.)''') if pkg_groups: - print('group: %s ' % ','.join(pkg_groups), file=f) - print('

', file=f) + details_table['groups'] = ','.join(pkg_groups) if po.kind == package.Kind.source: if args.repodir: repo = os.path.join(args.repodir, '%s.git' % pn) if os.path.exists(repo): repo_browse_url = '/cgit/cygwin-packages/%s/' % pn - print('packaging repository: %s.git' % (repo_browse_url, pn), file=f) + details_table['packaging repository'] = '%s.git' % (repo_browse_url, pn) + + # output details table + print('', file=f) + for d, v in details_table.items(): + if not v.startswith('

'): + v = '

' + v + '

' + print('' % (d, v), file=f) + print('

%s:

%s
', file=f) + # output per-arch package versions table print('