o
    
i@!                     @   s   d dl mZ d dl mZ d dl mZ d dlZddlmZmZmZm	Z	m
Z
 dd ZG d	d
 d
ZG dd dZdd ZG dd dZG dd dZdS )    )absolute_import)print_function)unicode_literalsN   )
round_tripround_trip_loadround_trip_dumpdedentYAMLc                 C   s8   dd l }|jj|jj| |jjd|jjd}| d S )Nr   LoaderDumper
)srsly.ruamel_yamlruamel_yamldumploadRoundTripLoaderRoundTripDumperstrip)ssrslyres r   \/home/ubuntu/.local/lib/python3.10/site-packages/srsly/tests/ruamel_yaml/test_indentation.pyrt   s   r   c                   @   s   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#S )$
TestIndentc                 C   s   d}t |}||ksJ d S )Nza: [a, b, c]
)r   selfr   outputr   r   r   test_roundtrip_inline_list   s   z%TestIndent.test_roundtrip_inline_listc                 C       t d}t|}||ksJ d S )Nz2        a: [a, b, c]
        j: [k, l, m]
        r	   r   r   r   r   r   &test_roundtrip_mapping_of_inline_lists   s
   z1TestIndent.test_roundtrip_mapping_of_inline_listsc                 C   r"   )NzZ        # comment A
        a: [a, b, c]
        # comment B
        j: [k, l, m]
        r#   r   r   r   r   /test_roundtrip_mapping_of_inline_lists_comments'   s
   z:TestIndent.test_roundtrip_mapping_of_inline_lists_commentsc                 C   r"   )Nz`        # comment A
        a: [a, b, c]  # comment B
        j: [k, l, m]  # comment C
        r#   r   r   r   r   6test_roundtrip_mapping_of_inline_sequence_eol_comments3   
   zATestIndent.test_roundtrip_mapping_of_inline_sequence_eol_commentsc                 C   s^   dd l }td}d}|jj||jjd}|d }|j  |jj||jjd}||ks-J d S )Nr   z8
        a:
        - b
        - c
        - d
        za: [b, c, d]
r   ar   )	r   r	   r   r   r   faset_flow_styler   r   )r   r   s1r   datavalr    r   r   r   test_added_inline_list?   s   
z!TestIndent.test_added_inline_listc                 C   sH   dd l }td}|jj||jjd}|jj||jjd}||ks"J d S )Nr   z=        - {a: 1, b: hallo}
        - {j: fka, k: 42}
        r   r   )r   r	   r   r   r   r   r   )r   r   r   r,   r    r   r   r   test_roundtrip_flow_mappingT   s   z&TestIndent.test_roundtrip_flow_mappingc                 C   r"   )Nzk        # comment A
        - {a: 1, b: hallo}  # comment B
        - {j: fka, k: 42}  # comment C
        r#   r   r   r   r   7test_roundtrip_sequence_of_inline_mappings_eol_commentsa   r'   zBTestIndent.test_roundtrip_sequence_of_inline_mappings_eol_commentsc                 C      d}t |dd d S )Nz*
        -   a:
            -   b
           indentr   r   inpr   r   r   test_indent_top_levell   s   z TestIndent.test_indent_top_levelc                 C      d}t |ddd d S )NzY
        a:
         -   b: c
         -   1
         -   d:
              -   2
           r   r4   block_seq_indentr5   r6   r   r   r   %test_set_indent_5_block_list_indent_1s      z0TestIndent.test_set_indent_5_block_list_indent_1c                 C   r9   )NzT
        a:
          - b: c
          - 1
          - d:
              - 2
        r2      r;   r5   r6   r   r   r   %test_set_indent_4_block_list_indent_2}   r>   z0TestIndent.test_set_indent_4_block_list_indent_2c                 C   r9   )NzO
        a:
        -  b: c
        -  1
        -  d:
           -  2
           r   r;   r5   r6   r   r   r   %test_set_indent_3_block_list_indent_0   r>   z0TestIndent.test_set_indent_3_block_list_indent_0c                 C   r9   )N
        a:
          -
           b: c
          -
           1
          -
           d:
             -
              2
        rA   r?   r;   r5   r6   r   r   r   &Xtest_set_indent_3_block_list_indent_2      z1TestIndent.Xtest_set_indent_3_block_list_indent_2c                 C   r9   )NzS
        a:
          - b: c
          - 1
          - d:
             - 2
        rA   r?   r;   r5   r6   r   r   r   %test_set_indent_3_block_list_indent_2   r>   z0TestIndent.test_set_indent_3_block_list_indent_2c                 C      d}t |ddd d S )NrC   r?   r;   r5   r6   r   r   r   &Xtest_set_indent_2_block_list_indent_2   rE   z1TestIndent.Xtest_set_indent_2_block_list_indent_2c                 C   rG   )NzR
        a:
          - b: c
          - 1
          - d:
            - 2
        r?   r;   r5   r6   r   r   r   %test_set_indent_2_block_list_indent_2   r>   z0TestIndent.test_set_indent_2_block_list_indent_2c                 C   r1   )Nza:
