
    M/e                     ,   d Z ddl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	 dd	l
mZ dd
lmZ ddlmZ  ej"                  e      Zdeee      dee   fdZdee   dee   dee   fdZdedee   dee   fdZdedee   deeef   fdZy)z*Contains UI methods for Apache operations.    N)Iterable)List)Optional)Sequence)Tuple)errors)os)util)VirtualHostvhostsreturnc                     | sg S | D cg c]  }|j                         dz    }}|r|d   dd |d<   t        j                  d|d      \  }}|t        j                  k(  rt	        ||       }|S g S c c}w )zSelect multiple Vhosts to install the certificate for

    :param vhosts: Available Apache VirtualHosts
    :type vhosts: :class:`list` of type `~VirtualHost`

    :returns: List of VirtualHosts
    :rtype: :class:`list`of type `~VirtualHost`
    
NzJWhich VirtualHosts would you like to install the wildcard certificate for?T)tagsforce_interactive)display_reprdisplay_util	checklistOK_reversemap_vhosts)r   vhost	tags_listcodenamesreturn_vhostss         F/usr/lib/python3/dist-packages/certbot_apache/_internal/display_ops.pyselect_vhost_multipler      s     	8>?u##%d*?I?!"cr*	"((T$0KD% |*5&9I @s   A0r   c                     g }| D ]J  }|D ]C  }|j                         j                         |j                         k(  s3|j                  |       E L |S )zmHelper function for select_vhost_multiple for mapping string
    representations back to actual vhost objects)r   stripappend)r   r   r   	selectionr   s        r   r   r   )   s^     M ,	 	,E!!#))+y/@@$$U+	,,     domainc                 X    |syt        | |      \  }}|t        j                  k(  r||   S y)a  Select an appropriate Apache Vhost.

    :param str domain: Domain for vhost selection

    :param vhosts: Available Apache VirtualHosts
    :type vhosts: :class:`list` of type `~VirtualHost`

    :returns: VirtualHost or `None`
    :rtype: `~obj.Vhost` or `None`

    N)_vhost_menur   r   )r$   r   r   tags       r   select_vhostr(   5   s3     FF+ID#|c{r#   c                 L   t         j                  t        d      z
  t        d      z
  dz
  }|dk  rt        j	                  d       d}d}nt        |dz        }||z
  }g }|D ]  }t        |j                               dk(  r#t        t        |j                                     }n|j                         sd}nd	}|j                  d
j                  t        j                  j                  |j                        d| |d| |j                  rdnd|j                   rdnd||              	 t        j"                  d|  dt        j$                   d|d      \  }}	||	fS # t&        j(                  $ r1 d|  d}
t        j+                  |
       t'        j(                  |
      w xY w)zSelect an appropriate Apache Vhost.

    :param vhosts: Available Apache Virtual Hosts
    :type vhosts: :class:`list` of type `~obj.Vhost`

    :returns: Display tuple - ('code', tag')
    :rtype: `tuple`

    HTTPSEnabled	      zPDisplay size is too small for certbot_apache._internal.display_ops._vhost_menu()   g333333? zMultiple Namesz@{fn:{fn_size}s} | {name:{name_size}s} | {https:5s} | {active:7s}N)fnnamehttpsactivefn_size	name_sizez?We were unable to find a vhost with a ServerName or Address of .z,Which virtual host would you like to choose?T)r   z<Encountered vhost ambiguity when trying to find a vhost for z but was unable to ask for user guidance in non-interactive mode. Certbot may need vhosts to be explicitly labelled with ServerName or ServerAlias directives.)r   WIDTHlenloggerdebugint	get_namesnextiterr!   formatr	   pathbasenamefilepsslenabledmenulinesepr   MissingCommandlineFlagerror)r$   r   
free_charsfilename_sizedisp_name_sizechoicesr   	disp_namer   r'   msgs              r   r&   r&   I   s    ##c'l2S^CaGJA~ J 	K  JO,#m3G 
u !Q&T%//"345I"I(I &77##EKK0-@/!&g$)MMyr%( ! *		

&1 %%#HAbjj\ 2 t	-	c 9 (( 1Jh &' 	 	S++C001s   +0E AF#)__doc__loggingtypingr   r   r   r   r   certbotr   certbot.compatr	   certbot.displayr
   r   certbot_apache._internal.objr   	getLogger__name__r9   r   strr   r(   r;   r&    r#   r   <module>rZ      s    0         0 4			8	$(4+<"= ${BS 0	hsm 	Xk5J 	tT_O` 	 h{&; @U (< <Xk%: <uS#X <r#   