From 10d944a13cb317a2997d5a032e6a1d34d774180b Mon Sep 17 00:00:00 2001 From: vsivanandharao Date: Sun, 4 Feb 2024 15:12:36 -0600 Subject: [PATCH] Remove previous button in case of single file directory Make sure previous doesn't overlap with last item in directory --- pystream/models/config.py | 2 +- pystream/models/squire.py | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pystream/models/config.py b/pystream/models/config.py index 0b466e4..b3bf3a0 100644 --- a/pystream/models/config.py +++ b/pystream/models/config.py @@ -71,7 +71,7 @@ def parse_authorization(cls, value: Any) -> Dict[str, SecretStr]: raise ValueError("input should be a valid dictionary with username as key and password as value") r = {} for k, v in val.items(): - if len(k) < 3: + if len(k) < 4: raise ValueError(f"[{k}: {v}] username should be at least 4 or more characters") if len(v) < 8: raise ValueError(f"[{k}: {v}] password should be at least 8 or more characters") diff --git a/pystream/models/squire.py b/pystream/models/squire.py index 6e9d9ad..533421b 100644 --- a/pystream/models/squire.py +++ b/pystream/models/squire.py @@ -103,9 +103,14 @@ def get_iter(filename: pathlib.PurePath) -> Union[Tuple[str, str], Tuple[None, N key=lambda x: natural_sort_key(x) ) idx = dir_content.index(filename.name) - try: - previous_ = dir_content[idx - 1] - except IndexError: + if idx > 0: # 0-1 is -1, which will in turn fetch the last item from the list instead of leaving it blank + try: + previous_ = dir_content[idx - 1] + if previous_ == filename.name: # This should be covered by > 0, but double check as a safety net + previous_ = None + except IndexError: + previous_ = None + else: previous_ = None try: next_ = dir_content[idx + 1]