diff options
author | Papoteur <papoteur@mageia.org> | 2023-11-29 19:35:27 +0100 |
---|---|---|
committer | Papoteur <papoteur@mageia.org> | 2023-11-29 19:35:27 +0100 |
commit | 88278e3ece78f7e208caf1887660160933d0800e (patch) | |
tree | 55a90b6cc798accbdc23e502a26bb72377eae911 | |
parent | 7b238b69ed630759d867fca8fc43faca4617a3a8 (diff) | |
download | mga-advisor-88278e3ece78f7e208caf1887660160933d0800e.tar mga-advisor-88278e3ece78f7e208caf1887660160933d0800e.tar.gz mga-advisor-88278e3ece78f7e208caf1887660160933d0800e.tar.bz2 mga-advisor-88278e3ece78f7e208caf1887660160933d0800e.tar.xz mga-advisor-88278e3ece78f7e208caf1887660160933d0800e.zip |
Export the description starting on a newline
-rw-r--r-- | mga-advisor.py | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/mga-advisor.py b/mga-advisor.py index f804a57..2e650c7 100644 --- a/mga-advisor.py +++ b/mga-advisor.py @@ -6,6 +6,7 @@ import yaml import re from subprocess import run import requests +from textwrap import wrap from PySide6.QtWidgets import ( QApplication, @@ -24,6 +25,9 @@ from PySide6.QtCore import QFile, QDate, QDir, Qt, QTimer from PySide6.QtUiTools import QUiLoader BASE_URL = "https://bugs.mageia.org/rest/bug/" +class folded_str(str): pass + +class literal_str(str): pass class LineDialog(QDialog): def __init__(self, title, init="", parent=None): @@ -168,6 +172,19 @@ class Widget(QWidget): self.ui.list_cve.takeItem(self.ui.list_cve.currentRow()) def adv_text(self): + def change_style(style, representer): + def new_representer(dumper, data): + scalar = representer(dumper, data) + scalar.style = style + return scalar + return new_representer + from yaml.representer import SafeRepresenter + represent_folded_str = change_style('>', SafeRepresenter.represent_str) + represent_literal_str = change_style('|', SafeRepresenter.represent_str) + yaml.add_representer(folded_str, represent_folded_str) + yaml.add_representer(literal_str, represent_literal_str) + + data = dict() if self.ui.bugfix_rb.isEnabled(): data['type'] = 'bugfix' @@ -194,13 +211,14 @@ class Widget(QWidget): srcs[rel][repo].append(self.sanitize_line(name)) data['src'] = srcs if len(self.ui.description_te.toPlainText()) != 0: - data['description'] = self.ui.description_te.toPlainText() + lines_desc = wrap(self.ui.description_te.toPlainText(), width=72, break_on_hyphens=False) + data['description'] = literal_str("\n".join(lines_desc)) refs = [] if self.ui.list_ref.count(): for n in range(0, self.ui.list_ref.count()): refs.append(self.ui.list_ref.item(n).text()) data['references'] = refs - return yaml.dump(data, default_flow_style=False, sort_keys=False, width=75) + return yaml.dump(data, default_flow_style=False, sort_keys=False, width=75, allow_unicode=True) def export(self): if QDir().mkpath(QDir().homePath() + "/mageia-advisories/advisories"): |