ó
|£*^c        
   @   s=  d  Z  d Z d Z d d d d d d d	 d
 d d g
 Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l	 Z	 d d l
 Z
 y d d l Z Wn' e k
 rÃ d e f d „  ƒ  YZ n Xd Z e	 j d  d d f k  re Z e Z d „  Z d „  Z n e Z e Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z e d „ Z d „  Z d „  Z d  e f d! „  ƒ  YZ  d e  f d" „  ƒ  YZ! d e  f d# „  ƒ  YZ" d$ e f d% „  ƒ  YZ# d e# f d& „  ƒ  YZ$ d e# f d' „  ƒ  YZ% d( e f d) „  ƒ  YZ& d* e f d+ „  ƒ  YZ' d, e
 j( f d- „  ƒ  YZ( d. d/ „ Z) d S(0   sh  
**polib** allows you to manipulate, create, modify gettext files (pot, po and
mo files).  You can load existing files, iterate through it's entries, add,
modify entries, comments or metadata, etc. or create new po files from scratch.

**polib** provides a simple and pythonic API via the :func:`~polib.pofile` and
:func:`~polib.mofile` convenience functions.
s%   David Jean Louis <izimobil@gmail.com>s   1.0.7t   pofilet   POFilet   POEntryt   mofilet   MOFilet   MOEntryt   default_encodingt   escapet   unescapet   detect_encodingiÿÿÿÿNt   ioc           B   s   e  Z e d  d d „ ƒ Z RS(   t   rc         C   s   t  j |  | | ƒ S(   N(   t   codecst   open(   t   fpatht   modet   encoding(    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyR   "   s    N(   t   __name__t
   __module__t   staticmethodt   NoneR   (    (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyR
   !   s   s   utf-8i   i   i    c         C   s   |  S(   N(    (   t   s(    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt   b1   s    c         C   s   t  |  d ƒ S(   Nt   unicode_escape(   t   unicode(   R   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt   u4   s    c         C   s   |  j  d ƒ S(   Ns   latin-1(   t   encode(   R   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyR   ;   s    c         C   s   |  S(   N(    (   R   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyR   >   s    c      	   K   s£   | j  d ƒ } | d k r3 t |  | d k ƒ } n  | d k rE t pH t } | |  d | d | j  d t ƒ d | j  d ƒ ƒ} | j ƒ  } | j  d d ƒ | _ | S(	   so   
    Internal function used by :func:`polib.pofile` and :func:`polib.mofile` to
    honor the DRY concept.
    R   R   R    t   check_for_duplicatest   klasst	   wrapwidthiN   N(   t   getR   R	   t   _POFileParsert   _MOFileParsert   Falset   parseR   (   t   ft   typet   kwargst   enct   klst   parsert   instance(    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt   _pofile_or_mofileD   s    c         C   s3   y t  j j |  ƒ SWn t t f k
 r. t SXd S(   s  
    Safely returns the value of os.path.exists(filename_or_contents).

    Arguments:

    ``filename_or_contents``
        either a filename, or a string holding the contents of some file.
        In the latter case, this function will always return False.
    N(   t   ost   patht   existst
   ValueErrort   UnicodeEncodeErrorR!   (   t   filename_or_contents(    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt   _is_file]   s    
c         K   s   t  |  d | � S(   sO  
    Convenience function that parses the po or pot file ``pofile`` and returns
    a :class:`~polib.POFile` instance.

    Arguments:

    ``pofile``
        string, full or relative path to the po/pot file or its content (data).

    ``wrapwidth``
        integer, the wrap width, only useful when the ``-w`` option was passed
        to xgettext (optional, default: ``78``).

    ``encoding``
        string, the encoding to use (e.g. "utf-8") (default: ``None``, the
        encoding will be auto-detected).

    ``check_for_duplicates``
        whether to check for duplicate entries when adding entries to the
        file (optional, default: ``False``).

    ``klass``
        class which is used to instantiate the return value (optional,
        default: ``None``, the return value with be a :class:`~polib.POFile`
        instance).
    R    (   R*   (   R    R%   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyR    o   s    c         K   s   t  |  d | � S(   sˆ  
    Convenience function that parses the mo file ``mofile`` and returns a
    :class:`~polib.MOFile` instance.

    Arguments:

    ``mofile``
        string, full or relative path to the mo file or its content (data).

    ``wrapwidth``
        integer, the wrap width, only useful when the ``-w`` option was passed
        to xgettext to generate the po file that was used to format the mo file
        (optional, default: ``78``).

    ``encoding``
        string, the encoding to use (e.g. "utf-8") (default: ``None``, the
        encoding will be auto-detected).

    ``check_for_duplicates``
        whether to check for duplicate entries when adding entries to the
        file (optional, default: ``False``).

    ``klass``
        class which is used to instantiate the return value (optional,
        default: ``None``, the return value with be a :class:`~polib.POFile`
        instance).
    R   (   R*   (   R   R%   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyR   �   s    c         C   sH  d } t  j t | ƒ ƒ } t  j t | ƒ ƒ } d „  } t |  ƒ s… | j |  ƒ } | rD| j d ƒ j ƒ  } | | ƒ r‚ | SqDn¿ | s‘ t r  d } | }	 n d } | }	 t	 |  | ƒ }
 x| |
 j
 ƒ  D]n } |	 j | ƒ } | rÈ |
 j ƒ  | j d ƒ j ƒ  } t | t ƒ s#| j d ƒ } n  | | ƒ r6| SqÈ qÈ W|
 j ƒ  t S(   sÀ  
    Try to detect the encoding used by the ``file``. The ``file`` argument can
    be a PO or MO file path or a string containing the contents of the file.
    If the encoding cannot be detected, the function will return the value of
    ``default_encoding``.

    Arguments:

    ``file``
        string, full or relative path to the po/mo file or its content.

    ``binary_mode``
        boolean, set this to True if ``file`` is a mo file.
    s(   "?Content-Type:.+? charset=([\w_\-:\.]+)c         S   s*   y t  j |  ƒ Wn t k
 r% t SXt S(   s*   Check whether ``charset`` is valid or not.(   R   t   lookupt   LookupErrorR!   t   True(   t   charset(    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt   charset_existsÃ   s
    i   t   rbR   s   utf-8(   t   ret   compileR   R   R1   t   searcht   groupt   stript   PY3R   t	   readlinest   closet
   isinstancet	   text_typet   decodeR   (   t   filet   binary_modet   PATTERNt   rxtt   rxbR6   t   matchR&   R   t   rxR#   t   l(    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyR	   °   s6    	
	

c         C   s@   |  j  d d ƒ j  d d ƒ j  d d ƒ j  d d ƒ j  d	 d
 ƒ S(   sx   
    Escapes the characters ``\\``, ``\t``, ``\n``, ``\r`` and ``"`` in
    the given string ``st`` and returns it.
    s   \s   \\s   	s   \ts   s   \rs   
s   \ns   "s   \"(   t   replace(   t   st(    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyR   é   s
    c         C   s   d „  } t  j d | |  ƒ S(   sz   
    Unescapes the characters ``\\``, ``\t``, ``\n``, ``\r`` and ``"`` in
    the given string ``st`` and returns it.
    c         S   sS   |  j  d ƒ }  |  d k r d S|  d k r/ d S|  d k r? d S|  d k rO d S|  S(	   Ni   t   ns   
t   ts   	R   s   s   \(   R;   (   t   m(    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt   unescape_replü   s    s   \\(\\|n|t|r|")(   R8   t   sub(   RL   RP   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyR   ÷   s    	t	   _BaseFilec           B   s¤   e  Z d  Z d „  Z d „  Z e r0 d „  Z n	 d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d d
 d „ Z d e e d „ Z d „  Z d „  Z d „  Z RS(   s–   
    Common base class for the :class:`~polib.POFile` and :class:`~polib.MOFile`
    classes. This class should **not** be instanciated directly.
    c         O   s­   t  j |  ƒ | j d d	 ƒ } | r= t | ƒ r= | |  _ n | j d ƒ |  _ | j d d ƒ |  _ | j d t ƒ |  _ | j d t	 ƒ |  _
 d |  _ i  |  _ d |  _ d	 S(
   ss  
        Constructor, accepts the following keyword arguments:

        ``pofile``
            string, the path to the po or mo file, or its content as a string.

        ``wrapwidth``
            integer, the wrap width, only useful when the ``-w`` option was
            passed to xgettext (optional, default: ``78``).

        ``encoding``
            string, the encoding to use, defaults to ``default_encoding``
            global variable (optional).

        ``check_for_duplicates``
            whether to check for duplicate entries when adding entries to the
            file, (optional, default: ``False``).
        R    R   R   iN   R   R   t    i    N(   t   listt   __init__R   R   R1   R   R   R   R   R!   R   t   headert   metadatat   metadata_is_fuzzy(   t   selft   argsR%   R    (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyRU     s    		c         C   s½   g  } |  j  ƒ  g g  |  D] } | j s | ^ q } x' | D] } | j | j |  j ƒ ƒ q< Wx- |  j ƒ  D] } | j | j |  j ƒ ƒ ql Wt d ƒ j | ƒ } t | t	 ƒ s¹ t
 ‚ | S(   sA   
        Returns the unicode representation of the file.
        s   
(   t   metadata_as_entryt   obsoletet   appendt   __unicode__R   t   obsolete_entriesR   t   joinR@   RA   t   AssertionError(   RY   t   rett   et   entriest   entry(    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyR^   8  s    #c         C   s
   |  j  ƒ  S(   N(   R^   (   RY   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt   __str__K  s    c         C   s   t  |  ƒ j |  j ƒ S(   sH   
            Returns the string representation of the file.
            (   R   R   R   (   RY   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyRf   N  s    c         C   s%   |  j  | j d d d | j ƒd k	 S(   sŒ  
        Overridden ``list`` method to implement the membership test (in and
        not in).
        The method considers that an entry is in the file if it finds an entry
        that has the same msgid (the test is **case sensitive**) and the same
        msgctxt (or none for both entries).

        Argument:

        ``entry``
            an instance of :class:`~polib._BaseEntry`.
        t   byt   msgidt   msgctxtN(   t   findRh   Ri   R   (   RY   Re   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt   __contains__T  s    c         C   s   t  |  ƒ t  | ƒ k S(   N(   t   str(   RY   t   other(    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt   __eq__d  s    c         C   sE   |  j  r+ | |  k r+ t d | j ƒ ‚ n  t t |  ƒ j | ƒ d S(   s   
        Overridden method to check for duplicates entries, if a user tries to
        add an entry that is already in the file, the method will raise a
        ``ValueError`` exception.

        Argument:

        ``entry``
            an instance of :class:`~polib._BaseEntry`.
        s   Entry "%s" already existsN(   R   R.   Rh   t   superRR   R]   (   RY   Re   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyR]   g  s    c         C   sH   |  j  r+ | |  k r+ t d | j ƒ ‚ n  t t |  ƒ j | | ƒ d S(   sm  
        Overridden method to check for duplicates entries, if a user tries to
        add an entry that is already in the file, the method will raise a
        ``ValueError`` exception.

        Arguments:

        ``index``
            index at which the entry should be inserted.

        ``entry``
            an instance of :class:`~polib._BaseEntry`.
        s   Entry "%s" already existsN(   R   R.   Rh   Ro   RR   t   insert(   RY   t   indexRe   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyRp   v  s    c         C   sŽ   t  d d ƒ } |  j ƒ  } | rn g  } x+ | D]# \ } } | j d | | f ƒ q. Wd j | ƒ d | _ n  |  j rŠ | j j d ƒ n  | S(   sQ   
        Returns the file metadata as a :class:`~polib.POFile` instance.
        Rh   RS   s   %s: %ss   
t   fuzzy(   R   t   ordered_metadataR]   R`   t   msgstrRX   t   flags(   RY   Rc   t   mdatat   strst   namet   value(    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyR[   ˆ  s    	R^   c         C   sí   |  j  d k r* | d k r* t d ƒ ‚ n  t |  | ƒ ƒ  } | d k rT |  j  } n  | d k rr t | d ƒ } n? t j | d d |  j ƒ} t | t ƒ s± | j	 |  j ƒ } n  | j
 | ƒ | j ƒ  |  j  d k ré | ré | |  _  n  d S(   sf  
        Saves the po file to ``fpath``.
        If it is an existing file and no ``fpath`` is provided, then the
        existing file is rewritten with the modified data.

        Keyword arguments:

        ``fpath``
            string, full or relative path to the file.

        ``repr_method``
            string, the method to use for output.
        s-   You must provide a file path to save() methodt	   to_binaryt   wbt   wR   N(   R   R   t   IOErrort   getattrR   R
   R   R@   RA   RB   t   writeR?   (   RY   R   t   repr_methodt   contentst   fhandle(    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt   save˜  s    
Rh   c         C   s�   | r |  } n" g  |  D] } | j  s | ^ q } xH | D]@ } t | | ƒ | k r9 | t k	 ru | j | k ru q9 n  | Sq9 Wd S(   s  
        Find the entry which msgid (or property identified by the ``by``
        argument) matches the string ``st``.

        Keyword arguments:

        ``st``
            string, the string to search for.

        ``by``
            string, the property to use for comparison (default: ``msgid``).

        ``include_obsolete_entries``
            boolean, whether to also search in entries that are obsolete.

        ``msgctxt``
            string, allows specifying a specific message context for the
            search.
        N(   R\   R~   R!   Ri   R   (   RY   RL   Rg   t   include_obsolete_entriesRi   Rd   Rc   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyRj   ·  s    
"c         C   sÅ   |  j  j ƒ  } d d d d d d d d d	 d
 d g } g  } xH | D]@ } y& | j | ƒ } | j | | f ƒ WqC t k
 r‚ qC XqC Wx7 t | j ƒ  ƒ D]# } | | } | j | | f ƒ qš W| S(   s´   
        Convenience method that returns an ordered version of the metadata
        dictionary. The return value is list of tuples (metadata name,
        metadata_value).
        s   Project-Id-Versions   Report-Msgid-Bugs-Tos   POT-Creation-Dates   PO-Revision-Dates   Last-Translators   Language-Teams   MIME-Versions   Content-Types   Content-Transfer-Encodingt   Languages   Plural-Forms(   RW   t   copyt   popR]   t   KeyErrort   sortedt   keys(   RY   RW   t
   data_ordert   ordered_datat   dataRy   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyRs   ×  s.    	
c      	   C   s¾  g  } |  j  ƒ  } d „  } | j d d „  ƒ |  j ƒ  } | g | } t | ƒ } t d ƒ t d ƒ } } x<| D]4} t d ƒ }	 | j r§ |  j | j d ƒ }	 n  | j r&g  }
 x1 t | j	 j
 ƒ  ƒ D] } |
 j | j	 | ƒ qÌ W|	 |  j | j d | j ƒ 7}	 |  j d j |
 ƒ ƒ }
 n( |	 |  j | j ƒ 7}	 |  j | j ƒ }
 | j t | ƒ t |	 ƒ t | ƒ t |
 ƒ f ƒ | |	 t d ƒ 7} | |
 t d ƒ 7} qs Wd d	 | } | t | ƒ } g  } g  } xB | D]: \ } } } } | | | | g 7} | | | | g 7} qÜW| | } t j d
 t j d | d d | d d | ƒ } t rŠt j j d k rŠ| t j d | ƒ j ƒ  7} n | t j d | ƒ j ƒ  7} | | 7} | | 7} | S(   s?   
        Return the binary representation of the file.
        c         S   s^   |  j  r |  j  p |  j } | j  r- | j  p3 | j } | | k rF d S| | k  rV d Sd Sd  S(   Ni   iÿÿÿÿi    (   Ri   Rh   (   t   _selfRm   t
   self_msgidt   other_msgid(    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt   cmp  s    t   keyc         S   s   |  j  p |  j S(   N(   Ri   Rh   (   t   o(    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt   <lambda>  s    RS   s   s    i   i   i   t   Iiiiiiii    i   i   t   ii   i   i   (   t   translated_entriest   sortR[   t   lenR   Ri   t   _encodet   msgid_pluralR‰   t   msgstr_pluralRŠ   R]   Rh   R`   Rt   t   structt   packR   t   MAGICR=   t   syst   version_infot   minort   arrayt   tobytest   tostring(   RY   t   offsetsRd   R‘   t   mentryt   entries_lent   idsRw   Rc   Rh   Rt   Rq   t   keystartt
   valuestartt   koffsetst   voffsetst   o1t   l1t   o2t   l2t   output(    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyRz   ú  sZ    			!1


c         C   s(   t  | t ƒ r$ | j |  j ƒ } n  | S(   s›   
        Encodes the given ``mixed`` argument with the file encoding if and
        only if it's an unicode string and returns the encoded string.
        (   R@   RA   R   R   (   RY   t   mixed(    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyRš   M  s    N(   R   R   t   __doc__RU   R^   R=   Rf   Rk   Rn   R]   Rp   R[   R   Rƒ   R!   Rj   Rs   Rz   Rš   (    (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyRR     s"   	&								#	Sc           B   sV   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 RS(	   s–   
    Po (or Pot) file reader/writer.
    This class inherits the :class:`~polib._BaseFile` class and, by extension,
    the python ``list`` type.
    c         C   s§   d |  j  j d ƒ } } xV | D]N } t | ƒ s? | d 7} q  | d  d	 k r` | d | 7} q  | d | 7} q  Wt | t ƒ s– | j |  j ƒ } n  | t j |  ƒ S(
   sD   
        Returns the unicode representation of the po file.
        RS   s   
s   #
i   t   ,t   :s   #%s
s   # %s
(   Rµ   R¶   (	   RV   t   splitR™   R@   RA   RB   R   RR   R^   (   RY   Rb   t   headersRV   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyR^   `  s    c         C   s   t  j |  | d ƒ d S(   s¹   
        Saves the binary representation of the file to given ``fpath``.

        Keyword argument:

        ``fpath``
            string, full or relative path to the mo file.
        Rz   N(   RR   Rƒ   (   RY   R   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt   save_as_mofiler  s    	c         C   sb   t  g  |  D] } | j s
 | ^ q
 ƒ } | d k r8 d St  |  j ƒ  ƒ } t | d t | ƒ ƒ S(   s`   
        Convenience method that returns the percentage of translated
        messages.
        i    id   (   R™   R\   R—   t   intt   float(   RY   Rc   t   totalt
   translated(    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt   percent_translated}  s
    (c         C   s#   g  |  D] } | j  ƒ  r | ^ q S(   sQ   
        Convenience method that returns the list of translated entries.
        (   R½   (   RY   Rc   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyR—   ˆ  s    c         C   s=   g  |  D]2 } | j  ƒ  r | j r d | j k r | ^ q S(   sS   
        Convenience method that returns the list of untranslated entries.
        Rr   (   R½   R\   Ru   (   RY   Rc   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt   untranslated_entriesŽ  s    $c         C   s&   g  |  D] } d | j  k r | ^ q S(   sL   
        Convenience method that returns the list of fuzzy entries.
        Rr   (   Ru   (   RY   Rc   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt   fuzzy_entries•  s    c         C   s    g  |  D] } | j  r | ^ q S(   sO   
        Convenience method that returns the list of obsolete entries.
        (   R\   (   RY   Rc   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyR_   ›  s    c         C   s±   t  d „  |  Dƒ ƒ } t d „  | Dƒ ƒ } xR | D]J } | j | j ƒ } | d k rp t ƒ  } |  j | ƒ n  | j | ƒ q3 Wx) |  D]! } | j | k rˆ t | _	 qˆ qˆ Wd S(   s)  
        Convenience method that merges the current pofile with the pot file
        provided. It behaves exactly as the gettext msgmerge utility:

        * comments of this file will be preserved, but extracted comments and
          occurrences will be discarded;
        * any translations or comments in the file will be discarded, however,
          dot comments and file positions will be preserved;
        * the fuzzy flags are preserved.

        Keyword argument:

        ``refpot``
            object POFile, the reference catalog.
        c         s   s   |  ] } | j  | f Vq d  S(   N(   Rh   (   t   .0Re   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pys	   <genexpr>²  s    c         s   s   |  ] } | j  Vq d  S(   N(   Rh   (   RÁ   Re   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pys	   <genexpr>³  s    N(
   t   dictt   setR   Rh   R   R   R]   t   mergeR4   R\   (   RY   t   refpott   self_entriest   refpot_msgidsRe   Rc   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyRÄ   ¡  s    	(   R   R   R´   R^   R¹   R¾   R—   R¿   RÀ   R_   RÄ   (    (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyR   Y  s   							c           B   se   e  Z d  Z d Z d Z d „  Z d „  Z d d „ Z d „  Z	 d „  Z
 d „  Z d	 „  Z d
 „  Z RS(   s�   
    Mo file reader/writer.
    This class inherits the :class:`~polib._BaseFile` class and, by
    extension, the python ``list`` type.
    IÞ•    I•Þ    c         O   s)   t  j |  | | Ž d |  _ d |  _ d S(   sr   
        Constructor, accepts all keywords arguments accepted by
        :class:`~polib._BaseFile` class.
        i    N(   RR   RU   R   t   magic_numbert   version(   RY   RZ   R%   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyRU   Ì  s    	c         C   s   t  j |  | ƒ d S(   s¡   
        Saves the mofile as a pofile to ``fpath``.

        Keyword argument:

        ``fpath``
            string, full or relative path to the file.
        N(   RR   Rƒ   (   RY   R   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt   save_as_pofileÕ  s    	c         C   s   t  j |  | d ƒ d S(   s•   
        Saves the mofile to ``fpath``.

        Keyword argument:

        ``fpath``
            string, full or relative path to the file.
        Rz   N(   RR   Rƒ   (   RY   R   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyRƒ   à  s    	c         C   s   d S(   sV   
        Convenience method to keep the same interface with POFile instances.
        id   (    (   RY   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyR¾   ë  s    c         C   s   |  S(   sV   
        Convenience method to keep the same interface with POFile instances.
        (    (   RY   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyR—   ñ  s    c         C   s   g  S(   sV   
        Convenience method to keep the same interface with POFile instances.
        (    (   RY   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyR¿   ÷  s    c         C   s   g  S(   sV   
        Convenience method to keep the same interface with POFile instances.
        (    (   RY   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyRÀ   ý  s    c         C   s   g  S(   sV   
        Convenience method to keep the same interface with POFile instances.
        (    (   RY   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyR_     s    N(   R   R   R´   RŸ   t   MAGIC_SWAPPEDRU   RÊ   R   Rƒ   R¾   R—   R¿   RÀ   R_   (    (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyR   Ã  s   							t
   _BaseEntryc           B   sS   e  Z d  Z d „  Z d d „ Z e r3 d „  Z n	 d „  Z d „  Z d d „ Z RS(   s�   
    Base class for :class:`~polib.POEntry` and :class:`~polib.MOEntry` classes.
    This class should **not** be instanciated directly.
    c         O   s—   | j  d d ƒ |  _ | j  d d ƒ |  _ | j  d d ƒ |  _ | j  d i  ƒ |  _ | j  d d	 ƒ |  _ | j  d t ƒ |  _ | j  d t	 ƒ |  _
 d	 S(
   si  
        Constructor, accepts the following keyword arguments:

        ``msgid``
            string, the entry msgid.

        ``msgstr``
            string, the entry msgstr.

        ``msgid_plural``
            string, the entry msgid_plural.

        ``msgstr_plural``
            list, the entry msgstr_plural lines.

        ``msgctxt``
            string, the entry context (msgctxt).

        ``obsolete``
            bool, whether the entry is "obsolete" or not.

        ``encoding``
            string, the encoding to use, defaults to ``default_encoding``
            global variable (optional).
        Rh   RS   Rt   R›   Rœ   Ri   R\   R   N(   R   Rh   Rt   R›   Rœ   R   Ri   R!   R\   R   R   (   RY   RZ   R%   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyRU     s    iN   c   	      C   sY  |  j  r d } n d } g  } |  j d	 k	 rR | |  j d | d |  j | ƒ 7} n  | |  j d | d |  j | ƒ 7} |  j r¢ | |  j d | d |  j | ƒ 7} n  |  j r|  j } t | ƒ } | j ƒ  xf | D]9 } | | } d | } | |  j d | | | | ƒ 7} qÑ Wn" | |  j d | d |  j	 | ƒ 7} | j
 d ƒ t d ƒ j | ƒ } | S(
   sB   
        Returns the unicode representation of the entry.
        s   #~ RS   Ri   Rh   R›   s   [%s]Rt   s   
N(   R\   Ri   R   t
   _str_fieldRh   R›   Rœ   RT   R˜   Rt   R]   R   R`   (	   RY   R   t   delflagRb   t   msgstrsRŠ   Rq   Rt   t   plural_index(    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyR^   4  s2    		"			



c         C   s
   |  j  ƒ  S(   N(   R^   (   RY   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyRf   Z  s    c         C   s   t  |  ƒ j |  j ƒ S(   sI   
            Returns the string representation of the entry.
            (   R   R   R   (   RY   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyRf   ]  s    c         C   s   t  |  ƒ t  | ƒ k S(   N(   Rl   (   RY   Rm   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyRn   c  s    c      	   C   sŒ  | j  t ƒ } t | ƒ d k r1 d g | } nå t | ƒ } d } x0 d d d d d g D] }	 | | j |	 ƒ 7} qY Wt | ƒ d	 }
 | rŸ |
 t | ƒ 7}
 n  | |
 | } | d k rt | ƒ | k rd g g  t | | d
 d t d t ƒD] } t | ƒ ^ qñ } n	 | g } | j d ƒ r2| d } n  d | | | t | j	 d ƒ ƒ f g } x+ | D]# } | j
 d | t | ƒ f ƒ qaW| S(   Ni   RS   i    s   \s   
s   s   	t   "i   i   t   drop_whitespacet   break_long_wordst	   previous_i	   s   %s%s%s "%s"s   %s"%s"(   t
   splitlinesR4   R™   R   t   countt   wrapR!   R   t
   startswithR‡   R]   (   RY   t	   fieldnameRÎ   RÐ   t   fieldR   t   linest   escaped_fieldt   specialchars_countt   ct   flengtht   real_wrapwidtht   itemRb   t   line(    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyRÍ   f  s2    
#	!(	   R   R   R´   RU   R^   R=   Rf   Rn   RÍ   (    (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyRÌ     s   	"%		c           B   s}   e  Z d  Z d „  Z d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d	 „  Z
 d
 „  Z d „  Z d „  Z d „  Z RS(   s%   
    Represents a po file entry.
    c         O   s¿   t  j |  | | Ž | j d d ƒ |  _ | j d d ƒ |  _ | j d g  ƒ |  _ | j d g  ƒ |  _ | j d d
 ƒ |  _ | j d d
 ƒ |  _	 | j d d
 ƒ |  _
 | j d	 d
 ƒ |  _ d
 S(   sz  
        Constructor, accepts the following keyword arguments:

        ``comment``
            string, the entry comment.

        ``tcomment``
            string, the entry translator comment.

        ``occurrences``
            list, the entry occurrences.

        ``flags``
            list, the entry flags.

        ``previous_msgctxt``
            string, the entry previous context.

        ``previous_msgid``
            string, the entry previous msgid.

        ``previous_msgid_plural``
            string, the entry previous msgid_plural.

        ``linenum``
            integer, the line number of the entry
        t   commentRS   t   tcommentt   occurrencesRu   t   previous_msgctxtt   previous_msgidt   previous_msgid_pluralt   linenumN(   RÌ   RU   R   Rã   Rä   Rå   Ru   R   Ræ   Rç   Rè   Ré   (   RY   RZ   R%   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyRU   ’  s    iN   c         C   sž  |  j  r t j |  | ƒ Sg  } d d g } x» | D]³ } t |  | d ƒ } | r2 x‘ | j d ƒ D]} } | d k rÃ t | ƒ t | d ƒ | k rÃ | t | | d | d d	 | d d
 t ƒ7} qa | j d | d | f ƒ qa Wq2 q2 W|  j	 r×g  } xD |  j	 D]9 \ } }	 |	 r.| j d | |	 f ƒ q| j | ƒ qWd j
 | ƒ }
 | d k rÃt |
 ƒ d | k rÃ| g  t |
 j d d ƒ | d d d	 d d
 t ƒD] } | j d d ƒ ^ q¡7} q×| j d |
 ƒ n  |  j r | j d d j
 |  j ƒ ƒ n  d d d g } xE | D]= } t |  | ƒ } | r| |  j | d d | | ƒ 7} qqW| j t j |  | ƒ ƒ t d ƒ j
 | ƒ } t | t ƒ sšt ‚ | S(   sB   
        Returns the unicode representation of the entry.
        Rã   s   #. Rä   s   # i    s   
i   t   initial_indentt   subsequent_indentRÓ   s   %s%ss   %s:%st    i   t   -t   *s   #: s   #, %ss   , Ræ   Rç   Rè   s   #| RS   (   Rã   s   #. (   Rä   s   # (   R\   RÌ   R^   R~   R·   R™   R×   R!   R]   Rå   R`   RK   Ru   RÍ   R   R@   RA   Ra   (   RY   R   Rb   t   commentsRÞ   t   valRã   t   filelistR   t   linenot   filestrRJ   t   fieldsR#   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyR^   ¸  sV    	,

&	"	)	 	&c         C   sœ  |  j  | j  k r& |  j  r d Sd Sn  t |  j ƒ } t | j ƒ } d } x¡ | D]™ } y | | } Wn t k
 r{ d SX| d } | d | d k r¹ | d | d k r² d Sd Sn  | d | d k rS | d | d k rå d Sd SqS qS W|  j rl| j sd Sxc |  j D]U } | | j k r)d S|  j | | j | k rGd S|  j | | j | k  rd SqWn  |  j | j k r‚d S|  j | j k  r˜d Sd S(   sT   
        Called by comparison operations if rich comparison is not defined.
        iÿÿÿÿi   i    (   R\   R‰   Rå   t
   IndexErrorR›   Rh   (   RY   Rm   t   occ1t   occ2t   post   entry1t   entry2(    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt   __cmp__ý  sH    	
		c         C   s   |  j  | ƒ d k S(   Ni    (   Rû   (   RY   Rm   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt   __gt__.  s    c         C   s   |  j  | ƒ d k  S(   Ni    (   Rû   (   RY   Rm   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt   __lt__1  s    c         C   s   |  j  | ƒ d k S(   Ni    (   Rû   (   RY   Rm   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt   __ge__4  s    c         C   s   |  j  | ƒ d k S(   Ni    (   Rû   (   RY   Rm   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt   __le__7  s    c         C   s   |  j  | ƒ d k S(   Ni    (   Rû   (   RY   Rm   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyRn   :  s    c         C   s   |  j  | ƒ d k S(   Ni    (   Rû   (   RY   Rm   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt   __ne__=  s    c         C   sk   |  j  s d |  j k r t S|  j d k r/ t S|  j rg x( |  j D] } |  j | d k rB t SqB Wt St S(   sc   
        Returns ``True`` if the entry has been translated or ``False``
        otherwise.
        Rr   RS   (   R\   Ru   R!   Rt   R4   Rœ   (   RY   Rø   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyR½   @  s    	c         C   sõ   | j  |  _  | j |  _ | j |  _ | j |  _ d |  j k } | j |  _ | re |  j j d ƒ n  | j |  _ | j |  _ | j |  _ | j	 |  _	 | j
 |  _
 | j rñ xD | j D]6 } y |  j | Wq´ t k
 ré d |  j | <q´ Xq´ Wn  d S(   sC   
        Merge the current entry with the given pot entry.
        Rr   RS   N(   Rh   Ri   Rå   Rã   Ru   R]   R›   R\   Ræ   Rç   Rè   Rœ   Rˆ   (   RY   Rm   Rr   Rø   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyRÄ   P  s&    	c         C   s   t  |  j |  j f ƒ S(   N(   t   hashRh   Rt   (   RY   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt   __hash__i  s    (   R   R   R´   RU   R^   Rû   Rü   Rý   Rþ   Rÿ   Rn   R   R½   RÄ   R  (    (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyR   �  s   	&E	1								c           B   s    e  Z d  Z d „  Z d „  Z RS(   s%   
    Represents a mo file entry.
    c         O   sV   t  j |  | | Ž d |  _ d |  _ g  |  _ g  |  _ d |  _ d |  _ d |  _	 d S(   sÉ  
        Constructor, accepts the following keyword arguments,
        for consistency with :class:`~polib.POEntry`:

        ``comment``
        ``tcomment``
        ``occurrences``
        ``flags``
        ``previous_msgctxt``
        ``previous_msgid``
        ``previous_msgid_plural``

        Note: even though these keyword arguments are accepted,
        they hold no real meaning in the context of MO files
        and are simply ignored.
        RS   N(
   RÌ   RU   Rã   Rä   Rå   Ru   R   Ræ   Rç   Rè   (   RY   RZ   R%   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyRU   s  s    						c         C   s   t  |  j |  j f ƒ S(   N(   R  Rh   Rt   (   RY   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyR  �  s    (   R   R   R´   RU   R  (    (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyR   o  s   	R   c           B   s°   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   sW   
    A finite state machine to parse efficiently and correctly po
    file format.
    c         O   s  | j  d t ƒ } t | ƒ ru y t j | d d | ƒ|  _ Wq„ t k
 rq t } t j | d d | ƒ|  _ q„ Xn | j ƒ  |  _ | j  d ƒ } | d k r¨ t	 } n  | d | d | d | j  d t
 ƒ ƒ |  _ i  |  _ d |  _ t d |  j ƒ |  _ d |  _ d |  _ d |  _ d |  _ d d	 d
 d d d d d d d d d d d g } |  j d d d	 g d	 ƒ |  j d d
 d d d d d d d d d d g d ƒ |  j d
 | d
 ƒ |  j d | d ƒ |  j d | d ƒ |  j d | d ƒ |  j d | d ƒ |  j d | d ƒ |  j d d d	 d
 d d d d d d d d g d ƒ |  j d d d	 d
 d d d d d d d d d g d ƒ |  j d d d
 d d d d g d ƒ |  j d d d d g d ƒ |  j d d d d d g d ƒ |  j d d d d d d d d d g d ƒ d S(   s®  
        Constructor.

        Keyword arguments:

        ``pofile``
            string, path to the po file or its content

        ``encoding``
            string, the encoding to use, defaults to ``default_encoding``
            global variable (optional).

        ``check_for_duplicates``
            whether to check for duplicate entries when adding entries to the
            file (optional, default: ``False``).
        R   t   rtR   R    R   i    Ré   RL   t   het   gct   oct   flt   ctt   pct   pmt   ppt   tct   mst   mpt   mxt   mit   mcN(   R   R   R1   R
   R   R‚   R3   RÕ   R   R   R!   R)   t   transitionst   current_lineR   t   current_entryt   current_statet   current_tokent   msgstr_indext   entry_obsoletet   add(   RY   R    RZ   R%   R&   R   t   all(    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyRU   š  sR    "							!!!%c   
      C   s‰  i d d 6d d 6d d 6d d 6} i d	 d 6d
 d 6d d 6} g  } x |  j  D]õ} |  j d 7_ | j ƒ  } | d k r€ qM n  | j d+ d ƒ } t | ƒ } | d d k r´ qM n  | d d k r | d k r | d j ƒ  } | d } | d 8} d |  _ n	 d |  _ | d | k rž| d k rž| t | d ƒ j ƒ  } t j	 d | d d !ƒ rzt
 d |  j j |  j f ƒ ‚ n  | |  _ |  j | | d ƒ qM n  | |  _ | d d k rÙ| d k rÉqM n  |  j d ƒ qM | d  d k r4t j	 d | d d !ƒ r$t
 d |  j j |  j f ƒ ‚ n  |  j d ƒ qM | d  d k rT|  j d ƒ qM | d d k r†| d k rvqM n  |  j d ƒ qM | d d k s©| d j d  ƒ rÒ| d k rÂ| d! 7} n  |  j d" ƒ qM | d d# k r| d k rôqM n  |  j d$ ƒ qM | d d% k r#| d k rBt
 d& |  j j |  j f ƒ ‚ n  | d j ƒ  } | |  _ | d j d ƒ r�|  j d ƒ qM n  | d k r¯t
 d' |  j j |  j f ƒ ‚ n  | d | k rèt
 d( |  j j |  j | d f ƒ ‚ n  | t | d ƒ j ƒ  } | |  _ |  j | | d ƒ qM t
 d& |  j j |  j f ƒ ‚ qM W|  j r‹t | ƒ d k r‹| d j d ƒ r‹|  j j |  j ƒ n  |  j j d ƒ } | r`|  j j | ƒ | j |  j _ d+ } x• | j j ƒ  D]� } y2 | j d) d ƒ \ } }	 |	 j ƒ  |  j j | <WqØt t f k
 rX| d+ k	 rY|  j j | c d* | j ƒ  7<qYqØXqØWn  t |  j  t ƒ s‚|  j  j ƒ  n  |  j S(,   s€   
        Run the state machine, parse the file line by line and call process()
        with the current matched symbol.
        R  Ri   R  Rh   R  Rt   R  R›   R  R
  R	  i   RS   i   i    s   #~|s   #~i   s
   ([^\\]|^)"iÿÿÿÿsB   Syntax error in po file %s (line %s): unescaped double quote founds   #:R  RÑ   R  i   s   msgstr[R  s   #,R  t   #s   ##Rì   R  s   #.R  s   #|s$   Syntax error in po file %s (line %s)s?   Syntax error in po file %s (line %s): invalid continuation lines8   Syntax error in po file %s (line %s): unknown keyword %sR¶   s   
N(   R‚   R  R<   R·   R   R™   R  t   lstripR8   R:   R}   R)   R   R  t   processRØ   R  R]   Rj   t   removeRu   RX   Rt   RÕ   RW   R.   Rˆ   R@   RT   R?   (
   RY   t   keywordst   prev_keywordst   tokensRâ   t	   nb_tokenst   metadataentryR’   t   msgRð   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyR"   ë  sÀ    



			#		.c         C   sA   x: | D]2 } t  |  d | ƒ } | | f |  j | | f <q Wd S(   sF  
        Add a transition to the state machine.

        Keywords arguments:

        ``symbol``
            string, the matched token (two chars symbol).

        ``states``
            list, a list of states (two chars symbols).

        ``next_state``
            the next state the fsm will have after the action.
        s	   handle_%sN(   R~   R  (   RY   t   symbolt   statest
   next_statet   statet   action(    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyR  „  s    c         C   s`   y5 |  j  | |  j f \ } } | ƒ  r4 | |  _ n  Wn$ t k
 r[ t d |  j ƒ ‚ n Xd S(   s-  
        Process the transition corresponding to the current state and the
        symbol provided.

        Keywords arguments:

        ``symbol``
            string, the matched token (two chars symbol).

        ``linenum``
            integer, the current line number of the parsed file.
        s!   Syntax error in po file (line %s)N(   R  R  t	   ExceptionR}   R  (   RY   R%  R)  R(  (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyR  —  s    	c         C   sD   |  j  j d k r' |  j  j d 7_ n  |  j  j |  j d 7_ d S(   s   Handle a header comment.RS   s   
i   i   (   R)   RV   R  (   RY   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt	   handle_he®  s    c         C   s¥   |  j  d
 k r: |  j j |  j ƒ t d |  j ƒ |  _ n  |  j j d k ra |  j j d 7_ n  |  j j d ƒ } | j	 d ƒ r� | d	 } n  |  j j | 7_ t
 S(   s   Handle a translator comment.R  R  R  Ré   RS   s   
R  Rì   i   (   R  R  R  (   R  R)   R]   R  R   R  Rä   R  R  RØ   R4   (   RY   Rä   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt	   handle_tcµ  s    c         C   s~   |  j  d k r: |  j j |  j ƒ t d |  j ƒ |  _ n  |  j j d k ra |  j j d 7_ n  |  j j |  j d 7_ t S(	   s   Handle a generated comment.R  R  R  Ré   RS   s   
i   (   R  R  R  (	   R  R)   R]   R  R   R  Rã   R  R4   (   RY   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt	   handle_gcÂ  s    c         C   sõ   |  j  d k r: |  j j |  j ƒ t d |  j ƒ |  _ n  |  j d j ƒ  } x¡ | D]™ } | d k rT yQ | j d ƒ \ } } | j ƒ  s� | | } d } n  |  j j	 j | | f ƒ Wqí t
 t f k
 ré |  j j	 j | d f ƒ qí XqT qT Wt S(	   s   Handle a file:num occurrence.R  R  R  Ré   i   RS   R¶   (   R  R  R  (   R  R)   R]   R  R   R  R  R·   t   isdigitRå   R.   t   AttributeErrorR4   (   RY   Rå   t
   occurrencet   filRâ   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt	   handle_ocÌ  s    
	$c         C   sy   |  j  d k r: |  j j |  j ƒ t d |  j ƒ |  _ n  |  j j g  |  j d j d ƒ D] } | j	 ƒ  ^ q[ 7_ t
 S(   s   Handle a flags line.R  R  R  Ré   i   Rµ   (   R  R  R  (   R  R)   R]   R  R   R  Ru   R  R·   R<   R4   (   RY   RÞ   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt	   handle_flÞ  s    .c         C   sZ   |  j  d k r: |  j j |  j ƒ t d |  j ƒ |  _ n  t |  j d d !ƒ |  j _ t	 S(   s$   Handle a previous msgid_plural line.R  R  R  Ré   i   iÿÿÿÿ(   R  R  R  (
   R  R)   R]   R  R   R  R   R  Rè   R4   (   RY   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt	   handle_ppç  s
    c         C   sZ   |  j  d k r: |  j j |  j ƒ t d |  j ƒ |  _ n  t |  j d d !ƒ |  j _ t	 S(   s   Handle a previous msgid line.R  R  R  Ré   i   iÿÿÿÿ(   R  R  R  (
   R  R)   R]   R  R   R  R   R  Rç   R4   (   RY   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt	   handle_pmð  s
    c         C   sZ   |  j  d k r: |  j j |  j ƒ t d |  j ƒ |  _ n  t |  j d d !ƒ |  j _ t	 S(   s   Handle a previous msgctxt line.R  R  R  Ré   i   iÿÿÿÿ(   R  R  R  (
   R  R)   R]   R  R   R  R   R  Ræ   R4   (   RY   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt	   handle_pcù  s
    c         C   sZ   |  j  d k r: |  j j |  j ƒ t d |  j ƒ |  _ n  t |  j d d !ƒ |  j _ t	 S(   s   Handle a msgctxt.R  R  R  Ré   i   iÿÿÿÿ(   R  R  R  (
   R  R)   R]   R  R   R  R   R  Ri   R4   (   RY   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt	   handle_ct  s
    c         C   si   |  j  d k r: |  j j |  j ƒ t d |  j ƒ |  _ n  |  j |  j _ t |  j	 d d !ƒ |  j _
 t S(   s   Handle a msgid.R  R  R  Ré   i   iÿÿÿÿ(   R  R  R  (   R  R)   R]   R  R   R  R  R\   R   R  Rh   R4   (   RY   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt	   handle_mi
  s    c         C   s    t  |  j d d !ƒ |  j _ t S(   s   Handle a msgid plural.i   iÿÿÿÿ(   R   R  R  R›   R4   (   RY   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt	   handle_mp  s    c         C   s    t  |  j d d !ƒ |  j _ t S(   s   Handle a msgstr.i   iÿÿÿÿ(   R   R  R  Rt   R4   (   RY   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt	   handle_ms  s    c         C   s\   |  j  d } |  j  |  j  j d ƒ d d !} t | ƒ |  j j t | ƒ <t | ƒ |  _ t S(   s   Handle a msgstr plural.i   RÑ   i   iÿÿÿÿ(   R  Rj   R   R  Rœ   Rº   R  R4   (   RY   Rq   Ry   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt	   handle_mx  s
     c         C   sA  t  |  j d d !ƒ } |  j d k r: |  j j | 7_ n|  j d k r^ |  j j | 7_ nß |  j d k r‚ |  j j | 7_ n» |  j d k r¦ |  j j | 7_ n— |  j d k rÑ |  j j |  j	 c | 7<nl |  j d k rõ |  j j
 | 7_
 nH |  j d	 k r|  j j | 7_ n$ |  j d
 k r=|  j j | 7_ n  t S(   s+   Handle a msgid or msgstr continuation line.i   iÿÿÿÿR  R  R  R  R  R  R
  R	  (   R   R  R  R  Ri   Rh   R›   Rt   Rœ   R  Rè   Rç   Ræ   R!   (   RY   t   token(    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt	   handle_mc%  s$    (   R   R   R´   RU   R"   R  R  R+  R,  R-  R2  R3  R4  R5  R6  R7  R8  R9  R:  R;  R=  (    (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyR   ”  s&   	Q	™					
															R    c           B   sD   e  Z d  Z d „  Z d „  Z d „  Z d d d d „ Z d „  Z RS(   s+   
    A class to parse binary mo files.
    c      	   O   sp   t  | d ƒ |  _ | j d ƒ } | d k r6 t } n  | d | d | j d t ƒ d | j d t ƒ ƒ |  _ d S(   s®  
        Constructor.

        Keyword arguments:

        ``mofile``
            string, path to the mo file or its content

        ``encoding``
            string, the encoding to use, defaults to ``default_encoding``
            global variable (optional).

        ``check_for_duplicates``
            whether to check for duplicate entries when adding entries to the
            file (optional, default: ``False``).
        R7   R   R   R   R   N(   R   R‚   R   R   R   R   R!   R)   (   RY   R   RZ   R%   R   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyRU   C  s    	c         C   s   |  j  r |  j  j ƒ  n  d S(   s†   
        Make sure the file is closed, this prevents warnings on unclosed file
        when running tests with python >= 3.2.
        N(   R‚   R?   (   RY   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt   __del___  s    	c         C   sV  |  j  d d ƒ } | t j k r* d } n$ | t j k rB d } n t d ƒ ‚ | |  j _ |  j  | d ƒ \ } } | d k r� t d	 ƒ ‚ n  | |  j _ |  j  | d ƒ \ } } |  j j	 | ƒ g  } x- t
 | ƒ D] } | j |  j  | d ƒ ƒ qÔ W|  j j	 | ƒ g  }	 x- t
 | ƒ D] } |	 j |  j  | d ƒ ƒ qW|  j j }
 xöt
 | ƒ D]è} |  j j	 | | d ƒ |  j j | | d ƒ } |  j j	 |	 | d ƒ |  j j |	 | d ƒ } | d k r¡| r¡| j t d
 ƒ ƒ i  } } x� | D]• } | j t d ƒ d ƒ } | d t d ƒ k röy: | d j |
 ƒ } | d j |
 ƒ } | j ƒ  | | <Wq‹t k
 r‡t d ƒ | | <q‹XqöqöW| |  j _ qVn  | j t d ƒ ƒ } t | ƒ d k r|  j d | d d | d d t d „  t | j t d ƒ ƒ ƒ Dƒ ƒ ƒ } n |  j d | d | ƒ } |  j j | ƒ qVW|  j j ƒ  |  j S(   s^   
        Build the instance with the file handle provided in the
        constructor.
        s   <Ii   s   <IIs   >IIs,   Invalid mo file, magic number is incorrect !i   i    i   s1   Invalid mo file, unexpected major revision numbers   
R¶   RS   s    Rh   R›   Rœ   c         s   s!   |  ] \ } } | | f Vq d  S(   N(    (   RÁ   t   kt   v(    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pys	   <genexpr>£  s    Rt   (   i    i   (   t   _readbinaryR   RŸ   RË   R}   R)   RÈ   RÉ   R‚   t   seekt   rangeR]   R   t   readR·   R   RB   R<   Rõ   R   RW   R™   t   _build_entryRÂ   t	   enumerateR?   (   RY   RÈ   t   iiRÉ   t   numofstringst   msgids_hash_offsett   msgstrs_hash_offsett   msgids_indexR–   t   msgstrs_indexR   Rh   Rt   t   raw_metadataRW   Râ   R!  R?  R@  t   msgid_tokensRe   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyR"   g  sd    			

	(c   	      C   s÷   | j  t d ƒ ƒ } |  j j } t | ƒ d k rd i | d j | ƒ d 6| d j | ƒ d 6} n i | j | ƒ d 6} | r– | j | ƒ | d <n  | r² | j | ƒ | d <n  | rí x% | D] } | | j | ƒ | | <q¿ W| | d <n  t | �  S(	   Ns   i   i    Ri   Rh   Rt   R›   Rœ   (   R·   R   R)   R   R™   RB   R   (	   RY   Rh   Rt   R›   Rœ   t   msgctxt_msgidR   R%   R?  (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyRE  ­  s     c         C   sB   |  j  j | ƒ } t j | | ƒ } t | ƒ d k r> | d S| S(   s–   
        Private method that unpack n bytes of data using format <fmt>.
        It returns a tuple or a mixed value if the tuple length is 1.
        i   i    (   R‚   RD  R�   t   unpackR™   (   RY   t   fmtt   numbytest   bytest   tup(    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyRA  Â  s
    N(	   R   R   R´   RU   R>  R"   R   RE  RA  (    (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyR    >  s   			Ft   TextWrapperc           B   s    e  Z d  Z d „  Z d „  Z RS(   sX   
    Subclass of textwrap.TextWrapper that backport the
    drop_whitespace option.
    c         O   s5   | j  d t ƒ } t j j |  | | Ž | |  _ d  S(   NRÒ   (   R‡   R4   t   textwrapRU  RU   RÒ   (   RY   RZ   R%   RÒ   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyRU   Õ  s    c         C   s  g  } |  j  d k r+ t d |  j  ƒ ‚ n  | j ƒ  xC| rzg  } d } | r\ |  j } n	 |  j } |  j  t | ƒ } |  j r§ | d j ƒ  d k r§ | r§ | d =n  xK | rô t | d ƒ } | | | k rð | j | j	 ƒ  ƒ | | 7} qª Pqª W| r*t | d ƒ | k r*|  j
 | | | | ƒ n  |  j rT| rT| d j ƒ  rT| d =n  | r8 | j | d j | ƒ ƒ q8 q8 W| S(   sŸ  _wrap_chunks(chunks : [string]) -> [string]

        Wrap a sequence of text chunks and return a list of lines of
        length 'self.width' or less.  (If 'break_long_words' is false,
        some lines may be longer than this.)  Chunks correspond roughly
        to words and the whitespace between them: each chunk is
        indivisible (modulo 'break_long_words'), but a line break can
        come between any two chunks.  Chunks should not have internal
        whitespace; ie. a chunk is either all whitespace or a "word".
        Whitespace chunks will be removed from the beginning and end of
        lines, but apart from that whitespace is preserved.
        i    s   invalid width %r (must be > 0)iÿÿÿÿRS   (   t   widthR.   t   reverseRë   Rê   R™   RÒ   R<   R]   R‡   t   _handle_long_wordR`   (   RY   t   chunksRÛ   t   cur_linet   cur_lent   indentRW  RJ   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt   _wrap_chunksÚ  s4    
		%
	 
!(   R   R   R´   RU   R^  (    (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyRU  Ð  s   	iF   c         K   s>   t  j d k  r( t d | | � j |  ƒ St j |  d | | �S(   sM   
    Wrap a single paragraph of text, returning a list of wrapped lines.
    i   i   RW  (   i   i   (   R    R¡   RU  R×   RV  (   t   textRW  R%   (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyR×   #  s    (*   R´   t
   __author__t   __version__t   __all__R£   R   R+   R8   R�   R    RV  R
   t   ImportErrort   objectR   R¡   R!   R=   R   RA   R   R   R4   Rl   R*   R1   R    R   R	   R   R   RT   RR   R   R   RÌ   R   R   R   R    RU  R×   (    (    (    sb   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/polib/__init__.pyt   <module>   sX   						 	!9		ÿ NjI�â%ÿ «’S