# Path: srsly/tests/ruamel_yaml/roundtrip.py
# def round_trip(
#     inp,
#     outp=None,
#     extra=None,
#     intermediate=None,
#     indent=None,
#     block_seq_indent=None,
#     top_level_colon_align=None,
#     prefix_colon=None,
#     preserve_quotes=None,
#     explicit_start=None,
#     explicit_end=None,
#     version=None,
#     dump_data=None,
# ):
#     """
#     inp:    input string to parse
#     outp:   expected output (equals input if not specified)
#     """
#     if outp is None:
#         outp = inp
#     doutp = dedent(outp)
#     if extra is not None:
#         doutp += extra
#     data = round_trip_load(inp, preserve_quotes=preserve_quotes)
#     if dump_data:
#         print("data", data)
#     if intermediate is not None:
#         if isinstance(intermediate, dict):
#             for k, v in intermediate.items():
#                 if data[k] != v:
#                     print("{0!r} <> {1!r}".format(data[k], v))
#                     raise ValueError
#     res = round_trip_dump(
#         data,
#         indent=indent,
#         block_seq_indent=block_seq_indent,
#         top_level_colon_align=top_level_colon_align,
#         prefix_colon=prefix_colon,
#         explicit_start=explicit_start,
#         explicit_end=explicit_end,
#         version=version,
#     )
#     if res != doutp:
#         diff(doutp, res, "input string")
#     print("\nroundtrip data:\n", res, sep="")
#     assert res == doutp
#     res = round_trip_dump(
#         data,
#         indent=indent,
#         block_seq_indent=block_seq_indent,
#         top_level_colon_align=top_level_colon_align,
#         prefix_colon=prefix_colon,
#         explicit_start=explicit_start,
#         explicit_end=explicit_end,
#         version=version,
#     )
#     print("roundtrip second round data:\n", res, sep="")
#     assert res == doutp
#     return data
# 
# def dedent(data):
#     try:
#         position_of_first_newline = data.index("\n")
#         for idx in range(position_of_first_newline):
#             if not data[idx].isspace():
#                 raise ValueError
#     except ValueError:
#         pass
#     else:
#         data = data[position_of_first_newline + 1 :]
#     return textwrap.dedent(data)
# 
# def round_trip_load(inp, preserve_quotes=None, version=None):
#     import srsly.ruamel_yaml  # NOQA
# 
#     dinp = dedent(inp)
#     return srsly.ruamel_yaml.load(
#         dinp,
#         Loader=srsly.ruamel_yaml.RoundTripLoader,
#         preserve_quotes=preserve_quotes,
#         version=version,
#     )
# 
# def round_trip_dump(
#     data,
#     stream=None,
#     indent=None,
#     block_seq_indent=None,
#     top_level_colon_align=None,
#     prefix_colon=None,
#     explicit_start=None,
#     explicit_end=None,
#     version=None,
# ):
#     import srsly.ruamel_yaml  # NOQA
# 
#     return srsly.ruamel_yaml.round_trip_dump(
#         data,
#         stream=stream,
#         indent=indent,
#         block_seq_indent=block_seq_indent,
#         top_level_colon_align=top_level_colon_align,
#         prefix_colon=prefix_colon,
#         explicit_start=explicit_start,
#         explicit_end=explicit_end,
#         version=version,
#     )


import pytest
import platform
        import srsly
        import srsly
