a ì)g2%ã@sDddlmZmZmZeZdd„Zdd„Zdd„Zdd „Z d d „Z d S) é)Úabsolute_importÚdivisionÚprint_functioncCsTd}t|ƒD]B\}}|dkr(||d}|dvr |dkr |rJ||krNd}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 Nréz"'ú\)Ú enumerate)ÚtokenÚ quote_charZ prev_charÚidxZcur_char©r úA/usr/lib/python3.9/site-packages/ansible/module_utils/splitter.pyÚ_get_quote_state!s r cCs8| |¡}| |¡}||kr4|||7}|dkr4d}|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)rZ cur_depthZ open_tokenZ close_tokenZnum_openZ num_closer r r Ú_count_jinja2_blocks5s   rcCsÊg}| ¡}z| d¡}d}Wnty4d}Yn0| d¡}d}d}d}d}d}t|ƒD]2\} } |  ¡ d¡} d} t| ƒD]¸\} }|dkrœ|sœd} q€|}t||ƒ}|du}d}|rÎ|sÎ| |¡d}n¶|sä|sä|sä|sä|r„| dkr|s|rd |d |f|d <npt| ƒd krHd }| dkr0d}d |d ||f|d <n8d }|d  d¡sj| dkrjd}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  d¡r|| d krŒ|d d7<d} q\|sª|sª|sª|r²t dƒ‚|rÆdd„|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%séÿÿÿÿrÚz%s%s%sz{{z}}z{%z%}z{#z#}zLerror while splitting arguments, either an unbalanced jinja2 block or quotescSsg|]}| d¡‘qS)r)Údecode)Ú.0Úxr r r Ú Îózsplit_args..) ÚstripÚencodeÚUnicodeDecodeErrorÚsplitrr ÚappendÚlenÚendswithrÚ Exception)ÚargsÚparamsZ do_decodeÚitemsr Z inside_quotesZ print_depthZ block_depthZ comment_depthZitemidxÚitemÚtokensZline_continuationr rZwas_inside_quotesZappendedZspacerZprev_print_depthZprev_block_depthZprev_comment_depthr r r Ú split_argsDs„            &r'cCs<t|ƒdko:|ddkr$|ddkp:|ddko:|ddkS)Nrú"rú')r©Údatar r r Ú is_quotedÓsr,cCst|ƒr|dd…S|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 Úunquote×s r-N) Z __future__rrrÚtypeZ __metaclass__r rr'r,r-r r r r Ús