# Path: openformats/utils/newlines.py
# def find_newline_type(content):
#     if isinstance(content, six.text_type):
#         NEWLINE = "\n"
#         CARRIAGE_RETURN = "\r"
#     else:
#         NEWLINE = b"\n"
#         CARRIAGE_RETURN = b"\r"
# 
#     try:
#         first_newline_pos = content.index(NEWLINE)
#     except ValueError:
#         return 'UNIX'
#     else:
#         if (first_newline_pos > 0 and
#                 content[first_newline_pos - 1] == CARRIAGE_RETURN):
#             return 'DOS'
#         else:
#             return 'UNIX'
# 
# def force_newline_type(content, newline_type):
#     if isinstance(content, six.text_type):
#         NEWLINE = "\n"
#         CARRIAGE_RETURN_NEWLINE = "\r\n"
#     else:
#         NEWLINE = b"\n"
#         CARRIAGE_RETURN_NEWLINE = b"\r\n"
# 
#     new_content = content.replace(CARRIAGE_RETURN_NEWLINE, NEWLINE)
#     if newline_type == 'DOS':
#         new_content = new_content.replace(NEWLINE, CARRIAGE_RETURN_NEWLINE)
#     return new_content


import six
from .utils.newlines import find_newline_type, force_newline_type
                        if chunk not in (self.SectionStart, self.SectionEnd,
                                         None)])

    def edit_newlines(self, chunk, enforce_newline_type=None):
        r"""
        This is the part that renders the newlines to their correct type when
        returning the final result. You have the option to enforce the newline
        type if you want to.

            >>> source = "hello\r\nworld"
            >>> t = Transcriber(source)
            >>> t.source

            >>> "hello\nworld"

            >>> source = trascriber.source
            >>> # Work as if source was UNIX-type
            >>> t.copy_until(source.index('\n') + 1)  # include the '\n'
            >>> t.add("fellas")
            >>> t.get_destination()

            >>> "hello\r\nfellas"  # <- it remembered newline type from source

            >>> t.get_destination(enforce_newline_type="UNIX")

            >>> "hello\nfellas"
        """

        if ((enforce_newline_type is None and self.newline_type == "DOS") or
                enforce_newline_type == "DOS"):

# Path: openformats/utils/newlines.py
# def find_newline_type(content):
#     if isinstance(content, six.text_type):
#         NEWLINE = "\n"
#         CARRIAGE_RETURN = "\r"
#     else:
#         NEWLINE = b"\n"
#         CARRIAGE_RETURN = b"\r"
# 
#     try:
#         first_newline_pos = content.index(NEWLINE)
#     except ValueError:
#         return 'UNIX'
#     else:
#         if (first_newline_pos > 0 and
#                 content[first_newline_pos - 1] == CARRIAGE_RETURN):
#             return 'DOS'
#         else:
#             return 'UNIX'
# 
# def force_newline_type(content, newline_type):
#     if isinstance(content, six.text_type):
#         NEWLINE = "\n"
#         CARRIAGE_RETURN_NEWLINE = "\r\n"
#     else:
#         NEWLINE = b"\n"
#         CARRIAGE_RETURN_NEWLINE = b"\r\n"
# 
#     new_content = content.replace(CARRIAGE_RETURN_NEWLINE, NEWLINE)
#     if newline_type == 'DOS':
#         new_content = new_content.replace(NEWLINE, CARRIAGE_RETURN_NEWLINE)
#     return new_content


# Path: openformats/transcribers.py
import six
from .utils.newlines import find_newline_type, force_newline_type

                        if chunk not in (self.SectionStart, self.SectionEnd,
                                         None)])

    def edit_newlines(self, chunk, enforce_newline_type=None):
        r"""
        This is the part that renders the newlines to their correct type when
        returning the final result. You have the option to enforce the newline
        type if you want to.

            >>> source = "hello\r\nworld"
            >>> t = Transcriber(source)
            >>> t.source

            >>> "hello\nworld"

            >>> source = trascriber.source
            >>> # Work as if source was UNIX-type
            >>> t.copy_until(source.index('\n') + 1)  # include the '\n'
            >>> t.add("fellas")
            >>> t.get_destination()

            >>> "hello\r\nfellas"  # <- it remembered newline type from source

            >>> t.get_destination(enforce_newline_type="UNIX")

            >>> "hello\nfellas"
        """

        if ((enforce_newline_type is None and self.newline_type == "DOS") or
                enforce_newline_type == "DOS"):

            return force_newline_type(chunk, 'DOS')