
    gl                        S 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 python_scripts in HACS.    )annotations)TYPE_CHECKING   )HacsCategoryHacsDispatchEvent)HacsException)
concurrent   )HacsRepository)HacsBasec                  x   ^  \ rS rSrSrSrSU 4S jjr\S 5       rS r	S r
\" SS	S
9SS j5       rSS jrSrU =r$ )HacsPythonScriptRepository   zpython_scripts in HACS.python_scriptc                ^  > [         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python_scriptsTN)super__init__data	full_namelowerfull_name_lowerr   PYTHON_SCRIPTcategorycontentpathremote	localpathlocalsingle)selfr   r   	__class__s      </config/custom_components/hacs/repositories/python_script.pyr   #HacsPythonScriptRepository.__init__   sv    d#'		$-OO$5		!)77		#3 "&.."    c                H    U R                   R                  R                   S3$ )zReturn localpath.z/python_scripts)r   coreconfig_pathr"   s    r$   r   $HacsPythonScriptRepository.localpath   s      ))..,,-_==r&   c                (  #    U R                  5       I Sh  vN   U R                  R                  (       a  SU R                  R                  l        SnU R                   HT  nUR                  U R                  R                  R
                   5      (       d  M:  UR                  S5      (       d  MR  Sn  O   U(       d5  [        U R                   SU R                  R                  SS5       S35      e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Ny7f)
z	Validate.N F.pyT Repository structure for tags/ is not compliantz%s %s)common_validaterepository_manifestcontent_in_rootr   r   r   	treefiles
startswithendswithr   stringrefreplacevalidateerrorsr   statusstartuploggererrorsuccess)r"   	complianttreefiler@   s       r$   validate_repository.HacsPythonScriptRepository.validate_repository$   s1     ""$$$ ##33')DLL$	H""dll&7&7&>&>%?AAhFWFWX]F^F^ 	 ' ;;-9$((:J:J7SU:V9WWhi 
 ==--yy''///KK%%gt{{EB . }}$$$+ 	%s$   FFA>FF1BFAFc                   #    U R                  5         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   systemaction
validationasync_run_repository_checksr*   s    r$   async_post_registration2HacsPythonScriptRepository.async_post_registration>   sL      	99""))&&BB4HHH #Hs   AA) A'!A)
      )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        SnU R                   HT  nUR                  U R                  R                  R
                   5      (       d  M:  UR                  S5      (       d  MR  Sn  O   U(       d5  [        U R                   SU R                  R                  SS5       S35      eU R                  5         U R                  R                  (       aX  U R                   R#                  [$        R&                  S	S
U R                  R(                  U R                  R*                  S.5        gg GNn7f)zUpdate.Nr-   Fr.   Tr/   r0   r1   i9  update)idrI   
repositoryrepository_id)common_updater3   r4   r   r   r   r5   r6   r7   r   r8   r9   r:   rG   r   	installedr   async_dispatchr   
REPOSITORYr   rT   )r"   ignore_issuesforcerB   rC   s        r$   update_repository,HacsPythonScriptRepository.update_repositoryF   s3     ''===e ##33')DLL$	H""dll&7&7&>&>%?AAhFWFWX]F^F^ 	 ' ;;-9$((:J:J7SU:V9WWhi 
 	 99II$$!,,&"&))"5"5%)YY\\	 + >s   FFBF'F?CF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_pathr6   r   r   r   r7   filenamer   	file_name)r"   rC   s     r$   rG   +HacsPythonScriptRepository.update_filenamesi   se    		H!!,,!!(( $$--e44&.&7&7		#	 "r&    )r   r   r   str)FF)returnNone)__name__
__module____qualname____firstlineno____doc__r   r   propertyr   rD   rL   r	   r]   rG   __static_attributes____classcell__)r#   s   @r$   r   r      sU    !H# > >%4I 3  4 D8 8r&   r   N)rm   
__future__r   typingr   enumsr   r   
exceptionsr   utils.decoratorr	   baser   r   r   re   r&   r$   <module>rw      s.    ' "   3 & (  _8 _8r&   