-   foo
-   bar
r2   r3   r5   )r   r   r   r   r   !test_roundtrip_four_space_indents   s   z,TestIndent.test_roundtrip_four_space_indentsc                 C   s$   d}d}t t|t|ksJ d S )Nz4
        a:
        -   foo
        -   bar
        z0
        a:
        - foo
        - bar
        )r   r   r	   )r   r7   expr   r   r   )test_roundtrip_four_space_indents_no_fail   s   z4TestIndent.test_roundtrip_four_space_indents_no_failN)__name__
__module____qualname__r!   r$   r%   r&   r.   r/   r0   r8   r=   r@   rB   rD   rF   rH   rI   rJ   rL   r   r   r   r   r      s$    





r   c                   @   s   e Zd Zdd ZdS )TestYpkgIndentc                 C   s   d}t |ddddd d S )Na  
        name       : nano
        version    : 2.3.2
        release    : 1
        homepage   : http://www.nano-editor.org
        source     :
          - http://www.nano-editor.org/dist/v2.3/nano-2.3.2.tar.gz : ff30924807ea289f5b60106be8
        license    : GPL-2.0
        summary    : GNU nano is an easy-to-use text editor
        builddeps  :
          - ncurses-devel
        description: |
            GNU nano is an easy-to-use text editor originally designed
            as a replacement for Pico, the ncurses-based editor from the non-free mailer
            package Pine (itself now available under the Apache License as Alpine).
        r2   r?   T )r4   r<   top_level_colon_alignprefix_colonr5   r6   r   r   r   test_00   s   
zTestYpkgIndent.test_00N)rM   rN   rO   rT   r   r   r   r   rP      s    rP   c                 C   s&   ddl m} |t| \}}}||fS )Nr   )load_yaml_guess_indent)srsly.ruamel_yaml.utilrU   r	   )r   rU   xyzr   r   r   guess   s   rZ   c                   @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
TestGuessIndentc                 C      d}t |dks
J d S )Nz        a:
        - 1
        )r?   r   rZ   r6   r   r   r   test_guess_20      zTestGuessIndent.test_guess_20c                 C   r\   )Nz!        a:
          - 1
        r2   r?   r]   r6   r   r   r   test_guess_42  r_   zTestGuessIndent.test_guess_42c                 C   r\   )Nz8        b:
              a:
                - 1
        r`   r]   r6   r   r   r   test_guess_42a  s   zTestGuessIndent.test_guess_42ac                 C   r\   )Nz#        b:
           a: 1
        )rA   Nr]   r6   r   r   r   test_guess_3None  r_   z TestGuessIndent.test_guess_3NoneN)rM   rN   rO   r^   ra   rb   rc   r   r   r   r   r[      s
    	r[   c                   @   s<   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd ZdS )TestSeparateMapSeqIndentsc                 C   s$   t  }d|_d|_d}|| d S )N   rA   z9
        a:
           -  1
           -  [1, 2]
        )r
   r4   r<   r   r   yamlr7   r   r   r   rT      s
   z!TestSeparateMapSeqIndents.test_00c                 C   s0   t  }|jdd |jdd d}|| d S )Nre   )sequencerA   )offsetz9
        a:
           -  1
           -  {b: 3}
        r
   r4   r   rf   r   r   r   test_01,  s
   z!TestSeparateMapSeqIndents.test_01c                 C   s(   t  }|jdddd d}|| d S )Nr:   re   rA   )mappingrh   ri   zS
        a:
             b:
                -  1
                -  [1, 2]
        rj   rf   r   r   r   test_027  s   z!TestSeparateMapSeqIndents.test_02c                 C   r1   )Nzg
        a:
            b:
                c:
                -   1
                -   [1, 2]
        r2   r3   r5   r6   r   r   r   test_03B  s   z!TestSeparateMapSeqIndents.test_03c                 C   s&   t  }|jddd d}|| d S )Nr:   re   )rl   rh   zp
        a:
             b:
             -     1
             -     [1, 2]
             -     {d: 3.14}
        rj   rf   r   r   r   test_04L  s   z!TestSeparateMapSeqIndents.test_04c                 C   s(   t  }|jddd d|_|d d S )Nr2   r?   )rh   ri   Ta  
        role::startup::author::rsyslog_inputs:
          imfile:
            - ruleset: 'AEM-slinglog'
              File: '/opt/aem/author/crx-quickstart/logs/error.log'
              startmsg.regex: '^[-+T.:[:digit:]]*'
              tag: 'error'
            - ruleset: 'AEM-slinglog'
              File: '/opt/aem/author/crx-quickstart/logs/stdout.log'
              startmsg.regex: '^[-+T.:[:digit:]]*'
              tag: 'stdout'
        )r
   r4   preserve_quotesr   )r   rg   r   r   r   test_issue_51X  s   z'TestSeparateMapSeqIndents.test_issue_51N)	rM   rN   rO   rT   rk   rm   rn   ro   rq   r   r   r   r   rd     s    
rd   )
__future__r   r   r   pytest	roundtripr   r   r   r	   r
   r   r   rP   rZ   r[   rd   r   r   r   r   <module>   s   
 E 