# 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/pdf_types/compound_types.py
# class PdfDict(PdfType, UserDict):
#     """PDF dict type"""
#     def __init__(self, *args, **kwargs):
#         PdfType.__init__(self)
#         UserDict.__init__(self, *args, **kwargs)
# 
#     def __getattr__(self, name):
#         try:
#             return self[name].parsed_object
#         except AttributeError:
#             return self[name]
#         except KeyError:
#             raise AttributeError('Object has no attribute "{}"'.format(name))
#     def pdf_encode(self):
#         return b'<<'+b' '.join(k.pdf_encode()+b' '+v.pdf_encode()
#                                for k, v in six.iteritems(self))+b'>>'
# 
# Path: gymnast/exc.py
# class PdfError(Exception):
#     """Generic PDF exception"""
#     pass


from .common         import PdfType
from .compound_types import PdfDict
from ..exc           import PdfError
        from .. import pdf_elements
                     #'XRef'          : XRef
                     'Catalog'       : pdf_elements.PdfCatalog
                    }
        if self._parsed_obj is not None:
            return self._parsed_obj
        val = self.value
        if isinstance(val, PdfDict):
            try:
                self._parsed_obj = obj_types[val['Type']]\
                                          .from_object(val, self.object_key)
                return self._parsed_obj
            except KeyError:
                return val
        return val

class PdfObjectReference(PdfType):
    """PDF indirect object reference"""
    def __init__(self, object_number, generation, document=None):
        super(PdfObjectReference, self).__init__()
        self._object_number = object_number
        self._generation    = generation
        self._document      = document

        if   not isinstance(self._object_number, int) \
          or not isinstance(self._generation,    int) \
          or self._object_number <= 0 or self._generation < 0:
            raise ValueError('Invalid indirect object identifier')

    def get_object(self, document=None):
        if not document and not self._document:

# 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/pdf_types/compound_types.py
# class PdfDict(PdfType, UserDict):
#     """PDF dict type"""
#     def __init__(self, *args, **kwargs):
#         PdfType.__init__(self)
#         UserDict.__init__(self, *args, **kwargs)
# 
#     def __getattr__(self, name):
#         try:
#             return self[name].parsed_object
#         except AttributeError:
#             return self[name]
#         except KeyError:
#             raise AttributeError('Object has no attribute "{}"'.format(name))
#     def pdf_encode(self):
#         return b'<<'+b' '.join(k.pdf_encode()+b' '+v.pdf_encode()
#                                for k, v in six.iteritems(self))+b'>>'
# 
# Path: gymnast/exc.py
# class PdfError(Exception):
#     """Generic PDF exception"""
#     pass


# Path: gymnast/pdf_types/object_types.py
from .common         import PdfType
from .compound_types import PdfDict
from ..exc           import PdfError
        from .. import pdf_elements

                     #'XRef'          : XRef
                     'Catalog'       : pdf_elements.PdfCatalog
                    }
        if self._parsed_obj is not None:
            return self._parsed_obj
        val = self.value
        if isinstance(val, PdfDict):
            try:
                self._parsed_obj = obj_types[val['Type']]\
                                          .from_object(val, self.object_key)
                return self._parsed_obj
            except KeyError:
                return val
        return val

class PdfObjectReference(PdfType):
    """PDF indirect object reference"""
    def __init__(self, object_number, generation, document=None):
        super(PdfObjectReference, self).__init__()
        self._object_number = object_number
        self._generation    = generation
        self._document      = document

        if   not isinstance(self._object_number, int) \
          or not isinstance(self._generation,    int) \
          or self._object_number <= 0 or self._generation < 0:
            raise ValueError('Invalid indirect object identifier')

    def get_object(self, document=None):
        if not document and not self._document:

            raise PdfError('Evaluating indirect references requires a document')