Skip to content

Commit

Permalink
fix: remove excessive debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
james-garner-canonical committed Nov 20, 2024
1 parent 9f96ca4 commit 4b22eec
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions lib/charms/operator_libs_linux/v0/apt.py
Original file line number Diff line number Diff line change
Expand Up @@ -1340,16 +1340,10 @@ def load_deb822(self, filename: str) -> None:
`_parse_deb822_paragraph` assumes that comments have been removed entirely,
instead reading the 'Enabled' key to determine if an entry is enabled
"""
logger.info(filename)
from pathlib import Path

logger.info(Path(filename).read_text())
parsed: List[int] = []
skipped: List[InvalidSourceError] = []
with open(filename, "r") as f:
logger.info(filename)
for line_number, paragraph in self._iter_paragraphs(f):
logger.info("%s: %s", line_number, paragraph)
try:
repos = self._parse_deb822_paragraph(
paragraph, filename=filename, line_number=line_number
Expand All @@ -1358,27 +1352,25 @@ def load_deb822(self, filename: str) -> None:
skipped.append(e)
continue
for repo in repos:
logger.info(repo)
repo_identifier = "{}-{}-{}".format(repo.repotype, repo.uri, repo.release)
self._repository_map[repo_identifier] = repo
parsed.append(line_number)
logger.debug("parsed repo: '%s'", repo_identifier)

if skipped:
logger.debug("the following errors were raised: %s", skipped)
logger.debug(
"the following errors were encountered when reading deb822 format sources:\n%s",
'\n'.join(str(error) for error in skipped),
)

if parsed:
logger.info("parsed %d apt package repositories", len(parsed))
else:
logger.info("here")
raise InvalidSourceError("all repository lines in '{}' were invalid!".format(filename))

@staticmethod
def _iter_paragraphs(lines: Iterable[str]) -> Iterator[Tuple[int, List[str]]]:
logger.info("_iter_paragraphs")
current: Optional[Tuple[int, List[str]]] = None
for n, line in enumerate(lines): # 0 indexed line numbers, following `load`
logger.info("%s: %s", n, line)
if line.startswith("#"):
continue
if not line:
Expand Down

0 comments on commit 4b22eec

Please sign in to comment.