-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path_platforms.py
37 lines (22 loc) · 1.05 KB
/
_platforms.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import os, pickle
# Helpers
from _constants import *
from _debug import *
class PlatformsHelper():
_platformsCache = {}
def __init__(self):
if os.path.exists(PLATFORMS_CACHE_FILENAME):
try:
with open(PLATFORMS_CACHE_FILENAME, 'rb') as fp: self._platformsCache = pickle.load(fp)
DebugHelper.print(DebugType.TYPE_INFO, f"<{PLATFORMS_CACHE_FILENAME}> sucessfully loaded!", "PLATFORMS")
except Exception as e: DebugHelper.print(DebugType.TYPE_ERROR, f"Error: {list(e.args)}", "EXCEPTION")
def platformsCount(self) -> int:
return len(self._platformsCache)
def getRomsCount(self, platform_name: str) -> int:
return len(self._platformsCache[platform_name])
def getPlatformName(self, index: int) -> str:
return list(self._platformsCache.keys())[index]
def getRomName(self, platform_name: str, index: int) -> str:
return list(self._platformsCache[platform_name].keys())[index]
def getRom(self, platform_name: str, rom_name: str) -> dict:
return self._platformsCache[platform_name][rom_name]