Skip to content

Commit

Permalink
chore: run tox -e fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
james-garner-canonical committed Nov 20, 2024
1 parent f66e79f commit 47128aa
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions lib/charms/operator_libs_linux/v0/apt.py
Original file line number Diff line number Diff line change
Expand Up @@ -1382,7 +1382,9 @@ def _iter_paragraphs(lines: Iterable[str]) -> Iterator[Tuple[int, List[str]]]:

@staticmethod
def _parse_deb822_paragraph(
lines: List[str], filename: str, line_number: int,
lines: List[str],
filename: str,
line_number: int,
) -> Iterator[DebianRepository]:
"""Parse a list of lines forming a deb822 style repository definition.
Expand All @@ -1397,19 +1399,19 @@ def _parse_deb822_paragraph(
parts: Dict[str, List[str]] = {}
current = None
for line in lines:
if line.startswith(' '):
if line.startswith(" "):
assert current is not None
parts[current].append(line)
continue
assert not line.startswith('#')
raw_key, _, raw_value = line.partition(':')
assert not line.startswith("#")
raw_key, _, raw_value = line.partition(":")
parts[raw_key.strip()] = [raw_value.lstrip()]
options = {k: '\n'.join(v) for k, v in parts.items()}
options = {k: "\n".join(v) for k, v in parts.items()}

enabled_field = options.pop('Enabled', 'yes')
if enabled_field == 'yes':
enabled_field = options.pop("Enabled", "yes")
if enabled_field == "yes":
enabled = True
elif enabled_field == 'no':
elif enabled_field == "no":
enabled = False
else:
raise InvalidSourceError(
Expand All @@ -1419,13 +1421,13 @@ def _parse_deb822_paragraph(
)

gpg_key = options.pop("Signed-By", "")
repotypes = options.pop('Types').split()
uris = options.pop('URIs').split()
suites = options.pop('Suites').split()
repotypes = options.pop("Types").split()
uris = options.pop("URIs").split()
suites = options.pop("Suites").split()

components: List[str]
if len(suites) == 1 and suites[0].endswith("/"):
if 'Components' in options:
if "Components" in options:
raise InvalidSourceError(
(
"For paragraph starting on line %s in %s,"
Expand All @@ -1437,7 +1439,7 @@ def _parse_deb822_paragraph(
)
components = []
else:
if 'Components' not in options:
if "Components" not in options:
raise InvalidSourceError(
(
"For paragraph starting on line %s in %s,"
Expand All @@ -1447,7 +1449,7 @@ def _parse_deb822_paragraph(
line_number,
filename,
)
components = options.pop('Components').split()
components = options.pop("Components").split()

for repotype, uri, suite in itertools.product(repotypes, uris, suites):
yield DebianRepository(
Expand Down

0 comments on commit 47128aa

Please sign in to comment.