ÿØÿàJFIFÿþ ÿÛC       ÿÛC ÿÀÿÄÿÄ"#QrÿÄÿÄ&1!A"2qQaáÿÚ ?Øy,æ/3JæÝ¹È߲؋5êXw²±ÉyˆR”¾I0ó2—PI¾IÌÚiMö¯–þrìN&"KgX:Šíµ•nTJnLK„…@!‰-ý ùúmë;ºgµŒ&ó±hw’¯Õ@”Ü— 9ñ-ë.²1<yà‚¹ïQÐU„ہ?.’¦èûbß±©Ö«Âw*VŒ) `$‰bØÔŸ’ëXÖ-ËTÜíGÚ3ð«g Ÿ§¯—Jx„–’U/ÂÅv_s(Hÿ@TñJÑãõçn­‚!ÈgfbÓc­:él[ðQe 9ÀPLbÃãCµm[5¿ç'ªjglå‡Ûí_§Úõl-;"PkÞÞÁQâ¼_Ñ^¢SŸx?"¸¦ùY騐ÒOÈ q’`~~ÚtËU¹CڒêV  I1Áß_ÿÙ HXc @s dZddlmZddlZddlZddlmZmZddlm Z ddl m Z dZ dZ d efd YZd efd YZddedd ZejdZdZdddZdeeeeeeedZdZdS(s babel.messages.pofile ~~~~~~~~~~~~~~~~~~~~~ Reading and writing of files in the ``gettext`` PO (portable object) format. :copyright: (c) 2013 by the Babel Team. :license: BSD, see LICENSE for more details. i(tprint_functionN(tCatalogtMessage(twraptext(t text_typecCs)d}tjdj||dd!S(sReverse `escape` the given string. >>> print(unescape('"Say:\\n \\"hello, world!\\"\\n"')) Say: "hello, world!" :param string: the string to unescape cSsC|jd}|dkrdS|dkr/dS|dkr?dS|S(Nitns tts trs (tgroup(tmatchtm((s9/usr/lib/python2.7/site-packages/babel/messages/pofile.pytreplace_escapes s   s \\([\\trn"])ii(tretcompiletsub(tstringR ((s9/usr/lib/python2.7/site-packages/babel/messages/pofile.pytunescapes cCs^d|krP|j}|jdr4|d}ntt|}dj|St|SdS(sReverse the normalization done by the `normalize` function. >>> print(denormalize(r'''"" ... "Say:\n" ... " \"hello, world!\"\n"''')) Say: "hello, world!" >>> print(denormalize(r'''"" ... "Say:\n" ... " \"Lorem ipsum dolor sit " ... "amet, consectetur adipisicing" ... " elit, \"\n"''')) Say: "Lorem ipsum dolor sit amet, consectetur adipisicing elit, " :param string: the string to denormalize s s""itN(t splitlinest startswithtmapRtjoin(Rt escaped_linestlines((s9/usr/lib/python2.7/site-packages/babel/messages/pofile.pyt denormalize-s    t_NormalizedStringcBs,eZdZdZdZdZRS(cGs+g|_x|D]}|j|qWdS(N(t_strstappend(tselftargstarg((s9/usr/lib/python2.7/site-packages/babel/messages/pofile.pyt__init__Ns  cCs|jj|jdS(N(RRtstrip(Rts((s9/usr/lib/python2.7/site-packages/babel/messages/pofile.pyRSscCsdjtt|jS(NR(RRRR(R((s9/usr/lib/python2.7/site-packages/babel/messages/pofile.pyRVscCs t|jS(N(tboolR(R((s9/usr/lib/python2.7/site-packages/babel/messages/pofile.pyt __nonzero__Ys(t__name__t __module__RRRR#(((s9/usr/lib/python2.7/site-packages/babel/messages/pofile.pyRLs   t PoFileParsercBseZdZddddgZedZdZdZdZed Z ed Z d Z d Z d Z dZRS(sSupport class to read messages from a ``gettext`` PO (portable object) file and add them to a `Catalog` See `read_po` for simple cases. tmsgidtmsgstrtmsgctxtt msgid_pluralcCs2||_||_d|_d|_|jdS(Ni(tcatalogtignore_obsoletetcountertoffsett_reset_message_state(RR+R,((s9/usr/lib/python2.7/site-packages/babel/messages/pofile.pyRks     cCsgg|_g|_g|_g|_g|_g|_d|_t|_ t|_ t|_ t|_ dS(N( tmessagest translationst locationstflagst user_commentst auto_commentstNonetcontexttFalsetobsoletetin_msgidt in_msgstrt in_msgctxt(R((s9/usr/lib/python2.7/site-packages/babel/messages/pofile.pyR/rs          c Cs|jjt|jdkrMtg|jD]}|j^q/}n|jdj}t|ttfrgt|j j D] }d^q}xU|jD]J\}}||j j kr|j d|j dqn|j||>> from datetime import datetime >>> from babel._compat import StringIO >>> buf = StringIO(''' ... #: main.py:1 ... #, fuzzy, python-format ... msgid "foo %(name)s" ... msgstr "quux %(name)s" ... ... # A user comment ... #. An auto comment ... #: main.py:3 ... msgid "bar" ... msgid_plural "baz" ... msgstr[0] "bar" ... msgstr[1] "baaz" ... ''') >>> catalog = read_po(buf) >>> catalog.revision_date = datetime(2007, 4, 1) >>> for message in catalog: ... if message.id: ... print((message.id, message.string)) ... print(' ', (message.locations, sorted(list(message.flags)))) ... print(' ', (message.user_comments, message.auto_comments)) (u'foo %(name)s', u'quux %(name)s') ([(u'main.py', 1)], [u'fuzzy', u'python-format']) ([], []) ((u'bar', u'baz'), (u'bar', u'baaz')) ([(u'main.py', 3)], []) ([u'A user comment'], [u'An auto comment']) .. versionadded:: 1.0 Added support for explicit charset argument. :param fileobj: the file-like object to read the PO file from :param locale: the locale identifier or `Locale` object, or `None` if the catalog is not bound to a locale (which basically means it's a template) :param domain: the message domain :param ignore_obsolete: whether to ignore obsolete messages in the input :param charset: the character set of the catalog. tlocaletdomainRj(RR&Rl(RkRpRqR,RjR+tparser((s9/usr/lib/python2.7/site-packages/babel/messages/pofile.pytread_pos. sL(\s+|[^\s\w]*\w+[a-zA-Z]-(?=\w+[a-zA-Z])|(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))cCsDd|jddjddjddjdd jd d S( sEscape the given string so that it can be included in double-quoted strings in ``PO`` files. >>> escape('''Say: ... "hello, world!" ... ''') '"Say:\\n \\"hello, world!\\"\\n"' :param string: the string to escape s"%s"s\s\\s s\ts s\rs s\ns"s\"(treplace(R((s9/usr/lib/python2.7/site-packages/babel/messages/pofile.pytescapeVs    RiLc Cs|r-|dkr-t|}g}x|jtD]}tt|||krtj|}|jx|rg}d}xu|rtt|dd|} || |kr|j|j|| 7}q|s|j|jnPqW|jdj |qrWq4|j|q4Wn|jt}t|dkrXt|S|r|d r|d=|dcd7>> print(normalize('''Say: ... "hello, world!" ... ''', width=None)) "" "Say:\n" " \"hello, world!\"\n" >>> print(normalize('''Say: ... "Lorem ipsum dolor sit amet, consectetur adipisicing elit, " ... ''', width=32)) "" "Say:\n" " \"Lorem ipsum dolor sit " "amet, consectetur adipisicing" " elit, \"\n" :param string: the string to normalize :param prefix: a string that should be prepended to every line :param width: the maximum line width; use `None`, 0, or a negative number to completely disable line wrapping iiiuis u"" u ( R?RRVRutWORD_SEPRWtreverseRtpopR( Rtprefixtwidtht prefixlenRRPtchunkstbuftsizetl((s9/usr/lib/python2.7/site-packages/babel/messages/pofile.pyt normalizehs6      c  sdfdfddfd} dfd} d} |rfd} n|rud} nx8td| D]$} | js|rqnj}r d kr g}x0|jD]"}|t|d d d 7}qWd j|}n|d nx| jD]}| |q$Wx!| jD]}| |ddqBW|sg}xrt | j D]a\}}|r| r|j d|j t jd|fqx|j d|j t jdqxW| dj|ddn| jr,ddjdgt | jn| jr|r| d| jd ddt| jdkr| d| jdddqn| | dqW|sx^tjjd| D]>} x| jD]}| |qW| | dddqWndS(sWrite a ``gettext`` PO (portable object) template file for a given message catalog to the provided file-like object. >>> catalog = Catalog() >>> catalog.add(u'foo %(name)s', locations=[('main.py', 1)], ... flags=('fuzzy',)) >>> catalog.add((u'bar', u'baz'), locations=[('main.py', 3)]) >>> from babel._compat import BytesIO >>> buf = BytesIO() >>> write_po(buf, catalog, omit_header=True) >>> print(buf.getvalue().decode("utf8")) #: main.py:1 #, fuzzy, python-format msgid "foo %(name)s" msgstr "" #: main.py:3 msgid "bar" msgid_plural "baz" msgstr[0] "" msgstr[1] "" :param fileobj: the file-like object to write to :param catalog: the `Catalog` instance :param width: the maximum line width for the generated output; use `None`, 0, or a negative number to completely disable line wrapping :param no_location: do not emit a location comment for every message :param omit_header: do not include the ``msgid ""`` entry at the top of the output :param sort_output: whether to sort the messages in the output by msgid :param sort_by_file: whether to sort the messages in the output by their locations :param ignore_obsolete: whether to ignore obsolete messages and not include them in the output; by default they are included as comments :param include_previous: include the old msgid as a comment when updating the catalog :param include_lineno: include line number in the location comment Rcst|d|dS(NRyRz(R(tkeyRy(Rz(s9/usr/lib/python2.7/site-packages/babel/messages/pofile.pyt _normalizescs8t|tr'|jjd}nj|dS(Ntbackslashreplace(RARtencodeRjtwrite(ttext(R+Rk(s9/usr/lib/python2.7/site-packages/babel/messages/pofile.pyt_writescsYrdkr}nd}x1t||D] }d||jfq1WdS(NiiLs#%s %s (RR (RdRyt_widthRP(RRz(s9/usr/lib/python2.7/site-packages/babel/messages/pofile.pyt_write_comments  csjt|jttfr|jrDd||j|fnd||jd|fd||jd|fxtjD]Q}y|j|}Wntk rd}nXd||||fqWnr|jr d||j|fnd||j|fd||jpXd|fdS( Ns %smsgctxt %s s %smsgid %s is%smsgid_plural %s iRs%smsgstr[%d] %s s %smsgstr %s ( RAtidRBR@R7RCRDRt IndexError(RJRyRHR(RRR+(s9/usr/lib/python2.7/site-packages/babel/messages/pofile.pyt_write_messages(  $  !   RJRatsort_byiRztsubsequent_indents# u RyR]u%s:%dt/u%sRRR[s#%s s, smsgid %st|ismsgid_plural %ss s#~ N(R6t_sort_messagesRtheader_commentRRRR4R5tsortedR2RRttostsepR3t previous_idR?R9tvalues(RkR+Rzt no_locationt omit_headert sort_outputt sort_by_fileR,tinclude_previoustinclude_linenoRRRRJtcomment_headerRRPRdtlocstfilenameR=((RRR+RkRzs9/usr/lib/python2.7/site-packages/babel/messages/pofile.pytwrite_posf.      )$ *    cCsKt|}|dkr%|jn"|dkrG|jddn|S(s Sort the given message iterable by the given criteria. Always returns a list. :param messages: An iterable of Messages. :param sort_by: Sort by which criteria? Options are `message` and `location`. :return: list[Message] RJRaRcSs|jS(N(R2(R ((s9/usr/lib/python2.7/site-packages/babel/messages/pofile.pytGR(RBR>(R0R((s9/usr/lib/python2.7/site-packages/babel/messages/pofile.pyR9s    (Rot __future__RRR tbabel.messages.catalogRRt babel.utilRt babel._compatRRRtobjectRR&R6R8RsR RvRuRRVRR(((s9/usr/lib/python2.7/site-packages/babel/messages/pofile.pyt s$    4 =