data_renewal_request.py (1913B)
1 #!/usr/bin/env python3 2 # This Source Code Form is subject to the terms of the Mozilla Public 3 # License, v. 2.0. If a copy of the MPL was not distributed with this 4 # file, You can obtain one at https://mozilla.org/MPL/2.0/. 5 6 """ 7 A script to help generate a data review request comment. Once the CSV has been filled by product, 8 copy the filled version into the tools directory and run this script from there to generate a filled 9 renewal request data review comment. 10 """ 11 12 import csv 13 import sys 14 15 try: 16 version = sys.argv[1] 17 except Exception: 18 print("usage is to include arguments of the form <version>") 19 sys.exit() 20 21 expiry_filename = version + "_expiry_list.csv" 22 filled_renewal_filename = version + "_filled_renewal_request.txt" 23 24 csv_reader = csv.DictReader(open(expiry_filename)) 25 output_string = "" 26 total_count = 0 27 updated_version = int(version) + 13 28 for row in csv_reader: 29 if row["keep(Y/N)"] == "n": 30 continue 31 total_count += 1 32 output_string += f"` {row['name']}`\n" 33 output_string += "1) Provide a link to the initial Data Collection Review Request for this collection.\n" 34 output_string += f" - {eval(row['data_reviews'])[0]}\n" 35 output_string += "\n" 36 output_string += "2) When will this collection now expire?\n" 37 if len(row["new expiry version"]) == 0: 38 output_string += f" - {updated_version}\n" 39 else: 40 output_string += f" - {row['new expiry version']}\n" 41 42 output_string += "\n" 43 output_string += "3) Why was the initial period of collection insufficient?\n" 44 output_string += f" - {row['reason to extend']}\n" 45 output_string += "\n" 46 output_string += "———\n" 47 48 header = "# Request for Data Collection Renewal\n" 49 header += "### Renew for 1 year\n" 50 header += f"Total: {total_count}\n" 51 header += "———\n\n" 52 53 with open(filled_renewal_filename, "w+") as out: 54 out.write(header + output_string) 55 out.close()