ó
ã¶xTc           @   sH   d  d l  Z  d  d l Z d  d l m Z m Z d e f d „  ƒ  YZ d S(   iÿÿÿÿN(   t	   compileUit   loadUit   Driverc           B   s\   e  Z d  Z d Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z RS(
   s}    This encapsulates access to the pyuic functionality so that it can be
    called by code that is Python v2/v3 specific.
    s	   PyQt4.uicc         C   ss   | j  r] t j |  j ƒ } t j ƒ  } | j t j d ƒ ƒ | j | ƒ | j t j	 ƒ n  | |  _
 | |  _ d S(   sk    Initialise the object.  opts is the parsed options.  ui_file is the
        name of the .ui file.
        s   %(name)s: %(message)sN(   t   debugt   loggingt	   getLoggert   LOGGER_NAMEt   StreamHandlert   setFormattert	   Formattert
   addHandlert   setLevelt   DEBUGt   _optst   _ui_file(   t   selft   optst   ui_filet   loggert   handler(    (    sR   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/python2.7/site-packages/PyQt4/uic/driver.pyt   __init__)   s    		c         C   s$   |  j  j r |  j ƒ  S|  j ƒ  d S(   si    Invoke the action as specified by the parsed options.  Returns 0 if
        there was no error.
        i    (   R   t   previewt   _previewt	   _generate(   R   (    (    sR   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/python2.7/site-packages/PyQt4/uic/driver.pyt   invoke8   s    

c         C   sH   d d l  m } | j |  j g ƒ } t |  j ƒ } | j ƒ  | j ƒ  S(   sh    Preview the .ui file.  Return the exit status to be passed back to
        the parent process.
        iÿÿÿÿ(   t   QtGui(   t   PyQt4R   t   QApplicationR   R   t   showt   exec_(   R   R   t   appt   widget(    (    sR   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/python2.7/site-packages/PyQt4/uic/driver.pyR   D   s
    
c         C   sÞ   t  j d k rj |  j j d k rL d d l m } | t  j j d d ƒ} q� t |  j j d d d ƒ} n3 |  j j d k rˆ t  j } n t |  j j d ƒ } t	 |  j
 | |  j j |  j j |  j j |  j j |  j j ƒ d S(	   s    Generate the Python code. i   t   -iÿÿÿÿ(   t   TextIOWrappert   encodingt   utf8t   wtN(   t   syst
   hexversionR   t   outputt   ioR!   t   stdoutt   buffert   openR    R   t   executet   indentt   pyqt3_wrappert   from_importst   resource_suffix(   R   R!   t   pyfile(    (    sR   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/python2.7/site-packages/PyQt4/uic/driver.pyR   Q   s    c         C   s$   t  j j d | j | j f ƒ d S(   s    Handle an IOError exception. s   Error: %s: "%s"
N(   R%   t   stderrt   writet   strerrort   filename(   R   t   e(    (    sR   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/python2.7/site-packages/PyQt4/uic/driver.pyt
   on_IOErrore   s    c         C   s   t  j j d | ƒ d S(   s!    Handle a SyntaxError exception. s   Error in input file: %s
N(   R%   R2   R3   (   R   R6   (    (    sR   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/python2.7/site-packages/PyQt4/uic/driver.pyt   on_SyntaxErrorj   s    c         C   sG   | j  d j d ƒ r) t j j d ƒ n t j j t | ƒ d ƒ d S(   s'    Handle a NoSuchWidgetError exception. i    t   Q3s5   Error: Q3Support widgets are not supported by PyQt4.
s   
N(   t   argst
   startswithR%   R2   R3   t   str(   R   R6   (    (    sR   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/python2.7/site-packages/PyQt4/uic/driver.pyt   on_NoSuchWidgetErroro   s    c         C   sk   t  j |  j ƒ j t  j k r@ d d l } | j t j ƒ  Œ  n' d d l	 m
 } t j j d | j ƒ d S(   s    Handle a generic exception. iÿÿÿÿN(   t   QtCores>  An unexpected error occurred.
Check that you are using the latest version of PyQt and send an error report to
support@riverbankcomputing.com, including the following information:

  * your version of PyQt (%s)
  * the UI file that caused this error
  * the debug output of pyuic4 (use the -d flag when calling pyuic4)
(   R   R   R   t   levelR   t	   tracebackt   print_exceptionR%   t   exc_infoR   R>   R2   R3   t   PYQT_VERSION_STR(   R   R6   R@   R>   (    (    sR   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/python2.7/site-packages/PyQt4/uic/driver.pyt   on_Exceptionw   s    	(   t   __name__t
   __module__t   __doc__R   R   R   R   R   R7   R8   R=   RD   (    (    (    sR   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/python2.7/site-packages/PyQt4/uic/driver.pyR   "   s   							(   R%   R   t	   PyQt4.uicR    R   t   objectR   (    (    (    sR   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/python2.7/site-packages/PyQt4/uic/driver.pyt   <module>   s   