from .roundtrip import round_trip, dedent, round_trip_load, round_trip_dump  # NOQA
        from srsly.ruamel_yaml.comments import CommentedMap
        from srsly.ruamel_yaml.scalarstring import walk_tree
        from srsly.ruamel_yaml.compat import ordereddict
        from srsly.ruamel_yaml.comments import CommentedMap
        from srsly.ruamel_yaml.scalarstring import walk_tree, preserve_literal
        from srsly.ruamel_yaml.scalarstring import DoubleQuotedScalarString as dq
        from srsly.ruamel_yaml.scalarstring import SingleQuotedScalarString as sq
        """
        round_trip(inp, preserve_quotes=True)

    def test_non_preserved_double_quoted_string(self):
        inp = """
        a: "abc"
        """
        exp = """
        a: abc
        """
        round_trip(inp, outp=exp)


class TestReplace:
    """inspired by issue 110 from sandres23"""

    def test_replace_preserved_scalar_string(self):

        s = dedent(
            """\
        foo: |
          foo
          foo
          bar
          foo
        """
        )
        data = round_trip_load(s, preserve_quotes=True)
        so = data["foo"].replace("foo", "bar", 2)
        assert isinstance(so, srsly.ruamel_yaml.scalarstring.LiteralScalarString)

# Path: srsly/tests/ruamel_yaml/roundtrip.py
# def round_trip(
#     inp,
#     outp=None,
#     extra=None,
#     intermediate=None,
#     indent=None,
#     block_seq_indent=None,
#     top_level_colon_align=None,
#     prefix_colon=None,
#     preserve_quotes=None,
#     explicit_start=None,
#     explicit_end=None,
#     version=None,
#     dump_data=None,
# ):
#     """
#     inp:    input string to parse
#     outp:   expected output (equals input if not specified)
#     """
#     if outp is None:
#         outp = inp
#     doutp = dedent(outp)
#     if extra is not None:
#         doutp += extra
#     data = round_trip_load(inp, preserve_quotes=preserve_quotes)
#     if dump_data:
#         print("data", data)
#     if intermediate is not None:
#         if isinstance(intermediate, dict):
#             for k, v in intermediate.items():
#                 if data[k] != v:
#                     print("{0!r} <> {1!r}".format(data[k], v))
#                     raise ValueError
#     res = round_trip_dump(
#         data,
#         indent=indent,
#         block_seq_indent=block_seq_indent,
#         top_level_colon_align=top_level_colon_align,
#         prefix_colon=prefix_colon,
#         explicit_start=explicit_start,
#         explicit_end=explicit_end,
#         version=version,
#     )
#     if res != doutp:
#         diff(doutp, res, "input string")
#     print("\nroundtrip data:\n", res, sep="")
#     assert res == doutp
#     res = round_trip_dump(
#         data,
#         indent=indent,
#         block_seq_indent=block_seq_indent,
#         top_level_colon_align=top_level_colon_align,
#         prefix_colon=prefix_colon,
#         explicit_start=explicit_start,
#         explicit_end=explicit_end,
#         version=version,
#     )
#     print("roundtrip second round data:\n", res, sep="")
#     assert res == doutp
#     return data
# 
# def dedent(data):
#     try:
#         position_of_first_newline = data.index("\n")
#         for idx in range(position_of_first_newline):
#             if not data[idx].isspace():
#                 raise ValueError
#     except ValueError:
#         pass
#     else:
#         data = data[position_of_first_newline + 1 :]
#     return textwrap.dedent(data)
# 
# def round_trip_load(inp, preserve_quotes=None, version=None):
#     import srsly.ruamel_yaml  # NOQA
# 
#     dinp = dedent(inp)
#     return srsly.ruamel_yaml.load(
#         dinp,
#         Loader=srsly.ruamel_yaml.RoundTripLoader,
#         preserve_quotes=preserve_quotes,
#         version=version,
#     )
# 
# def round_trip_dump(
#     data,
#     stream=None,
#     indent=None,
#     block_seq_indent=None,
#     top_level_colon_align=None,
#     prefix_colon=None,
#     explicit_start=None,
#     explicit_end=None,
#     version=None,
# ):
#     import srsly.ruamel_yaml  # NOQA
# 
#     return srsly.ruamel_yaml.round_trip_dump(
#         data,
#         stream=stream,
#         indent=indent,
#         block_seq_indent=block_seq_indent,
#         top_level_colon_align=top_level_colon_align,
#         prefix_colon=prefix_colon,
#         explicit_start=explicit_start,
#         explicit_end=explicit_end,
#         version=version,
#     )


# Path: srsly/tests/ruamel_yaml/test_string.py
import pytest
import platform
        import srsly
        import srsly
from .roundtrip import round_trip, dedent, round_trip_load, round_trip_dump  # NOQA
        from srsly.ruamel_yaml.comments import CommentedMap
        from srsly.ruamel_yaml.scalarstring import walk_tree
        from srsly.ruamel_yaml.compat import ordereddict
        from srsly.ruamel_yaml.comments import CommentedMap
        from srsly.ruamel_yaml.scalarstring import walk_tree, preserve_literal
        from srsly.ruamel_yaml.scalarstring import DoubleQuotedScalarString as dq
        from srsly.ruamel_yaml.scalarstring import SingleQuotedScalarString as sq

        """
        round_trip(inp, preserve_quotes=True)

    def test_non_preserved_double_quoted_string(self):
        inp = """
        a: "abc"
        """
        exp = """
        a: abc
        """
        round_trip(inp, outp=exp)


class TestReplace:
    """inspired by issue 110 from sandres23"""

    def test_replace_preserved_scalar_string(self):

        s = dedent(
            """\
        foo: |
          foo
          foo
          bar
          foo
        """
        )
        data = round_trip_load(s, preserve_quotes=True)
        so = data["foo"].replace("foo", "bar", 2)
        assert isinstance(so, srsly.ruamel_yaml.scalarstring.LiteralScalarString)

        assert so == dedent(