+
   'bc            	       sV   R 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t]P                  ER8  d   ^ RIH
t
 M^ RIH
t
 ]
ER,          t]].R3,          t]].R3,          t^ RIt^ RIt^ RIt^ RIt^ R	IHt ]! R
R4       ]! RR4       ^ RIHt ^ RIHt  ]! RR4       ^ RIHt ^ RIHtHt ]P>                  PA                  ^ ]P>                  PC                  ]P>                  PE                  ]#4      RR4      4       ^ RI$t$^ RI%H&t& ]'       d   ^ RIH&t& ^ RI'H(t(H)t) ]PT                  ! R4      t+/ RRbRRbRRbRRbRR bR!R bR"R bR#R bR$R bR%R bR&R bR'R bR(R bR)R bR*R bR+R bR,R b/ R-R bR.R bR/R bR0R bR1R bR2R bR3R bR4R bR5R bR6R bR7R bR8R bR9R bR:R;bR<R;bR=R>bR?R>bC/ R@RAbRBRAbRCRDbRERDbRFRDbRGRHbRIRHbRJRHbRKRLbRMRLbRNRObRPRObRQRRbRSRRbRTRRbRURVbRWRRbC/ RXRRbRYRZbR[RZbR\R]bR^R]bR_R`bRaR`bRbRcbRdRebRfRcbRgRhbRiRcbRjRebRkRhbRlRcbRmRnbRoRnbC/ RpRnbRqRrbRsRrbRtRubRvRubRwRubRxRubRyRubRzR{bR|RubR}RubR~RubRRubRRubRRubRRubRRbC/ RRubRRubRRubRRubRRubRRubRRubRRubRRubRRubRRubRRubRRubRRubRRubRRubRRubC/ RRubRRubRRubRRubRRubRRubRRubRRubRRubRRubRRubRRubRRubRRubRRubRRubRRubC/ RRubRRubRRubRRubRRubRRubRRubRRubRRubRRubRRubRRubRRubRRubRRubRRubRRubC/ RRubRRubRRubRRubRRubRRubRRubRRubRRubRRubRRubRRubRRubRRubRRubRRubRRubC/ RRubRRubRRubRRubRRubRRubRRubRRubRRubRRubRRubRRrbRRrbRRrbRRubRRubRRrbC/ RRubRRubRRbRRubRRubRRbRRbRRbRRbRRbRRbRRbRRbRRbRRbRRbRRbC/ RRbRRbRRbRRbRRbRER bERRbERERbERERbERERbERER	bER
ERbERERbERERbERERbERRbERERbC/ ERERbERERbERERbERERbERERbERERbERERbERERbER ERbER!ERbER"ERbER#ERbER$ERbER%ERbER&ERbER'ERbER(ERbC/ ER)ERbER*ERbER+ERbER,ERbER-ERbER.ERbER/ERbER0ERbER1ERbER2ERbER3ERbER4ERbER5ERbER6ERbER7ERbER8ERbER9ERbC/ ER:ERbER;ERbER<ERbER=ERbER>ERbER?ERbER@ERbERAERbERBERbERCERbERDERbEREERbERFERbERGERbERHERbERIERbERJERbC/ ERKERLbERMERLbERNERObERPERObERQERRbERSERRbERTERUbERVERWbERXERWbERYERZbER[ERZbER\ER]bER^ER]bER_ER`bERaER`bERbERcbERdERcbC/ EReERfbERgERfbERhERibERjERibERkERibERlERmbERnERmbERoERmbERpERmbERqERmbERrERmbERsERmbERtERmbERuERvbERwERvbERxERybERzERybC/ ER{ER|bER}ER|bER~ERbERERbERERbERERbERERbERERbERERbERERbERERbERERbERERbERERbERERbERERbERERbC/ ERERbERERbERERbERERbERERbERERbERERbERERbERERbERERbERERbERERbERERbERERbERERbERERbERERbC/ ERERbERERbERERbERERbERERbERERbERERbERERbERERbERERbERERbERERbERERbERERbERERbERERbERERbC/ ERERbERERbERERbERERbERERbERERbERERbERERbERERbERERbERERbERERbERERbERERbERERbERERbERERbCERERERERERERERER/Ct,ERER ER llt-ERER ER llt.ER ER lt/ERER ER llt0]1ER8X  d   ]Pd                  ! ]Pf                  ER7      t4]+Pk                  ]Pl                  4       ]+Po                  ]44        ]Pp                  ! ]Pr                  ER4       ]! 4        ER ER lt<]0! R]=! ]>! ],P                  4       4      ER,          4      ]<ER7       R# R#   ] d    ]! RR4       ^ RIHt  EL0i ; i  ]Pt                   d4    ]+Pw                  ER4       ]Pp                  ! ]Pr                  ER4        Li ; i(  za
dictionary_download.py

