ó
Ñ«ÆYc           @   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(    (    s4   /usr/lib/python2.7/dist-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   (    (    s4   /usr/lib/python2.7/dist-packages/PyQt4/uic/driver.pyt   invoke3   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(    (    s4   /usr/lib/python2.7/dist-packages/PyQt4/uic/driver.pyR   ?   s
    
c         C   s  t  } t j d k rv |  j j d k rR d d l m } | t j j d d ƒ} q¯ t	 |  j j d d d ƒ} t
 } n9 |  j j d k r” t j } n t	 |  j j d ƒ } t
 } t |  j | |  j j |  j j |  j j |  j j |  j j ƒ | rÿ | j ƒ  n  d S(	   s    Generate the Python code. i   t   -iÿÿÿÿ(   t   TextIOWrappert   encodingt   utf8t   wtN(   t   Falset   syst
   hexversionR   t   outputt   ioR!   t   stdoutt   buffert   opent   TrueR    R   t   executet   indentt   pyqt3_wrappert   from_importst   resource_suffixt   close(   R   t   needs_closeR!   t   pyfile(    (    s4   /usr/lib/python2.7/dist-packages/PyQt4/uic/driver.pyR   L   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(    (    s4   /usr/lib/python2.7/dist-packages/PyQt4/uic/driver.pyt
   on_IOErrorg   s    c         C   s   t  j j d | ƒ d S(   s!    Handle a SyntaxError exception. s   Error in input file: %s
N(   R&   R6   R7   (   R   R:   (    (    s4   /usr/lib/python2.7/dist-packages/PyQt4/uic/driver.pyt   on_SyntaxErrorl   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&   R6   R7   t   str(   R   R:   (    (    s4   /usr/lib/python2.7/dist-packages/PyQt4/uic/driver.pyt   on_NoSuchWidgetErrorq   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   RB   R6   R7   t   PYQT_VERSION_STR(   R   R:   RD   RB   (    (    s4   /usr/lib/python2.7/dist-packages/PyQt4/uic/driver.pyt   on_Exceptiony   s    	(   t   __name__t
   __module__t   __doc__R   R   R   R   R   R;   R<   RA   RH   (    (    (    s4   /usr/lib/python2.7/dist-packages/PyQt4/uic/driver.pyR      s   							(   R&   R   t	   PyQt4.uicR    R   t   objectR   (    (    (    s4   /usr/lib/python2.7/dist-packages/PyQt4/uic/driver.pyt   <module>   s   