33import argparse
44import os
55from datetime import datetime
6+ from textwrap import dedent
67
78import koji
89import requests
910
11+
1012def print_header (out ):
11- print ('''
12- <!DOCTYPE html>
13- <html lang="en">
14- <head>
15- <meta charset="UTF-8">
16- <meta name="viewport" content="width=device-width, initial-scale=1.0">
17- <title>XCP-ng Package Update</title>
18- <script src="https://cdn.tailwindcss.com"></script>
19- </head>
20- <body class="bg-gray-400 text-center">
21- ''' , file = out )
13+ print (dedent ( '''
14+ <!DOCTYPE html>
15+ <html lang="en">
16+ <head>
17+ <meta charset="UTF-8">
18+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
19+ <title>XCP-ng Package Update</title>
20+ <script src="https://cdn.tailwindcss.com"></script>
21+ </head>
22+ <body class="bg-gray-400 text-center">
23+ ''') , file = out )
2224
2325def print_footer (out , generated_info ):
2426 now = datetime .now ()
25- print (f'''
26- Last generated at { now } . { generated_info or '' }
27- </body>
28- </html>
29- ''' , file = out )
27+ print (dedent ( f'''
28+ Last generated at { now } . { generated_info or '' }
29+ </body>
30+ </html>
31+ ''') , file = out )
3032
3133def print_table_header (out , tag ):
32- print (f'''
33- <div class="px-3 py-3">
34- <div class="relative overflow-x-auto shadow-md sm:rounded-lg">
35- <table class="table-fixed w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400">
36- <caption class="p-5 text-lg font-semibold text-left rtl:text-right text-gray-900 bg-white dark:text-white dark:bg-gray-800">
37- { tag }
38- </caption>
39- <thead class="text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400">
40- <tr>
41- <th scope="col" class="px-6 py-3">
42- Build
43- </th>
44- <th scope="col" class="px-6 py-3">
45- Cards
46- </th>
47- <th scope="col" class="px-6 py-3">
48- By
49- </th>
50- </tr>
51- </thead>
52- <tbody>
53- ''' , file = out )
34+ print (dedent ( f'''
35+ <div class="px-3 py-3">
36+ <div class="relative overflow-x-auto shadow-md sm:rounded-lg">
37+ <table class="table-fixed w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400">
38+ <caption class="p-5 text-lg font-semibold text-left rtl:text-right text-gray-900 bg-white dark:text-white dark:bg-gray-800">
39+ { tag }
40+ </caption>
41+ <thead class="text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400">
42+ <tr>
43+ <th scope="col" class="px-6 py-3">
44+ Build
45+ </th>
46+ <th scope="col" class="px-6 py-3">
47+ Cards
48+ </th>
49+ <th scope="col" class="px-6 py-3">
50+ By
51+ </th>
52+ </tr>
53+ </thead>
54+ <tbody>
55+ ''') , file = out ) # nopep8
5456
5557def print_table_footer (out ):
56- print ('''
57- </tbody>
58- </table>
59- </div>
60- </div>
61- ''' , file = out )
58+ print (dedent ( '''
59+ </tbody>
60+ </table>
61+ </div>
62+ </div>
63+ ''') , file = out )
6264
6365def print_table_line (out , build , link , issues , by ):
64- issues_content = '\n ' .join ([f'<li><a class="font-medium text-blue-600 dark:text-blue-500 hover:underline" href="https://project.vates.tech/vates-global/browse/XCPNG-{ i ['sequence_id' ]} /">XCPNG-{ i ['sequence_id' ]} </a></li>' for i in issues ])
66+ issues_content = '\n ' .join ([
67+ f'''<li>
68+ <a class="font-medium text-blue-600 dark:text-blue-500 hover:underline"
69+ href="https://project.vates.tech/vates-global/browse/XCPNG-{ i ['sequence_id' ]} /">XCPNG-{ i ['sequence_id' ]}
70+ </a>
71+ </li>'''
72+ for i in issues
73+ ])
6574 print (f'''
66- <tr class="odd:bg-white odd:dark:bg-gray-900 even:bg-gray-50 even:dark:bg-gray-800 border-b dark:border-gray-700 border-gray-200">
67- <th scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
68- <a class="font-medium text-blue-600 dark:text-blue-500 hover:underline" href="{ link } ">{ build } </a>
69- </th>
70- <td class="px-6 py-4">
71- <ul>
72- { issues_content }
73- </ul>
74- </td>
75- <td class="px-6 py-4">
76- { by }
77- </td>
78- </tr>
79- ''' , file = out )
75+ <tr class="odd:bg-white odd:dark:bg-gray-900 even:bg-gray-50 even:dark:bg-gray-800 border-b dark:border-gray-700 border-gray-200">
76+ <th scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
77+ <a class="font-medium text-blue-600 dark:text-blue-500 hover:underline" href="{ link } ">{ build } </a>
78+ </th>
79+ <td class="px-6 py-4">
80+ <ul>
81+ { issues_content }
82+ </ul>
83+ </td>
84+ <td class="px-6 py-4">
85+ { by }
86+ </td>
87+ </tr>
88+ ''' , file = out ) # nopep8
8089
8190parser = argparse .ArgumentParser (description = 'Generate a report of the packages in the pipe' )
8291parser .add_argument ('output' , nargs = '?' , help = 'Report output path' , default = 'report.html' )
@@ -90,8 +99,10 @@ def print_table_line(out, build, link, issues, by):
9099session .ssl_login (config ['cert' ], None , config ['serverca' ])
91100
92101# load the issues from plane, so we can search for the plane card related to a build
93- resp = requests .get ('https://project.vates.tech/api/v1/workspaces/vates-global/projects/43438eec-1335-4fc2-8804-5a4c32f4932d/issues/' ,
94- headers = {'x-api-key' : args .plane_token })
102+ resp = requests .get (
103+ 'https://project.vates.tech/api/v1/workspaces/vates-global/projects/43438eec-1335-4fc2-8804-5a4c32f4932d/issues/' ,
104+ headers = {'x-api-key' : args .plane_token },
105+ )
95106project_issues = resp .json ()
96107
97108with open (args .output , 'w' ) as out :
0 commit comments