ó
˝ŢZc           @   sH   d  d l  Z  d  d l Z d d l m Z m Z d e f d     YZ d S(   i˙˙˙˙Ni   (   t	   compileUit   loadUit   Driverc           B   se   e  Z d  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	   PyQt5.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(    (    s/   lib/python2.7/site-packages/PyQt5/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   (    (    s/   lib/python2.7/site-packages/PyQt5/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	   QtWidgets(   t   PyQt5R   t   QApplicationR   R   t   showt   exec_(   R   R   t   appt   widget(    (    s/   lib/python2.7/site-packages/PyQt5/uic/driver.pyR   ?   s
    
c         C   s3  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
 } |  j j } | rĘ t
 } n! |  j j rĺ t
 } d } n t  } t |  j | |  j j |  j j | |  j j |  | r/| j   n  d	 S(
   s    Generate the Python code. i   t   -i˙˙˙˙(   t   TextIOWrappert   encodingt   utf8t   wtt   .N(   t   Falset   syst
   hexversionR   t   outputt   ioR!   t   stdoutt   buffert   opent   Truet   import_fromt   from_importsR    R   t   executet   indentt   resource_suffixt   close(   R   t   needs_closeR!   t   pyfileR/   R0   (    (    s/   lib/python2.7/site-packages/PyQt5/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(    (    s/   lib/python2.7/site-packages/PyQt5/uic/driver.pyt
   on_IOErrorp   s    c         C   s   t  j j d |  d S(   s!    Handle a SyntaxError exception. s   Error in input file: %s
N(   R'   R7   R8   (   R   R;   (    (    s/   lib/python2.7/site-packages/PyQt5/uic/driver.pyt   on_SyntaxErroru   s    c         C   s   t  j j t |  d  d S(   s&    Handle a NoSuchClassError exception. s   
N(   R'   R7   R8   t   str(   R   R;   (    (    s/   lib/python2.7/site-packages/PyQt5/uic/driver.pyt   on_NoSuchClassErrorz   s    c         C   s   t  j j t |  d  d S(   s'    Handle a NoSuchWidgetError exception. s   
N(   R'   R7   R8   R>   (   R   R;   (    (    s/   lib/python2.7/site-packages/PyQt5/uic/driver.pyt   on_NoSuchWidgetError   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 PyQt5 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 pyuic5 (use the -d flag when calling pyuic5)
(   R   R   R   t   levelR   t	   tracebackt   print_exceptionR'   t   exc_infoR   RA   R7   R8   t   PYQT_VERSION_STR(   R   R;   RC   RA   (    (    s/   lib/python2.7/site-packages/PyQt5/uic/driver.pyt   on_Exception   s    	(   t   __name__t
   __module__t   __doc__R   R   R   R   R   R<   R=   R?   R@   RG   (    (    (    s/   lib/python2.7/site-packages/PyQt5/uic/driver.pyR      s   				$				(   R'   R   t    R    R   t   objectR   (    (    (    s/   lib/python2.7/site-packages/PyQt5/uic/driver.pyt   <module>   s   