diff --git a/airgun/__init__.py b/airgun/__init__.py index 16f9520e9..8ed326105 100644 --- a/airgun/__init__.py +++ b/airgun/__init__.py @@ -1,3 +1,7 @@ +import re + from airgun.settings import Settings settings = Settings() + +ERRATA_REGEXP = re.compile(r'\w{3,4}[:-]\d{4}[-:]\d{1,4}') diff --git a/airgun/entities/errata.py b/airgun/entities/errata.py index 7904b77dd..c065c94f3 100644 --- a/airgun/entities/errata.py +++ b/airgun/entities/errata.py @@ -1,5 +1,4 @@ -import re - +from airgun import ERRATA_REGEXP from airgun.entities.base import BaseEntity from airgun.navigation import NavigateStep, navigator from airgun.utils import retry_navigation @@ -137,6 +136,6 @@ def step(self, *args, **kwargs): repo = kwargs.get('repo') self.parent.search(entity_name, applicable=applicable, installable=installable, repo=repo) row_filter = {'title': entity_name} - if re.search(r'\w{3,4}[:-]\d{4}[-:]\d{4}', entity_name): + if ERRATA_REGEXP.search(entity_name): row_filter = {'errata_id': entity_name} self.parent.table.row(**row_filter)['Errata ID'].widget.click() diff --git a/airgun/views/errata.py b/airgun/views/errata.py index f8c25607d..eed66a8e0 100644 --- a/airgun/views/errata.py +++ b/airgun/views/errata.py @@ -1,8 +1,7 @@ -import re - from widgetastic.widget import Checkbox, Text, View from widgetastic_patternfly import BreadCrumb +from airgun import ERRATA_REGEXP from airgun.views.common import BaseLoggedInView, SatTab, TaskDetailsView from airgun.widgets import ItemsList, ReadOnlyEntry, SatSelect, SatTable, Search @@ -40,7 +39,7 @@ def search(self, query, applicable=True, installable=False, repo=None): if repo is not None: self.repo_filter.fill(repo) - if re.search(r'\w{3,4}[:-]\d{4}[-:]\d{4}', query): + if ERRATA_REGEXP.search(query): query = f'id = {query}' self.searchbox.search(query)