-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from altescy/use-manifest
Add some features that makes use of manifest files
- Loading branch information
Showing
5 changed files
with
139 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from typing import Generic, Iterator, TypeVar | ||
|
||
T = TypeVar("T") | ||
|
||
|
||
class SizedIterator(Generic[T]): | ||
""" | ||
A wrapper for an iterator that knows its size. | ||
Args: | ||
iterator: The iterator. | ||
size: The size of the iterator. | ||
""" | ||
|
||
def __init__(self, iterator: Iterator[T], size: int): | ||
self.iterator = iterator | ||
self.size = size | ||
|
||
def __iter__(self) -> Iterator[T]: | ||
return self.iterator | ||
|
||
def __next__(self) -> T: | ||
return next(self.iterator) | ||
|
||
def __len__(self) -> int: | ||
return self.size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters