
    Vh$                    .    d dl mZ d Zd Zd Zd Zd Zy)    )annotationsc                z    d}t        |       D ]*  \  }}|dkD  r| |dz
     }|dv s|dk7  s|r	||k(  s&d})|}, |S )z
    the goal of this block is to determine if the quoted string
    is unterminated in which case it needs to be put back together
    Nr      z"'\)	enumerate)token
quote_char	prev_charidxcur_chars        M/home/dcms/DCMS/lib/python3.12/site-packages/ansible/module_utils/splitter.py_get_quote_stater       sa     I"5) &X7cAgIud!2z)!%J%
&     c                r    | j                  |      }| j                  |      }||k7  r|||z
  z  }|dk  rd}|S )z
    this function counts the number of opening/closing blocks for a
    given opening/closing type and adjusts the current depth for that
    block based on the difference
    r   )count)r   	cur_depth
open_tokenclose_tokennum_open	num_closes         r   _count_jinja2_blocksr   4   sI     {{:&HK(I9h*+	q=Ir   c                   g }| j                         } 	 | j                  d      } d}| j                  d      }d}d}d}d}d}t	        |      D ]  \  }	}
|
j                         j                  d      }d}t	        |      D ]Y  \  }}|dk(  r|sd}|}t        ||      }|du}d}|r|s|j                  |       d}ns|s|s|s|s|ri|dk(  r|s|r|d	   ||d	<   nQt        |      d
kD  rd}|dkD  rd}|d	   |||d	<   n+d}|d	   j                  d      s|dk(  rd}|d	   |||d	<   d}|}t        ||dd      }||k7  r|s|j                  |       d}|}t        ||dd      }||k7  r|s|j                  |       d}|}t        ||dd      }||k7  r|s|j                  |       d}|r2|r6|r:|r>|rB|dk7  sI|j                  |       \ t        |      d
kD  r9|	t        |      d
z
  k7  r(|s&|d	   j                  d      r|
dk(  r|d	xx   dz  cc<   d} |s|s|s|rt        d      |r|D cg c]  }|j                  d       }}|S # t        $ r d}Y Ew xY wc c}w )a  
    Splits args on whitespace, but intelligently reassembles
    those that may have been split over a jinja2 block or quotes.

    When used in a remote module, we won't ever have to be concerned about
    jinja2 blocks, however this function is/will be used in the
    core portions as well before the args are templated.

    example input: a=b c="foo bar"
    example output: ['a=b', 'c="foo bar"']

    Basically this is a variation shlex that has some more intelligence for
    how Ansible needs to use it.
    zutf-8TF
Nr    r   r    z{{z}}z{%z%}z{#z#}zLerror while splitting arguments, either an unbalanced jinja2 block or quotes)stripencodeUnicodeDecodeErrorsplitr   r   appendlenendswithr   	Exceptiondecode)argsparams	do_decodeitemsr	   inside_quotesprint_depthblock_depthcomment_depthitemidxitemtokensline_continuationr   r   was_inside_quotesappendedspacerprev_print_depthprev_block_depthprev_comment_depthxs                         r   
split_argsr9   C   s   $ F ::<D{{7#	 JJtE JMKKM #5) S"
 ##C(!#F+ A	%JC
 }]$(! !.)%<J&d2M H %6e$}Qb!8M6G+1":u!=F2J[1_FQw!$-3BZ!GF2JF!":..t4!%-3BZ!GF2J  +.uk4NK..xe$*.uk4NK..xe$!.0tTRM 228e$  ;-_glquwlwe$CA	%L u:>gUa7@Q":&&t,
r
d"
 "gS"n k]mfgg -34!((7#44Me  	` 5s   I I0I-,I-c                n    t        |       dkD  xr& | d   dk(  xr | d   dk(  xs | d   dk(  xr | d   dk(  S )Nr   "r   ')r"   datas    r   	is_quotedr?      sI    t9q=gd1gn@bSfDGsNDfW[\^W_cfWfgr   c                &    t        |       r| dd S | S )za removes first and last quotes from a string, if the string starts and ends with the same quotes r   r   )r?   r=   s    r   unquoterA      s    AbzKr   N)
__future__r   r   r   r9   r?   rA    r   r   <module>rD      s&   : #(L^hr   