ó
‹²,]c           @   s‡  d  Z  d d l Z d d l m Z m Z d d l m Z m Z m Z m	 Z	 m
 Z
 m Z m Z m Z m Z m Z m Z d d l m Z m Z d d l m Z d d l m Z d d l m Z d d	 l m Z d d
 l m Z d d l m  Z  m! Z! d d l" m# Z# d d l$ m% Z% d Z& d Z' d e# f d „  ƒ  YZ( d e! e% e  f d „  ƒ  YZ) d e f d „  ƒ  YZ* d „  Z+ e, d k rƒe+ ƒ  n  d S(   s   Report Error DialogiÿÿÿÿN(   t   Qtt   Signal(   t   QApplicationt	   QCheckBoxt   QDialogt   QFormLayoutt   QHBoxLayoutt   QLabelt	   QLineEditt   QMessageBoxt   QPlainTextEditt   QPushButtont   QVBoxLayout(   t   __project_url__t   __trouble_url__(   t   _(   t   get_font(   t   icon_manager(   t   restore_keyevent(   t   GithubBackend(   t   BaseEditMixint   TracebackLinksMixin(   t
   CodeEditor(   t   ConsoleBaseWidgeti   i2   t   DescriptionWidgetc           B   s>   e  Z d  Z d d „ Z d „  Z d „  Z d „  Z d „  Z RS(   s"   Widget to enter error description.c         C   s«   t  j |  | ƒ |  j d d d d d t d t d t d t d	 t d
 t d t d t ƒ 
|  j t ƒ  ƒ d |  _ |  j |  j ƒ |  j	 t
 |  j ƒ ƒ |  j d ƒ |  _ d  S(   Nt   languaget   mdt   color_schemet	   Scintillat   linenumberst   scrollflagareat   wrapt	   edge_linet   highlight_current_linet   highlight_current_cellt   occurrence_highlightingt   auto_unindentsR   ### What steps will reproduce the problem?

<!--- You can use Markdown here --->

t   eof(   R   t   __init__t   setup_editort   Falset   Truet   set_fontR   t   headert   set_textt   move_cursort   lent   get_positiont   header_end_pos(   t   selft   parent(    (    s9   lib/python2.7/site-packages/spyder/widgets/reporterror.pyR&   *   s"    		c         C   s   |  j  |  j ƒ |  j ƒ  d S(   s   Remove text.N(   t   truncate_selectionR0   t   remove_selected_text(   R1   (    (    s9   lib/python2.7/site-packages/spyder/widgets/reporterror.pyt   remove_textE   s    c         C   s0   |  j  |  j ƒ |  j ƒ  r, t j |  ƒ n  d S(   s   Cut textN(   R3   R0   t   has_selected_textR   t   cut(   R1   (    (    s9   lib/python2.7/site-packages/spyder/widgets/reporterror.pyR7   J   s    c         C   s  t  | ƒ \ } } } } } |  j d ƒ } | |  j k  rO |  j |  j d ƒ n¯ | t j k r„ |  j ƒ  rw |  j ƒ  qþ |  j ƒ  nz | t j	 k rÌ |  j ƒ  r¬ |  j ƒ  qþ |  j | k r¿ d S|  j
 ƒ  n2 | t j k rî | rî |  j ƒ  n t j |  | ƒ d S(   s5   Reimplemented Qt Method to avoid removing the header.t   cursorR%   N(   R   R/   R0   t   restrict_cursor_positionR    t
   Key_DeleteR6   R5   t   stdkey_cleart   Key_Backspacet   stdkey_backspacet   Key_XR7   R   t   keyPressEvent(   R1   t   eventt   textt   keyt   ctrlt   shiftt   cursor_position(    (    s9   lib/python2.7/site-packages/spyder/widgets/reporterror.pyR?   P   s"    c         C   s   d S(   s5   Reimplemented Qt Method to not show the context menu.N(    (   R1   R@   (    (    s9   lib/python2.7/site-packages/spyder/widgets/reporterror.pyt   contextMenuEventh   s    N(	   t   __name__t
   __module__t   __doc__t   NoneR&   R5   R7   R?   RF   (    (    (    s9   lib/python2.7/site-packages/spyder/widgets/reporterror.pyR   '   s   			t   ShowErrorWidgetc           B   s,   e  Z d  Z e Z e e ƒ Z d d „ Z	 RS(   s=   Widget to show errors as they appear in the Internal console.c         C   s;   t  j |  | ƒ t j |  ƒ t j |  ƒ |  j t ƒ d  S(   N(   R   R&   R   R   t   setReadOnlyR)   (   R1   R2   (    (    s9   lib/python2.7/site-packages/spyder/widgets/reporterror.pyR&   r   s    N(
   RG   RH   RI   R
   t   QT_CLASSR   t   strt   go_to_errorRJ   R&   (    (    (    s9   lib/python2.7/site-packages/spyder/widgets/reporterror.pyRK   m   s   t   SpyderErrorDialogc           B   sA   e  Z d  Z d e d „ Z d „  Z d „  Z d „  Z d „  Z	 RS(   s(   Custom error dialog for error reporting.c         C   s²  t  j |  | ƒ | |  _ |  j t d ƒ ƒ |  j t ƒ d |  _ |  j rZ t d ƒ } n t d ƒ } t t d ƒ j	 d | d t
 d t ƒ ƒ } | j t ƒ | j t ƒ | j t j ƒ | j d	 ƒ t ƒ  |  _ |  j j j |  j ƒ t t d
 ƒ j	 t ƒ ƒ |  _ t ƒ  } d } t t d ƒ j	 | ƒ ƒ } | j d t j | ƒ | j d t j |  j ƒ t t d ƒ j	 | ƒ ƒ } t t d ƒ ƒ }	 |	 j t ƒ |	 j t j ƒ |	 j d	 ƒ t |  ƒ |  _ |  j j j |  j ƒ t |  ƒ |  _  |  j  j! t" ƒ  ƒ |  j  j# ƒ  t$ |  j j% ƒ  ƒ |  _& t t d
 ƒ j	 t' ƒ ƒ |  _( t) t d ƒ ƒ |  _* |  j ro|  j* j# ƒ  n  t+ j, d ƒ }
 t- |
 t d ƒ ƒ |  _. |  j. j/ t0 ƒ |  j. j1 j |  j2 ƒ t- t d ƒ ƒ |  _3 |  j3 j1 j |  j4 ƒ |  j r |  j3 j# ƒ  n  t- t d ƒ ƒ |  _5 |  j r7|  j5 j1 j |  j6 ƒ n  t7 ƒ  } | j8 |  j. ƒ | j8 |  j3 ƒ | j8 |  j5 ƒ t9 ƒ  } | j8 | ƒ | j: d ƒ | j; | ƒ | j8 |  j ƒ | j: d ƒ | j8 | ƒ | j: d ƒ | j8 |	 ƒ | j: d ƒ | j8 |  j ƒ | j8 |  j  ƒ | j8 |  j( ƒ | j: d ƒ | j8 |  j* ƒ | j: d ƒ | j; | ƒ | j< d d d d ƒ |  j= | ƒ |  j> d d ƒ |  j j? ƒ  |  j@ |  j |  j ƒ d  S(   Ns   Issue reportert    s%   Please fill the following informations+   Spyder has encountered an internal problem!s<  <h3>{title}</h3>Before reporting this problem, <i>please</i> consult our comprehensive <b><a href="{trouble_url}">Troubleshooting Guide</a></b> which should help solve most issues, and search for <b><a href="{project_url}">known bugs</a></b> matching your error message or problem description for a quicker solution.t   titlet   trouble_urlt   project_urls   font-size: 12px;s   {} more characters to go...s   <font color="Red">*</font>s   <b>Title</b>: {}i    s   <b>Steps to reproduce:</b> {}s¦   Please enter a detailed step-by-step description (in English) of what led up to the problem below. Issue reports without a clear way to reproduce them will be closed.s*   Hide all future errors during this sessiont   githubs   Submit to Githubs   Show detailst   Closei   i   iÿÿÿÿi   i   i   i
   i:  iX  (A   R   R&   t	   is_reportt   setWindowTitleR   t   setModalR)   t   error_tracebackR   t   formatR   R   t   setOpenExternalLinkst   setWordWrapt   setAlignmentR    t   AlignJustifyt   setStyleSheetR   RR   t   textChangedt   connectt   _contents_changedt   TITLE_MIN_CHARSt   title_chars_labelR   t	   setWidgett	   LabelRolet	   FieldRoleR   t   input_descriptionRK   t   detailst   set_pythonshell_fontR   t   hideR.   t   toPlainTextt   initial_charst   DESC_MIN_CHARSt   desc_chars_labelR   t   dismiss_boxt   imat   iconR   t
   submit_btnt
   setEnabledR(   t   clickedt   _submit_to_githubt   details_btnt   _show_detailst	   close_btnt   rejectR   t	   addWidgetR   t
   addSpacingt	   addLayoutt   setContentsMarginst	   setLayoutt   resizet   setFocust   setTabOrder(   R1   R2   RW   RR   t
   main_labelt   form_layoutt   red_asteriskt   title_labelt   steps_headert
   steps_textt   gh_icont   buttons_layoutt   layout(    (    s9   lib/python2.7/site-packages/spyder/widgets/reporterror.pyR&   |   sž    									c         C   s”  |  j  ƒ  d k	 rK t |  j  ƒ  d t ƒ r< |  j  ƒ  j } qQ |  j  ƒ  } n d } |  j j ƒ  } |  j j ƒ  } |  j	 d  } | d k	 r£ | j
 d | d | ƒ } n | } yS | d k rÁ d } n d } t | d ƒ } | j | | ƒ } | rû |  j ƒ  n  Wn‘ t k
 rt j |  t d ƒ t d	 ƒ ƒ }	 |	 t j t j g k rt j ƒ  j | ƒ d
 }
 | d k	 rŒ| j d |
 d | d t ƒ qŒqn Xd S(   s/   Action to take when pressing the submit button.t   mainiÿÿÿÿt   descriptiont	   tracebackt
   ccordoba12s
   spyder-idet   spydert   Errors  An error occurred while trying to send the issue to Github automatically. Would you like to open it manually?<br><br>If so, please make sure to paste your clipboard into the issue report box that will appear in a new browser tab before clicking <i>Submit</i> on that page.sZ    
<!---   *** BEFORE SUBMITTING: PASTE CLIPBOARD HERE TO COMPLETE YOUR REPORT ***   ---!>
t   bodyRR   t   open_webpageN(   R2   RJ   t   getattrR(   R   RR   RA   Ri   Rm   RZ   t   render_issueR   t   send_reportt   closet	   ExceptionR	   t   questionR   t   Yest   OkR   t	   clipboardt   setTextt   report_issueR)   (   R1   R   RR   RŽ   R   t
   issue_textt   orgt   github_backendt   github_reportt   rett
   issue_body(    (    s9   lib/python2.7/site-packages/spyder/widgets/reporterror.pyRw   ÷   s>    	
c         C   s   |  j  | 7_  d S(   s9   Append text to the traceback, to be displayed in details.N(   RZ   (   R1   RA   (    (    s9   lib/python2.7/site-packages/spyder/widgets/reporterror.pyt   append_traceback0  s    c         C   s¡   |  j  j ƒ  r5 |  j  j ƒ  |  j j t d ƒ ƒ nh |  j d d ƒ |  j  j ƒ  j d ƒ |  j  j	 |  j
 d t d t ƒ|  j  j ƒ  |  j j t d ƒ ƒ d S(	   s    Show traceback on its own dialogs   Show detailsi:  i¼  RQ   t   errort   prompts   Hide detailsN(   Rj   t	   isVisibleRl   Rx   Rž   R   R   t   documentt   setPlainTextt   append_text_to_shellRZ   R)   R(   t   show(   R1   (    (    s9   lib/python2.7/site-packages/spyder/widgets/reporterror.pyRy   4  s    c         C   só   t  |  j j ƒ  ƒ |  j } | t k  rQ |  j j d j t | t d ƒ ƒ ƒ n |  j j t d ƒ ƒ t  |  j	 j
 ƒ  ƒ } | t k  r± |  j j d j t | t d ƒ ƒ ƒ n |  j j t d ƒ ƒ | t k oÜ | t k } |  j j | ƒ d S(   s   Activate submit_btn.u   {} {}s   more characters to go...s   Description complete; thanks!s   Title complete; thanks!N(   R.   Ri   Rm   Rn   Ro   Rp   Rž   R[   R   RR   RA   Rd   Re   Rt   Ru   (   R1   t
   desc_charst   title_charst   submission_enabled(    (    s9   lib/python2.7/site-packages/spyder/widgets/reporterror.pyRc   B  s     
		N(
   RG   RH   RI   RJ   R(   R&   Rw   R¦   Ry   Rc   (    (    (    s9   lib/python2.7/site-packages/spyder/widgets/reporterror.pyRP   y   s   {	9		c          C   sC   d d l  m }  |  ƒ  } t ƒ  } | j ƒ  t j | j ƒ  ƒ d  S(   Niÿÿÿÿ(   t   qapplication(   t   spyder.utils.qthelpersR±   RP   R­   t   syst   exitt   exec_(   R±   t   appt   dlg(    (    s9   lib/python2.7/site-packages/spyder/widgets/reporterror.pyt   testZ  s
    		
t   __main__(-   RI   R³   t   qtpy.QtCoreR    R   t   qtpy.QtWidgetsR   R   R   R   R   R   R   R	   R
   R   R   R‘   R   R   t   spyder.config.baseR   t   spyder.config.guiR   t   spyder.utilsR   Rr   R²   R   t   spyder.widgets.github.backendR   t   spyder.widgets.mixinsR   R   t$   spyder.widgets.sourcecode.codeeditorR   t   spyder.widgets.sourcecode.baseR   Rd   Ro   R   RK   RP   R¸   RG   (    (    (    s9   lib/python2.7/site-packages/spyder/widgets/reporterror.pyt   <module>	   s(   LFá	