
    g              	         S r SSKJr  SSKrSSKJrJr  SSKJr  SSK	J
s  Jr  SSKrSSKJr  SSKJr  SS	KJr  \(       a  SS
KJr  SSKJr  \R2                  " \R4                  " S5      S\R6                  " S5      \/05      \R:                  \R<                          SS j5       5       5       r\R2                  " \R4                  " S5      S\R6                  " S5      \R@                  \R6                  " S5      \RB                  05      \R:                  \R<                          SS j5       5       5       r"\R2                  " \R4                  " S5      S05      \R:                  \R<                          SS j5       5       5       r#\R2                  " \R4                  " S5      S\R4                  " S5      \RB                  \R4                  " S5      \RH                  05      \R:                  \R<                          SS j5       5       5       r%\R2                  " \R4                  " S5      S\R4                  " S5      \RB                  05      \R:                  \R<                          SS j5       5       5       r&g)z!Register info websocket commands.    )annotationsN)TYPE_CHECKINGAny)websocket_api)regex   )DOMAIN)HacsDispatchEvent)HomeAssistant)HacsBasetypezhacs/repositories/list
categoriesc                8  #    U R                   R                  [        5      nUR                  [        R
                  " US   UR                  R                   Vs/ s GH  nUR                   R                  UR                  SUR                  R                  5      ;   d  MD  UR                  (       a  MW  UR                   R                  (       d  Mt  0 SUR                   R                  _SUR                  _SUR                  _SUR                   R                   _SUR"                  _SUR                   R                  _S	UR$                  R&                  _S
UR                  R)                  [+        UR                   R,                  5      5      (       + _SUR                   R.                  _SUR                   R0                  _SUR                   R2                  _SUR                   R4                  _SUR                   R6                  _SUR                   R8                  _SUR$                  R:                  _SUR                   R,                  _SUR                   R<                  _UR                   R>                  UR@                  RB                  RD                  URF                  UR                   RH                  URJ                  UR                   RL                  URN                  URP                  UR                   RR                  S.	EPGM     sn5      5        gs  snf 7f)zList repositories.idr   authorsavailable_versioninstalled_versionconfig_flowcan_downloadcategorycountrycustomdescriptiondomain	downloads	file_name	full_namehidehomeassistant	installed)	last_updated
local_pathnamenewpending_upgradestarsstatestatustopicsN)*datagetr	   send_messager   result_messagerepositorieslist_allr   commonr    ignored_by_country_configurationlast_fetchedr   display_available_versiondisplay_installed_versionr   r   repository_manifestr   
is_defaultstrr   r   r   r   r   r   r   r   r    r!   contentpathlocaldisplay_namer$   pending_updatestargazers_countr'   display_statusr)   )hass
connectionmsghacsrepos        8/config/custom_components/hacs/websocket/repositories.pyhacs_repositories_listrE      s     YY]]6*D$$I< !--66;!: 7D99%%t{{?U?U)VV;< ===> II**?tyy00')G)G ()G)G "499#8#8	
 #D$5$5 		 2 2 t77?? $"3"3">">s499<<?P"QQ "499#8#8 dii..  !4!4  !4!4  !4!4 DIINN $T%=%=%K%K  $)),,!"  !4!4#$ %)II$:$:"&,,"3"3"9"9 --99=='+':':!YY77!ZZ"11"ii..58 7;!$	
&!s&   ALAL L3LH9L	Lzhacs/repositories/clear_new
repositoryc                  #    U R                   R                  [        5      nUR                  S5      =n(       a-  UR                  R	                  U5      nSUR                   l        OUR                  R                   H  nUR                   R
                  (       d  M   UR                   R                  UR                  S/ 5      ;   d  ML  UR                  R                  SUR                   R                  5        SUR                   l        M     UR                  [        R                  0 5        UR                   R                  5       I Sh  vN   UR                  [         R"                  " US   5      5        g N-7f)z/Clear new repositories for specific categories.rF   Fr   zClearing new flag from '%s'Nr   )r*   r+   r	   r.   	get_by_idr$   r/   r   logdebugr   async_dispatchr
   
REPOSITORYasync_writer,   r   r-   )r?   r@   rA   rB   rC   rF   s         rD   hacs_repositories_clear_newrN   O   s     YY]]6*Dww|$$t$&&006
#
 %%..Dyy}}}!3!3sww|R7P!P1II'' !&		 / 	)44b9
))


