diff options
author | Papoteur <papoteur@mageia.org> | 2024-02-07 23:12:57 +0100 |
---|---|---|
committer | Papoteur <papoteur@mageia.org> | 2024-02-07 23:12:57 +0100 |
commit | 053612db41a9135968b927ee34888299c48e737a (patch) | |
tree | b44e94cb5a88de764358476bcca82737b1bff9a6 | |
parent | d5d06532d0fcfcf20e2ebd3fe239fc95e60475d8 (diff) | |
download | mga-advisor-053612db41a9135968b927ee34888299c48e737a.tar mga-advisor-053612db41a9135968b927ee34888299c48e737a.tar.gz mga-advisor-053612db41a9135968b927ee34888299c48e737a.tar.bz2 mga-advisor-053612db41a9135968b927ee34888299c48e737a.tar.xz mga-advisor-053612db41a9135968b927ee34888299c48e737a.zip |
Add dialog to confirm overwriting the file
-rw-r--r-- | mga-advisor.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/mga-advisor.py b/mga-advisor.py index a8e01c5..8f30f0d 100644 --- a/mga-advisor.py +++ b/mga-advisor.py @@ -136,7 +136,7 @@ class Widget(QWidget): cve = cve.strip() if cve != "": self.ui.list_cve.addItem(cve) - self.ui.list_ref.addItem(f"https://bugs.mageia.org/show_bug.cgi?id={self.ui.bug_le.text()}") + self.ui.list_ref.addItem(os.path.join(BASE_URL, self.ui.bug_le.text()) ) for url in re.split(';|,| ', r.json()['bugs'][0]['url']): url = url.strip() if url != "": @@ -257,9 +257,15 @@ class Widget(QWidget): def export(self): if QDir().mkpath(QDir().homePath() + "/mageia-advisories/advisories"): if self.ui.bug_le.text() != "": - #TODO check that it exists - with open(f"{QDir().homePath()}/mageia-advisories/advisories/{self.ui.bug_le.text()}.adv", 'w') as f: + + filename = f"{QDir().homePath()}/mageia-advisories/advisories/{self.ui.bug_le.text()}.adv" + if os.path.exists(filename): + response = QMessageBox.question(self, 'File exists', f'The file {filename} already exists. Do you want to override it ?', QMessageBox.Yes | QMessageBox.No) + if response == QMessageBox.No: + return + with open(filename, 'w') as f: f.write(self.adv_text()) + QMessageBox.information(self, 'Success', f'The file {filename} has been written!') def cancel(self): self.close() |