o nnh$@s8ddlmZddZddZddZdd Zd d Zd S) ) annotationscCsTd}t|D]!\}}|dkr||d}|dvr'|dkr'|r%||kr$d}q|}q|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 Nrz"'\) enumerate)token quote_char prev_charidxcur_charr H/usr/local/lib/python3.10/dist-packages/ansible/module_utils/splitter.py_get_quote_state s r cCs8||}||}||kr|||7}|dkrd}|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_tokennum_open num_closer r r _count_jinja2_blocks4s   rcCsg}|}z |d}d}Wn tyd}Ynw|d}d}d}d}d}d}t|D]\} } | d} d} t| D]\} }|dkrM|sMd} q@|}t||}|du}d}|rf|sf||d}nS|sp|sp|sp|sp|r| dkr|s|rd |d |f|d <n4t| d krd }| dkrd}d |d ||f|d <nd }|d ds| dkrd}d |d ||f|d <d}|}t ||dd}||kr|s||d}|}t ||dd}||kr|s||d}|}t ||dd}||kr|s||d}|s|s|s|s|s|d kr||q@t|d kr=| t|d kr=| s=|d dr5| d kr=|d d7<d} q.|sL|sL|sL|rPt d|rZdd|D}|S)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. utf-8TF Nr rz%s%srz%s%s%sz{{z}}z{%z%}z{#z#}zLerror while splitting arguments, either an unbalanced jinja2 block or quotescSsg|]}|dqS)r)decode).0xr r r szsplit_args..) stripencodeUnicodeDecodeErrorsplitrr appendlenendswithr Exception)argsparams do_decodeitemsr inside_quotes print_depth block_depth comment_depthitemidxitemtokensline_continuationr rwas_inside_quotesappendedspacerprev_print_depthprev_block_depthprev_comment_depthr r r split_argsCs              ( &r8cCs<t|dko|ddkr|ddkp|ddko|ddkS)Nr"r')r#datar r r is_quoteds<r=cCst|r |ddS|S)za removes first and last quotes from a string, if the string starts and ends with the same quotes rr)r=r;r r r unquotes r>N) __future__rr rr8r=r>r r r r s