!!!M88TCD "s   BE;(E;	BE;E9.E;zhacs/repositories/removedc                d  #    U R                   R                  [        5      n/ nUR                  R                   HH  nUR
                  UR                  R                  ;  d  M)  UR                  UR                  5       5        MJ     UR                  [        R                  " US   U5      5        g7f)z+Get information about removed repositories.r   N)r*   r+   r	   r.   list_removedrF   r0   ignored_repositoriesappendto_jsonr,   r   r-   )r?   r@   rA   rB   r8   rC   s         rD   hacs_repositories_removedrT   q   s}      YY]]6*DG!!..??$++"B"BBNN4<<>* / M88TGLMs   AB0#AB0zhacs/repositories/addr   c           	       #    U R                   R                  [        5      n[        R                  " US   5      nUS   nUc  gXCR
                  R                  ;   a%  UR
                  R                  R                  U5        UR
                  R                  R                  U5      =n(       a  UnXSR
                  R                  ;  a  UR                  R                  SXT5        OaUR                  R                  U5      (       d   UR                  UUS9I Sh  vN   O'UR!                  ["        R$                  SS	U S
3S.5        UR/                  [0        R2                  " US   0 5      5        g NV! [         a`  nUR!                  ["        R$                  S['        [(        R*                  " 5       S   R,                  5      ['        U5      S.5         SnANSnAff = f7f)zAdd custom repositoriy.rF   r   Nz!%s is not a valid category for %s)repository_full_namer   add_repositoryr   )action	exceptionmessagezRepository 'z' exists in the store.)rX   rZ   r   )r*   r+   r	   r   extract_repository_from_urlr0   skipremoverenamed_repositoriesr   rI   errorr.   get_by_full_nameasync_register_repositoryBaseExceptionrK   r
   ERRORr7   sysexc_info__name__r,   r   r-   )r?   r@   rA   rB   rF   r   renamedrY   s           rD   hacs_repositories_addrh      s     YY]]6*D223|3DEJ:H[[%%%
+++2266zBBwB
{{---:HQ//
;;	00%/! 1   $ 	##*)*5KL	
 M88TBGH5 
	 !''.!$S\\^A%6%?%?!@"9~ 
	sD   DG E3 E1E3 AG 1E3 3
G=AGG GG zhacs/repositories/removec                @  #    U R                   R                  [        5      nUR                  R	                  US   5      nUR                  5         UR                   R                  5       I Sh  vN   UR                  [        R                  " US   0 5      5        g N.7f)zRemove custom repositoriy.rF   Nr   )
r*   r+   r	   r.   rH   r]   rM   r,   r   r-   )r?   r@   rA   rB   rF   s        rD   hacs_repositories_removerj      sz      YY]]6*D"",,S->?J
))


!!!M88TBGH "s   A+B-B./B)r?   r   r@   zwebsocket_api.ActiveConnectionrA   zdict[str, Any]returnNone)'__doc__
__future__r   rd   typingr   r   homeassistant.componentsr   'homeassistant.helpers.config_validationhelpersconfig_validationcv
voluptuousvolcustom_components.hacs.utilsr   constr	   enumsr
   homeassistant.corer   baser   websocket_commandRequiredOptionalr7   require_adminasync_responserE   ensure_liststringrN   rT   Lowerrh   rj        rD   <module>r      s   ' " 
 % 2 4 4  .  %0   V6\"SE -
-.- 
- 
	-  -`   V;\"BNN\"BII E
E.E 
E 
	E  E2   V9
 N
N.N 
N 
	N  N   V5\"BIIZ #)) 2I
2I.2I 
2I 
	2I  2Ij   V8\"BII I
I.I 
I 
	I  Ir   