;ς α˜@c@s­dZdkZdkZdkZdkZdklZlZlZdk l Z dZ ye Wne j odZ dZnXdefd„ƒYZd fd „ƒYZdS( sόGenerate binary message catalog from textual translation description. This program converts a textual Uniforum-style message catalog (.po file) into a binary GNU catalog (.mo file). This is essentially the same function as the GNU msgfmt program, however, it is a simpler implementation. This file was taken from Python-2.3.2/Tools/i18n and altered in several ways. Now you can simply use it from another python module: from msgfmt import Msgfmt mo = Msgfmt(po).get() where po is path to a po file as string, an opened po file ready for reading or a list of strings (readlines of a po file) and mo is the compiled mo file as binary string. Exceptions: * IOError if the file couldn't be read * msgfmt.PoSyntaxError if the po file has syntax errors N(sFileTypes StringTypesListType(sStringIOs1.1ptsiis PoSyntaxErrorcBs tZdZd„Zd„ZRS(s Syntax error in a po file cCs ||_dS(N(smsgsself(sselfsmsg((sb/mnt/gmirror/ports/www/zope-placelesstranslationservice/work/PlacelessTranslationService/msgfmt.pys__init__0scCsd|iSdS(NsPo file syntax error: %s(sselfsmsg(sself((sb/mnt/gmirror/ports/www/zope-placelesstranslationservice/work/PlacelessTranslationService/msgfmt.pys__str__3s(s__name__s __module__s__doc__s__init__s__str__(((sb/mnt/gmirror/ports/www/zope-placelesstranslationservice/work/PlacelessTranslationService/msgfmt.pys PoSyntaxError.s  sMsgfmtcBsPtZdZdd„Zd„Zd„Zd„Zd„Zd„Zd„Z RS( s sunknowncCs||_||_h|_dS(N(sposselfsnamesmessages(sselfsposname((sb/mnt/gmirror/ports/www/zope-placelesstranslationservice/work/PlacelessTranslationService/msgfmt.pys__init__8s  cCsΎg}t|iƒtjo#|iidƒ|iiƒ}nt|iƒtjo |i}nt|iƒtjot |idƒiƒ}n| ot dt|iƒ‚n|SdS(s8 read po data from self.po and store it in self.poLines isrbsself.po is invalid! %sN( soutputstypesselfsposFileTypesseeks readlinessListTypes StringTypesopens ValueError(sselfsoutput((sb/mnt/gmirror/ports/www/zope-placelesstranslationservice/work/PlacelessTranslationService/msgfmt.pys readPoData=s cCs$| o|o||i|  8      c Csd} d}t}d}|iƒ}d}x΅|D]­}|d7}|ddjp |i dƒo ||jo#|i || |ƒt}d}n|d djo |idƒo d}n|ddjoq1n|i dƒo| }|d}d }} n%|i d ƒo|}|d }n|iƒ}| oq1nyt|tƒƒ}Wn4tj o(}td |||i|fƒ‚nX|| jo||7}q1||jo| |7} q1td ||ifƒ‚q1W||jo|i || |ƒn|iƒSdS(s iiis#smsgids#,sfuzzyissmsgstris%s (line %d of po file %s): %sserror in line %d of po file %sN(sIDsSTRsNonessectionsfuzzysselfs readPoDataslinesslnosls startswithsaddsmsgidsmsgstrsfindsstripsevalsglobalss Exceptionsmsgs PoSyntaxErrorsnamesgenerate( sselfsmsgidslinesslslnosSTRssectionsmsgsfuzzysmsgstrsID((sb/mnt/gmirror/ports/www/zope-placelesstranslationservice/work/PlacelessTranslationService/msgfmt.pysgetysP  . !   $   cCst|iƒƒSdS(N(sStringIOsselfsget(sself((sb/mnt/gmirror/ports/www/zope-placelesstranslationservice/work/PlacelessTranslationService/msgfmt.pys getAsFile·scCs|iƒSdS(N(sselfs getAsFile(sself((sb/mnt/gmirror/ports/www/zope-placelesstranslationservice/work/PlacelessTranslationService/msgfmt.pys__call__Ίs( s__name__s __module__s__doc__s__init__s readPoDatasaddsgeneratesgets getAsFiles__call__(((sb/mnt/gmirror/ports/www/zope-placelesstranslationservice/work/PlacelessTranslationService/msgfmt.pysMsgfmt6s     ) > (s__doc__ssyssossstructsarraystypessFileTypes StringTypesListTypes cStringIOsStringIOs __version__sTrues NameErrorsFalses Exceptions PoSyntaxErrorsMsgfmt( s StringTypesFalsesstructsStringIOsTruesFileTypessyssListTypes PoSyntaxErrorsarrays __version__sossMsgfmt((sb/mnt/gmirror/ports/www/zope-placelesstranslationservice/work/PlacelessTranslationService/msgfmt.pys?s