
    q&f                     r    d dl Z ddlmZ ddlmZmZ ddlmZ ddlmZm	Z	m
Z
 ddZdd	Z G d
 d      Zd Zy)    N   )_)errorpycompat)procutil   )	hgweb_modhgwebdir_modserverc                 N   t        | t              rt        j                  d| z        t        | t              rt
        j                  j                  |       r t        | t              st        | t              rt        j                  | |      S t        j                  | ||      S )a  create an hgweb wsgi object

    config can be one of:
    - repo object (single repo view)
    - path to repo (single repo view)
    - path to config file (multi-repo view)
    - dict of virtual:real pairs (multi-repo view)
    - list of virtual:real tuples (multi-repo view)
    s+   Mercurial only supports encoded strings: %rbaseui)namer   )
isinstancestrr   ProgrammingErrorbytesospathisdirdictlistr
   hgwebdirr	   hgweb)configr   r   s      :/usr/lib/python3/dist-packages/mercurial/hgweb/__init__.pyr   r      s     &#$$:VC
 	
 
FE	"277==+@fd#fd# $$VF;;??6V<<    c                 0    t        j                  | |      S )Nr   )r
   r   )r   r   s     r   r   r   8   s      77r   c                       e Zd Zd Zd Zd Zy)httpservicec                 .    || _         || _        || _        y N)uiappopts)selfr#   r$   r%   s       r   __init__zhttpservice.__init__=   s    	r   c                 "   t        j                          t        j                  | j                  | j
                        | _        | j                  d   r&| j                  j                  s| j                  d   sy | j                  j                  r)| j                  j                  j                  d      dz   }nd}d| j                  j                  z  }|dk(  rd}| j                  j                  }|dk(  rd	}n	d
|v rd|z  }| j                  j                  }d
|v rd|z  }dt        j                  |      t        j                  |      |fz  }| j                  d   r| j                  j!                  d|z         nz| j                  d   r| j                  j"                  }n| j                  j                   } |t%        d      |t        j                  |      | j                  j                  fz         | j                  j'                          y )Ns   ports	   print_url   /r   z:%dz:80 z0.0.0.0*:z[%s]s   http://%s%s/%ss   %s
s!   listening at %s (bound to %s:%d)
)r   setsignalhandlerr   create_serverr#   r$   httpdr%   verboseprefixstripportaddrfqaddrr   sysbyteswritestatusr   flush)r&   r1   r3   bindaddrr5   urlr7   s          r   initzhttpservice.initB   s   !!#))$''488<
 IIgGGOOIIl+::ZZ&&,,T2T9FFtzz&5=D::??y HH_(H""&=f_Ff%d##
 

 99\"GGMM'C-(yy!78))(3TZZ__EF 	r   c                 8    | j                   j                          y r"   )r/   serve_forever)r&   s    r   runzhttpservice.runr   s    

  "r   N)__name__
__module____qualname__r'   r<   r?    r   r   r    r    <   s    
.`#r   r    c                     |rt        j                  ||       S |st        j                  t	        d            t        j                  ||       S )Nr   s5   there is no Mercurial repository here (.hg not found))r
   r   r   	RepoErrorr   r	   r   )r   repowebconfs      r   	createapprH   v   sH    $$WV<<//JK  tF33r   )NNr"   )r   i18nr   r*   r   r   utilsr   r	   r
   r   r   r   r    rH   rC   r   r   <module>rK      s;    
 
  =287# 7#t4r   