# Path: gymnast/pdf_types/common.py
# class PdfType(object):
#     """Abstract base class for PDF objects"""
#     def pdf_encode(self):
#         """Translate the object into bytes in PDF format"""
#         raise NotImplementedError
#     @property
#     def value(self):
#         """Objects, references, and such will override this in clever
#         ways."""
#         return self
#     @property
#     def parsed_object(self):
#         """Objects, references, and such will override this in clever
#         ways."""
#         return self
# 
# Path: gymnast/exc.py
# class PdfParseError(PdfError):
#     """Exception parsing PDF file"""
#     pass
# 
# class PdfError(Exception):
#     """Generic PDF exception"""
#     pass
# 
# Path: gymnast/pdf_codec.py
# def register_codec():
#     """Register the 'pdf_doc' codec in the codec registry."""
#     codecs.register(lambda s: getregentry() if s == ENCODING_NAME else None)


import binascii
import codecs
import io
from .common     import PdfType
from ..exc       import PdfParseError, PdfError
from ..pdf_codec import register_codec

    ESCAPES = {b'n'   : b'\n',
               b'r'   : b'\r',
               b't'   : b'\t',
               b'b'   : b'\b',
               b'f'   : b'\f',
               b'('   : b'(',
               b')'   : b')',
               b'\n'  : b'',
               b'\r'  : b''}

    @staticmethod
    def _parse_escape(data):
        r"""Handle escape sequences in literal PDF strings.  This should be
        pretty straightforward except that there are line continuations, so
        \\n, \\r\n, and \\r are ignored. Moreover, actual newline characters
        are also valid.  It's very stupid. See pp. 53-56 in the Reference if
        you want to be annoyed.

        Arguments:
            data - io.BytesIO-like object

        Returns the unescaped bytes"""
        e_str = data.read(1)
        try:
            val = PdfLiteralString.ESCAPES[e_str]
        except KeyError:
            # Not a normal escape, hopefully it's an octal
            if not e_str.isdigit():
                print(e_str)

# Path: gymnast/pdf_types/common.py
# class PdfType(object):
#     """Abstract base class for PDF objects"""
#     def pdf_encode(self):
#         """Translate the object into bytes in PDF format"""
#         raise NotImplementedError
#     @property
#     def value(self):
#         """Objects, references, and such will override this in clever
#         ways."""
#         return self
#     @property
#     def parsed_object(self):
#         """Objects, references, and such will override this in clever
#         ways."""
#         return self
# 
# Path: gymnast/exc.py
# class PdfParseError(PdfError):
#     """Exception parsing PDF file"""
#     pass
# 
# class PdfError(Exception):
#     """Generic PDF exception"""
#     pass
# 
# Path: gymnast/pdf_codec.py
# def register_codec():
#     """Register the 'pdf_doc' codec in the codec registry."""
#     codecs.register(lambda s: getregentry() if s == ENCODING_NAME else None)


# Path: gymnast/pdf_types/string_types.py
import binascii
import codecs
import io
from .common     import PdfType
from ..exc       import PdfParseError, PdfError
from ..pdf_codec import register_codec


    ESCAPES = {b'n'   : b'\n',
               b'r'   : b'\r',
               b't'   : b'\t',
               b'b'   : b'\b',
               b'f'   : b'\f',
               b'('   : b'(',
               b')'   : b')',
               b'\n'  : b'',
               b'\r'  : b''}

    @staticmethod
    def _parse_escape(data):
        r"""Handle escape sequences in literal PDF strings.  This should be
        pretty straightforward except that there are line continuations, so
        \\n, \\r\n, and \\r are ignored. Moreover, actual newline characters
        are also valid.  It's very stupid. See pp. 53-56 in the Reference if
        you want to be annoyed.

        Arguments:
            data - io.BytesIO-like object

        Returns the unescaped bytes"""
        e_str = data.read(1)
        try:
            val = PdfLiteralString.ESCAPES[e_str]
        except KeyError:
            # Not a normal escape, hopefully it's an octal
            if not e_str.isdigit():
                print(e_str)

                raise PdfParseError('Invalid escape sequence in literal string')