Skip to content

Commit

Permalink
Dump debug info when accessing the rpm_spec property
Browse files Browse the repository at this point in the history
Signed-off-by: Nikola Forró <[email protected]>
  • Loading branch information
nforro committed Jul 16, 2024
1 parent 8aba712 commit 756dd40
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions specfile/specfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# SPDX-License-Identifier: MIT

import datetime
import logging
import re
import types
from dataclasses import dataclass
Expand Down Expand Up @@ -38,6 +39,8 @@
ValueParser,
)

logger = logging.getLogger(__name__)


class Specfile:
"""
Expand Down Expand Up @@ -75,6 +78,7 @@ def __init__(
Path(sourcedir or self.path.parent), macros, force_parse
)
self._parser.parse(str(self))
self._dump_debug_info("After initial parsing")

def __eq__(self, other: object) -> bool:
if not isinstance(other, Specfile):
Expand Down Expand Up @@ -107,6 +111,14 @@ def __exit__(
) -> None:
self.save()

def _dump_debug_info(self, message) -> None:
logger.debug(
f"DBG: {message}:\n"
f" {self!r} @ 0x{id(self):012x}\n"
f" {self._parser!r} @ 0x{id(self._parser):012x}\n"
f" {self._parser.spec!r} @ 0x{id(self._parser.spec):012x}"
)

@staticmethod
def _read_lines(path: Path) -> Tuple[List[str], bool]:
content = path.read_text(encoding="utf8", errors="surrogateescape")
Expand Down Expand Up @@ -160,7 +172,9 @@ def tainted(self) -> bool:
@property
def rpm_spec(self) -> rpm.spec:
"""Underlying `rpm.spec` instance."""
self._dump_debug_info("`rpm_spec` property, before parsing")
self._parser.parse(str(self))
self._dump_debug_info("`rpm_spec` property, after parsing")
return self._parser.spec

def reload(self) -> None:
Expand Down

0 comments on commit 756dd40

Please sign in to comment.