in src/core/src/package_managers/YumPackageManager.py [0:0]
def extract_packages_and_versions_including_duplicates(self, output):
"""Returns packages and versions from given output"""
self.composite_logger.log_verbose("[YPM] Extracting package and version data...")
packages = []
versions = []
package_extensions = Constants.SUPPORTED_PACKAGE_ARCH
def is_package(chunk):
# Using a list comprehension to determine if chunk is a package
return len([p for p in package_extensions if p in chunk]) == 1
lines = output.strip().split('\n')
for line_index in range(0, len(lines)):
# Do not install Obsoleting Packages. The obsoleting packages list comes towards end in the output.
if lines[line_index].strip().startswith("Obsoleting Packages"):
break
line = re.split(r'\s+', lines[line_index].strip())
next_line = []
if line_index < len(lines) - 1:
next_line = re.split(r'\s+', lines[line_index + 1].strip())
# If we run into a length of 3, we'll accept it and continue
if len(line) == 3 and is_package(line[0]):
packages.append(self.get_product_name(line[0]))
versions.append(line[1])
# We will handle these two edge cases where the output is on
# two different lines and treat them as one line
elif len(line) == 1 and len(next_line) == 2 and is_package(line[0]):
packages.append(self.get_product_name(line[0]))
versions.append(next_line[0])
line_index += 1
elif len(line) == 2 and len(next_line) == 1 and is_package(line[0]):
packages.append(self.get_product_name(line[0]))
versions.append(line[1])
line_index += 1
else:
self.composite_logger.log_verbose("[YPM] > Inapplicable line (" + str(line_index) + "): " + lines[line_index])
return packages, versions