From 47c21fa7346da1a51cadd5360e20f5d879f98a87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Forr=C3=B3?= Date: Wed, 25 Oct 2023 17:30:45 +0200 Subject: [PATCH] Add valid property to sources MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nikola Forró --- specfile/sources.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/specfile/sources.py b/specfile/sources.py index 2f3f82c..34b6675 100644 --- a/specfile/sources.py +++ b/specfile/sources.py @@ -66,6 +66,12 @@ def comments(self) -> Comments: """List of comments associated with the source.""" ... + @property + @abstractmethod + def valid(self) -> bool: + """Whether the source is not located in a false branch of a condition.""" + ... + class TagSource(Source): """Class that represents a source backed by a spec file tag.""" @@ -161,6 +167,11 @@ def comments(self) -> Comments: """List of comments associated with the source.""" return self._tag.comments + @property + def valid(self) -> bool: + """Whether the source is not located in a false branch of a condition.""" + return self._tag.valid + class ListSource(Source): """Class that represents a source backed by a line in a %sourcelist section.""" @@ -224,6 +235,11 @@ def comments(self) -> Comments: """List of comments associated with the source.""" return self._source.comments + @property + def valid(self) -> bool: + """Whether the source is not located in a false branch of a condition.""" + return self._source.valid + class Sources(collections.abc.MutableSequence): """Class that represents a sequence of all sources."""