+
    Ki  c                   s    ^ RI t ^ RIt^ RIt^ RIt^ RIHt ^ RIHt ^ RIH	t	H
t
HtHt ^ RIt^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ R	IHt ^ R
IHt ^ RIHt ^ RIHt  ! R R]4      t ! R R]4      t ! R R]4      t R# )i    N)gettext)Path)AnyDictListOptional)settings)MissingExecutableError)BaseService)ServiceGame)ServiceMedia)system)logger)slugifyc                   s   a  ] tR t^t o RtRtR
t]P                  P                  ]
P                  R4      tR.tRtV 3R lR ltRtV tR	# )FlathubBannerz!Standard size of a Flathub bannerflathubzflathub/bannersz%s.pngiconc                sL   < V ^8  d   QhRS[ S[S[3,          RS[S[,          /# )   detailsreturn)r   strr   r   Zformat__classdict__   "</usr/lib/python3.14/site-packages/lutris/services/flathub.py__annotate__ZFlathubBanner.__annotate__   s'     + +T#s(^ + +    c                s8    VP                  V P                  4      # N)get	url_field)selfr      &&r   get_media_urlZFlathubBanner.get_media_url   s    {{4>>**r    N)   r"   )__name__
__module____qualname____firstlineno____doc__serviceZsizeospathjoinr   	CACHE_DIRZ	dest_pathZfile_patternsr   r    __static_attributes____classdictcell__r      @r   r   r      sC     +GDX//1BCIJMI+ +r   r   c                   s8   a  ] tR t^"t o RtRt]R 4       tRtV t	R# )FlathubGamez Representation of a Flathub gamer   c                s    \        4       pVR,          Vn        \        VR,          4      Vn        \        VR,          4      Vn        VR,          Vn        RVn        \        P                  ! V4      Vn	        V# )z0Return a Flathub game instance from the API infoapp_idnameflatpak)
r1   appidr   slugZlutris_slugr3   runnerjsonZdumpsr   )ZclsZflathub_gameZservice_game   && r   new_from_flathub_gameZ!FlathubGame.new_from_flathub_game'   sh     #})(3#L$89#*<+?#@ (0'#zz,7r   r!   N)
r#   r$   r%   r&   r'   r(   Zclassmethodr:   r-   r.   r/   r0   r   r1   r1   "   s     *G	 	r   r1   c                   s6  a a ] tR t^4t oRtRt]! R4      tRtR]	/t
RtRt]P                  P                  ]P"                  R4      tRtRtR	tR
RR	]P.                  ! 4        R2/tRt]tV 3R ltR tR tR tR t R t!R t"R t#R t$R t%V3R lR lt&Rt'Vt(V ;t)# )FlathubServicezService class for Flathubr   FlathubZbannerz3https://flathub.org/api/v2/collection/category/gamezflathub-library.jsonZstableZx86_64Zuserr   zvar/lib/flatpak/app/z/.local/share/flatpak/app/r4   c                s  < \         P                  ! V P                  4      '       dM   \        P                  ! RV P
                  V P                  4       \        P                  ! V P                  4       \        SV `%  4        R# )z/Wipe the game cache, allowing it to be reloadedzDeleting %s cache %sN)
r   Zpath_exists
cache_pathr   debugidr)   ZremoveZsuperwipe_game_cache)r   	__class__s   &r   r@   ZFlathubService.wipe_game_cacheF   sL    doo..LL/$//JIIdoo&!r   c                s    \         P                  ! R 4      pV'       d   V.# \         P                  ! R4      pV'       d   VRR .# \        \        R4      4      h)r4   zflatpak-spawnz--hostz!No flatpak or flatpak-spawn found)shutilZwhichr   _)r   Zflatpak_abspathZflatpak_spawn_abspath   &  r   get_flatpak_cmdZFlathubService.get_flatpak_cmdM   sL     ,,y1#$$ &_ = )8Y??$Q'J%KLLr   c                sR   \         P                  ! V P                  ^R7      pVP                  4        VP	                  4       pVP                  ! R4      ;'       g    . p. pV F'  pVP                  \        P                  V4      4       K)  	  V F  pVP                  4        K  	  V# )z%Load the available games from Flathub)timeoutZhits)	requestsr   api_urlZraise_for_statusr8   appendr1   r:   Zsave)r   Zresponser8   entriesZflathub_gamesgames   &     r   loadZFlathubService.loadV   s    <<a8!!#}}((6"((bD  !B!B4!HI !DIIK "r   c                s    VR,          p\         P                  ! RW P                  4       V P                  4       '       g   \	        \        R4      4      hV P                  W4       R# )zInstall a Flathub gamer5   zInstalling %s from service %sz[Flathub is not configured on the system. Visit https://flatpak.org/setup/ for instructions.N)r   r>   r?   is_flathub_remote_activeZRuntimeErrorrC   Zinstall_from_api)r   db_gamer2   r9   r   installZFlathubService.installc   sT    !4fggF,,..op  	g.r   c           	     s8    V P                  4       p\        P                  ! V. RO,           RRRRRR7      pVP                  P	                  4       ;'       g    . #   \
        \        P                  3 d$   p\        P                  ! RT4       . u Rp?# Rp?ii ; i)z"Get list of installed Flathub appsTutf-8      @Zcapture_outputZcheckZencodingZtextrF   7Error occurred while getting installed flatpak apps: %sN)Zlistz--appz--columns=application)	rE   
subprocessrunstdout
splitlinesTimeoutErrorCalledProcessErrorr   	exception)r   flatpak_cmdprocesserrs   &   r   get_installed_appsZ!FlathubService.get_installed_appso   s    	..0K nnHH# G >>,,.44"4j;;< 	VX[\I	s$   AA A B6BBBc                s    V P                  4       pV'       g   \        P                  ! R4       R# V F  pRVP                  4       9   g   K   R# 	  R# )zBCheck if Flathub is configured and enabled as a flatpak repositoryz/Remotes not found, Flathub considered installedTr   F)get_active_remotesr   ZwarningZvalues)r   remotesZremoterD   r   rM   Z'FlathubService.is_flathub_remote_active   sC    ))+NNLMFFMMO+  r   c           
     s    V P                  4       p\        P                  ! VRR.,           RRRRRR7      p. pVP                  P	                  4        F\  pVP                  R4      pVP                  RV^ ,          P                  4       R	V^,          P                  4       R
V^,          /4       K^  	  V#   \        \        P                  3 d$   p\        P                  ! RT4       . u Rp?# Rp?ii ; i)z9Get a list of dictionaries containing name, title and urlr`   z--columns=name,title,urlTrP   rQ   rR   Z	r3   ZtitleZurlrS   N)rE   rT   rU   rV   rW   ZsplitrI   ZlowerrX   rY   r   rZ   )r   r[   r\   rJ   ZlineZcolsr]   s   &      r   r_   Z!FlathubService.get_active_remotes   s    	..0K nny*DEE# G G113zz$'Q$q'--/SXZ^_`Zabc 4 Nj;;< 	VX[\I	s   B2B5 5C3C.(C3.C3c           !     s"   V P                  4       pR VR ,          RV P                  V4      R\        VR,          4      R,           V P                  ,           RVR,          RRRV P	                  V4      RR	R VR ,          R
V P
                  RV P                  RV P                  /RRR/RV^ ,          RRRV^ ,          RRP                  VR,          4      RV P                   RVR ,           RV P
                   RV P                   2,           RR//.//# )r5   Z	game_slugr6   r3   Z-Zversionr<   r7   scriptrK   archbranchinstall_typer   Zdisable_runtimeTzrequire-binariesZ	installerZexecuteZfileZargsZ :i   NNz install --z$ --app --noninteractive flathub app/Z/)	rE   Zget_installed_slugr   r?   get_installed_runner_namerb   rc   rd   r+   )r   rN   r[   r9   r   generate_installerZ!FlathubService.generate_installer   s0   **,WW%009GGFO,s2TWW<GFOyd44W=WW-DIIdkk"D$5$5	 ,d3"KN!"KN"CHH[_$= +D,=,=+> ?##*7#3"4Adii[$++P%P .t$

 	