Uses Gio.File to download dictionary files with a Gtk3 progress dialog.
)Dict)Set)List)Optional)Callable)TYPE_CHECKINGN)Literal)require_versionGLibz2.0Gio)r   )r	   Soupz3.0)r
   z2.4)_initz..Zengine)Gtk)	add_childshow_allzibus-typing-boosterZafzMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/af_ZA/af_ZAZaf_ZAZanzMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/an_ES/an_ESZan_ESZarzGhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/ar/arZar_AEZar_BHZar_DJZar_DZZar_EGZar_ILZar_INZar_IQZar_JOZar_KMZar_KWZar_LBZar_LYZar_MAZar_MRZar_OMZar_PSZar_QAZar_SAZar_SDZar_SOZar_SYZar_TDZar_TNZar_YEZaszMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/as_IN/as_INZas_INZbezShttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/be_BY/be-officialZbe_BYZbgzMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/bg_BG/bg_BGZbg_BGZbnzMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/bn_BD/bn_BDZbn_BDZbn_INZbozGhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/bo/boZbo_CNZbo_INZbrzMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/br_FR/br_FRZbr_FRZbszMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/bs_BA/bs_BAZbs_BAZcazThttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/ca/dictionaries/caZca_ADZca_ESZca_ES_VALENCIAz]https://raw.githubusercontent.com/LibreOffice/dictionaries/master/ca/dictionaries/ca-valenciaZca_FRZca_ITZckbzVhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/ckb/dictionaries/ckbZckb_IQZcszMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/cs_CZ/cs_CZZcs_CZZdazMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/da_DK/da_DKZda_DKZdezPhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/de/de_DE_framiZde_ATzPhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/de/de_AT_framiZde_BEZde_CHzPhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/de/de_CH_framiZde_DEZde_ITZde_LIZde_LUZelzMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/el_GR/el_GRZel_CYZel_GRZenzJhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/en/en_USZen_001Zen_150zJhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/en/en_GBZen_AGZen_AIZen_ASZen_ATZen_AUzJhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/en/en_AUZen_BBZen_BEZen_BIZen_BMZen_BSZen_BWZen_BZZen_CAzJhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/en/en_CAZen_CCZen_CHZen_CKZen_CMZen_CXZen_CYZen_DEZen_DGZen_DKZen_DMZen_GBZen_ERZen_FIZen_FJZen_FKZen_FMZen_GDZen_GGZen_GHZen_GIZen_GMZen_GUZen_GYZen_HKZen_IEZen_ILZen_IMZen_INZen_IOZen_JEZen_JMZen_KEZen_KIZen_KNZen_KYZen_LCZen_LRZen_LSZen_MGZen_MHZen_MOZen_MPZen_MSZen_MTZen_MUZen_MWZen_MYZen_NAZen_NFZen_NGZen_NLZen_NRZen_NUZen_NZZen_PGZen_PHZen_PKZen_PNZen_PRZen_PWZen_RWZen_SBZen_SCZen_SDZen_SEZen_SGZen_SHZen_SIZen_SLZen_SSZen_SXZen_SZZen_TCZen_TKZen_TOZen_TTZen_TVZen_TZZen_UGZen_UMZen_USZen_US_POSIXZen_VCZen_VGZen_VIZen_VUZen_WSZen_ZAzJhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/en/en_ZAZen_ZMZen_ZWZeozGhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/eo/eoZeszJhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/es/es_ESZes_419zJhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/es/es_MXZes_ARzJhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/es/es_ARZes_BOzJhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/es/es_BOZes_BRzJhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/es/es_UYZes_BZZes_CLzJhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/es/es_CLZes_COzJhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/es/es_COZes_CRzJhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/es/es_CRZes_CUzJhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/es/es_CUZes_DOzJhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/es/es_DOZes_EAZes_ECzJhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/es/es_ECZes_ESZes_GQzJhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/es/es_GQZes_GTzJhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/es/es_GTZes_HNzJhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/es/es_HNZes_MXZes_NIzJhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/es/es_NIZes_PAzJhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/es/es_PAZes_PEzJhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/es/es_PEZes_PHzJhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/es/es_PHZes_PRzJhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/es/es_PRZes_PYzJhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/es/es_PYZes_SVzJhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/es/es_SVZes_USzJhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/es/es_USZes_UYZes_VEzJhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/es/es_VEZetzMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/et_EE/et_EEZet_EEZfazMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/fa_IR/fa-IRZfa_IRZfrzJhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/fr_FR/frZfr_BEZfr_BFZfr_BIZfr_BJZfr_BLZfr_CAZfr_CDZfr_CFZfr_CGZfr_CHZfr_CIZfr_CMZfr_DJZfr_DZZfr_FRZfr_GAZfr_GFZfr_GNZfr_GPZfr_GQZfr_HTZfr_KMZfr_LUZfr_MAZfr_MCZfr_MFZfr_MGZfr_MLZfr_MQZfr_MRZfr_MUZfr_NCZfr_NEZfr_PFZfr_PMZfr_REZfr_RWZfr_SCZfr_SNZfr_SYZfr_TDZfr_TGZfr_TNZfr_VUZfr_WFZfr_YTZgdzMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/gd_GB/gd_GBZgd_GBZglzJhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/gl/gl_ESZgl_ESZguzMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/gu_IN/gu_INZgu_INZgugzIhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/gug/gugZhezMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/he_IL/he_ILZhe_ILZhizMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/hi_IN/hi_INZhi_INZhrzMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/hr_HR/hr_HRZhr_HRZhuzMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/hu_HU/hu_HUZhu_HUZidzJhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/id/id_IDZid_IDZiszGhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/is/isZis_ISZitzMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/it_IT/it_ITZit_CHZit_ITZku_SYzShttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/kmr_Latn/kmr_LatnZku_TRZkmrZkmr_SYZkmr_TRZkmr_LatnZkmr_Latn_TRZkmr_Latn_SYZknzMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/kn_IN/kn_INZkn_INZkozMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/ko_KR/ko_KRZko_KRZlozMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/lo_LA/lo_LAZlo_LAZltzJhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/lt_LT/ltZlt_LTZlvzMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/lv_LV/lv_LVZlv_LVZmnzMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/mn_MN/mn_MNZmn_MNZmrzMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/mr_IN/mr_INZmr_INZnezMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/ne_NP/ne_NPZne_INZne_NPZnlzMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/nl_NL/nl_NLZnl_AWZnl_BEZnl_NLZnbzJhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/no/nb_NOZnb_NOZnb_SJZnnzJhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/no/nn_NOZnn_NOZoczMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/oc_FR/oc_FRZoc_FRZorzMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/or_IN/or_INZor_INZpazMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/pa_IN/pa_INZpa_INZplzMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/pl_PL/pl_PLZpl_PLZptzMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/pt_BR/pt_BRZpt_BRZpt_PTzMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/pt_PT/pt_PTZrozJhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/ro/ro_ROZro_ROZruzMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/ru_RU/ru_RUZru_RUZru_UAZsazMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/sa_IN/sa_INZsa_INZsizMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/si_LK/si_LKZsi_LKZskzMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/sk_SK/sk_SKZsk_SKZslzMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/sl_SI/sl_SIZsl_SIZsqzMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/sq_AL/sq_ALZsq_ALZsr_LatnzLhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/sr/sr-LatnZsrzGhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/sr/srZsr_CyrlZsr_MEZsr_RSZsr_YUZsvzMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/sv_SE/sv_SEZsv_FIzMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/sv_SE/sv_FIZsv_SEZswzMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/sw_TZ/sw_TZZsw_KEZsw_TZZtazMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/ta_IN/ta_INZta_INZtezMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/te_IN/te_INZte_INZthzMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/th_TH/th_THZth_THZtrzMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/tr_TR/tr_TRZtr_TRZukzMhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/uk_UA/uk_UAZuk_UAZvizJhttps://raw.githubusercontent.com/LibreOffice/dictionaries/master/vi/vi_VNZvi_VNc                s$   V ^8  d   QhR\         R\         R\        \        \         .R3,          ,          R\        \        \        .R3,          ,          R\        \        \        .R3,          ,          R\        \
        P                  ,          RR/# )	   url	dest_path	on_outputNon_progresson_completecancellablereturn)strr   r   floatInstallStatusr	   CancellableZformat   ";/usr/share/ibus-typing-booster/setup/dictionary_download.py__annotate__r     s     m5 m5	m5m5 #-.m5 (E7D=12	m5
 (M?D#89:m5 #//*m5 
m5    c                s  aaaaaaa  \         P                  ! \         P                  P                  V4      RR7        \        P                  P                  V4      pVP                  RR\        P                  P                  S4      o\         P"                  ^8X  dh   \         P$                  ! 4       p	\         P&                  P)                  R
T 4      p
R TTTTT3R llpT	P+                  T
\        P,                  STT
4       R# \         P.                  ! 4       p\         P&                  P)                  R
T 4      pRo^ oR T3R llpR TTTTTTT3R llpR TTTT3R llpTP1                  RT4       TP1                  RT4       TP1                  RT4       TP3                  TR4       R#   \         dc   p\
        P                  RT4       S'       d   S! RT 24       S'       d'   S'       d   SP                  4       '       g	   S! R4        Rp?ELRp?ii ; i  \        P                   dE   p\
        P                  RT4       S'       d   S! R	T 24       S'       d	   S! R4        Rp?R# Rp?ii ; i)a`  Download a file from url to dest_path asynchronously.

Using libsoup async instead of Gio.File.copy_async, which is
broken on Ubuntu for HTTP URIs.

on_output(line):       textual log
on_progress(fraction): 0.0..1.0 progress fraction
                       for the current file(may be coarse)
on_complete(status):   'success' | 'failure' | 'cancelled'
T)exist_okzFailed to make directory: %szFailed to make directory: failureNFzFailed to open destination: %szFailed to open destination: ZGETc                s(    V ^8  d   QhRRRRRRRR/# )	r   sessionzSoup.SessionresultzGio.AsyncResultmsgSoup.Messager   N r   r   r   r   )download_file_async.<locals>.__annotate__  s6     D	/ D	/'D	/)D	/ $D	/ 	D	/r    c                 s  <  V P                  V4      pR p VP                  4       p\        P
                  P                  T4      p SP                  TS4        SP                  S4       S'       d	   S! R4       S
'       d   S
! \        T4      R,          R	 R
24       TP                  4       pT\        P                  P                   8X  d%   S
'       d	   S
! R4       S	'       d   S	! R4       R # R # S
'       d   S
! RT 24       S	'       d   S	! R4       R # R #   \         dD     \        T4      p EL  \         d&    S
'       d	   S
! R4       S	'       d	   S	! R4         R # i ; ii ; i  \        P                   dE   p\        P                  RT4       S
'       d   S
! RT 24       S	'       d	   S	! R4        R p?R # R p?ii ; i  \        P                   dE   p\        P                  RT4       S
'       d   S
! RT 24       S	'       d	   S	! R4        R p?R # R p?ii ; i  \        P                   d   pS'       dC   SP#                  4       '       d-   S
'       d	   S
! R4       S	'       d   S	! R4        R p?R #  R p?R # \        P                  RT4       S
'       d   S
! RT 24       S	'       d   S	! R4        R p?R #  R p?R # R p?ii ; i)Nz'Failed: could not obtain response bytesr"   Write failed: %sWrite failed: zFailed to close output: %szFailed to close output:       ?      @.1f KiB	Finished.successFailed: HTTP z
Cancelled.	cancelledzFailed to send request: %szFailed to send request: )Zsend_and_read_finishget_data	ExceptionZbytesr   ZBytesnewZwrite_bytesErrorLOGGER	exceptioncloselenZ
get_statusr
   ZStatusZOKis_cancelled)r#   r$   r%   Zbody
