Ñò
ýÉªWc           @   s‚   d  d k  Z  d  d k Z d  d k Z d  d k l Z d  d k l Z d e  i  f d „  ƒ  YZ d „  Z e d j o e ƒ  n d S(   iÿÿÿÿN(   t   parseString(   t   CMSVersionDeploymentPolicyt   ReportConfigurationc           B   sG   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   s#   t  i  i |  ƒ t i ƒ  |  _ d  S(   N(   t	   BaseClasst   __init__R   t   getReportConfigurationFilePatht   filePath(   t   self(    (    sm   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/ReportConfiguration.pyR      s    c      
      sÉ   t  i i ˆ i ƒ p t St ˆ i d ƒ i ƒ  } y t | ƒ } Wn t i	 i
 i j
 o
 } t SXt ‡  f d †  | i d ƒ ƒ } t ‡ ‡  f d †  | d i d ƒ ƒ } y | d SWn t SXd  S(   Nt   rc            s   |  i  d  ƒ ˆ  d j S(   t   namei    (   t   getAttribute(   t   element(   t   data(    sm   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/ReportConfiguration.pyt   <lambda>   s    t   reportCategoryc            s*   ˆ  i  |  i d  ƒ d i i ƒ ˆ d j S(   t   titlei    i   (   t   trimt   getElementsByTagNamet
   firstChildt	   nodeValue(   R   (   R   R   (    sm   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/ReportConfiguration.pyR      s    i    t   report(   t   ost   patht   existsR   t   Falset   filet   readR    t   xmlt   parserst   expatt
   ExpatErrort   filterR   (   R   R   t   ft   domt   errt
   categoriest   reports(    (   R   R   sm   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/ReportConfiguration.pyt   checkExistence   s    !(c         C   s   d S(   Ni    (    (   R   (    (    sm   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/ReportConfiguration.pyt	   getNextId    s    c         C   s}   d | d GHt  |  i d ƒ i ƒ  } t | ƒ } |  i | | ƒ t  |  i d ƒ } |  i | ƒ } | i | ƒ | i ƒ  d  S(   Ns8   Adding report configuration '%s' to report-config.xml...i   R   t   w(   R   R   R   R    t	   insertDomt	   prettyxmlt   writet   close(   R   t   id_R   t   finR!   t   foutR)   (    (    sm   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/ReportConfiguration.pyt   insert#   s    c            sÛ   d ˆ  d GHt  ˆ i d ƒ i ƒ  } t | ƒ } t ‡  f d †  | i d ƒ ƒ } t ‡ ‡  f d †  | d i d ƒ ƒ } | d i | d ƒ ˆ i | ˆ  ƒ t  ˆ i d	 ƒ } ˆ i | ƒ } | i	 | ƒ | i
 ƒ  d  S(
   Ns:   Updating report configuration '%s' to report-config.xml...i   R   c            s   |  i  d  ƒ ˆ  d j S(   R	   i    (   R
   (   R   (   R   (    sm   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/ReportConfiguration.pyR   5   s    R   c            s*   ˆ  i  |  i d  ƒ d i i ƒ ˆ d j S(   R   i    i   (   R   R   R   R   (   R   (   R   R   (    sm   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/ReportConfiguration.pyR   6   s    i    R   R'   (   R   R   R   R    R   R   t   removeChildR(   R)   R*   R+   (   R   R   R-   R!   R#   R$   R.   R)   (    (   R   R   sm   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/ReportConfiguration.pyt   update0   s    !(c   	         s  t  ‡  f d †  | i d ƒ ƒ d } | i d ƒ } | i d ƒ } | i | i ˆ  d ƒ ƒ | i | ƒ | i d ƒ } | i | i ˆ  d ƒ ƒ | i | ƒ | i d	 ƒ } | i | i ˆ  d
 ƒ ƒ | i | ƒ | i d ƒ } | i | i ˆ  d ƒ ƒ | i | ƒ | i | ƒ d  S(   Nc            s   |  i  d  ƒ ˆ  d j S(   R	   i    (   R
   (   R   (   R   (    sm   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/ReportConfiguration.pyR   A   s    R   i    R   R   i   t   catalogNamei   t
   reportNamei   t   reportVersioni   (   R   R   t   createElementt   appendChildt   createTextNode(	   R   R!   R   t   categoryt   reportElementt   titleElementt   catalogNameElementt   reportNameElementt   reportVersionElement(    (   R   sm   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/ReportConfiguration.pyR(   @   s    %c         C   sü   d | d GH| d } | d } t  |  i d ƒ i ƒ  } t | ƒ } xx | i d ƒ D]g } | i d ƒ } | | j oE xB | i d ƒ D]- } | i i | j o | i | i	 ƒ q‡ q‡ WqU qU Wt  |  i d ƒ }	 |  i
 | ƒ }
 |	 i |
 ƒ |	 i ƒ  d	 S(
   sj    delete a report from the configuration file
        data[0]: catalog name
        data[1]: title
        s,   Delete report '%s' from report-config.xml...i   i    R   R   R	   R   R'   N(   R   R   R   R    R   R
   R   R   R0   t
   parentNodeR)   R*   R+   (   R   R   t   catNameR   R-   R!   t   catElemR	   t   reportTitleR.   R)   (    (    sm   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/ReportConfiguration.pyt   deleteW   s"    

   (	   t   __name__t
   __module__R   R%   R&   R/   R1   R(   RB   (    (    (    sm   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/ReportConfiguration.pyR   	   s   						c          C   s   t  ƒ  }  |  i d ƒ d  S(   Ns   Content Reportss   Content Ingest Reports#   /prepack-catalog/PrePackCatalog.cats/   /prepack-catalog/PrePackContentIngestionRep.clst   1(   s   Content Reportss   Content Ingest Reports#   /prepack-catalog/PrePackCatalog.cats/   /prepack-catalog/PrePackContentIngestionRep.clsRE   (   R   t   add(   t   cf(    (    sm   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/ReportConfiguration.pyt   mainp   s    	t   __main__(	   R   R   R   t   xml.dom.minidomR    R   R   RH   RC   (    (    (    sm   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/ReportConfiguration.pyt   <module>   s   g	