Skip to content

Commit

Permalink
Add valid property to sources
Browse files Browse the repository at this point in the history
Signed-off-by: Nikola Forró <[email protected]>
  • Loading branch information
nforro committed Oct 25, 2023
1 parent 256d332 commit 47c21fa
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions specfile/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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."""
Expand Down Expand Up @@ -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."""
Expand Down

0 comments on commit 47c21fa

Please sign in to comment.