
Tc           @   sH  d  d l  Z  d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l	 Z	 d  d l
 Z
 y d  d l Z Wn e k
 r d Z n Xd  d l m Z m Z d  d l m Z m Z m Z m Z m Z d  d l m Z d  d l Z e  j j   Z d Z yD e j d  j   \ Z  Z! e" e   pJd e" e!  pYd Z# Z$ Wn d) \ Z# Z$ n Xd	   Z% e% Z& e% Z' d
   Z( d d d d  Z) e d k	 re j* d  y e j+ d  WqqXn  d   Z, d e- f d     YZ. d d d d  Z/ d e0 d  Z1 e2 e0 d  Z3 d   Z4 e4 Z5 d d e0 e0 d d d  Z6 d   Z7 d d  Z8 d   Z9 d e0 d d  Z: d d d d  Z; d d e0 d d e0 e0 d  Z< d e0 d d d d  Z= d d e0 d d d e0 d e0 d d e0 d   Z> d!   Z? d"   Z@ d#   ZA e2 e0 d$  ZB d% d&  ZC d'   ZD d(   ZE d S(*   iN(   t   debbugst	   hiermatch(   t   NoReportt	   NoPackaget   NoBugst	   NoNetworkt   InvalidRegex(   t   launch_browsers   us-asciis	   stty sizei   iO   c         G   sb   t  s
 d  S| r |  | }  n  t |  t  rA |  j t d  }  n  t j j |   t j j   d  S(   Nt   replace(	   t   ISATTYt
   isinstancet   unicodet   encodet   charsett   syst   stderrt   writet   flush(   t   messaget   args(    (    s8   /usr/lib/python2.7/dist-packages/reportbug/ui/text_ui.pyt   ewrite7   s    c         C   s>   y t  j   } Wn t k
 r0 t  j d  n Xt  j |   S(   Nt   /(   t   ost   getcwdt   OSErrort   chdirt   system(   t   cmdlinet   x(    (    s8   /usr/lib/python2.7/dist-packages/reportbug/ui/text_ui.pyR   G   s
    t    i    c         C   s   | s t  d } n  | r& d | } n d } d j |  j    }  |  sO | d St j |  d | d | d | } | j d  r | S| d S(   s.   Wrapper for textwrap.fill to the existing API.i   t    R   s   
t   widtht   initial_indentt   subsequent_indent(   t   columnst   joint   splitt   textwrapt   fillt   endswith(   t   textt	   starttextt   indentt   linelent   sit   output(    (    s8   /usr/lib/python2.7/dist-packages/reportbug/ui/text_ui.pyt   indent_wrap_textN   s    	s   tab: completeR   c	   	      C   s   y} t  |  } | | k rN d | k o8 t |  k n rN | | d } n  t j j |  t j | | | | |  | |  Wn t k
 r t d |  n Xd  S(   Ni   s   Invalid report number: %s
(	   t   intt   lent	   reportbugt   utilst   launch_mbox_readerR    t   get_report_urlt
   ValueErrorR   (	   t   mbox_reader_cmdt   btst   bugst   numbert   mirrorst   archivedt   mboxt
   http_proxyt   timeout(    (    s8   /usr/lib/python2.7/dist-packages/reportbug/ui/text_ui.pyt   _launch_mbox_readerk   s    .t   our_completerc           B   s   e  Z d d   Z d   Z RS(   c         C   s.   d  |  _ | r* t t t |   |  _ n  d  S(   N(   t   Nonet   completionst   tuplet   mapt   str(   t   selfRB   (    (    s8   /usr/lib/python2.7/dist-packages/reportbug/ui/text_ui.pyt   __init__z   s    	c         C   sZ   |  j  s d  Sg  |  j  D] } | j |  r | ^ q } | t |  k  rR | | Sd  Sd  S(   N(   RB   RA   t
   startswithR0   (   RF   R(   t   iR   t   matching(    (    s8   /usr/lib/python2.7/dist-packages/reportbug/ui/text_ui.pyt   complete   s    	 +N(   t   __name__t
   __module__RA   RG   RK   (    (    (    s8   /usr/lib/python2.7/dist-packages/reportbug/ui/text_ui.pyR@   y   s   c         C   s   t  j j   } | s( t  j j |   n  t  j j   t rs | rZ | rZ t |  j } n  | rs t j	 |  qs n  y" | r t
 |   } n	 t
   } Wn! t k
 r t d  t  n Xt r t j	 d   n  | j   S(   Ns   
User interrupt (^D).
(   R   t   stdoutt   isattyR   R   R   t   readlineR@   RK   t   set_completert	   raw_inputt   EOFErrorR   t
   SystemExitRA   t   strip(   t   promptRB   t	   completert   isttyt   ret(    (    s8   /usr/lib/python2.7/dist-packages/reportbug/ui/text_ui.pyt   our_raw_input   s&    

c         C   s  d } x' | D] } | t  j k r | } Pq q W| s? i  } n  d | k rX | d } n  | r |  d d j |  d d } n+ t |  d d j |  d  j   d } t | |  }	 | rx$ |	 r |	 d d k r |	 d	 }	 q Wt |  t d	  k r*y t t |	   SWqt	 k
 r&qXqyX t |	  }
 |
 | k rOt |
  St
 |  } | j   d
 d j t t |   } Wqt	 t f k
 rqXn  |	 s| }	 n  |	 d }	 |	 d k rYd | d <xr | D]j }	 |	 t  j k rd } n d } | | j |	 | j |	 j   d   7} t t | d d |	 d   qWt |  | | | |  S|	 j   | k s}|	 j   | k r|	 j   S| rt t |   n
 t d  t |  | | | |  S(   NR   t   ?s    [t   |s   ]?R   i    t   #i   s(   Only the following entries are allowed: s   , s   Display this help.s
   (default) s   No help for this option.s   
s   %s - i   s   Invalid selection.
(   t   stringt   ascii_uppercaseR#   R.   RU   RZ   t   typeRE   R/   R5   t   listt   sortRD   t	   TypeErrort   gett   lowerR   t   select_optionst   upper(   t   msgt   okt   helpt   allow_numberst   nowrapt   err_messaget   optiont   defaultt   longmsgt   chR9   t   numst   desc(    (    s8   /usr/lib/python2.7/dist-packages/reportbug/ui/text_ui.pyRf      sd     	 "+ 

 	

	"$

c         C   sa   | r d } n d } t  |  | i | d 6| d 6d d 6d | } | d k rW t  n  | d k S(   s"   Return True for yes, False for no.t   Ynqt   yNqt   yt   ns   Quit.t   qRl   (   Rf   RT   (   Rh   t   yeshelpt   nohelpRo   Rl   Ri   t   res(    (    s8   /usr/lib/python2.7/dist-packages/reportbug/ui/text_ui.pyt   yes_no   s    	$		c         G   s1   | r t  t |  |   n t  t |    d  S(   N(   R   R.   (   R(   R   (    (    s8   /usr/lib/python2.7/dist-packages/reportbug/ui/text_ui.pyt   long_message   s    c         C   s   |  rm t  |   d t d k  rm | rm | rX d |  | f }  t |  | |  pR | } q t |  | |  } nP |  r t t |    n  | r t d | | |  p | } n t d | |  } | d  k	 r t | t  r t | t d  } n  | S(   Ni   i   s	   %s [%s]: s   [%s]> s   > R   (	   R0   R"   RZ   R   R.   RA   R
   R   R   (   RV   t   optionst   titlet   empty_okt   force_promptRo   RW   t   response(    (    s8   /usr/lib/python2.7/dist-packages/reportbug/ui/text_ui.pyt
   get_string   s    'c         C   sg   t  d  t  t |  d   g  } x2 t d d t j   } | sI Pn  | j |  q' t  d  | S(   Ns   
s+     Press ENTER on a blank line to continue.
R   R   (   R   R.   R   t   TrueRU   t   append(   RV   t   lt   entry(    (    s8   /usr/lib/python2.7/dist-packages/reportbug/ui/text_ui.pyt   get_multiline  s    

c         C   s   t  j  |   S(   N(   t   getpass(   RV   (    (    s8   /usr/lib/python2.7/dist-packages/reportbug/ui/text_ui.pyt   get_password  s    c         C   s   t  j j |   }  t  j j |   }  t j |  d  } | sA d  S| t |  k  r{ | | } t  j j |  rw | d S| Sd  Sd  S(   Nt   *R   (   R   t   patht
   expandusert
   expandvarst   globRA   R0   t   isdir(   R(   RI   t   pathsR   (    (    s8   /usr/lib/python2.7/dist-packages/reportbug/ui/text_ui.pyt   FilenameCompleter  s     
c      
   C   s"   t  |  d | d | d | d t S(   NR   R   Ro   RW   (   R   R   (   RV   R   R   Ro   (    (    s8   /usr/lib/python2.7/dist-packages/reportbug/ui/text_ui.pyt   get_filename#  s    c         C   s.   t  |  | | d | d | d | d t d t S(   NR   t   ordert   extrast   multipleR   (   t   menuR   t   False(   t   parR~   RV   R   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/reportbug/ui/text_ui.pyt   select_multiple'  s    !c
         C   s  i  }
 | s g  } n t  |  } | r8 t | d  n  t t |  d t d  t | t  r| j   } | r g  } x> | D]6 } | j |  r | j | | | f  | | =q q W| j	   } | j
   x | D] } | j |  q W| } q| j	   } | j
   n  | r9| j d  d } | d g 7} n  t d   |  } | | } t t t t |   t d  } t t j t j t |  d	    } d	 } xz | D]r \ } } t | d
 | | d d d | | | | | f } t |  t |  d k  rt d  n  | d	 } qWt |  d k rAt d  n  | rT| d 7} n  x|| rn| d | } n | } t | |  } | s| } n  yG t |  } d	 | k ot |  k n r| | d	 d } n  Wn t t f k
 rn X| | k s| | k r| r| r| d k r-|
 j   S| d k r=g  S|
 j |  rV|
 | =n
 d	 |
 | <t d d j |
 j     t |
  rd } qWd } qWq| Sn  | r| r| S|	 r| rd  St d  qWd  S(   Ns   

R+   s   
t   noneR   t   donec         S   s   |  d S(   Ni    (    (   R   (    (    s8   /usr/lib/python2.7/dist-packages/reportbug/ui/text_ui.pyt   <lambda>R  s    i   i   R*   R)   s   %*d %-*.*s  i   s   (one at a time) s   [%s] i    s   - selected: %s
s   , s   Invalid entry.
(   R   R   (   Ra   R   R.   R"   R
   t   dictt   copyt   has_keyR   t   itemsRb   RD   t   mint   maxR0   R/   t   matht   ceilt   log10RZ   R5   Rc   t   keysRd   R#   (   R   R~   RV   Ro   R   t   any_okR   R   R   R   t   selectedt   olistt   keyRn   t   allowedt   maxlen_namet   digitsRI   t   nameRs   R(   t   apromptR   t   num(    (    s8   /usr/lib/python2.7/dist-packages/reportbug/ui/text_ui.pyR   +  s    	
	
"(
 	"


	t   noc
         C   s  t  j | }
 t d |  |
 d  y1 t  j |  | | d | d d d | d | } Wn d  } n X| s~ t d |   t  n  | \ } } | j p | j s t d	  t j	 d
  n  d } t
 } x'| r d | | j | | f } n d | j | d f } | sdt j d d  } y | j |  | j   Wqdt k
 r`} | j t j k rZqa  qdXn  t
 } d } | d t |  k  rd | j   } n  | rd | } n  t d | i d d 6d d 6d d 6d d 6d d 6d d 6d d  6d! d" 6d# t d t |  d  } | d k r| S| d" k r4t  q | d  k ret t  j | |  | |   t } q | d k rt j j |	 t  j | |  | | t  | |  t } q | d k rPq | d k r| d 7} q | d k r | d 8} q q d  S($   Ns5   Retrieving report #%d from %s bug tracking system...
R   R:   t	   followupsi   R=   R;   s   No report available: #%s
s*   Cannot retrieve bug's package, exiting...
ii    s   Followup %d - %s

%ss   Original report - %s

%ss   sensible-pagert   wt   xOrbeqt   Nt   ps   What do you want to do now?s   Provide extra information.R   s/   Show other bug reports (return to bug listing).t   os   Show next message (followup).Rw   s!   Show previous message (followup).s   Redisplay this message.t   rs&   Launch e-mail client to read full log.t   es$   Launch web browser to read full log.t   bs   I'm bored; quit please.Rx   Rk   (   R    t   SYSTEMSR   t
   get_reportRA   R   t   packaget   sourceR   t   exitR   t   subjectR   t   popenR   t   closet   IOErrort   errnot   EPIPER0   Re   Rf   t   rangeR   R   R4   R   R1   R2   R3   (   R9   R   R:   R=   R>   t   screent	   queryonlyR   R;   R6   t   sysinfot   infot   buginfot   messagest   current_messaget
   skip_pagerR(   t   fdR   R~   (    (    s8   /usr/lib/python2.7/dist-packages/reportbug/ui/text_ui.pyt   show_report  s    
	

	

				c          C   s  t  j | j d  } | s8 t d t  j | d  d  Sd } |	 rM d } n  t |  t  r} t d t  j | d |  |  n@ t d t  j | d d j g  |  D] } t |  ^ q  |  g  } yzt  j	 |  | | d | d	 |
 d
 |	 d | d | \ } } } | s&| d  k rt  q&t  n  g  } | rrg  } x3 | D]+ } x" | d D] } | j | j  qPWq?W| S| rxP | D]H } x? | d D]3 } d | j | j f } | j t d  } | GHqWqWt j d  n  x | D] } | d } i  } g  } xZ | d D]N } d } | j d k r-d } n  d | j | f | | j <| j | j  q	W| j | g  t | j   d | D] } d | | | f ^ q}f  | j t | d |  qW| } | s| d  k rt  qt  n) | d k rt d |  n t d |  t | | | | | | | | | | |  |  SWn t t f k
 rt d t  j | d  t d d i d d 6d d 6 } | d k rt  qn! t k
 rt d  t  n Xd  S(   Nt   btsroots7   %s bug tracking system has no web URL; bypassing query
R   R   s	    (source)s'   Querying %s BTS for reports on %s%s...
R   R:   t   versionR   R=   R;   i   s   #%d  %sR   i    R   s     [RESOLVED]s   %s%st   reverses   %d bug report found:

s   %d bug reports found:

s   Unable to connect to %s BTS; t   continuet   yNs   Keep going.Rv   s   Abort.Rw   s    No record of this package found.(   R    R   Rd   R   R
   t
   basestringR}   R#   RE   t   get_reportsRA   R   R   R   t   bug_numR   R   R   R   R   t   pendingt   sortedR   t   extendt   browse_bugsR   R   Rf   (    R   R7   R>   R:   R=   R   R   R   R;   R   R   R<   t   buglistR6   t   latest_firstt   roott   srcstrR   R8   t   countt	   hierarchyt   hierarchy_newt   mboxbuglistR   t   bugRh   t	   entry_newt   bugs_newt   bugs_numbersR   t   kR{   (    (    s8   /usr/lib/python2.7/dist-packages/reportbug/ui/text_ui.pyt   handle_bts_query  s    	,		
	F			

c   +      C   s  y t  j   } Wn( t  j k
 r: } | GHt j d  n Xd } } d } } |  d } g  } t t t |    } d t |  d } x,| r| d } | d d !\ } } x | j d  r | d  } q Wt |  } xt |  rm| t d  } | t d } t |  } d } } | d k r3d	 } n  | d k rHd	 } n  | rk| j	 d
 | | | f  n | j	 | d  | | } } xE | D]= } | d } | d } | j	 | | | t
 | d  f  qW| |  d k s| t t |  | d d  d k r d }  | | k r"d	 }  n  d }! | r7d }! n  d | | | f }" |" d }# | rg|" d }# n  | t d | d  }$ i	 d d 6d d 6d d 6d d 6d d 6d d 6d d 6d  d! 6d" d# 6}% |  r|% d d  d$ |% d <n  xrx* | D]" }& t j j |& j | d%   qWt |# |! |% d& |$ }' |' d k r@g  } Pq|' d k r`t d' |
  qq|' d k rrqq|' d k rt  q|' d k rd  S|' d k r| rd  St |  d k rd( }( n t d) |$  }( x$ |( r|( d d* k r|( d }( qW|( ryc t |(  }( |( | k rRd |( k o<t |  k n rR| |( d }( n  t j |( |  d SWqt k
 rt d+ |(  qXqTt  q|' d# k rt |  | | | | | | |	 |
 | 
 }) t |) t  r|) d6 k rqqT|) Sq|' d! k r/t d. |$  }( t | | | |( | d/ t | | 	 q|' d k sG|' d0 k rtt |  d k rbd( }( qzt d1 |$  }( n |' }( x$ |( r|( d d* k r|( d }( q}W|( ry t |(  }( |( | k rd |( k ot |  k n r| |( d }( n  t |( | | | | d2 | d3 | d4 |	 d5 | }* |* r/|* SWqTt k
 rPt d+ |(  qTXqq| d } d } q q W| |  d k rPn  | d } |  | } | r | j	 d  | d } q q Wd  S(7   Ni   i    s     %s   d) %s
i   t   :it   sR   s    %s: %d remain%s
s   
i   s    (s to skip rest)t	   yNbmrqsfet   Nbmrqfes   (%d-%d/%d) s!   Is the bug you found listed aboves   What would you like to do nexts;   Problem already reported; optionally add extra information.Rv   s.   Problem not listed above; possibly check more.Rw   s-   Open the complete bugs list in a web browser.R   s`   Get more information about a bug (you can also enter a number
     without selecting "m" first).t   ms   Redisplay the last bugs shown.R   s   I'm bored; quit please.Rx   s7   Skip remaining problems; file a new report immediately.s'   Open the report using an e-mail client.R   s    Filter bug list using a pattern.t   fs    (skip to Next page).R   Rk   s   http://bugs.debian.org/%st   1s[   Enter the number of the bug report you want to give more info on,
or press ENTER to exit: #R]   s   Invalid report number: %s
t	   FilterEndt   Tops<   Please enter the number of the bug you would like to view: #R   RI   sA   Please enter the number of the bug you would like more info on: #R   R   R   R6   (   R   R   (   t   localet   getpreferredencodingt   ErrorR   R   R0   RE   R'   t   rowsR   R"   R   R   R   R   Rf   R   R   RZ   R/   R    R   R5   R   t   search_bugsR
   R   R?   R   R   (+   R   R   R8   R7   R   R:   R=   R>   R   R   R   R6   t   output_encodingRh   t   endcountt   catcountt   scountt
   startcountt   categoryt   lastpageR   t   linefmtt   catnamet   reportst   totalt   theset   remaint   tpluralt   rpluralt	   oldscountt	   oldecountt   reportt   skipmsgR~   t   rstrt   pstrR   t   helptextt   lineR   R9   t   retvalR{   (    (    s8   /usr/lib/python2.7/dist-packages/reportbug/ui/text_ui.pyR   R  s"   


	
 
 	 		

'&	 	

 				.		
	.		
 

c   	      C   s   g  |  D] } t  | d  ^ q } | r> t d   |  } n d Sg  } t j d  } x] |  pc g  D]O } xF | d D]: } | j |  } | ru | j t | j d    qu qu Wqd W| | f S(   s.   Find out bug count and bug # in the hierarchy.i   c         S   s   |  | S(   N(    (   R   Rv   (    (    s8   /usr/lib/python2.7/dist-packages/reportbug/ui/text_ui.pyR     s    i    s   \#(\d+)[ :](   i    i    (   R0   t   reducet   ret   compilet   matchR   R/   t   group(	   R   RI   t   lenlistR   R8   t   expR   R   R  (    (    s8   /usr/lib/python2.7/dist-packages/reportbug/ui/text_ui.pyt   proc_hierarchy  s    #'c
   .      C   sH  y t  j   }
 Wn( t  j k
 r: } | GHt j d  n Xt d  } | sQ d Sy t j |  |  } Wn t k
 r t d  d SXt	 |  \ } } t
 j d  } | s t d  d Sd } } d } } | d } g  } t t t |    } d t |  d	 } x6| rC| d } | d d
 !\ } } x | j d  rP| d  } q4Wt |  } xt |  r| t d
  } | t d
 } t |  } d } } | d k rd } n  | d k rd } n  | r| j d | | | | | f  n | j d | | | f  | | }  }! xE | D]= }" | d } | d } | j | | |" t | d  f  qW| | d k s| t t | | d d  d k r`d }# | | k rd }# n  d }$ | rd }$ n  d | | | f }% |% d }& | r|% d }& n  | t d | d  }' i d d 6d d 6d d 6d d 6d  d! 6d" d# 6d$ d 6d% d& 6d' d( 6d) d* 6d+ d, 6}( |# r|( d d  d- |( d <n  x_x* | D]" }) t j j |) j |
 d.   qWt |& |$ |( d/ |' }* |* d k rg  } Pq|* d k rt d0 |  q|* d! k rqq|* d# k r!t  q|* d k r1d1 S|* d k r.| rGd1 St |  d k rbd2 }+ n t d3 |'  }+ x$ |+ r|+ d d4 k r|+ d }+ qtW|+ r%yc t |+  }+ |+ | k rd |+ k ot |  k n r| |+ d }+ n  t j |+ |  d SWq+t k
 r!t d5 |+  q+Xqt  q|* d& k rzt | | | | | | | | | |	 
 }, |, d k rsqq|, Sq|* d( k rd S|* d, k rd6 S|* d* k rt d7 |'  }+ t |	 | | |+ | d8 t  | | 	 q|* d k s|* d9 k rt d: |'  }+ n |* }+ x$ |+ r0|+ d d4 k r0|+ d }+ qW|+ ry t |+  }+ |+ | k rd |+ k oot |  k n r| |+ d }+ n  t! |+ | | | | d; | d< | d= | }- |- r|- SWqt k
 rt d5 |+  qXqq| d } d } q`q`W| | d k rPn  | d } | | } | r| j d>  | d } qqWd S(?   s(   Search for the bug list using a pattern.i   sX   Enter the search pattern (a Perl-compatible regular expression)
or press ENTER to exit: R   s4   Invalid regular expression, press ENTER to continue.s   \#(\d+):s(   No match found, press ENTER to continue.i    s     %s   d) %s
i   R   iR   R   s    %s: %d report%s (%d remain%s)
s    %s: %d report%s
i   s    (s to skip rest)t   yNbmrqsfutet	   Nmbrqfutes   (%d-%d/%d) s!   Is the bug you found listed aboves   What would you like to do nexts;   Problem already reported; optionally add extra information.Rv   s.   Problem not listed above; possibly check more.Rw   s-   Open the complete bugs list in a web browser.R   s`   Get more information about a bug (you can also enter a number
     without selecting "m" first).R   s   Redisplay the last bugs shown.R   s   I'm bored; quit please.Rx   s7   Skip remaining problems; file a new report immediately.s)   Filter (search) bug list using a pattern.R   s   Up one level of filter.t   us'   Open the report using an e-mail client.R   s)   Top of the bug list (remove all filters).t   ts    (skip to Next page).R   Rk   s   http://bugs.debian.org/%sNR   s[   Enter the number of the bug report you want to give more info on,
or press ENTER to exit: #R]   s   Invalid report number: %s
R   s<   Please enter the number of the bug you would like to view: #R   RI   sA   Please enter the number of the bug you would like more info on: #R   R   R   s   
("   R   R   R   R   R   RZ   R   t   matched_hierarchyR   R  R  R  R0   RE   R'   R   R   R"   R   R   R   R   Rf   R   R   R/   R    R   R5   R   R   R?   R   R   (.   t   hierarchyfullR7   R   R:   R=   R>   R   R   R   R6   R   Rh   t   patternR   R   R8   R  R   R   R   R   R   R   R   R  R  R  R  R  R  R  R  R	  R
  R  R  R~   R  R  R   R  R  R   R9   R  R{   (    (    s8   /usr/lib/python2.7/dist-packages/reportbug/ui/text_ui.pyR     sD   	




	
 
 	 			

'&	 	

 				.			
.		
 

c         C   sq   | s t  |   d  S| r' |  d 7}  n  t j j d d  } y t j | d  j |   Wn t k
 rl n Xd  S(   Ns[   
(You may need to press 'q' to exit your pager and continue using
reportbug at this point.)t   PAGERs   sensible-pagerR   (   R   R   t   environRd   R   R   R   (   R(   t	   use_pagert   presubjt   pager(    (    s8   /usr/lib/python2.7/dist-packages/reportbug/ui/text_ui.pyt   display_report  s    
s   utf-8c         C   s  | s t  d  |  d f St j j | j   d  } d } x@ t t |   D], \ } } | d k rO | rO | d } qO qO Wd } d | k r d } n  | r| d$ k r d | } q| d% k s d | k r d | } q| d& k r d | } q| d k rd | } qn  d | k s+| d k r;t  d |  n t  d |  t j d | | | f  }	 |	 r}t  d | |	  n  t j j |  st  d  |  t	 j
 d!  n  d | k rd' St |  j   j | d"  }
 |
 |  k rt  d#  n  |
 |
 |  k f S((   Ns   No editor found!
i    s   
i   R   t   vims   -f t   vit   nvit   elvist   gvimt   kvims   -c :%ds
   elvis-tinyt	   gnuclientt   eet   picot   nanot   zilet   emacss   +%dt   jedt   xjeds   -g %dt   kates	   --line %dt   &sA   Spawning %s in background; please press Enter when done editing.
s   Spawning %s...
s
   %s %s '%s's)   Warning: possible error exit from %s: %d
s   Bug report file %s removed!i   R   s$   No changes were made in the editor.
(   R(  R)  R'  R*  R+  R,  (   s
   elvis-tinyR-  R.  R/  R0  R1  (   R3  R4  (   Ni   (   R   R   R   t   basenameR$   t	   enumeratet   fileR   t   existsR   R   RA   t   readt   decode(   R   t   filenamet   editorR   t   ednamet   ourlinet   linenoR  t   optst   resultt
   newmessage(    (    s8   /usr/lib/python2.7/dist-packages/reportbug/ui/text_ui.pyt   spawn_editor  sJ    

	
 c           C   s   t  S(   N(   R   (    (    (    s8   /usr/lib/python2.7/dist-packages/reportbug/ui/text_ui.pyt
   initialize&  s    c           C   s   t  j j   S(   N(   R   t   stdinRO   (    (    (    s8   /usr/lib/python2.7/dist-packages/reportbug/ui/text_ui.pyt	   can_input)  s    (   i   iO   (F   R   R   t   commandsR  R   R^   R   R   R   R%   R   RP   t   ImportErrorRA   R1   R    R   t   reportbug.exceptionsR   R   R   R   R   t   reportbug.urlutilsR   t   reportbug.utilsRG  RO   R	   R   t	   getoutputR$   R   t   cR/   R   R"   R   t   log_messaget   display_failureR   R.   t   parse_and_bindt   set_completer_delimsR?   t   objectR@   RZ   R   Rf   R   R|   R}   t   final_messageR   R   R   R   R   R   R   R   R   R   R  R   R&  RE  RF  RH  (    (    (    s8   /usr/lib/python2.7/dist-packages/reportbug/ui/text_ui.pyt   <module>   s   
()			;				h	Vd			8	