diff --git a/specfile/specfile.py b/specfile/specfile.py index cffdb9a..094727a 100644 --- a/specfile/specfile.py +++ b/specfile/specfile.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: MIT import datetime +import logging import re import types from dataclasses import dataclass @@ -38,6 +39,8 @@ ValueParser, ) +logger = logging.getLogger(__name__) + class Specfile: """ @@ -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): @@ -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") @@ -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: