Skip to content

Commit 9db14e1

Browse files
authored
Merge pull request #55 from Garulf/handle-grid-not-found
Handle grid not found
2 parents f8e33ee + 4c28003 commit 9db14e1

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"Name": "Steam Search",
55
"Description": "Search and launch your Steam Game library",
66
"Author": "Garulf",
7-
"Version": "9.0.0",
7+
"Version": "9.0.1",
88
"Language": "executable",
99
"Website": "https://github.com/Garulf/Steam-Search",
1010
"IcoPath": "run.exe",

plugin/library.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from dataclasses import dataclass
22
from pathlib import Path
3-
from typing import Union, TYPE_CHECKING
3+
from typing import Optional, Union, TYPE_CHECKING
44
import webbrowser
55
import logging
66
from functools import cached_property
@@ -66,19 +66,22 @@ def __init__(self, image_dir: Union[str, Path]):
6666
self._files_cache = {}
6767
self._iterdir = image_dir.iterdir()
6868

69-
def get_image(self, id: str, type: str, sep='_') -> Path:
70-
69+
def get_image(self, id: str, type: str, sep='_') -> Optional[Path]:
7170
prefix = f'{id}{sep}{type}'
72-
if prefix in self._files_cache:
73-
return self._files_cache[prefix]
74-
else:
75-
for file in self._iterdir:
76-
haystack_prefix = file.name.split(".", 1)[0]
77-
self._files_cache[haystack_prefix] = file
78-
if prefix == haystack_prefix:
79-
return file
71+
try:
72+
if prefix in self._files_cache:
73+
return self._files_cache[prefix]
74+
else:
75+
for file in self._iterdir:
76+
haystack_prefix = file.name.split(".", 1)[0]
77+
self._files_cache[haystack_prefix] = file
78+
if prefix == haystack_prefix:
79+
return file
80+
return None
81+
except FileNotFoundError:
8082
return None
8183

84+
8285
class LibraryItem:
8386
"""
8487
Base class for all library items.

0 commit comments

Comments
 (0)