
    lck                     v    d Z ddlZddlZddlZ ej        e          Zg dZdZ	d Z
d ZddZddZd	 Zd
 ZdS )z(Helper functions for documentation, etc.    N)s3s3ns3us3agsz0///smart_open.utils.QUESTION_MARK_PLACEHOLDER///c                 f   	 t          j        |           }d |j                                        D             S # t          $ rm 	 t          j        |           \  }}}}n# t          $ r i cY cY S w xY w|si cY S |t          |           d          }t          t          ||                    cY S w xY w)Nc                 X    i | ]'\  }}|j         t          j        j        k    ||j         (S  )defaultinspect	Parameterempty).0nameparams      0lib/python3.11/site-packages/smart_open/utils.py
<dictcomp>z"inspect_kwargs.<locals>.<dictcomp>,   sC     
 
 
e} 1 77
%-
 
 
    )
r   	signature
parametersitemsAttributeError
getargspec	TypeErrorlendictzip)kallabler   argsvarargskeywordsdefaultssupported_keywordss          r   inspect_kwargsr$      s    
%h//	
 
(399;;
 
 
 	
  7 7 7	070B80L0L-D'8XX 	 	 	 IIIII		  	III!3x==.//2C*H55666667s9   9 
B0AB0A/*B0.A//B085B0/B0c                     t          t          |                     fdt          |          D             }fd|                                D             }|rt                              d|           |S )a  Check which keyword arguments the callable supports.

    Parameters
    ----------
    kallable: callable
        A function or method to test
    kwargs: dict
        The keyword arguments to check.  If the callable doesn't support any
        of these, a warning message will get printed.

    Returns
    -------
    dict
        A dictionary of argument names and values supported by the callable.
    c                     g | ]}|v|	S r
   r
   )r   kr#   s     r   
<listcomp>z check_kwargs.<locals>.<listcomp>D   s$    UUU!BT9TUAUUUr   c                 $    i | ]\  }}|v 	||S r
   r
   )r   r'   vr#   s      r   r   z check_kwargs.<locals>.<dictcomp>E   s*    UUU!QQBT=TU1UUUr   z*ignoring unsupported keyword arguments: %r)sortedr$   r   loggerwarning)r   kwargsunsupported_keywordssupported_kwargsr#   s       @r   check_kwargsr1   3   s       x 8 899UUUUvf~~UUUUUUU6<<>>UUU [CEYZZZr   c                 J    |t          | |          } t          | |          } | S )aI  Clamp a numeric value to a specific range.

    Parameters
    ----------
    value: numeric
        The value to clamp.

    minval: numeric
        The lower bound.

    maxval: numeric
        The upper bound.

    Returns
    -------
    numeric
        The clamped value.  It will be in the range ``[minval, maxval]``.

    )minmax)valueminvalmaxvals      r   clampr8   M   s/    (  #E6""vELr   c                     | |t          d          | dnt          |           }|dnt          |          }d|d|S )ak  Create a byte range specifier in accordance with RFC-2616.

    Parameters
    ----------
    start: int, optional
        The start of the byte range.  If unspecified, stop indicated offset from EOF.

    stop: int, optional
        The end of the byte range.  If unspecified, indicates EOF.

    Returns
    -------
    str
        A byte range specifier.

    Nz7make_range_string requires either a stop or start value zbytes=-)
ValueErrorstr)startstop	start_strstop_strs       r   make_range_stringrB   g   s_    (  T TRSSS3UI0rrs4yyHH%IIxx00r   c                     |                      dd          \  }}|                     dd          \  }}|                     dd          \  }}|t          |          t          |          t          |          fS )a  Extract units, start, stop, and length from a content range header like "bytes 0-846981/846982".

    Assumes a properly formatted content-range header from S3.
    See werkzeug.http.parse_content_range_header for a more robust version.

    Parameters
    ----------
    content_range: str
        The content-range header to parse.

    Returns
    -------
    tuple (units: str, start: int, stop: int, length: int)
        The units and three integers from the content-range header.

        /r;   )splitint)content_rangeunitsnumbersrangelengthr>   r?   s          r   parse_content_rangerN      sl    " #((a00NE7MM#q))ME6++c1%%KE4#e**c$iiV44r   c                    t           j                            | d          }d}|j        t          v rKd| v rGt
          | vr>t
          }|                     d|          } t           j                            | d          }||S |j                            |d          }t           j                            |j        |j	        |dd          S )a  This is a hack to prevent the regular urlsplit from splitting around question marks.

    A question mark (?) in a URL typically indicates the start of a
    querystring, and the standard library's urlparse function handles the
    querystring separately.  Unfortunately, question marks can also appear
    _inside_ the actual URL for some schemas like S3, GS.

    Replaces question marks with a special placeholder substring prior to
    splitting.  This work-around behavior is disabled in the unlikely event the
    placeholder is already part of the URL.  If this affects you, consider
    changing the value of QUESTION_MARK_PLACEHOLDER to something more suitable.

    See Also
    --------
    https://bugs.python.org/issue43882
    https://github.com/python/cpython/blob/3.7/Lib/urllib/parse.py
    https://github.com/RaRe-Technologies/smart_open/issues/285
    https://github.com/RaRe-Technologies/smart_open/issues/458
    smart_open/utils.py:QUESTION_MARK_PLACEHOLDER
    F)allow_fragmentsN?r:   )
urllibparseurlsplitschemeWORKAROUND_SCHEMESQUESTION_MARK_PLACEHOLDERreplacepathSplitResultnetloc)urlsrplaceholderrY   s       r   safe_urlsplitr_      s    * 
		sE		:	:BK	y&& ?3#: ?:S[^:^ ? 0kk#{++\""3">> 	7??;,,D<##BIry$BGGGr   )r   N)NN)__doc__r   loggingurllib.parserR   	getLogger__name__r,   rV   rW   r$   r1   r8   rB   rN   r_   r
   r   r   <module>re      s    / .      		8	$	$666 N 
 
 
<  4   41 1 1 165 5 5.&H &H &H &H &Hr   