+
    Ki  c                   s    R t ^ RIt^ RIHt ^ RIHt ^ RIHt ^ RIH	t	 ^ RI
HtHt ^ RIHt ^ RIHt ^ R	IHtHt  ! R
 R4      tR# )zGame representation for viewsN)List)games)ServiceGameCollection)get_runner_human_name)SERVICESLutrisService)	MediaPath)logger)get_formatted_playtimegtk_safec                   s  a  ] tR t^t o RtR tR tR t]R 4       t	R t
R t]V 3R lR	 l4       t]R
 4       t]R 4       t]R 4       t]R 4       t]R 4       t]R 4       t]R 4       t]R 4       t]R 4       t]V 3R lR l4       tV 3R lR lt]R 4       t]R 4       t]R 4       t]R 4       t]R 4       t]R 4       tRtV tR# )	StoreItemzERepresentation of a game for views
TODO: Fix overlap with Game class
c                sl    V'       g   \        R 4      hWn        RV n        RV n        W n        W0n        R# )zNo game data providedNF)ZRuntimeError
_game_data_cached_installed_game_data"_cached_installed_game_data_loaded_service_obj_service_media)selfZ	game_dataserviceservice_medias   &&&&@/usr/lib/python3.14/site-packages/lutris/gui/views/store_item.py__init__ZStoreItem.__init__   s2    677#+/(27/#+    c                    V P                   # N)namer      &r   __str__ZStoreItem.__str__   s    yyr   c                s@    R V P                   : RV P                  : R2# )z
<Store id=z slug=Z>)idslugr   r   r   __repr__ZStoreItem.__repr__    s    *.''499==r   c                s"   V P                   '       gs   V P                  P                  R4      pV P                  P                  R4      pV'       d5   V'       d-   \        P                  ! W!4      ;'       g    / V n        RV n         V P
                  # )zProvides- and caches- the DB data for the installed game corresponding to this one,
if it's a service game. We can get away with caching this because StoreItem instances are
very short-lived, so the game won't be changed underneath us.appidr   T)r   r   getr   Zget_game_for_servicer   )r   r   
service_ids   &  r   _installed_game_dataZStoreItem._installed_game_data#   sm    
 666OO''0E,,Y7J383M3Mj3`3f3fdf0:>7///r   c                s     R V n         Wn        R# )TN)r   r   )r   installed_game_datas   &&r   apply_installed_game_dataZ#StoreItem.apply_installed_game_data1   s    26/+>(r   c                s    WP                   9   d   V P                   V,          # V P                  pV'       d   VP                  V4      # R # r   )r   r"   r    )r   Zkeyr#   s   && r   _get_game_attributeZStoreItem._get_game_attribute5   s>    //!??3''"77&**3//r   c                    < V ^8  d   QhRS[ /# i   Zreturn)strZformat__classdict__   "r   __annotate__StoreItem.__annotate__A   s      C r   c                s$   RV P                   9  d:   RV P                   9   d   V P                   R,          pM'V P                   R,          pMV P                   R,          pV'       g"   \        P                  ! RV P                  4       \	        V4      # )zGame internal IDr!   r   r   r   zNo id could be found for '%s')r   r   Zerrorr   r(   )r   Z_id   & r   r   ZStoreItem.id@   se    
 t.$//)oog.oof-//$'CLL8$))D3xr   c                sJ    \        V P                  P                  R 4      4      # )r   )r	   r   r    r   r   r   r   ZStoreItem.serviceR   s    ++I677r   c                r   r   )r   r   r   r   r   ZStoreItem.service_mediaV   s    """r   c                :    \        V P                  R,          4      # )zSlug identifierr   r	   r   r   r   r   r   ZStoreItem.slugZ        /00r   c                r/   )ZNamer   r0   r   r   r   r   ZStoreItem.name_   r1   r   c                J    \        V P                  R4      ;'       g    R4      # )zName used for sortingsortname )r	   r%   r   r   r   r3   ZStoreItem.sortnamed   s"     00<BBCCr   c                r2   )ZYearyearr4   )r(   r%   r   r   r   r5   ZStoreItem.yeari   s"     4++F399r::r   c                sN    V P                  R4      p\        V4      ;'       g    R# )zRunner slugrunnerr4   )r%   r	   )r   Z_runnerr.   r   r6   ZStoreItem.runnern   s'     **84 &&B&r   c                s>    \        \        V P                  4      4      # )zRunner name)r	   r   r6   r   r   r   runner_textZStoreItem.runner_textt   s     -dkk:;;r   c                s   V P                  R4      pV'       gf   V P                  \        9   dQ   \        V P                  ,          ! 4       pVP                  V P                  4      pV'       d   RP                  V4      p\        V4      # )ZPlatformplatformz, )r%   r   r   Zget_game_platformsr   Zjoinr	   )r   Z	_platformr   Z
_platformss   &   r   r8   ZStoreItem.platformy   sc     ,,Z8	T\\X5t||,.G 33DOODJ IIj1		""r   c                r&   r'   )boolr)   r+   r   r,   r-      s     	5 	54 	5r   c                sr    R pRV P                   9   d   V! V P                   4      # V! V P                  4      # )zGame is installedc                 s|    \        T ;'       d+    V P                  R 4      ;'       d    V P                  R4      4      # )	installedr6   )r9   r    )Zdatar   r   
check_dataZ'StoreItem.installed.<locals>.check_data   s/    MM+!6MM488H;MNNr   r:   )r   r"   )r   r;   r.   r   r:   ZStoreItem.installed   s6    	O $//)doo..$3344r   c                s0   < V ^8  d   QhRS[ S[,          /# r'   )r    r   r)   r+   r   r,   r-      s     U Ui Ur   c                s,  a aa	 S P                   P                  R4      '       dD   S P                   R,          p\        V\        4      '       d   V.# \        VS P                  4      .# S P                  P                  S P                  4      p\        ;QJ d    R V 4       F  '       g   K   RM	  RM! R V 4       4      '       d   V# S P                  ;'       g    \        pVV 3R l3.pS P                   P                  R4      o	S P                   P                  R4      oS	'       d?   S'       d7   S	\        9   d,   VV	3R lp\        S	,          ! 4       pVP                  We34       S P                  P                  V4      pV'       d
   W'.,           # T# )	z0Returns the path to the image file for this itemiconc              3   sL   "   T F  qP                   '       g   K  Vx  K  	  R # 5ir   )Zexists)Z.0Zmpr.   r   Z	<genexpr>Z,StoreItem.get_media_paths.<locals>.<genexpr>   s     8NbiirrNs   $
$TFc                  s   < S P                   # r   )r   r   s   r   Z<lambda>Z+StoreItem.get_media_paths.<locals>.<lambda>   s	    diir   r   r!   c                  sh   < \         P                  ! SS4      p V '       d   V P                  R 4      # R# )r   N)r   Zget_gamer    )Zservice_gamegame_service_idgame_service_names    r   get_service_slugZ3StoreItem.get_media_paths.<locals>.get_service_slug   s/    4==>OQ`a3?|''/ITIr   )r   r    Z
isinstancer   r   Zget_possible_media_pathsr   Zanyr   r   r   ZappendZget_fallback_media_path)
r   r<   Zpossible_pathsr   Zservicesr?   Zgame_serviceZfallback_pathr=   r>   s
   f       @@r   get_media_pathsZStoreItem.get_media_paths   s5   ??v&&??6*D$	**vdD$6$6788++DDTYYO38N83338N888!!##44}/01 OO//	://--l;5F(5RJ $$568LOO\<=**BB8L3@~/TnTr   c                $    V P                  R4      # )zDate of installinstalled_atr%   r   r   r   rB   ZStoreItem.installed_at   s     ''77r   c                    \        V P                  '       d:   \        P                  ! R\        P                  ! V P                  4      4      4      # R4      # )z(Date of install (textual representation)%X %xr4   )r	   rB   timestrftime	localtimer   r   r   installed_at_textZStoreItem.installed_at_text   s>     UYUfUfUfgt~~d>O>O/PQoolnoor   c                rA   )zDate of last play
