# 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

        Transcriber detects and remembers the newline type (DOS, ``'\r\n'`` or
        UNIX ``'\n'``) of 'source'. It then converts 'source' to UNIX-like
        newlines and works on this. When returning the destination, the initial
        newline type will be used. Because 'source' is being potentially
        edited, it's a good idea to save Transcriber's source back on top of
        the original one:

            >>> def parse(self, source):
            ...     self.transcriber = Transcriber(source)
            ...     self.source = self.transcriber.source
            ...     # ...

        The main methods provided are demonstrated below::

            >>> transcriber = Transcriber(source)

            source:      <string name="foo">hello world</string>
            ptr:         ^ (0)
            destination: []

            >>> transcriber.copy_until(source.index('>') + 1)

            source:      <string name="foo">hello world</string>
            ptr:                            ^
            destination: ['<string name="foo">']

            >>> transcriber.add("aee8cc2abd5abd5a87cd784be_tr")

            source:      <string name="foo">hello world</string>

# 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


        Transcriber detects and remembers the newline type (DOS, ``'\r\n'`` or
        UNIX ``'\n'``) of 'source'. It then converts 'source' to UNIX-like
        newlines and works on this. When returning the destination, the initial
        newline type will be used. Because 'source' is being potentially
        edited, it's a good idea to save Transcriber's source back on top of
        the original one:

            >>> def parse(self, source):
            ...     self.transcriber = Transcriber(source)
            ...     self.source = self.transcriber.source
            ...     # ...

        The main methods provided are demonstrated below::

            >>> transcriber = Transcriber(source)

            source:      <string name="foo">hello world</string>
            ptr:         ^ (0)
            destination: []

            >>> transcriber.copy_until(source.index('>') + 1)

            source:      <string name="foo">hello world</string>
            ptr:                            ^
            destination: ['<string name="foo">']

            >>> transcriber.add("aee8cc2abd5abd5a87cd784be_tr")

            source:      <string name="foo">hello world</string>

            ptr:                            ^