Skip to content

Commit

Permalink
system packages to use common splitter
Browse files Browse the repository at this point in the history
  • Loading branch information
shatakshiiii committed Jun 22, 2023
1 parent 50bebe2 commit 69b0278
Showing 1 changed file with 15 additions and 22 deletions.
37 changes: 15 additions & 22 deletions src/ansible_navigator/data/image_introspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,19 @@ def splitter(self, lines, line_split, section_delim=None):
result[current_key] = value
continue
current_key = key.lower().replace("_", "-").strip()
if current_key == "description":
description = []
while lines:
line = lines.pop(0)
if line == section_delim:
break
description.append(line)
if description:
result[current_key] = " ".join(description)
else:
result[current_key] = "No description available"
results.append(result)
return result
value = content
result[current_key] = value

Expand Down Expand Up @@ -370,28 +383,8 @@ def parse(self, command):

parsed = []
for package in packages:
entry = {}
while package:
line = package.pop(0)
left, _delim, right = self.re_partition(line, ":")
key = left.lower().replace("_", "-").strip()

# Description is at the end of the package section
# read until package is empty
if key == "description":
description = []
while package:
description.append(package.pop(0))
# Normalize the data, in the case description is totally empty
if description:
entry[key] = "\n".join(description)
else:
entry[key] = "No description available"
parsed.append(entry)
# other package details are 1 line each
else:
value = self._strip(right)
entry[key] = value
result = self.splitter(package, line_split=":", section_delim="---")
parsed.append(result)

command.details = parsed

Expand Down

0 comments on commit 69b0278

Please sign in to comment.