data_bytesZgbyteserrstatusr   r   r   r   
out_streams   &&&     r   on_read_finishedZ-download_file_async.<locals>.on_read_finished  sD   
?/ 33F;.2
!%J 
3**6;?$$[1 $Z!7 <DAB)T[[^^+ !+."#I. # !!M&":;"#I. #U ! 	%*4[
$ $%&OP&'	2		 zz $$%7= !N3%"89"#I. zz $$%A3G !$<SE"BC"#I., :: /;#;#;#=#= !,/"#K00 # $$%A3G !$<SE"BC"#I.. #/s  H" D H" E* G +H" 3H" AH" H" &H" 2H" :H" H" E'%D30H" 3E#E#E#E'H" "E##E''H" *G?0F>0F>8H" >GH" H0HHH" HH" "K7KKK-KKK2KKc                     V ^8  d   QhRRRR/# r   r%   r&   r   Nr'   r   r   r   r   r(   F  s     @ @ @4 @r    c                 s<   < V P                   P                  4       oR # N)Zresponse_headersZget_content_length)r%   total_bytes   &r   
on_headersZ'download_file_async.<locals>.on_headersF  s    **==?r    c                s$    V ^8  d   QhRRRRRR/# )r   _msgr&   chunkzSoup.Bufferr   Nr'   r   r   r   r   r(   J  s!     : :~ :m : :r    c                 s  < VP                  4       pS
\        V4      ,          o
 S	P                  VS4       S'       d#   S^ 8  d   \        RS
S,          4      pS! T4       S'       d   S! S
R,          R R24       R# R#   \        P                   dE   p\
        P                  R T4       S'       d   S! RT 24       S'       d	   S! R4        Rp?R# Rp?ii ; i)r)   r*   r"   Nr+   r,   r-   r.   )r3   r:   Zwriter   r6   r7   r8   Zmin)rG   rH   r<   r=   Zfracr   r   r   r   r?   received_bytesrD   s   &&   r   on_chunkZ%download_file_async.<locals>.on_chunkJ  s    ^^%
#j/)	Z5 ;?sN[89D.s3489  zz 	/5N3%01I&	s   B   C0CCCc                rA   rB   r'   r   r   r   r   r(   ]  s     # # #D #r    c                 s&  <  SP                  S4       V P                  ^8X  d#   S'       d	   S! R4       S'       d	   S! R4       R# S'       d   S! RV P                   24       S'       d   S! R4       R# R#   \        P                   d     L{i ; i)i   r/   r0   Nr1   r"   )r9   r   r6   Zstatus_code)r%   r   r   r   r?   s   &r   on_finishedZ(download_file_async.<locals>.on_finished]  s|    	[) ??c!+&I&coo%678	"  zz 		s   A8 8BBZgot_headersZ	got_chunkZfinishedi)osZmakedirspathdirnamer4   r7   r8   r;   r	   ZFileZnew_for_pathZreplaceZFileCreateFlagsZNONEr   r6   r
   ZMAJOR_VERSIONZSessionZMessager5   Zsend_and_read_asyncZPRIORITY_DEFAULTZSessionAsyncconnectZqueue_message)r   r   r   r   r   r   errorZ	dest_filer=   r#   Zmessager@   Zsession_soup2Zmessage_soup2rF   rJ   rK   r?   rI   rD   s   &&ffff           @@@r   download_file_asyncrQ     s   $#
BGGOOI.>HH)))4	&&$$	
 Q"&,,."&,,"2"25#">D	/ D	/L 	##!!	 	 	 $(LL$4$4UC$@MKN@ @: :&# #  -4+x0*k2t4s  #7?25':;0H0H0J0J	"# :: 93?4SE:;	"sG   5F- AH -H80H)H1HHHI620I1#I11I6c                s.   V ^8  d   QhR\         \        ,          R\        \        \        .R3,          ,          R\        \        \        .R3,          ,          R\        \        \
        .R3,          ,          R\        \        P                  ,          RR/# )r   	languagesr   Nr   r   r   r   )r   r   r   r   r   r   r	   r   r   r   r   r   r   r  s     I I3xI#-.I (E7D=12I (M?D#89:	I
 #//*I 
