# Path: srsly/tests/ruamel_yaml/roundtrip.py
# 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)


import re
import pytest  # NOQA
    import srsly.ruamel_yaml  # NOQA
    import srsly.ruamel_yaml  # NOQA
    import srsly.ruamel_yaml  # NOQA
    import srsly.ruamel_yaml  # NOQA
        import srsly.ruamel_yaml  # NOQA
    import srsly.ruamel_yaml  # NOQA
    import srsly.ruamel_yaml  # NOQA
    import srsly.ruamel_yaml  # NOQA
from .roundtrip import dedent


# ToDo use nullege to search add_multi_representer and add_path_resolver
# and add some test code

# Issue 127 reported by Tommy Wang


def test_issue_127():

    class Ref(srsly.ruamel_yaml.YAMLObject):
        yaml_constructor = srsly.ruamel_yaml.RoundTripConstructor
        yaml_representer = srsly.ruamel_yaml.RoundTripRepresenter
        yaml_tag = u"!Ref"

        def __init__(self, logical_id):
            self.logical_id = logical_id

        @classmethod
        def from_yaml(cls, loader, node):
            return cls(loader.construct_scalar(node))

        @classmethod
        def to_yaml(cls, dumper, data):
            if isinstance(data.logical_id, srsly.ruamel_yaml.scalarstring.ScalarString):
                style = data.logical_id.style  # srsly.ruamel_yaml>0.15.8
            else:
                style = None
            return dumper.represent_scalar(cls.yaml_tag, data.logical_id, style=style)


# Path: srsly/tests/ruamel_yaml/roundtrip.py
# 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)


# Path: srsly/tests/ruamel_yaml/test_add_xxx.py
import re
import pytest  # NOQA
    import srsly.ruamel_yaml  # NOQA
    import srsly.ruamel_yaml  # NOQA
    import srsly.ruamel_yaml  # NOQA
    import srsly.ruamel_yaml  # NOQA
        import srsly.ruamel_yaml  # NOQA
    import srsly.ruamel_yaml  # NOQA
    import srsly.ruamel_yaml  # NOQA
    import srsly.ruamel_yaml  # NOQA
from .roundtrip import dedent



# ToDo use nullege to search add_multi_representer and add_path_resolver
# and add some test code

# Issue 127 reported by Tommy Wang


def test_issue_127():

    class Ref(srsly.ruamel_yaml.YAMLObject):
        yaml_constructor = srsly.ruamel_yaml.RoundTripConstructor
        yaml_representer = srsly.ruamel_yaml.RoundTripRepresenter
        yaml_tag = u"!Ref"

        def __init__(self, logical_id):
            self.logical_id = logical_id

        @classmethod
        def from_yaml(cls, loader, node):
            return cls(loader.construct_scalar(node))

        @classmethod
        def to_yaml(cls, dumper, data):
            if isinstance(data.logical_id, srsly.ruamel_yaml.scalarstring.ScalarString):
                style = data.logical_id.style  # srsly.ruamel_yaml>0.15.8
            else:
                style = None
            return dumper.represent_scalar(cls.yaml_tag, data.logical_id, style=style)


    document = dedent(