Simplify MigrationItem.parse_item by extracting a method

Signed-off-by: Niels Thykier <niels@thykier.net>
ubuntu/rebased
Niels Thykier 6 years ago
parent 542f030a96
commit 04318473f6
No known key found for this signature in database
GPG Key ID: A65B78DBE67C7AAC

@ -109,6 +109,16 @@ class MigrationItemFactory(object):
return True
def _find_suite_for_item(self, suites, suite_name, package_name, version, auto_correct):
suite = suites.by_name_or_alias[suite_name]
assert suite.suite_class != SuiteClass.TARGET_SUITE
if version is not None and auto_correct and not self._is_right_version(suite, package_name, version):
for s in suites.source_suites:
if self._is_right_version(s, package_name, version):
suite = s
break
return suite
def parse_item(self, item_text, versioned=True, auto_correct=True):
"""
@ -163,13 +173,7 @@ class MigrationItemFactory(object):
if is_removal:
suite = suites.target_suite
else:
suite = suites.by_name_or_alias[suite_name]
assert suite.suite_class != SuiteClass.TARGET_SUITE
if version is not None and auto_correct and not self._is_right_version(suite, package_name, version):
for s in suites.source_suites:
if self._is_right_version(s, package_name, version):
suite = s
break
suite = self._find_suite_for_item(suites, suite_name, package_name, version, auto_correct)
uvname = self._canonicalise_uvname(item_text, package_name, architecture, suite, is_removal)

Loading…
Cancel
Save