11# Copyright Contributors to the Packit project.
22# SPDX-License-Identifier: MIT
33
4+ import collections
45import re
56import urllib .parse
67from abc import ABC , abstractmethod
@@ -185,8 +186,8 @@ def comments(self) -> Comments:
185186 return self ._source .comments
186187
187188
188- class Sources :
189- """Class that represents a list of all sources."""
189+ class Sources ( collections . abc . MutableSequence ) :
190+ """Class that represents a sequence of all sources."""
190191
191192 PREFIX = "Source"
192193
@@ -216,7 +217,7 @@ def __repr__(self) -> str:
216217 # don't have to reimplement __repr__()
217218 return f"{ self .__class__ .__name__ } ({ tags } , { sourcelists } , { allow_duplicates } )"
218219
219- def __contains__ (self , location : str ) -> bool :
220+ def __contains__ (self , location : object ) -> bool :
220221 items = self ._get_items ()
221222 if not items :
222223 return False
@@ -346,15 +347,6 @@ def _deduplicate_tag_names(self) -> None:
346347 ts0 , ts0 .index + 1
347348 )
348349
349- def append (self , location : str ) -> None :
350- """
351- Adds a new source.
352-
353- Args:
354- location: Location of the new source.
355- """
356- self .insert (len (self ), location )
357-
358350 def insert (self , i : int , location : str ) -> None :
359351 """
360352 Inserts a new source at a specified index.
@@ -409,11 +401,6 @@ def remove(self, location: str) -> None:
409401 if source .location == location :
410402 del container [index ]
411403
412- def clear (self ) -> None :
413- """Removes all sources."""
414- for _ , container , index in reversed (self ._get_items ()):
415- del container [index ]
416-
417404 def count (self , location : str ) -> int :
418405 """
419406 Counts sources by location.
@@ -429,19 +416,9 @@ def count(self, location: str) -> int:
429416 return 0
430417 return len ([s for s in list (zip (* items ))[0 ] if s .location == location ])
431418
432- def extend (self , locations : List [str ]) -> None :
433- """
434- Extends the sources by a list of locations.
435-
436- Args:
437- locations: List of locations of the sources to be added.
438- """
439- for location in locations :
440- self .append (location )
441-
442419
443420class Patches (Sources ):
444- """Class that represents a list of all patches."""
421+ """Class that represents a sequence of all patches."""
445422
446423 PREFIX = "Patch"
447424
0 commit comments