;ò +:óBc@s’dZdklZlZdkZdkZdkZeiZeZ dfd„ƒYZ dfd„ƒYZ dfd„ƒYZ e d joed IJed IJeid Zed IdieƒIJe ƒZgiZeD]%Zeidƒ oeeƒqÚqÚ[ZgiZeD]$Zeidƒoeeƒqq[Ze eeƒe eeƒeiƒZeiddƒZeGHedIJndS(s¹Simple script to generate .pox files parses XML for i18n attrs and JS files for _() calls and generates an XML .pox template document (.poxt file) (c) Guido Wesdorp 2005 (s parseStringsgetDOMImplementationNsPOXcBs)tZdZd„Zd„Zd„ZRS(scontainer for the resultscCs=tƒ}|itdtƒ|_|ii|_h|_dS(Nscatalog( sgetDOMImplementationsimplscreateDocumentsNonesselfsdocsdocumentElementsroots processed(sselfsimpl((s;/mnt/gmirror/ports/www/zope-kupu/work/kupu/tools/makepox.pys__init__s c Cs›|iƒiddƒiddƒ}x+|idƒdjo|iddƒq'W|ii|ƒo]|i|\}}||j o4|i |ƒ|i dd|i dƒ|fƒndSn|i }|i} |idƒ}|i d|ƒ| i|ƒ|id ƒ}|i|i|ƒƒ|i|ƒ|id ƒ}|i|i|ƒƒ|i|ƒ|i d d ƒ| i|ƒ|g|f|i||i}|iƒ o|i|ƒ}n|i||ƒn|idƒ}|o›gi}|iidƒD]} || iƒƒq-~}x_|D]S} |i| ƒ}| ot!d| |i"|f‚n|i}|i||ƒqSWq²qmqtWdS(NsError parsing %s: %s - %sisi18n:translatesi18n:attributess;sNo %s on %s in %s(#sopensfilenamesfps parseStringsreadsdomssyssexc_infosexcsestbswarn_on_broken_xmlsstderrsselfs next_nodesnodesnodeTypes attributessattrss getNamedItems translatesvaluesmsgidsstrips extract_textspoxsaddsappends_[1]ssplitsasattrsattritemsAttributeErrorsnodeName(sselfsfilenamespoxsnodesattrssmsgidsattritems translatestbsfpsexcsasesattrsdoms_[1]s attributes((s;/mnt/gmirror/ports/www/zope-kupu/work/kupu/tools/makepox.pys parse_file?s@   9 cCs€d}x?|iD]4}||iƒiƒiddƒiddƒ7}qWx-|idƒdjo|iddƒ}qKW|SdS(Nss s s s iÿÿÿÿ(sxmlsnodes childNodesschildstoxmlsstripsreplacesfind(sselfsnodesxmlschild((s;/mnt/gmirror/ports/www/zope-kupu/work/kupu/tools/makepox.pys extract_textcs 2cCs•|i p|ii|jo|i|_n]|i}|iƒo|id|_n3||ii jo|i |_n|ii |_|iSdS(Ni( sselfs_currents ownerDocumentsdomsdocumentElementscurs hasChildNodess childNodess parentNodes lastChilds nextSibling(sselfsdomscur((s;/mnt/gmirror/ports/www/zope-kupu/work/kupu/tools/makepox.pys next_nodeks  (s__name__s __module__s__doc__s__init__s parse_files extract_texts next_node(((s;/mnt/gmirror/ports/www/zope-kupu/work/kupu/tools/makepox.pys XMLParser8s   $ sJSParsercBsJtZdZd„ZeidƒZeidƒZd„Ze d„Z RS(sscans JS files for _() callscCs%x|D]}|i||ƒqWdS(N(sfilessfilesselfs parse_filespox(sselfsfilesspoxsfile((s;/mnt/gmirror/ports/www/zope-kupu/work/kupu/tools/makepox.pys__init__zss.*?[^a-zA-Z0-9_]_\(s^_\(c CsHt|ƒiƒ}d}t} g}x|D]}|d7}| t jp|i i |ƒo/|i |||| ƒ\}} |i|ƒn|o | tjo¢di|ƒiƒ}| otd||f‚n|iddƒiddƒ}x-|idƒd jo|iddƒ}qóWt} g}|i||ƒq+q+WdS( Niiss1Unrecognized function content -- file %s, line %ss s s s iÿÿÿÿ(sopensfilenames readlinesslinesslinenosFalsesmoreschunksslinesTruesselfs _startfuncregssearchs_get_func_contentschunksappendsjoinsstripsliterals ValueErrorsreplacesfindspoxsadd( sselfsfilenamespoxslinessliteralslinenoschunksslineschunksmore((s;/mnt/gmirror/ports/www/zope-kupu/work/kupu/tools/makepox.pys parse_file€s,   c Cs„|iƒ}| oD|ii|ƒp|ii|ƒ} |i| i dƒdƒ}n|iƒ}|d}|d}|ddgj ot d|||f‚ng}t}xVnoN|d}|d}||jo|djoPqón|i|ƒ|}q¼Wt}|iƒ}|o|ddjo8|diƒ}|ot d ||f‚nt}ndi|ƒ|fSd S( sßreturn the content of the _() call in line if more is True, this will assume the function is already opened and continue adding to the result from the start of the line without searching for '[^a-zA-Z_]_(' first returns a tuple (content, more) where more is True if the end of the function body is not reached, in that case this method should be called again with the 'more' argument set to True isis"s'sUbeginning of function body not a recognized quote character: %s -- (file %s, line %s)s\s+sstring concatenation only allowed for multiline strings, not for variable interpolation (use ${} instead) -- (file %s, line %s)N(slinesstripsmoresselfs _startfuncregssearchs_startfuncreg_2smatchsreplacesgroupsquotes ValueErrorsfilenameslinenosretsNones previous_charsnew_charsappendsFalsesTruesjoin( sselfslinesfilenameslinenosmoresnew_charsquotesrets previous_charsmatch((s;/mnt/gmirror/ports/www/zope-kupu/work/kupu/tools/makepox.pys_get_func_content˜s:  %            ( s__name__s __module__s__doc__s__init__srescompiles _startfuncregs_startfuncreg_2s parse_filesFalses_get_func_content(((s;/mnt/gmirror/ports/www/zope-kupu/work/kupu/tools/makepox.pysJSParserxs   s__main__sPOX extract v0.1s(c) Guido Wesdorp 2004isGoing to parse filess, s.jss sMsDone(s__doc__sxml.dom.minidoms parseStringsgetDOMImplementationssyssresossstderrsTrueswarn_on_broken_xmlsPOXs XMLParsersJSParsers__name__sargvsfilessjoinspoxsappends_[1]sfsendswithsxmlsjss get_resultspressreplace(sJSParsersfilesspoxs parseStringsPOXsxmlswarn_on_broken_xmlsfsjsssyssres_[1]sstderrsgetDOMImplementations XMLParsersosspres((s;/mnt/gmirror/ports/www/zope-kupu/work/kupu/tools/makepox.pys?s, '@Q     <;