
    h9                     V    S SK Jr  S SKrSSKJrJrJrJr  S rS r	S r
 " S S	5      rg)
    )print_functionN   )
round_tripdedentround_trip_loadround_trip_dumpc                 *    [        [        U 5      5      $ N)r   r   )ss    k/home/james-whalen/.local/lib/python3.13/site-packages/srsly/tests/ruamel_yaml/test_comment_manipulation.pyloadr   
   s    6!9%%    c                 :    [        U 40 UD6[        U5      :X  d   eg r
   )r   r   )datar   kws      r   comparer      s    4&2&&)333r   c                     SU;   d   e[        U5      R                  SS5      R                  SS5      n[        U 5      R                  SS5      U:X  d   eg )NEOL 
z|
)r   replacer   )r   r   dss      r   compare_eolr      sQ    A::			5"	%	-	-dE	:B4 ((u5;;;r   c                       \ rS rSrS rS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rSr g) TestCommentsManipulation   c                 V    [        S5      nUR                  SSSS9  Sn[        X5        g )N;
        - a   # comment 1
        - b
        - c
        	comment 2r      keycolumnzI
        - a   # comment 1
        - b   # comment 2
        - c
        r   yaml_add_eol_commentr   selfr   exps      r   0test_seq_set_comment_on_existing_explicit_columnITestCommentsManipulation.test_seq_set_comment_on_existing_explicit_column   9    
 	!!+1Q!?
 	r   c                 V    [        S5      nUR                  SSSS9  Sn[        X5        g )Nr   r   r   r    r!   z;
        - a   # comment 2
        - b
        - c
        r$   r&   s      r   6test_seq_overwrite_comment_on_existing_explicit_columnOTestCommentsManipulation.test_seq_overwrite_comment_on_existing_explicit_column+   r+   r   c                 V    [        S5      nUR                  SSSS9  Sn[        X5        g )Nz-
        - a
        - b
        - c
        z	comment 1r   r    r!   z;
        - a
        - b   # comment 1
        - c
        r$   r&   s      r   &test_seq_first_comment_explicit_column?TestCommentsManipulation.test_seq_first_comment_explicit_column;   r+   r   c                 T    [        S5      nUR                  SSS9  Sn[        X5        g )NW
        - a   # comment 1
        - b
        - c
        - d     # comment 3
        r   r   r"   ze
        - a   # comment 1
        - b   # comment 2
        - c
        - d     # comment 3
        r$   r&   s      r   ,test_seq_set_comment_on_existing_column_prevETestCommentsManipulation.test_seq_set_comment_on_existing_column_prevK   s7    
 	!!+1!5 	r   c                 ~    [        S5      n[        UR                  5        UR                  SSS9  Sn[	        X5        g )Nr3   r      r4   zg
        - a   # comment 1
        - b
        - c     # comment 2
        - d     # comment 3
        r   print_yaml_commentr%   r   r&   s      r   ,test_seq_set_comment_on_existing_column_nextETestCommentsManipulation.test_seq_set_comment_on_existing_column_next]   sG    
 	d  ! 	!!+1!5 	r   c                 ~    [        S5      n[        UR                  5        UR                  SSS9  Sn[	        X5        g)J
no comment line before or after, take the latest before
the new position
zo
        - a   # comment 1
        - b
        - c
        - d
        - e
        - f     # comment 3
        r      r4   z}
        - a   # comment 1
        - b
        - c
        - d   # comment 2
        - e
        - f     # comment 3
        Nr9   r&   s      r   4test_seq_set_comment_on_existing_column_further_awayMTestCommentsManipulation.test_seq_set_comment_on_existing_column_further_aways   sI    
 	
 	d  ! 	!!+1!5 	r   c                 V    [        S5      nUR                  SSSS9  Sn[        X5        g )Nr   z#  comment 2r   r    r!   zJ
        - a   # comment 1
        - b   #  comment 2
        - c
        r$   r&   s      r   :test_seq_set_comment_on_existing_explicit_column_with_hashSTestCommentsManipulation.test_seq_set_comment_on_existing_explicit_column_with_hash   s9    
 	!!.a!B
 	r   c                 V    [        S5      nUR                  SSSS9  Sn[        X5        g )NX
        a: 1   # comment 1
        b: 2
        c: 3
        d: 4
        e: 5
        r   c   r!   zf
        a: 1   # comment 1
        b: 2
        c: 3   # comment 2
        d: 4
        e: 5
        r$   r&   s      r   1test_dict_set_comment_on_existing_explicit_columnJTestCommentsManipulation.test_dict_set_comment_on_existing_explicit_column   9    
 	!!+3q!A 	r   c                 V    [        S5      nUR                  SSSS9  Sn[        X5        g )NrG   r   arI   r!   zX
        a: 1   # comment 2
        b: 2
        c: 3
        d: 4
        e: 5
        r$   r&   s      r   7test_dict_overwrite_comment_on_existing_explicit_columnPTestCommentsManipulation.test_dict_overwrite_comment_on_existing_explicit_column   rL   r   c                 T    [        S5      nUR                  SSS9  Sn[        X5        g )N
            a: 1   # comment 1
            b: 2
            c: 3
            d: 4
            e: 5     # comment 3
            r   br4   z
            a: 1   # comment 1
            b: 2   # comment 2
            c: 3
            d: 4
            e: 5     # comment 3
            r$   r&   s      r   ,test_map_set_comment_on_existing_column_prevETestCommentsManipulation.test_map_set_comment_on_existing_column_prev   7    
 	!!+3!7 	r   c                 T    [        S5      nUR                  SSS9  Sn[        X5        g )NrR   r   dr4   z
            a: 1   # comment 1
            b: 2
            c: 3
            d: 4     # comment 2
            e: 5     # comment 3
            r$   r&   s      r   ,test_map_set_comment_on_existing_column_nextETestCommentsManipulation.test_map_set_comment_on_existing_column_next   rV   r   c                 |    [        S5      nUR                  SSS9  [        [        U5      5        Sn[	        X5        g)r?   rR   r   rH   r4   z
            a: 1   # comment 1
            b: 2
            c: 3   # comment 2
            d: 4
            e: 5     # comment 3
            N)r   r%   r:   r   r   r&   s      r   4test_map_set_comment_on_existing_column_further_awayMTestCommentsManipulation.test_map_set_comment_on_existing_column_further_away   sF    
 
 	!!+3!7od#$ 	r   c                 p    [        S5      nUR                  S5        Sn[        XR                  SS95        g )Nz#
        a: 1
        b: 2
        Hello
World
zC
        # Hello
        # World
        a: 1
        b: 2
        #commentr   yaml_set_start_commentr   formatr&   s      r   test_before_top_map_rt/TestCommentsManipulation.test_before_top_map_rt  s>    
 	##$45 	jjj-.r   c                 p    [        S5      nUR                  S5        Sn[        XR                  SS95        g )NzC
        # abc
        # def
        a: 1 # 1
        b: 2
        r_   zG
        # Hello
        # World
        a: 1 # 1
        b: 2
        r`   ra   rc   r&   s      r   test_before_top_map_replace4TestCommentsManipulation.test_before_top_map_replace  s>    
 	##$45 	jjj-.r   c                     SSK Jn  U" 5       nSUS'   SUS'   UR                  S5        Sn[        X#R	                  S	S
95        g )Nr   CommentedMapr   rN   r8   rS   r_   zW
            # Hello
            # World
            a: 1
            b: 2
            r`   ra   srsly.ruamel_yaml.commentsrm   rd   r   re   )r'   rm   r   r(   s       r    test_before_top_map_from_scratch9TestCommentsManipulation.test_before_top_map_from_scratch.  sI    ;~S	S	##$45 	jjj-.r   c                 ~    [        S5      nUR                  S5        [        [        U5      5        Sn[	        X5        g )Nz!
        - a
        - b
        r_   A
        # Hello
        # World
        - a
        - b
        )r   rd   r:   r   r   r&   s      r   test_before_top_seq_rt/TestCommentsManipulation.test_before_top_seq_rt?  s@    
 	##$45od#$ 	r   c                     Sn[        UR                  SS95      nUR                  S5        [        [	        U5      5        Sn[        X#R                  SS95        g )Nz?
        # this
        # that
        - a
        - b
        r`   ra   r_   rs   )r   re   rd   r:   r   r   )r'   r   r   r(   s       r   test_before_top_seq_rt_replace7TestCommentsManipulation.test_before_top_seq_rt_replaceP  sX     AHHSH)*##$45od#$ 	jjj-.r   c                     SSK Jn  U" 5       nUR                  S5        UR                  S5        UR                  S5        [	        [        U5      5        Sn[        X#R                  SS95        g )	Nr   )CommentedSeqrN   rS   r_   rs   r`   ra   )ro   rz   appendrd   r:   r   r   re   )r'   rz   r   r(   s       r    test_before_top_seq_from_scratch9TestCommentsManipulation.test_before_top_seq_from_scratchb  s\    ;~CC##$45od#$ 	jjj-.r   c                 v    [        S5      nUS   R                  S5        Sn[        XR                  SS95        g )N?
        a: 1
        b:
          c: 2
          d: 3
        rS   r_   _
        a: 1
        b:
        # Hello
        # World
          c: 2
          d: 3
        r`   ra   rc   r&   s      r   test_before_nested_map_rt2TestCommentsManipulation.test_before_nested_map_rts  sB    
 	S	(()9: 	jjj-.r   c                     [        S5      nUS   R                  SSS9  Sn[        XR                  SS95        [	        US   R
                  5        g )	Nr   rS   r_   r8   indentzc
        a: 1
        b:
          # Hello
          # World
          c: 2
          d: 3
        r`   ra   )r   rd   r   re   r:   car&   s      r    test_before_nested_map_rt_indent9TestCommentsManipulation.test_before_nested_map_rt_indent  sW    
 	S	(()9!(D 	jjj-.d3illr   c                     SSK Jn  U" 5       nU" 5       nSUS'   X2S'   SUS'   SUS	'   US   R                  S
5        Sn[        X$R	                  SS95        g )Nr   rl   r   rN   rS   r8   rH   r@   rX   r_   r   r`   ra   rn   )r'   rm   r   databr(   s        r   #test_before_nested_map_from_scratch<TestCommentsManipulation.test_before_nested_map_from_scratch  sd    ;~S	S	c
c
S	(()9: 	jjj-.r   c                     SSK JnJn  U" 5       nU" 5       nSUS'   XCS'   UR                  S5        UR                  S5        US   R	                  SS	S
9  Sn[        X5R                  SS95        g )Nr   rm   rz   r   rN   rS   rH   rX   r_   r8   r   z]
        a: 1
        b:
          # Hello
          # World
        - c
        - d
        r`   ra   ro   rm   rz   r{   rd   r   re   r'   rm   rz   r   r   r(   s         r   #test_before_nested_seq_from_scratch<TestCommentsManipulation.test_before_nested_seq_from_scratch  so    I~S	S	SSS	(()9!(D 	jjj-.r   c                     SSK JnJn  U" 5       nU" 5       nSUS'   XCS'   UR                  S5        UR                  S5        US   R	                  SS	S
9  Sn[        X5R                  SS9SS	S9  g )Nr   r   r   rN   rS   rH   rX   r_   r8   r   za
        a: 1
        b:
          # Hello
          # World
          - c
          - d
        r`   ra      )r   block_seq_indentr   r   s         r   4test_before_nested_seq_from_scratch_block_seq_indentMTestCommentsManipulation.test_before_nested_seq_from_scratch_block_seq_indent  ss    I~S	S	SSS	(()9!(D 	jjj-a!Lr   c                     [        S5      nUR                  SSSS9  US   S   R                  SSS	9  S
n[        X5        g )Nz
        xyz:
          a: 1    # comment 1
          b: 2

        test1:
          test2:
            test3: 3
                test1before test1 (top level)zbefore test2aftertest2after test2r   r   z
        xyz:
          a: 1    # comment 1
          b: 2

        # before test1 (top level)
        test1:
          # before test2
          test2:
            # after test2
            test3: 3
        r   !yaml_set_comment_before_after_keyrd   r   r&   s      r   6test_map_set_comment_before_and_after_non_first_key_00OTestCommentsManipulation.test_map_set_comment_before_and_after_non_first_key_00  s]    

 	../~ 	/ 	
 	Wg55mA5N 	r   c                     [        S5      nUR                  SSSS9  US   S   R                  SSS	9  S
n[        X5        g )Ny
        xyz:
          a: 1    # comment 1
          b: 2

        test1:
          test2:
            test3: 3
        r   r   before test2

r   r   r   r   r   z
        xyz:
          a: 1    # comment 1
          b: 2

        # before test1 (top level)
        test1:
          # before test2
          EOL
          test2:
            # after test2
            test3: 3
        r   r   rd   r   r&   s      r   7Xtest_map_set_comment_before_and_after_non_first_key_01PTestCommentsManipulation.Xtest_map_set_comment_before_and_after_non_first_key_01  s^    

 	../7I 	/ 	
 	Wg55mA5N 	Dr   c                     [        S5      nUR                  SSSS9  US   S   R                  SSS	9  S
n[        X5        g )Nr   r   r   r   r   r   r   r   r   z
        xyz:
          a: 1    # comment 1
          b: 2

        # before test1 (top level)
        test1:
          # before test2

          test2:
            # after test2
            test3: 3
        r   r&   s      r   6test_map_set_comment_before_and_after_non_first_key_01OTestCommentsManipulation.test_map_set_comment_before_and_after_non_first_key_01  s^    

 	../7I 	/ 	
 	Wg55mA5N 	r   c                     [        S5      nUR                  SSSSS9  US   S   R                  SSS	9  S
n[        X5        g )Nr   r   xyz

before test1 (top level)
before test2r   r   after_indentr   r   r   z
        xyz:
          a: 1    # comment 1
          b: 2

        # xyz

        # before test1 (top level)
        test1:
            EOL
            # before test2
          test2:
            # after test2
            test3: 3
        r   r&   s      r   7Xtest_map_set_comment_before_and_after_non_first_key_02PTestCommentsManipulation.Xtest_map_set_comment_before_and_after_non_first_key_028  sa    

 	..-"	 	/ 	
 	Wg55mA5N 	Dr   c                     [        S5      nUR                  SSSSS9  US   S   R                  SSS	9  S
n[        X5        g )Nr   r   r   r   r   r   r   r   r   z
        xyz:
          a: 1    # comment 1
          b: 2

        # xyz

        # before test1 (top level)
        test1:

            # before test2
          test2:
            # after test2
            test3: 3
        r   r&   s      r   6test_map_set_comment_before_and_after_non_first_key_02OTestCommentsManipulation.test_map_set_comment_before_and_after_non_first_key_02]  sa    

 	..-"	 	/ 	
 	Wg55mA5N 	r    N)!__name__
__module____qualname____firstlineno__r)   r-   r0   r5   r<   rA   rD   rJ   rO   rT   rY   r\   rf   ri   rp   rt   rw   r|   r   r   r   r   r   r   r   r   r   r   __static_attributes__r   r   r   r   r      s       $,<$((((2/ /$/""/$/"/(*/(/(M(>D>#J"r   r   )
__future__r   pytest	roundtripr   r   r   r   r   r   r   r   r   r   r   <module>r      s.    &  K K&4<g	 g	r   