3
3
import argparse
4
4
import os
5
5
from datetime import datetime
6
+ from textwrap import dedent
6
7
7
8
import koji
8
9
import requests
9
10
11
+
10
12
def 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 )
22
24
23
25
def print_footer (out , generated_info ):
24
26
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 )
30
32
31
33
def 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
54
56
55
57
def 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 )
62
64
63
65
def 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
+ ])
65
74
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
80
89
81
90
parser = argparse .ArgumentParser (description = 'Generate a report of the packages in the pipe' )
82
91
parser .add_argument ('output' , nargs = '?' , help = 'Report output path' , default = 'report.html' )
@@ -90,8 +99,10 @@ def print_table_line(out, build, link, issues, by):
90
99
session .ssl_login (config ['cert' ], None , config ['serverca' ])
91
100
92
101
# 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
+ )
95
106
project_issues = resp .json ()
96
107
97
108
with open (args .output , 'w' ) as out :
0 commit comments