
    g                        S r SSKJr  SSKJr  SSKJr  SSKJrJ	r	  SSK
Jr  SSKJr  S	S
KJr  \(       a  SSKJr   " S S\5      rg)zClass for themes in HACS.    )annotations)TYPE_CHECKING)HomeAssistantError   )HacsCategoryHacsDispatchEvent)HacsException)
concurrent   )HacsRepository)HacsBasec                     ^  \ rS rSrSrSU 4S jjr\S 5       rS rS r	S r
SS jrSS	 jr\" S
SS9SS j5       rSS jrSrU =r$ )HacsThemeRepository   zThemes in HACS.c                ^  > [         TU ]  US9  X R                  l        UR	                  5       U R                  l        [        R                  U R                  l        SU R                  R                  l        U R                  U R                  R                  l        SU R                  l        g)zInitialize.)hacsthemesFN)super__init__data	full_namelowerfull_name_lowerr   THEMEcategorycontentpathremote	localpathlocalsingle)selfr   r   	__class__s      4/config/custom_components/hacs/repositories/theme.pyr   HacsThemeRepository.__init__   sv    d#'		$-OO$5		!)//		#+ "&..#    c                    U R                   R                  R                   SU R                  R                  R                  SS5       3$ )zReturn localpath.z/themes/.yaml )r   coreconfig_pathr   	file_namereplacer"   s    r$   r   HacsThemeRepository.localpath   s>     ))..,,-Xdii6I6I6Q6QRY[]6^5_``r&   c                @   #    U R                  5       I Sh  vN   g N7f)zRun post installation steps.N_reload_frontend_themesr.   s    r$   async_post_installation+HacsThemeRepository.async_post_installation$        **,,,   c                  #    U R                  5       I Sh  vN   SnU R                   H5  nUR                  S5      (       d  M  UR                  S5      (       d  M3  Sn  O   U(       d5  [	        U R
                   SU R                  R                  SS5       S	35      eU R                  R                  (       a  SU R                  R                  l        U R                  R                  (       ak  U R                  R                   HQ  nU R                  R                   R"                  (       a  M*  U R$                  R'                  S
U R
                  U5        MS     U R                  R(                  $  GNZ7f)z	Validate.NFzthemes/r(   Tz Repository structure for ztags/r)   z is not compliant%s %s)common_validate	treefiles
startswithendswithr	   stringrefr-   repository_manifestcontent_in_rootr   r   r   validateerrorsr   statusstartuploggererrorsuccess)r"   	complianttreefilerF   s       r$   validate_repository'HacsThemeRepository.validate_repository(   s     ""$$$ 	H""9--(2C2CG2L2L 	 ' ;;-9$((:J:J7SU:V9WWhi  ##33')DLL$ ==--yy''///KK%%gt{{EB . }}$$$+ 	%s#   E3E0)E3E3CE3/AE3c                   #    U R                  5         U R                  U R                  R                  l        U R
                  R                  R                  (       a.  U R
                  R                  R                  U 5      I Sh  vN   gg N7f)zRegistration.N)
update_filenamesr   r   r   r    r   systemaction
validationasync_run_repository_checksr.   s    r$   async_post_registration+HacsThemeRepository.async_post_registrationB   sb      	"&..99""))&&BB4HHH #Hs   BBBBc                L  #    U R                   R                  SU R                  5         U R                  R                  R
                  R                  SS0 5      I Sh  vN   g N! [         a1  nU R                   R                  SU R                  U5         SnAgSnAff = f7f)zReload frontend themes.z%s Reloading frontend themesfrontendreload_themesNr8   )	rE   debugr=   r   hassservices
async_callr   	exception)r"   r[   s     r$   r2   +HacsThemeRepository._reload_frontend_themesK   sy     8$++F	C))..))44ZRTUUU! 	CKK!!'4;;	BB	Cs@   'B$4A& A$A& #B$$A& &
B!0'BB$B!!B$c                @   #    U R                  5       I Sh  vN   g N7f)zRun post uninstall steps.Nr1   r.   s    r$   async_post_uninstall(HacsThemeRepository.async_post_uninstallS   r5   r6   
      )concurrenttasksbackoff_timec                  #    U R                  X5      I Sh  vN (       d  U(       d  gU R                  R                  (       a  SU R                  R                  l        U R                  5         U R                  U R                  R                  l        U R                  R                  (       aX  U R                  R                  [        R                  SSU R                  R                  U R                  R                   S.5        gg N7f)zUpdate.Nr)   i9  update)idrO   
repositoryrepository_id)common_updater?   r@   r   r   r   rM   r   r    r   	installedr   async_dispatchr   
REPOSITORYr   rf   )r"   ignore_issuesforces      r$   update_repository%HacsThemeRepository.update_repositoryW   s      ''===e ##33')DLL$ 	"&.. 99II$$!,,&"&))"5"5%)YY\\	  >s   D
DC1D
c                $   U R                    H  nUR                  R                  U R                  R                  R
                  5      (       d  MC  UR                  R                  S5      (       d  Me  UR                  U R                  l	        M     g)zGet the filename to target.r(   N)
tree	full_pathr;   r   r   r   r<   filenamer   r,   )r"   rI   s     r$   rM   $HacsThemeRepository.update_filenamesq   se    		H!!,,!!(( $$--g66&.&7&7		#	 "r&    )r   r   r   str)returnNone)FF)__name__
__module____qualname____firstlineno____doc__r   propertyr   r3   rJ   rR   r2   r^   r
   ro   rM   __static_attributes____classcell__)r#   s   @r$   r   r      sa    $ a a-%4IC- 3 428 8r&   r   N)r~   
__future__r   typingr   homeassistant.exceptionsr   enumsr   r   
exceptionsr	   utils.decoratorr
   baser   r   r   rv   r&   r$   <module>r      s1     "   7 3 & (  e8. e8r&   