r   c                s    V P                   # r   )r7   r   rN   r   r   re   Z(FlathubService.get_installed_runner_name   s    {{r   c                s   a V3R  lR 4       w  r#rE\         P                  P                  V P                  V,          W4V4      # )c              3   sR   <"   T F  pSR ,          R,          V,          x  K  	  R# 5i)ra   rK   Nr!   )Z.0Zkey
_installers   & r   Z	<genexpr>Z4FlathubService.get_game_directory.<locals>.<genexpr>   s'      3
9j#Jx (--9js   $')rd   applicationrb   rc   )r)   r*   r+   install_locations)r   rh   rd   ri   rb   rc   s   &f    r   get_game_directoryZ!FlathubService.get_game_directory   s<    3
9j3
/4 ww||D22<@+U[\\r   c                s6   < V ^8  d   QhRS[ RS[S[,          /# )r   rN   r   )Zdictr   r   r   r   r   r   ZFlathubService.__annotate__   s      $ 49 r   c                s    R .# )ZLinuxr!   rg   r   r   get_game_platformsZ!FlathubService.get_game_platforms   s
    yr   r!   )*r#   r$   r%   r&   r'   r?   rC   r3   r   r   ZmediasZdefault_formatrH   r)   r*   r+   r   r,   r=   rc   rb   rd   r   Zhomerj   r7   r1   Z
game_classr@   rE   rL   rO   r^   rM   r_   rf   re   rk   rl   r-   r.   Z__classcell__)rA   r   s   @@r   r;   r;   4   s     #	BY<DD&FNCGh002HIJFDL!#96diik]RlCmnFJ"M
/"	*
B]  r   r;   )!r8   r)   rB   rT   r    rC   Zpathlibr   Ztypingr   r   r   r   rG   Zlutrisr   Zlutris.exceptionsr   Zlutris.services.baser   Zlutris.services.service_gamer	   Zlutris.services.service_mediar
   Zlutris.utilr   Zlutris.util.logr   Zlutris.util.stringsr   r   r1   r;   r!   r   r   <module>rm      s^     	      , ,   4 , 4 6  " '
+L 
++ $W[ Wr   