
    IZj                         d Z ddlZddlmZ ddlmZ  ej        e          Zdede	de	dz  d	e	dz  d
e
e         f
dZ	 	 	 	 dde
e         de	de	dz  d	e	dz  deded
e
e         fdZdS )z%
Utilities dedicated to URL sampling
    N)sample   )UrlStoreurlstore
samplesizeexclude_minexclude_maxreturnc           
      F   g }| j         D ]d |                               D             }|r*|t          |          |k     s|=t          |          |k    r*t                              dt          |                     xt          |          |k    rt          t          ||                    }n|}|                    fd|D                        t                              dt          |          t          |          t          |          z             |S )z4Iterate through the hosts in store and draw samples.c                 H    g | ]}|j         d v|                                 S ))   /N)urlpathpath).0ps     \/Users/jameslopez/projects/MentorCore/.venv/lib/python3.11/site-packages/courlan/sampling.py
<listcomp>z _make_sample.<locals>.<listcomp>   s7     
 
 
y,, FFHH,,,    Nzdiscarded (size): %s		urls: %s)kc                     g | ]}|z   S  r   )r   r   domains     r   r   z _make_sample.<locals>.<listcomp>,   s    9991FQJ999r   z%s		urls: %s	prop.: %s)	urldict
_load_urlslenLOGGERwarningsortedr   extenddebug)r   r   r   r	   output_urlsurlpathsmysampler   s          @r   _make_sampler$      sA    K" 
 

 
((00
 
 
 	&H++&H++NN=vs8}}UUUx==:%%fX<<<==HHH9999999:::'MMMMCMM)		
 	
 	
 	
 r   F
input_urlsstrictverbosec                    |r%t                               t          j                   n$t                               t          j                   t          dd||          }|                    |            t          ||||          S )zRSample a list of URLs by domain name, optionally using constraints on their numberTN)
compressedlanguager&   r'   )r   setLevelloggingDEBUGERRORr   add_urlsr$   )r%   r   r   r	   r&   r'   r   s          r   sample_urlsr0   6   su      '&&&&&&&4$vwWWWHj!!!*k;GGGr   )NNFF)__doc__r,   randomr   r   r   	getLogger__name__r   intliststrr$   boolr0   r   r   r   <module>r9      s2                		8	$	$$$$ t$ t	$
 
#Y$ $ $ $T #"H HS	HH tH t	H
 H H 
#YH H H H H Hr   