From 3cfed58227cc570a1670f5777143b1670d7653cc Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Wed, 31 Mar 2021 11:09:21 +0200 Subject: [PATCH] Move URL regexes to class scope. Refer to URL regexes by 'self' argument. Signed-off-by: Mateusz Starzyk --- scripts/assemble_changelog.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/assemble_changelog.py b/scripts/assemble_changelog.py index 0428dddb3..a7477aa8e 100755 --- a/scripts/assemble_changelog.py +++ b/scripts/assemble_changelog.py @@ -201,6 +201,8 @@ class ChangeLog: # a version that is not yet released. Something like "3.1a" is accepted. _version_number_re = re.compile(br'[0-9]+\.[0-9A-Za-z.]+') _incomplete_version_number_re = re.compile(br'.*\.[A-Za-z]') + _only_url_re = re.compile(br'^\s*\w+://\S+\s*$') + _has_url_re = re.compile(br'.*://.*') def add_categories_from_text(self, filename, line_offset, text, allow_unknown_category): @@ -219,13 +221,12 @@ class ChangeLog: category.name.decode('utf8')) body_split = category.body.splitlines() - _only_url_re = re.compile(br'^\s*\w+://\S+\s*$') - _has_url_re = re.compile(br'.*://.*') + for line_number, line in enumerate(body_split, 1): - if not _only_url_re.match(line) and \ + if not self._only_url_re.match(line) and \ len(line) > MAX_LINE_LENGTH: long_url_msg = '. URL exceeding length limit must be ' \ - 'alone in it\'s line.' if _has_url_re.match(line) \ + 'alone in it\'s line.' if self._has_url_re.match(line) \ else "" raise InputFormatError(filename, category.body_line + line_number,