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

1#! /usr/bin/env python3 

2 

3""" 

4Writes out a rfc2822-formatted list of sections and their descriptions. 

5 

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""" 

11 

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 

25 

26 

27################################################################################ 

28 

29import sys 

30from typing import TYPE_CHECKING, NoReturn 

31 

32from sqlalchemy import sql 

33 

34from daklib.dbconn import DBConn 

35 

36if TYPE_CHECKING: 

37 from sqlalchemy.orm import Session 

38 

39################################################################################ 

40 

41 

42def write_sections(session: "Session") -> None: 

43 query = """ 

44 SELECT 

45 section, 

46 description, 

47 longdesc 

48 FROM section 

49 ORDER BY section 

50 """ 

51 

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() 

57 

58 

59################################################################################ 

60 

61 

62def usage() -> NoReturn: 

63 print("usage: dak write-sections") 

64 sys.exit(0) 

65 

66 

67################################################################################ 

68 

69 

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() 

73 

74 session = DBConn().session() 

75 write_sections(session) 

76 

77 

78######################################################################################### 

79 

80 

81if __name__ == "__main__": 

82 main()