Coverage for dak/write_sections.py: 52%
19 statements
« prev ^ index » next coverage.py v7.6.0, created at 2026-01-04 16:18 +0000
« prev ^ index » next coverage.py v7.6.0, created at 2026-01-04 16:18 +0000
1#! /usr/bin/env python3
3"""
4Writes out a rfc2822-formatted list of sections and their descriptions.
6@contact: Debian FTP Master <ftpmaster@debian.org>
7@copyright: 2009 Peter Palfrader <peter@palfrader.org>
8@copyright: 2020 Joerg Jaspert <joerg@debian.org>
9@license: GNU General Public License version 2 or later
10"""
12# This program is free software; you can redistribute it and/or modify
13# it under the terms of the GNU General Public License as published by
14# the Free Software Foundation; either version 2 of the License, or
15# (at your option) any later version.
16#
17# This program is distributed in the hope that it will be useful,
18# but WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20# GNU General Public License for more details.
21#
22# You should have received a copy of the GNU General Public License
23# along with this program; if not, write to the Free Software
24# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27################################################################################
29import sys
30from typing import TYPE_CHECKING, NoReturn
32from sqlalchemy import sql
34from daklib.dbconn import DBConn
36if TYPE_CHECKING:
37 from sqlalchemy.orm import Session
39################################################################################
42def write_sections(session: "Session") -> None:
43 query = """
44 SELECT
45 section,
46 description,
47 longdesc
48 FROM section
49 ORDER BY section
50 """
52 for section, description, longdesc in session.execute(sql.text(query)):
53 print("Section: {0}".format(section))
54 print("Description: {0}".format(description))
55 print("Longdesc: {0}".format(longdesc))
56 print()
59################################################################################
62def usage() -> NoReturn:
63 print("usage: dak write-sections")
64 sys.exit(0)
67################################################################################
70def main() -> None:
71 if len(sys.argv) != 1: 71 ↛ 74line 71 didn't jump to line 74 because the condition on line 71 was always true
72 usage()
74 session = DBConn().session()
75 write_sections(session)
78#########################################################################################
81if __name__ == "__main__":
82 main()