ó
@K7]c           @` s  d  d l  m Z m Z m Z d  d l Z d  d l Z d  d l m Z d  d l m	 Z	 d j
 ƒ  Z e j d ƒ Z e j d ƒ Z e j d ƒ Z e j d	 ƒ Z e j d
 e j e j ƒ ƒ Z d „  Z d „  Z d „  Z d e d „ Z d e d „ Z d „  Z d S(   i    (   t   absolute_importt   divisiont   print_functionN(   t
   exceptions(   t
   comma_joins\   
AGPL
LGPL
GPL3
GPL2
GPL
BSD
MIT
APACHE
PSF
CC
MOZILLA
PUBLIC-DOMAIN
PROPRIETARY
OTHER
NONE
s	   GPL[^3]*2s	   GPL[^2]*3s   GPL[^2]*>= *2s   CC\w+s   [%s]c         C` s   t  j |  ƒ p t j |  ƒ S(   s3   True if family matches GPL3 or GPL >= 2, else False(   t   gpl23_regext   searcht
   gpl3_regex(   t   family(    (    s9   lib/python2.7/site-packages/conda_build/license_family.pyt
   match_gpl3"   s    c         C` sU   |  j  ƒ  }  t j d d |  ƒ }  t j d d |  ƒ }  t j d d |  ƒ }  |  j ƒ  S(   s7   Set to ALL CAPS, replace common GPL patterns, and strips   GENERAL PUBLIC LICENSEt   GPLs   LESSER *t   Ls   AFFERO *t   A(   t   uppert   ret   subt   strip(   t   s(    (    s9   lib/python2.7/site-packages/conda_build/license_family.pyt	   normalize(   s
    c         C` s+   t  j d |  ƒ }  t j d d |  ƒ }  |  S(   s0   Remove punctuation, spaces, tabs, and line feedst    s   \s+t    (   t
   punk_regexR   R   (   R   (    (    s9   lib/python2.7/site-packages/conda_build/license_family.pyt   remove_special_characters1   s    c         C` s@   t  |  t ƒ r- |  j d |  j d ƒ ƒ } n |  } t | | ƒ S(   s—   Return best guess of license_family from the conda package index.

    Note: Logic here is simple, and focuses on existing set of allowed families
    t   license_familyt   license(   t
   isinstancet   dictt   gett   guess_license_family(   t   indext
   recognizedt   license_name(    (    s9   lib/python2.7/site-packages/conda_build/license_family.pyt   guess_license_family_from_index8   s    c         C` sÅ   |  d k r d St |  ƒ }  t j d d |  ƒ } t | ƒ rA d St j | ƒ rT d St j |  ƒ rg d St |  ƒ }  x$ | D] } t | ƒ |  k rz | Sqz Wx$ | D] } |  t | ƒ k r¡ | Sq¡ Wd S(	   s—   Return best guess of license_family from the conda package index.

    Note: Logic here is simple, and focuses on existing set of allowed families
    t   NONEs   [A,L]GPLR   t   GPL3t   GPL2t   CCt   OTHERN(	   t   NoneR   R   R   R	   t
   gpl2_regexR   t   cc_regexR   (   R   R   t	   sans_lgplR   (    (    s9   lib/python2.7/site-packages/conda_build/license_family.pyR   G   s$    c         C` s–   y |  d d } Wn t  k
 r& d  SXg  t D] } t t | ƒ ƒ ^ q. } t t | ƒ ƒ | k r’ t t j d | t t t ƒ ƒ f ƒ ƒ ‚ n  d  S(   Nt   aboutR   s?   about/license_family '%s' not allowed. Allowed families are %s.(	   t   KeyErrort   allowed_license_familiesR   R   t   RuntimeErrorR   t   indentR   t   sorted(   t   metaR   t   famt   allowed_families(    (    s9   lib/python2.7/site-packages/conda_build/license_family.pyt   ensure_valid_license_familyg   s    "	(   t
   __future__R    R   R   R   t   stringt   conda_buildR   t   conda_build.utilsR   t   splitR,   t   compileR'   R   R   R(   t   escapet   punctuationR   R	   R   R   R&   R    R   R3   (    (    (    s9   lib/python2.7/site-packages/conda_build/license_family.pyt   <module>   s$   				