
    o'e(                     B    d dl Z d dlZddlmZmZ  G d de          ZdS )    N   )	compileUiloadUic                   L    e Zd ZdZdZd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd ZdS )Driverz} This encapsulates access to the pyuic functionality so that it can be
    called by code that is Python v2/v3 specific.
    z	PyQt5.uicc                 >   |j         rt          j        | j                  }t          j                    }|                    t          j        d                     |                    |           |                    t          j	                   || _
        || _        dS )zk Initialise the object.  opts is the parsed options.  ui_file is the
        name of the .ui file.
        z%(name)s: %(message)sN)debuglogging	getLoggerLOGGER_NAMEStreamHandlersetFormatter	Formatter
addHandlersetLevelDEBUG_opts_ui_file)selfoptsui_fileloggerhandlers        0lib/python3.11/site-packages/PyQt5/uic/driver.py__init__zDriver.__init__$   s    
 : 	+&t'788F+--G  !23J!K!KLLLg&&&OOGM***
    c                 n    | j         j        r|                                 S |                                  dS )zi Invoke the action as specified by the parsed options.  Returns 0 if
        there was no error.
        r   )r   preview_preview	_generate)r   s    r   invokezDriver.invoke3   s4    
 : 	#==??"qr   c                     ddl m} |                    | j        g          }t	          | j                  }|                                 |                                S )zh Preview the .ui file.  Return the exit status to be passed back to
        the parent process.
        r   )	QtWidgets)PyQt5r#   QApplicationr   r   showexec_)r   r#   appwidgets       r   r   zDriver._preview?   sW    
 	$#####$$dm_55&&yy{{r   c           	      (   d}t           j        dk    rR| j        j        dk    r#ddlm}  |t           j        j        d          }nXt          | j        j        dd          }d	}n9| j        j        dk    rt           j        }nt          | j        j        d          }d	}| j        j	        }|rd	}n| j        j
        rd	}d
}nd}t          | j        || j        j        | j        j        || j        j        |           |r|                                 dS dS )z Generate the Python code. Fi   -r   )TextIOWrapperutf8)encodingwtT.N)sys
hexversionr   outputior,   stdoutbufferopenimport_fromfrom_importsr   r   executeindentresource_suffixclose)r   needs_closer,   pyfiler8   r9   s         r   r    zDriver._generateL   s6    >Z''z C'',,,,,,&sz'86JJJdj/GGG"z C''dj/66"j, 	!LLZ$ 	!LKK L$-);TZ=Ndj8+	G 	G 	G  	LLNNNNN	 	r   c                 f    t           j                            d|j        d|j        d           dS )z Handle an IOError exception. zError: z: "z"
N)r1   stderrwritestrerrorfilenamer   es     r   
on_IOErrorzDriver.on_IOErrorp   s4     	
!***ajjjIJJJJJr   c                 J    t           j                            d|z             dS )z! Handle a SyntaxError exception. zError in input file: %s
N)r1   rA   rB   rE   s     r   on_SyntaxErrorzDriver.on_SyntaxErroru   s&     	
4q899999r   c                 d    t           j                            t          |          dz              dS )z& Handle a NoSuchClassError exception. 
Nr1   rA   rB   strrE   s     r   on_NoSuchClassErrorzDriver.on_NoSuchClassErrorz   *     	
Q$'''''r   c                 d    t           j                            t          |          dz              dS )z' Handle a NoSuchWidgetError exception. rK   NrL   rE   s     r   on_NoSuchWidgetErrorzDriver.on_NoSuchWidgetError   rO   r   c                     t          j        | j                  j        t           j        k    r!ddl} |j        t          j                      dS ddl	m
} t          j                            d|j        z             dS )z Handle a generic exception. r   N)QtCorea?  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   levelr   	tracebackprint_exceptionr1   exc_infor$   rS   rA   rB   PYQT_VERSION_STR)r   rF   rU   rS   s       r   on_ExceptionzDriver.on_Exception   s     T-..4EE%I%s|~~6666$$$$$$J       r   N)__name__
__module____qualname____doc__r   r   r!   r   r    rG   rI   rN   rQ   rY    r   r   r   r      s          K     
 
 
  " " "HK K K
: : :
( ( (
( ( (
    r   r   )r1   r
    r   r   objectr   r^   r   r   <module>ra      so   . 


         x x x x xV x x x x xr   