diff options
| author | Christian Krinitsin <mail@krinitsin.com> | 2025-05-25 19:34:53 +0200 |
|---|---|---|
| committer | Christian Krinitsin <mail@krinitsin.com> | 2025-05-25 19:34:53 +0200 |
| commit | 6373e8d12fef4e235390f2014dca853d6bc6268c (patch) | |
| tree | c47a7ec807ea074558c97ba648c8bf23b24abe99 /gitlab/description_parser.py | |
| parent | cc84a7857c120d4c1c1b150e7fb8676d30fb5957 (diff) | |
| download | qemu-analysis-6373e8d12fef4e235390f2014dca853d6bc6268c.tar.gz qemu-analysis-6373e8d12fef4e235390f2014dca853d6bc6268c.zip | |
refactor gitlab script
Diffstat (limited to 'gitlab/description_parser.py')
| -rwxr-xr-x | gitlab/description_parser.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/gitlab/description_parser.py b/gitlab/description_parser.py index 2615b6368..36b450bd4 100755 --- a/gitlab/description_parser.py +++ b/gitlab/description_parser.py @@ -1,29 +1,29 @@ -import re +from re import sub, search, DOTALL from tomlkit import string -def remove_comments(description): - return re.sub(r'<!--(.|\n)*?-->', '', description) +def remove_comments(description : str) -> str: + return sub(r'<!--(.|\n)*?-->', '', description) -def get_headline_content(description, headline): +def get_headline_content(description : str, headline : str) -> str: pattern = rf'## {headline}\s+(.*?)(?=##\s|\Z)' - match = re.search(pattern, description, re.DOTALL) + match = search(pattern, description, DOTALL) if match: - return string(match.group(1).strip(), multiline=True) + return string(match.group(1).strip(), multiline = True) else: return "n/a" -def get_bullet_point(description, headline, category): +def get_bullet_point(description : str, headline : str, category : str) -> str: pattern = rf'{headline}(?:(?:.|\n)+?){category}:\s+(?:`)?(.+?)(?:`)?(?=\s)(?:\n|$)' - match = re.search(pattern, description) + match = search(pattern, description) if match: return match.group(1).strip() else: return "n/a" -def parse_description(desc): - desc = remove_comments(desc) +def parse_description(description : str) -> dict: + desc = remove_comments(description) result = { "host-os": get_bullet_point(desc, "Host", "Operating system"), |