Ir    c           
     s8  aaaaaa	a
 . o
\        V 4       Fg  p\        P                  VR4      pV'       g   K#  R F>  pS
P                  RV V 2R\        P
                  ! R4      V,           V,           /4       K@  	  Ki  	  / o	R	R VVVVVV	V
3R llloS! 4        R# )
z/Download dictionaries sequentially, one by one. r   destibus-typing-booster/data/c                (    V ^8  d   QhR\         RR/# )r   indexr   N)intr   r   r   r   Z>download_dictionaries_sequentially_async.<locals>.__annotate__  s     1% 1%S 1% 1%r    c           	     sh  <a aa S'       d>   SP                  4       '       d(   \        P                  R4       S	'       d	   S	! R4       R# S \        S4      8  dL   \	        SP                  4       4      p\        P                  RV4       S	'       d   S	! V'       d   RMR4       R# SS ,          R,          oSS ,          R,          o\        P                  R	SS ^,           \        S4      4       S
'       d   S
! R
S R24       R V
3R llpR V3R llpR VVV V
VV3R llp\        SSVVVSR7       R# )zDownload the next urlz&Download cancelled, stopping sequence.r2   NzAll downloads done: success=%sr0   r"   r   rT   zDownloading url %s (%d/%d)   📥 z...c                rV   r   liner   Nr   r   r   r   r   Udownload_dictionaries_sequentially_async.<locals>.download_next.<locals>.__annotate__  s     	  	  	  	 r    c                ,   < S'       d   S! V 4       R# R# )zCall on_outputNr'   )r[   r   rE   r   handle_outputZVdownload_dictionaries_sequentially_async.<locals>.download_next.<locals>.handle_output  s    $ r    c                rV   r   fractionr   Nr   r   r   r   r   r]     s     	& 	&e 	& 	&r    c                r^   )zCall on_progressNr'   )ra   r   rE   r   handle_progressZXdownload_dictionaries_sequentially_async.<locals>.download_next.<locals>.handle_progress  s    H% r    c                rV   r   r>   r   Nr   r   r   r   r   r]     s     	% 	%M 	%d 	%r    c                s   < V R8H  SS&   S'       d   S! S RS RV R8X  d   RMR 24       V R8X  d   \         P                  RS4       R# S! S^,           4       R# )	zCalled when one url is completed

Puts easily parsable lines into the output to make it
easy for dialog to update the progress.
r0   u    ➡️ Z    ✔️   ⚠️r2   z%Installation cancelled before url #%dNr7   info)r>   destinationdownload_nextrW   r   resultsr   s   &r   handle_completeZXdownload_dictionaries_sequentially_async.<locals>.download_next.<locals>.handle_complete  s`     "Y.GCLSE+aFiDW]e7fgh$CUK%!)$r    r   r   r   r   )r;   r7   ri   r:   ZallZvaluesrQ   )rW   r0   r_   rc   rm   rj   r   r   rk   r   r   r   rl   url_lists   f    @@r   rk   Z?download_dictionaries_sequentially_async.<locals>.download_next  s    ;3355KK@AK(CM!'..*+GKK8'BIi@uoe$uof-0#uqy#h-PcU#&'	  	 
	& 	&
	% 	% 	#''#	%r    N)z.dicz.aff)i    )sortedDICTIONARY_SOURCESZgetZappenditb_utilxdg_save_data_path)rR   r   r   r   r   ZlanguageZurl_basesuffixrk   rl   ro   s   &ffff   @@@r   (download_dictionaries_sequentially_asyncru   r  s     &(H9%%))(B7&FOO(F8,++,GH#$% & '	 &  "G1% 1% 1%f Or    c                rV   )r   data_dirr   Nr\   r   r   r   r   r     s     +U +Uc +Ud +Ur    c           
     s   \         P                  P                  4       R,          R,          p\         P                  ! V 4      pVP                  4       '       g   \        P                  RV 4       R# R EF  pW,          pVP                  RRR7       VP                  R4       FZ  pVP                  4       '       g   K  VP                  4       '       d   K3  \        P                  RV4        VP                  4        K\  	  \         P                  ! V 4      P                  R
4       F  pR F  pW'P                   RV 2,          p	V	P                  4       '       g   K2  WIP                  ,          p
 V
P                  4       '       d@   V
P                  4       '       d   V
P                  4        M\        P                  RV
4       K  \        P                   ! W4       \        P                  RW4       K  	  K  	  EK  	  R#   \         d#   p\        P                  R	YV4        Rp?EK  Rp?ii ; i  \         d$   p\        P                  RYT4        Rp?EK.  Rp?ii ; i)zEnsure Enchant hunspell/nuspell directories link to downloaded dictionaries.

Creates or replaces symlinks for *.dic/*.aff in data_dir under
~/.config/enchant/{hunspell,nuspell}/, and cleans up broken symlinks.
z.configZenchantz!Data directory does not exist: %sNT)Zparentsr!   Z*zRemoving broken symlink: %sz&Failed to remove broken symlink %s: %sz*.dicZ.z'Preserving existing user dictionary: %su   Linked %s → %su&   Failed to create symlink %s → %s: %s)ZhunspellZnuspell)ZdicZaff)pathlibZPathZhomeZexistsr7   ZwarningZmkdirZglobZ
is_symlinkri   ZunlinkZOSErrorrP   ZstemZnamerL   Zsymlink)rv   Zconfig_rootZ	data_pathZbackendZbackend_dirZlinkr=   Z	dict_filert   ZsourcerT   s   &          r   ensure_enchant_symlinksrx     s    ,,##%	1I=KX&I:HE*!+$6$$S)D  94@MKKM	 * !h/44W=I("'7q%AA}}"[[0U{{}}??,, KKM"KK I4Q$JJv,KK 2DA ) > +  MLL@$M MM*  ULL@$PSU UUs<   -H 0+H0'H0,H0 H-H((H-0I	;I	I	c                s    V ^8  d   QhR\         \        P                  ,          R\        \        ,          R\         \
        ,          RR/# )r   parentrR   r   r   N)r   r   ZWindowr   r   CompleteCallbackr   r   r   r   r     sI     y ySZZ y3xy *+y 
	yr    c                s  aaaaaaaaaaaa \         P                  ! R\        R4      ,           V RRR7      oSP                  RR4       SP	                  4       p\         P
                  ! RR7      oSP                  ^ 4       \        VS4       \         P                  ! 4       oSP                  R	4       SP                  \         P                  P                  4       SP                  4       o\         P                  ! 4       pVP                  R4       VP!                  \         P"                  P$                  \         P"                  P$                  4       \        VS4       \        W44       \         P&                  ! 4       oSP)                  R4       SP+                  R
4       \        VS4       \         P,                  ! 4       pVP/                  \         P0                  P2                  4       VP5                  \         P6                  P8                  4       VP;                  \         P6                  P<                  4       VP?                  R	4       VPA                  R4       VP                  R	4       VPC                  ^ 4       \        W54       \         PD                  PG                  \        R4      4      o\        VS4       \         PD                  PG                  \        R4      4      o\        VS4       \I        S4       SPK                  R	4       ^ o^\M        V4      ,          o\N        PP                  ! 4       oR VVVV3R llpR VVV3R llpR VVVVVV3R llpR VVV3R llp	R VV3R llp
SPS                  RV	4       SPS                  RV
4       \U        VVVVSR7       Ro\V        PX                  ! 4       ^ 8  d   R# \V        PZ                  ! 4       oSP]                  4        SP_                  4        R# )zDShow a transient GTK dialog to download dictionaries asynchronously.rY   zDownload dictionariesT)ZtitleZtransient_forZmodalZdestroy_with_parenti  i  rS   )ZlabelFz0%Z_CancelZ_Closec                rV   rZ   r\   r   r   r   r   7download_dictionaries_with_dialog.<locals>.__annotate__  s     J J# J$ Jr    c                s6  < SP                  4       pSP                  WR,           4       SP                  SP                  4       4       RV 9   g   RV 9   dC   S^,          oSP	                  4       pRpSP                  V'       d	   W#,           MR V  24       R# R# )z9Append a line to the textbuffer showing detailed progressZ
rf   rg   rS   N)get_end_iterinsertZscroll_mark_onscreenZ
get_insertZget_textset_text)r[   endZtextZnewline
textbuffertextview	top_label	url_indexs   &   r   append_lineZ6download_dictionaries_with_dialog.<locals>.append_line  s     %%'#d{+%%j&;&;&=>tx4/NI%%'DGD$.b!A$HI  0r    c                rV   r`   rb   r   r   r   r   r{   *  s     I IU It Ir    c           
     s   < \        SP                  4       SV ,           S,          4      pSP                  V4       SP                  S RS R\	        V^d,          4       R24       R# )z1Update the progressbar showing the total progress/z (z%)N)ZmaxZget_fractionset_fractionr~   rX   )ra   Zcurrent_fractionprogressbar	url_countr   s   & r   update_progressbarZ=download_dictionaries_with_dialog.<locals>.update_progressbar*  si     $$&X)=(JL  !12k9+R,<s,B(C'DBG	Ir    c                rV   rd   re   r   r   r   r   r{   4  s        }    r    c                s  < V R8X  dI   SP                  R4       SP                  S RS R24       \        \        P                  ! R4      4       MLV R8X  d$   SP                  4       pSP                  VR4       M"SP                  4       pSP                  VR4       SP                  R	4       SP                  R
4       S'       d   S! V 4       R# R# )z/Installation of all urls finished or cancelled.r0   r+   r   z (100%)rU   r2   u#   ⚠️ Download cancelled by user.
u   ❌ There were some failures.
FTN)r   r~   rx   rr   rs   r|   r}   set_visible)r>   r   cancel_buttonclose_buttonr   r   r   r   s   & r   finishZ1download_dictionaries_with_dialog.<locals>.finish4  s    Y$$S)  I;a	{'!BC#++,GHJ{"))+Cc#IJ))+Cc#DE!!%(  & r    c                <    V ^8  d   QhR\         P                  RR/# r   _buttonr   Nr   Buttonr   r   r   r   r{   F  s     ' '3:: '$ 'r    c                sl   < SP                  4        SP                  R4       SP                  R4       R# )zCancel button clickedFTN)Zcancelr   )r   r   r   r   s   &r   	on_cancelZ4download_dictionaries_with_dialog.<locals>.on_cancelF  s+    !!%(  &r    c                r   r   r   r   r   r   r   r{   L  s      #**  r    c                s|   < Se'   SP                  4       '       d   SP                  4        SP                  4        R# )zClose button clickedN)Z
is_runningZquitdestroy)r   dialogglib_main_loops   &r   on_closeZ3download_dictionaries_with_dialog.<locals>.on_closeL  s-    %.*C*C*E*E!r    Zclickedrn   N)0r   ZDialogr   Zset_default_sizeZget_content_areaZLabelZ
set_xalignr   ZTextViewZset_editableZset_wrap_modeZWrapModeZ	WORD_CHARZ
get_bufferZScrolledWindowZset_vexpandZ
set_policyZ
PolicyTypeZ	AUTOMATICZProgressBarZset_show_textr~   ZBoxZset_orientationZOrientationZ
HORIZONTALZ
set_halignZAlignZENDZ
set_valignZCENTERZset_can_focusZset_hexpandZset_spacingr   Znew_with_mnemonicr   r   r:   r	   r   rO   ru   r   Z
main_depthZMainLoopZrunr   )ry   rR   r   ZvboxZscrolledZaction_arear   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   s   &&f        @@@@@@@@@@@r   !download_dictionaries_with_dialogr     s    ZZ122 	"F
 C%""$D		#IdI||~H% 3<<112$$&J!!#H00#..2J2JKh!d//#Kd#dK '')K : :;399==)399++,e$D!E"Ad JJ009>Mk=):://(<Lk<(VU#IY'I#&??#4KJ JI I   $' '  )Y/H-,&! /3N 1]]_N
NNr    Z__main__)ZstreamrS   z.IBUS-WARNING **: Using the fallback 'C' localeZCc                rV   rd   re   r   r   r   r   r   q  s     9 9M 9d 9r    c                s    V R8X  d   \         P                  R4       R# V R8X  d   \         P                  R4       R# \         P                  R4       R# )z$Called when downloads have completedr0   z!Install completed without errors.r2   u&   ⚠️ Installation cancelled by user.u   ❌ There were some failures.Nrh   )r>   s   &r   finish_testr   q  s9    YKK;<{"KK@AKK78r    :Ni   N)r   )i   i   )r0   r2   r"   rC   )@Z__doc__Ztypingr    r   r   r   r   r   ZsysZversion_infor   Ztyping_extensionsr   r   ZOutputCallbackrz   rw   rL   ZlocaleZloggingZgir   Zgi.repositoryr   r	   r
   r4   Zi18nr   r   Z	i18n_initrM   r}   ZjoinrN   Z__file__rr   Zitb_gtkr   Zg_compat_helpersr   r   Z	getLoggerr7   rq   rQ   ru   rx   r   Z__name__ZStreamHandlerZstderrZLOG_HANDLERZsetLevelZDEBUGZ
addHandlerZ	setlocaleZLC_ALLr6   r8   r   Zsetrp   Zkeysr'   r    r   <module>r      sQ  &
        
v)9:3%+&]OT12   	      u   #FE"" & 277<< 94J K   " 
		0	1o
Yo\o 	
Yo \	o
 	
So Vo Vo Vo Vo Vo Vo Vo Vo Vo Vo  V!o" V#o$ V%o& V'o( V)o* V+o, V-o. V/o0 V1o2 V3o4 V5o6 V7o8 V9o: V;o< V=o> 	
Y?o@ \AoH 	
_IoJ bKoL 	
YMoN \OoP 	
YQoR \SoT \UoV 	
SWoX VYoZ V[o\ 	
Y]o^ \_o` 	
Yaob \cod 	
`eof cgoh cioj ukol cmon coop 
cqor fsot 	
Yuov \wox 	
Yyoz \{o| 	
\}o~ _o@ _AoB _CoD _EoF _GoH _IoJ _KoL 	
YMoN \OoP \QoR 	
VSoT ZUoV ZWoX YYoZ Y[o\ Y]o^ Y_o` Yaob Ycod Yeof Ygoh Yioj Ykol Ymon Yoop Yqor Ysot Yuov Ywox Yyoz Y{o| Y}o~ Yo@ YAoB YCoD YEoF YGoH YIoJ YKoL YMoN YOoP YQoR YSoT YUoV YWoX YYoZ Y[o\ Y]o^ Y_o` Yaob Ycod Yeof Ygoh Yioj Ykol Ymon Yoop Yqor Ysot Yuov Ywox Yyoz Y{o| Y}o~ Yo@ YAoB YCoD YEoF YGoH YIoJ YKoL YMoN YOoP YQoR YSoT YUoV YWoX YYoZ Y[o\ Y]o^ Y_o` Yaob Ycod Yeof Ygoh Yioj Ykol Ymon Yoop Yqor Ysot Yuov Ywox Yyoz Y{o| Y}o~ Yo@ YAoB YCoD YEoF YGoH YIoJ YKoL YMoN YOoP YQoR YSoT _UoV YWoX YYoZ Y[o\ Y]o^ Y_o` Yaob Ycod Yeof 	
Sgoh 	
Vioj Zkol Ymon Yoop Yqor Ysot Yuov Ywox Yyoz Y{o| Y}o~ Yo@ YAoB YCoD YEoF YGoH YIoJ YKoL YMoN YOoP YQoR YSoT YUoV YWoX YYoZ Y[o\ Y]o^ Y_o` 	
Yaob \cod 	
Yeof \goh 	
Vioj Ykol Ymon Yoop Yqor Ysot Yuov Ywox Yyoz Y{o| Y}o~ Yo@ YAoB YCoD YEoF YGoH YIoJ YKoL YMoN YOoP YQoR YSoT YUoV YWoX YYoZ Y[o\ Y]o^ Y_o` Yaob Ycod Yeof Ygoh Yioj Ykol Ymon Yoop Yqor Ysot Yuov Ywox Yyoz Y{o| Y}o~ Yo@ YAoB YCoD YEoF 	
YGoH \IoJ 	
VKoL YMoN 	
YOoP \QoR 
VSoT 	
YUoV \WoX 	
YYoZ \[o\ 	
Y]o^ \_o` 	
Yaob \cod 	
Veof Ygoh 	
Sioj Vkol 	
Ymon \oop \qor bsot buov 
`wox cyoz c{o| e}o~ ho@	 hA	oB	 	
YC	oD	 \E	oF	 	
YG	oH	 \I	oJ	 	
YK	oL	 \M	oN	 	
VO	oP	 YQ	oR	 	
YS	oT	 \U	oZ	 	
Y[	o\	 \]	o^	 	
Y_	o`	 \a	ob	 	
Yc	od	 \e	of	 \g	oh	 	
Yi	oj	 \k	ol	 \m	on	 \o	op	 	
Vq	or	 Ys	ot	 Yu	ov	 	
Vw	ox	 Yy	oz	 	
Y{	o|	 \}	o~	 	
Y	o@
 \A
oB
 	
YC
oD
 \E
oF
 	
YG
oH
 \I
oJ
 	
YK
oL
 \M
oN
 \O
oP
 	
VQ
oR
 YS
oT
 	
YU
oV
 \W
oX
 \Y
oZ
 	
Y[
o\
 \]
o^
 	
Y_
o`
 \a
ob
 	
Yc
od
 \e
of
 	
Yg
oh
 \i
oj
 	
Yk
ol
 \m
on
 ]o
op
 	
Sq
or
 Xs
ot
 Vu
ov
 Vw
ox
 Vy
oz
 	
Y{
o|
 \}
o~
 \
o@ 	
YAoB \CoD \EoF 	
YGoH \IoJ 	
YKoL \MoN 	
YOoP \QoR 	
YSoT \UoV 	
Y\
VY]o hm5 m5^I IV+UZy yv z''szz:K
OOGMM"
k"-+ K9 &F%**,-b12 + a  #FE"""#n << -IJ,-s%   !_ (_$ _! _!$A`('`(