+
    KiH  c                   sx    R t ^ RIt^ RIHt ]P                  P                  R4      t^tR tR t	 ! R R4      t
R# )z:Reads the Dolphin game database, stored in a binary formatN)loggerz#~/.cache/dolphin-emu/gamelist.cachec                s2    RP                  R V  4       4      # )z1Return the hexadecimal representation of a stringZ c              3   D   "   T F  pR P                  V4      x  K  	  R# 5iz{:02x}NZformatZ.0c   & E/usr/lib/python3.14/site-packages/lutris/util/dolphin/cache_reader.py	<genexpr>Z!get_hex_string.<locals>.<genexpr>   s     71HOOA&&    )joinstring   &r   get_hex_stringr      s    887777    c           
     sh    \        RRP                  R V RRR1,           4       4      ,           ^ 4      # )z@Return the length of a string as specified in the Dolphin formatZ0xZ c              3   r   r   r   r   r   r   r   Zget_word_len.<locals>.<genexpr>   s     G,Qhooa00,r	   Ni)Zintr
   r   r   r   get_word_lenr      s+    tbggG&2,GGGKKr   c                   s6  a  ] tR t^t o ^t/ RRbRRbRRbR^bR^bR^bR	RbR
RbRRbRRbRRbRRbRRbRRbRRbRRbR^b/ RRbR^bR^bR^bR^bR^bR^bRRbR^bR^bRRbR RbR!RbR"RbR#R$bR%R$bR&R'bCR(R'/CtR) tR* tR+ tR, t	R- t
R. tR/ tR0 tR1 tR2tV tR3# )4DolphinCacheReaderZvalidbZ	file_pathsZ	file_nameZ	file_sizeZvolume_sizeZvolume_size_typeZis_datel_discZis_nkitZshort_namesaZ
long_namesZshort_makersZlong_makersZdescriptionsZinternal_nameZgame_idZ
gametdb_idZtitle_idZmaker_idZregionZcountryZplatformZ	platform_Z	blob_typeZ
block_sizeZcompression_methodZrevisionZdisc_numberZapploader_dateZcustom_nameZcustom_descriptionZcustom_makerZvolume_banneriZcustom_bannerZdefault_coverr   Zcustom_coverc                s0   ^ V n         \        \        R4      ;_uu_ 4       pVP                  4       V n        RRR4       \        V P                  R,          4      pV\        8w  d   \        P                  ! R\        V4       R# R#   + '       g   i     LW; i)i    ZrbN:N   Nz.Dolphin cache version expected %s but found %s)	offsetZopenDOLPHIN_GAME_CACHE_FILEZreadcache_contentr   SUPPORTED_CACHE_VERSIONr    Zwarning)selfZdolphin_cache_fileZcache_version   &  r   __init__ZDolphinCacheReader.__init__A   so    )4004F!3!8!8!:D 1$T%7%7%;<33NNKMdfst 4 10s   BB	c                s   / pV P                   P                  4        F  w  r#VR 8X  d   V P                  4       W&   K   VR8X  d   V P                  4       W&   K;  VR8X  d   V P	                  4       W&   KV  VR8X  d   V P                  4       W&   Kq  VR8X  d   V P                  4       W&   K  V P                  V4      W&   K  	  V# )r   r   r   r   r   )	structureZitems
get_stringget_boolean	get_array	get_image	get_coverget_raw)r   ZgameZkeyr   s   &   r   get_gameZDolphinCacheReader.get_gameI   s    nn**,FCCx OO-	c ,,.	c NN,	c NN,	c NN,	 LLO	 - r   c                s<   V ;P                   V P                  ,          un         . pV P                   \        V P                  4      8  d#    VP	                  V P                  4       4       KF  V#   \         d#   p\        P                  ! R T4        Rp?Kp  Rp?ii ; i)z#Failed to read Dolphin database: %sN)	r   header_sizeZlenr   Zappendr%   Z	Exceptionr    Zerror)r   ZgamesZexr   r   	get_gamesZDolphinCacheReader.get_gamesZ   sw    t'''kkC 2 233HT]]_-   HBBGGHs   A. .B9BBc                s    \        \        V P                  V P                  V P                  ^,            4      4      pV ;P                  ^,          un        V# )i   )Zboolr   r   r   )r   resr   r   r    ZDolphinCacheReader.get_booleand   s=    < 2 24;;q QRSq
r   c                s   \        V P                  V P                  V P                  ^,            4      pV ;P                  ^,          un        / p\        V4       F&  pV P	                  ^4      pV P                  4       W$&   K(  	  V# r   )r   r   r   Zranger$   r   )r   	array_lenZarrayZ_iZ	array_key   &    r   r!   ZDolphinCacheReader.get_arrayi   sk     !3!3DKK$++PQ/!RS	q	"BQI#0E # r   c                sv   \        V P                  V P                  V P                  ^,            4      pV ;P                  ^,          un        V P                  V P                  V P                  V^,          ,            pV ;P                  V^,          ,          un        \        V P                  V P                  V P                  ^,            4      pV ;P                  ^,          un        \        V P                  V P                  V P                  ^,            4      pV ;P                  ^,          un        W43V3# r)   )r   r   r   )r   Zdata_lenr(   ZwidthZheightr+   r   r"   ZDolphinCacheReader.get_imager   s     2 24;;q QRq  t{{X\/IJx!|#T//dkkAoNOqd00t{{QOPq##r   c                s    \        V P                  V P                  V P                  ^,            4      pV ;P                  ^,          un        V P                  V4      # r)   )r   r   r   r$   )r   r*   r   r   r#   ZDolphinCacheReader.get_cover}   sC     !3!3DKK$++PQ/!RS	q||I&&r   c                s    \        V P                  V P                  V P                  V,            4      pV ;P                  V,          un        V# )N)r   r   r   )r   word_lenr(   s   && r   r$   ZDolphinCacheReader.get_raw   s9    T//dkkH>TUVx
r   c                sB   \        V P                  V P                  V P                  ^,            4      pV ;P                  ^,          un        V P                  V P                  V P                  V,            pV ;P                  V,          un        VP                  R4      # )r   Zutf8)r   r   r   Zdecode)r   r,   r   r   r   r   ZDolphinCacheReader.get_string   so     2 24;;q QRq##DKK$++2HIx}}V$$r   )r   r   N)Z__name__Z
__module__Z__qualname__Z__firstlineno__r&   r   r   r%   r'   r    r!   r"   r#   r$   r   Z__static_attributes__Z__classdictcell__)Z__classdict__s   @r   r   r      s    K$$S$ 	S$ 	Q	$
 	q$ 	A$ 	$ 	3$ 	s$ 	c$ 	$ 	s$ 	$ 	$ 	3$  	c!$" 	A#$$ 	C%$& 	!'$( 	1)$* 	A+$, 	Q-$. 	Q/$0 	a1$2 	c3$4 	A5$6 	q7$8 	#9$: 	s;$< 	c=$> 	?$@ 	A$B 	C$D 	E$F 	G$ILu"
	$'

% %r   r   )Z__doc__ZosZlutris.util.logr    ZpathZ
expanduserr   r   r   r   r   ) r   r   <module>r-      sA    @ 	 "'',,-RS  8
Ls% s%r   