8,j<JddlZddlmZddlmZmZGddeZdZdS)N) ElementTree)User UserExceptionceZdZdZfdZdZdZedZe dZ edZ dZ d Z d Zd ZxZS) TranslationFilez! Encapsulate a translation file. c ~tjd i|tj|r|d| tj| |_ na#t$r6}td|dt|d}~wwxYwtjt|_ ||_||_||_i|_i|_i|_g}|j D]}|jdkr||d}g} |D]5} | jdkr| j}| jdkr| | 6|ra| |j|<| D]T} | d } | | js!| d } | | js@| j|j| j<U|D]}|j |d |_d |_d |_d |_d |_d |_ d |_!g|_"dS) 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 NC:\PYTHON\GemmaClient\venv\Lib\site-packages\PyQt6/lupdate/translation_file.pyrzTranslationFile.__init__s ""6""" 7>>' " " ; MM*11':: ; ; ; E(.w77??AA  E E E#$++G :CFFDDEEE E %/ ::DJ '%!#  * M MJ~**   z * * *DK  + +6V##7DDVy((&&r*** M'2t$"- M MJ * 9 9I ( ( %/__]%C%CN%-^5H- 9G9LD&y~66& * *J J  j ) ) ) ) "#23/!"&'#*+'!#s#+B C1C  Cc |d|j|j|jD]} |j|j}n#t$rg}YnwxYw||j}|j D]}| ||}|,| || ||n| ||}|{| |}|||d||j|xjdz c_n|d||j|dD]A}|ddkr&|jr |jd=+|dd B||jvr|xjdz c_n|xjdz c_|d ||ƐdS) 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 F5 FG !"nW\:  ! ! !  !#'"?"? "M"M "++ F+ F!//EE )&&z222((5HIIII"&!3!3G,".".J%!%!6!6w!?!?J'..z:::MM5<<$(KK$?$?AABBBLLA%LLLMM3::$(KK$?$?AABBB+5*<*<]*K*KII)--f55CC-2I$2$9&$A$A . 2 26< H H H"T%::://14///))Q.))!!!T%;%;G%D%DEEEEW+ F5 F5 FsA A! A!cR|jD]O\}}d}|D]C}||dj}|d}||jr|jr9|d||xjdz c_| dd|| |}| |||d||xj dz c_  |d ||xj dz c_ EQt|jD]}t#jd }t#jd }||_||||j||j||d |jt/|jd dd5} | d| dt3t"drt#j|jt#j|j| d| ddddn #1swxYwY|js|dSdS)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}...wzutf-8 )encodingnewlinez' z indentunicode)rY)r#itemsrMr(r'r rrr/rQrHrKr.r0sortedr"keysrElementr&extendrropenwritehasattrr[r!_summary) r2r r:rTr<rr>r9name_elfs r@rczTranslationFile.writess "&!5!5!7!7 9 9 D+"& ) 9 9 Z__X%>%>%CDD!+!?!?!-.2E-(4 B I I(.!0!011133q8333&**6:>>>.6262O2O$(3*3*/,,Z9LMMM = D DV L LNNN..!3...MMBII$*,,---33q83335 9:41668899 * *D$,Y77J!)&11GGL   g & & &   d4T: ; ; ; J  j ) ) ) ) &--dm<<=== $-w E E E  GG> ? ? ? GG% & & &{H-- /"4:...  #DJ / / 5 5a) 5 L L L GGDMMM                 MMOOOOO  sBK??LLc|dD]}||||dS)z> Add a message element to a list of updated message elements. locationN)rNr)r&)r<rT location_els r@rKzTranslationFile._add_message_elsT &--j99 + +K   k * * * * "":.....c|D]}d}d}d}g}|D]~}|jdkr|j}|jdkr|j}(|jdkr|j};|jdr)||jdd|jg||jkr||jkr|||kr||jjkr|cSdS)z7 Return the message element for a message from a list. r rcomment extracommentextra-N) r%r' startswithr&rrm_get_message_extra_commentsembedded_commentsextras) clsr r:r<rrm extra_commentrtr;s r@rJzTranslationFile._find_messages&  JFGMF! 9 96X%%WFFVy(( gGGV~--$&GMMV&&x009MM26!"":rw"7888'''/)) ? ? H HHH2999   trkc@d|jjS)zA Return a message's extra comments as they appear in a .ts file.  )joinrsextra_comments)r s r@rrz+TranslationFile._get_message_extra_commentssxx1@AAArkc\ |j|}n#t$rg}||j|<YnwxYw|S)z< Return the list of updated message elements for a context. )r"rG)r2r rTs r@rHz(TranslationFile._get_updated_message_elssT ?"&"8">   ? ? ?"$ +>D "4 ( ( ( ?#"s ))c tjdtj|jtjtj|jt|j S)z Return a 'location' element. ri)start)rEline) rr`rrrelpathrEdirnameabspathrrline_nr)r2r s r@rSz!TranslationFile._make_location_el)sm":)9 goobgoodm.L.LMM)OO))+++ +rkcbi}|jjr|jj|d<|jrd|d<tjd|}tjd}|j|_|||jr5tjd}|j|_|||jj rCtjd}| ||_||tjdd }|j |j}|rW||_| d ||j|xjd z c_|jr'|tjd |||jjD]8\} } tjd| z} | | _|| 9|j||S)z Return a 'message' element. idyesnumerusr rrmrnrrD)rBz%Reused existing translation for '{0}'r numerusformro)rs message_idrrr`rr'r&rmrzrrr$rOrrrMr,rtr1) r2r attrsr<r= comment_elextracomment_elr>rfieldvaluer;s r@rLz TranslationFile._make_message_el1sA  $ / ?!3>E$K ? %$E)  (E:: '11   )$$$ ? *$,Y77J%oJO   j ) ) )  $ 3 /)1.AAO#'#C#CG#L#LO   o . . .$,]!### (,,W^<<  9"-N  MM;BB KK7799 : : :  3 3q 8 3 3 ? $  ! !+"5!#### $ $ $ .)))#5< " "LE5$X%566BBG   b ! ! ! ! $$Z000rkc,gfd}jrTjr*|djjn#|djjr#|djjr#|djjr#|djjr#|djjr#|djs.d j ttj d S) z- Display the summary of changes to the user. cs.djd|zdS)NzSummary of changes to {ts}:tsz )r&rr)r~r2 summary_liness r@summaryz)TranslationFile._summary..summaryos_! P$$5<< <NNPPP  $ / / / / /rkz0{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&rprintrlinesepry)r2rrs` @r@rezTranslationFile._summaryis  0 0 0 0 0 0 < L& LJQQ d&=??@@@@5< G?FF;== > > >   ( G6==%'' ( ( (  ! - G5<<*,, - - -  & 2 G:AA/11 2 2 2  * 6 G>EE355 6 6 6 P  !5! )r xml.etreeruserrrrrrrkr@rsx& !!!!!!%%%%%%%%}.}.}.}.}.d}.}.}.D   rk