ó
3Rc           @   sy   d  Z  d d l Z d Z d   Z d   Z d Z e j e e j  Z d   Z	 d   Z
 d	   Z d
   Z e d  Z d S(   s   provides git-dch helpersi˙˙˙˙NiL   c         C   sr   i  } g  } xY |  D]Q } | j  d  rW | j d d  d j   j   } t | | <q | j |  q W| | f S(   s˙   Return a dictionary of all Git-Dch: commands found in lines.
    The command keys will be lowercased, i.e. {'ignore' : True,
    'short': True}.  For now, all the options are binary.  Also return
    all of the lines that do not contain Git-Dch: commands.s	   Git-Dch: t    i   (   t
   startswitht   splitt   stript   lowert   Truet   append(   t   linest   optionst   commandst   other_linest   linet   cmd(    (    s+   /usr/lib/python2.7/dist-packages/gbp/dch.pyt   extract_git_dch_cmds   s    "c         C   sI   | j  rA t j | j   } g  |  D] } | j |  s" | ^ q" S|  Sd S(   sK   Filter any lines that match options.ignore_regex
    (i.e. --ignore-regex).N(   t   ignore_regext   ret   compilet   match(   R   R   t	   ignore_reR   (    (    s+   /usr/lib/python2.7/dist-packages/gbp/dch.pyt   filter_ignore_rx_matches'   s    	&s   (?:bug|issue)?\#?\s?\d+c   	      C   sŕ   t  j d | j t f t  j  } i  } g  } xĽ |  D] } | j |  } | rĹ g  t j | t  j  D] } | j   ^ qf } y | | j	 d  c | 7<WqŇ t
 k
 rÁ | | | j	 d  <qŇ Xq5 | j |  q5 W| | f S(   s)  Return a dictionary of the bug tracking system commands
    contained in the the given lines.  i.e. {'closed' : [1], 'fixed':
    [3, 4]}.  Right now, this will only notice a single directive
    clause on a line.  Also return all of the lines that do not
    contain bug tracking system commands.s   (?P<bts>%s):\s+%st   bts(   R   R   t   meta_closest   _bug_rt   IR   t   _bug_ret   findallR   t   groupt   KeyErrorR   (	   R   t   optst   bts_rxR	   R
   R   t   mt   bugt   bug_nums(    (    s+   /usr/lib/python2.7/dist-packages/gbp/dch.pyt   extract_bts_cmds4   s    ".c         C   si   g  } g  } xP |  D]H } | j  d  rN | j | j d d  d j    q | j |  q W| | f S(   st   Return a list of all of the Thanks: entries, and a list of all
    of the lines that do not contain Thanks: entries.s   Thanks: R    i   (   R   R   R   R   (   R   R   t   thanksR
   R   (    (    s+   /usr/lib/python2.7/dist-packages/gbp/dch.pyt   extract_thanks_infoJ   s    &c         C   s   |  j    o |  j   S(   N(   t   isalnumt   isspace(   t   ch(    (    s+   /usr/lib/python2.7/dist-packages/gbp/dch.pyt   _ispunctW   s    c         C   s   t  |   d k  r |  S|  d r8 t |  d d  r8 |  S|  d rn t |  d d  sj |  d d j   rn |  S|  d d g |  d S(   s;   Terminate the first line of lines with a '.' if multi-line.i   i    i˙˙˙˙i   t   .(   t   lenR'   t   islower(   R   (    (    s+   /usr/lib/python2.7/dist-packages/gbp/dch.pyt   terminate_first_line_if_needed[   s    2c         C   sš  |  d g } |  d j    } |  d } t | |  \ } } d | k rL d S| j rx d | d | j !| d | d <n  t | |  \ } } t | |  \ } } t | |  } d | k sŇ | j rd | k r| j g  | D] }	 |	 j	   rß |	 ^ qß  n  | r(d	 | d
 }
 | j |
 g  n  x~ | D]v } d | d j
 | |  f } t | d
  t |  t k r| j d g  n | d
 c d 7<| d
 c | 7<q/Wt |  } | S(   sŮ   Return a list of lines (without newlines) as the changelog
    entry for commit_info (generated by
    GitRepository.get_commit_info()).  If last_commit is not False,
    then this entry is the last one in the series.t   subjectt   bodyt   idt   ignores   [%s] i    t   fullt   shorts   Thanks to %si˙˙˙˙s   (%s: %s)s   , t    R    N(   t
   splitlinesR   t   Nonet   idlenR!   R#   R   R0   t   extendR   t   joinR)   t   MAX_CHANGELOG_LINE_LENGTHR+   (   t   commit_infoR   t   last_committ   entryR-   t   commitidt   git_dch_cmdst   bts_cmdsR"   R   t
   thanks_msgR   t   bts_msg(    (    s+   /usr/lib/python2.7/dist-packages/gbp/dch.pyt   format_changelog_entryg   s0    
	#!/ (   t   __doc__R   R8   R   R   R   R   R   R   R!   R#   R'   R+   t   FalseRA   (    (    (    s+   /usr/lib/python2.7/dist-packages/gbp/dch.pyt   <module>   s   		
				