o4i:BddlZddlmZddlmZmZGddeZdZy)N) ElementTree)User UserExceptioncveZdZdZfdZdZdZedZe dZ edZ dZ d Z d Zd ZxZS) TranslationFilez! Encapsulate a translation file. c t|d i|tjj |rJ|j dj | tj|j|_ ntjt|_ ||_||_||_i|_i|_i|_g}|jD]}|j,dk7r|j/|d}g} |D]?} | j,dk(r | j0}| j,dk(s/| j/| A|so| |j(|<| D]e} | j3d } | | j0s#| j3d } | | j0sC| j0|j*| j0<g|D]}|jj5|d |_d |_d |_d |_d |_d |_ d |_!g|_"y#t$r*}tdj |dt|d}~wwxYw) z" Initialise the translation file. zReading {0}...z {}: {}: {}zinvalid translation fileNcontextnamemessagesource translationr)#super__init__ospathisfileprogressformatrparsegetroot_root Exceptionrstr fromstring _EMPTY_TS_ts_file _no_obsolete _no_summary_updated_contexts _contexts _translationstagappendtextfindremove_nr_new_nr_new_duplicates"_nr_new_using_existing_translation _nr_existing_nr_kept_obsolete_nr_discarded_obsolete_nr_discarded_untranslated_new_message_els)selfts_file no_obsolete no_summarykwargse context_els context_elr message_elsel message_el source_eltranslation_el __class__s j/mnt/ssd/data/python-lab/DaemonControl/venv/lib/python3.12/site-packages/PyQt6/lupdate/translation_file.pyrzTranslationFile.__init__sA "6" 77>>' " MM*11': ; E(..w7??A %// :DJ '%!#  ** MJ~~*   z *DK  +66V#77DVVy(&&r*  + '2t$"- MJ * 9I (  %/__]%CN%-^5H5H 9G9L9LD&&y~~6 M% M>& *J JJ  j ) * "#23/!"&'#*+'!#E E#$++G :CFDEE Es(H I%IIc |jdj|j|j|jD]} |j |j }|j|j }|jD]}|j||}|$|j||j||n|j||}|q|j|}|j||jdj|j|j |xj"dz c_n|jdj|j|j |j%dD]C}|j'ddk(s|j(r|j*d=2|j-dd E||j.vr|xj0dz c_n|xj2dz c_|j5d |j7|y#t$rg}YwxYw) z7 Update the translation file from a SourceFile object. zUpdating {0} from {1}...NzAdded new message '{0}'rzUpdated message '{0}'rtypevanished unfinishedr)rrrfilenamecontextsr#r KeyError_get_updated_message_elsmessages _find_messager)_add_message_el_make_message_elr&prettyrr*findallgetr'attribsetr1r+r-insert_make_location_el)r2rr r:updated_message_elsr r<r>s r@updatezTranslationFile.updatejs *11$--) *5 FG !"nnW\\: #'"?"? "M "+++ F!//E )&&z2((5HI"&!3!3G,".J%!%!6!6w!?J'..z:MM5<<$(KK$?ABLLA%LMM3::$(KK$?AB+5*<*<]*KI)--f5C-22$2$9$9&$A . 2 26< H I"T%:%:://14/))Q.)!!!T%;%;G%DEW+ F5 F !  !sH99 IIc|jjD]>\}}d}|D]0}|j|jdj}|jd}||jr|j r6|j dj||xjdz c_|jdd||j|}|j|||j dj||xjdz c_ |j d j||xjdz c_ 3At|jj!D]}}t#j$d }t#j$d }||_|j'||j)|j||j*j'||j d j|j,|j*D]} t#j.| d t1|j,ddd5} | j3d| j3dt#j"|j*j3| d| j3dddd|j4s|j7yy#1swY'xYw)z4 Write the translation file back to the filesystem. Nrrz Discarded obsolete message '{0}'rrBrCzKept obsolete message '{0}'z$Discarded untranslated message '{0}'r r zWriting {0}... )spacewzutf-8 )encodingnewlinez' z unicode)r[)r#itemsrMr(r'r rrr/rQrHrKr.r0sortedr"keysrElementr&extendrrindentopenwriter!_summary) r2r r:rTr<rr>r9name_elr;fs r@rezTranslationFile.writes "&!5!5!7 9 D+"& ) 9 Z__X%>%C%CD!+!?!-.2E2E(( B I I(.!0133q83&**6:>.6262O2O$(3*/,,Z9LM = D DV LN..!3.MMBII$*,-33q835 9 9@4116689 *D$,,Y7J!))&1GGL   g &   d44T: ; JJ  j ) * &--dmm<=** 1B   r 0 1$--w E  GG> ? GG% &  # #DJJ / 5 5a) 5 L GGDM    MMO   s +A$K55K>ct|jdD]}|j||j|y)z> Add a message element to a list of updated message elements. locationN)rNr)r&)r<rT location_els r@rKzTranslationFile._add_message_els< &--j9 +K   k * + "":.c|D]}d}d}d}g}|D]}|jdk(r |j}|jdk(r |j};|jdk(r |j}W|jjdss|j|jdd|jg||jk7r||j k7r||j |k7r||jjk7r|cSy)z7 Return the message element for a message from a list. r rcomment extracommentextra-N) r%r' startswithr&rrn_get_message_extra_commentsembedded_commentsextras) clsr r:r<rrn extra_commentrur;s r@rJzTranslationFile._find_messages& JFGMF! 966X%WWFVVy( ggGVV~-$&GGMVV&&x0MM266!":rww"78 9''//) ? ? HH22999 = @rlcLdj|jjS)zA Return a message's extra comments as they appear in a .ts file.  )joinrtextra_comments)r s r@rsz+TranslationFile._get_message_extra_commentssxx11@@AArlch |j|}|S#t$rg}||j|<Y|SwxYw)z< Return the list of updated message elements for a context. )r"rG)r2r rTs r@rHz(TranslationFile._get_updated_message_elssM ?"&"8"8">  #"  ?"$ +>D " "4 (""  ?s 11c 2tjdtjj |j tjj tjj|jt|jS)z Return a 'location' element. rj)start)rEline) rrarrrelpathrEdirnameabspathrrline_nr)r2r s r@rSz!TranslationFile._make_location_el*sd"":)9)9 ggoobggoodmm.LM)O)+ +rlci}|jjr|jj|d<|jrd|d<tjd|}tjd}|j |_|j||jr7tjd}|j|_|j||jjrrfieldvaluer;s r@rLz TranslationFile._make_message_el2s  $ $ / /!33>>E$K ??$E)  ((E: ''1   )$ ??$,,Y7J%ooJO   j )  $ $ 3 3)11.AO#'#C#CG#LO   o .$,,]!# ((,,W^^< "-N  MM;BB KK79 :  3 3q 8 3 ??  ! !+"5"5!## $ .)#55<< "LE5$$X%56BBG   b ! " $$Z0rlcPgfd}jrZjr-|djjjn!|djjjr!|djjjr!|djjj r!|djj j r!|djj jr!|djjs+jd jj ttjjy ) z- Display the summary of changes to the user. cs+jdjjjd|zy)NzSummary of changes to {ts}:tsrW)r&rr)rr2 summary_liness r@summaryz)TranslationFile._summary..summaryps@!$$5<< <NP  $ /rlz0{0} new messages were added (and {1} duplicates)z{0} new messages were addedz){0} messages reused existing translationsz {0} existing messages were foundz{0} obsolete messages were keptz${0} obsolete messages were discardedz({0} untranslated messages were discardedz{ts} was unchangedrN)r*r+rr,r-r.r/r0r&rprintrlineseprz)r2rrs` @r@rfzTranslationFile._summaryjsl  0 <<&&JQQ d&=&=?@5<    6==%%' (  ! ! 5<<**, -  & & :AA//1 2  * * >EE335 6  !5!@//##JBB #+6p-.rlrz )r xml.etreeruserrrrrrrlr@rs&& !%~.d~.F   rl