ó
X¾÷Xc           @   sg   d  d l  Z  d  d l Z d  d l m Z d  d l m Z d „  Z d „  Z d e j f d „  ƒ  YZ	 d S(   iÿÿÿÿN(   t   find_package(   t   basec          C   s7   d }  t  j j t  j j t j d ƒ ƒ r3 d }  n  |  S(   Ns	   share/mant   man(   t   ost   patht   existst   joint   syst   prefix(   t   manpath(    (    s,   /tmp/pip-build-h1VYrz/pbr/pbr/hooks/files.pyt   get_manpath   s    $	c         C   s   t  j j t ƒ  d |  ƒ S(   Ns   man%s(   R   R   R   R
   (   t   section(    (    s,   /tmp/pip-build-h1VYrz/pbr/pbr/hooks/files.pyt   get_man_section"   s    t   FilesConfigc           B   sM   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 RS(   t   filesc         C   s;   t  t |  ƒ j | ƒ | |  _ |  j j d d ƒ |  _ d  S(   Nt
   data_filest    (   t   superR   t   __init__t   namet   configt   getR   (   t   selfR   R   (    (    s,   /tmp/pip-build-h1VYrz/pbr/pbr/hooks/files.pyR   *   s    	c         C   s'   |  j  |  j d <t t |  ƒ j ƒ  d  S(   NR   (   R   R   R   R   t   save(   R   (    (    s,   /tmp/pip-build-h1VYrz/pbr/pbr/hooks/files.pyR   /   s    c   
   
   C   s6  g  } x|  j  j d ƒ D]} | j ƒ  j d ƒ rd | k r| j d ƒ \ } } | j ƒ  d  } | j ƒ  } | j t j j ƒ s™ | t j j 7} n  x€ t j | ƒ D]_ \ } } } | j	 d | j
 | | ƒ ƒ | j g  | D] }	 d t j j | |	 ƒ ^ qâ ƒ q© Wq | j	 | ƒ q Wd j | ƒ |  _  d  S(   Ns   
t   *t   =iÿÿÿÿs   %s = s    %s(   R   t   splitt   rstript   endswitht   stripR   R   t   sept   walkt   appendt   replacet   extendR   (
   R   t   finishedt   linet   targett   source_globt   source_prefixt   dirpatht   dirnamest   fnamest   f(    (    s,   /tmp/pip-build-h1VYrz/pbr/pbr/hooks/files.pyt   expand_globs3   s    !4c         C   s   d |  j  | f |  _  d  S(   Ns   %s
%s =(   R   (   R   t   man_path(    (    s,   /tmp/pip-build-h1VYrz/pbr/pbr/hooks/files.pyt   add_man_pathF   s    c         C   s   d |  j  | f |  _  d  S(   Ns   %s
  %s(   R   (   R   t   man_page(    (    s,   /tmp/pip-build-h1VYrz/pbr/pbr/hooks/files.pyt   add_man_pageI   s    c         C   ss   t  ƒ  } |  j d } xV | j ƒ  D]H } | j ƒ  d } | j | t ƒ  ƒ } | j | j ƒ  ƒ | | | <q# W| S(   Nt   manpagesiÿÿÿÿ(   t   dictt
   pbr_configR   R   R   t   listR    (   R   t   man_sectionsR1   t   manpaget   section_numberR   (    (    s,   /tmp/pip-build-h1VYrz/pbr/pbr/hooks/files.pyt   get_man_sectionsL   s    	c   	      C   s  |  j  j d |  j ƒ j ƒ  } g  } xN | j d ƒ D]= } t j j | j ƒ  ƒ r4 | j t	 j
 | j ƒ  ƒ ƒ q4 q4 Wd j | ƒ |  j  d <|  j ƒ  d |  j k r|  j ƒ  } xT | j ƒ  D]C \ } } t | ƒ } |  j | ƒ x | D] } |  j | ƒ qé Wq½ Wn  d  S(   Nt   packagess   
R1   (   R   R   R   R   R   R   R   t   isdirR    R    t   smart_find_packagesR   R,   R3   R8   t   itemsR   R.   R0   (	   R   R9   t   expandedt   pkgR5   R   t   pagesR	   t   page(    (    s,   /tmp/pip-build-h1VYrz/pbr/pbr/hooks/files.pyt   hookV   s    #
(
   t   __name__t
   __module__R   R   R   R,   R.   R0   R8   RA   (    (    (    s,   /tmp/pip-build-h1VYrz/pbr/pbr/hooks/files.pyR   &   s   						
(
   R   R   t   pbrR    t	   pbr.hooksR   R
   R   t
   BaseConfigR   (    (    (    s,   /tmp/pip-build-h1VYrz/pbr/pbr/hooks/files.pyt   <module>   s   		