Skip to content

Commit

Permalink
Merge pull request #55 from Garulf/handle-grid-not-found
Browse files Browse the repository at this point in the history
Handle grid not found
  • Loading branch information
Garulf authored Apr 18, 2023
2 parents f8e33ee + 4c28003 commit 9db14e1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"Name": "Steam Search",
"Description": "Search and launch your Steam Game library",
"Author": "Garulf",
"Version": "9.0.0",
"Version": "9.0.1",
"Language": "executable",
"Website": "https://github.com/Garulf/Steam-Search",
"IcoPath": "run.exe",
Expand Down
25 changes: 14 additions & 11 deletions plugin/library.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataclasses import dataclass
from pathlib import Path
from typing import Union, TYPE_CHECKING
from typing import Optional, Union, TYPE_CHECKING
import webbrowser
import logging
from functools import cached_property
Expand Down Expand Up @@ -66,19 +66,22 @@ def __init__(self, image_dir: Union[str, Path]):
self._files_cache = {}
self._iterdir = image_dir.iterdir()

def get_image(self, id: str, type: str, sep='_') -> Path:

def get_image(self, id: str, type: str, sep='_') -> Optional[Path]:
prefix = f'{id}{sep}{type}'
if prefix in self._files_cache:
return self._files_cache[prefix]
else:
for file in self._iterdir:
haystack_prefix = file.name.split(".", 1)[0]
self._files_cache[haystack_prefix] = file
if prefix == haystack_prefix:
return file
try:
if prefix in self._files_cache:
return self._files_cache[prefix]
else:
for file in self._iterdir:
haystack_prefix = file.name.split(".", 1)[0]
self._files_cache[haystack_prefix] = file
if prefix == haystack_prefix:
return file
return None
except FileNotFoundError:
return None


class LibraryItem:
"""
Base class for all library items.
Expand Down

0 comments on commit 9db14e1

Please sign in to comment.