lastplayedrC   r   r   r   rJ   ZStoreItem.lastplayed   s     ''55r   c                rD   )z*Date of last play (textual representation)rE   r4   )r	   rJ   rF   rG   rH   r   r   r   lastplayed_textZStoreItem.lastplayed_text   s<     SWSbSbSbgt~~doo/NOkkhjkkr   c                s|     \        V P                  R4      ;'       g    ^ 4      #   \        \        3 d     R# i ; i)zPlaytime duration in hoursplaytimeg        )Zfloatr%   Z	TypeError
ValueErrorr   r   r   rL   ZStoreItem.playtime   s<    	11*=BBCC:& 		s   & & ;;c                s     \        V P                  4      p\        V4      #   \         d(    \        P                  ! RT P                  T 4       Rp L<i ; i)z3Playtime duration in hours (textual representation)z Invalid playtime value %s for %sr4   )r   rL   rM   r   Zwarningr	   )r   Z_playtime_textr.   r   playtime_textZStoreItem.playtime_text   sM    	 3DMMBN ''  	 NN=t}}dSN	 s   " /AA)r   r   r   r   r   N) Z__name__Z
__module__Z__qualname__Z__firstlineno____doc__r   r   r   Zpropertyr"   r$   r%   r   r   r   r   r   r3   r5   r6   r7   r8   r:   r@   rB   rI   rJ   rK   rL   rN   Z__static_attributes__Z__classdictcell__)r*   s   @r   r
   r
      s    ,> 0 0?	  " 8 8 # # 1 1 1 1 D D ; ; ' '
 < < 
# 
# 	5 	5U U> 8 8 p p 6 6 l l   ( (r   r
   )rO   rF   Ztypingr    Zlutris.databaser   Zlutris.database.servicesr   Zlutris.runnersr   Zlutris.servicesr   r   Zlutris.services.service_mediar   Zlutris.util.logr   Zlutris.util.stringsr   r	   r
   ) r   r   <module>rP      s/    #   ! : 0 3 3 " @F( F(r   