Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dump debug info when accessing the rpm_spec property #397

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading