ensured tests are passing

This commit is contained in:
ari committed 2019-12-19 21:58:44 -05:00
1 parent fdd2fbd85a
commit cdcd2eabe2
11 files changed
+37 -22

No files matched your search

+17
View File
@@ -48,6 +48,23 @@ class CMapNotFound(ParserError):
class PSException(ParserError): class PSException(ParserError):
pass pass
class PDFValueError(ParserError):
pass
class PDFObjectNotFound(ParserError):
pass
class PDFException(ParserError):
pass
class PDFTypeError(PDFException):
pass
class PDFSyntaxError(PDFException):
pass
class PDFTextExtractionNotAllowed(PDFException):
pass
class PSEOF(PSException): class PSEOF(PSException):
pass pass
@@ -1,5 +1,6 @@
from pdfmajor.execptions import PSEOF
from pdfmajor.parser.PSStackParser import PSStackParser from pdfmajor.parser.PSStackParser import PSStackParser
from pdfmajor.parser.PSStackParser import PSEOF, KWD from pdfmajor.parser.PSStackParser import KWD
from pdfmajor.parser.PSStackParser import PSLiteral from pdfmajor.parser.PSStackParser import PSLiteral
from pdfmajor.parser.PSStackParser import literal_name from pdfmajor.parser.PSStackParser import literal_name
from pdfmajor.parser.EncodingDB import name2unicode from pdfmajor.parser.EncodingDB import name2unicode
+2 -2
View File
@@ -2,7 +2,7 @@ import re
from logging import getLogger from logging import getLogger
from typing import Tuple, Optional, Dict from typing import Tuple, Optional, Dict
from pdfmajor.execptions import PSEOF from pdfmajor.execptions import PSEOF, PDFSyntaxError
from ...utils import settings, choplist, nunpack from ...utils import settings, choplist, nunpack
from ..PSStackParser import KWD from ..PSStackParser import KWD
@@ -105,7 +105,7 @@ class PDFXRef(PDFBaseXRef):
try: try:
return self.offsets[objid] return self.offsets[objid]
except KeyError: except KeyError:
raise PDFSyntaxError raise
## PDFXRefFallback ## PDFXRefFallback
+6 -4
View File
@@ -8,16 +8,18 @@ from pdfmajor.execptions import (
ParserError, ParserError,
PDFNoOutlines, PDFNoOutlines,
PDFDestinationNotFound, PDFDestinationNotFound,
PDFNoValidXRef PDFNoValidXRef,
PSEOF,
PDFObjectNotFound,
PDFTypeError,
PDFSyntaxError
) )
from ...utils import settings, choplist, decode_text from ...utils import settings, choplist, decode_text
from ..PSStackParser import KWD from ..PSStackParser import KWD
from ..PSStackParser import literal_name from ..PSStackParser import literal_name
from ..PSStackParser import PSEOF
from ..PDFStream import int_value, str_value, dict_value, list_value, decipher_all from ..PDFStream import int_value, str_value, dict_value, list_value, decipher_all
from ..PDFStream import PDFObjectNotFound, PDFTypeError from ..PDFParser import PDFStreamParser, PDFStream
from ..PDFParser import PDFStreamParser, PDFStream, PDFSyntaxError
from .PDFSecurityHandler import PDFStandardSecurityHandler from .PDFSecurityHandler import PDFStandardSecurityHandler
from .PDFSecurityHandler import PDFStandardSecurityHandlerV4 from .PDFSecurityHandler import PDFStandardSecurityHandlerV4
+2 -3
View File
@@ -1,13 +1,12 @@
import logging import logging
from ..execptions import PDFTextExtractionNotAllowed from pdfmajor.execptions import PDFTextExtractionNotAllowed, PDFObjectNotFound
from ..utils import settings from ..utils import settings
from .constants import LIT from .constants import LIT
from .PDFStream import PDFObjectNotFound
from .PDFStream import resolve1, int_value, list_value, dict_value from .PDFStream import resolve1, int_value, list_value, dict_value
from .PDFParser import PDFParser from .PDFParser import PDFParser
from .PDFDocument import PDFDocument, PDFTextExtractionNotAllowed from .PDFDocument import PDFDocument
from ..utils import get_logger from ..utils import get_logger
+1 -6
View File
@@ -5,10 +5,10 @@ from ..utils import settings
from pdfmajor.execptions import ( from pdfmajor.execptions import (
PSSyntaxError, PSSyntaxError,
PSEOF, PSEOF,
PDFSyntaxError
) )
from .PSStackParser import PSStackParser from .PSStackParser import PSStackParser
from .PSStackParser import KWD from .PSStackParser import KWD
from .PDFStream import PDFException
from .PDFStream import PDFStream from .PDFStream import PDFStream
from .PDFStream.PDFObjRef import PDFObjRef from .PDFStream.PDFObjRef import PDFObjRef
from .PDFStream import int_value from .PDFStream import int_value
@@ -17,11 +17,6 @@ from .PDFStream import dict_value
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
## Exceptions
##
class PDFSyntaxError(PDFException):
pass
## PDFParser ## PDFParser
## ##
+1 -1
View File
@@ -1,6 +1,6 @@
import zlib import zlib
from ..PSStackParser import PSException from pdfmajor.execptions import PDFValueError, PDFObjectNotFound
from ..PSStackParser import PSObject from ..PSStackParser import PSObject
from ...utils import lzwdecode, settings from ...utils import lzwdecode, settings
+1 -1
View File
@@ -1,7 +1,7 @@
import logging import logging
from io import TextIOWrapper from io import TextIOWrapper
from pdfmajor.execptions import PSSyntaxError, PSTypeError from pdfmajor.execptions import PSSyntaxError, PSTypeError, PSEOF
from ...utils import choplist, settings from ...utils import choplist, settings
-1
View File
@@ -1 +0,0 @@
../pdfmajor
+3 -2
View File
@@ -1,7 +1,8 @@
from pathlib import Path from pathlib import Path
from unittest import TestCase, main from unittest import TestCase, main
from pdfmajor.interpreter import PDFInterpreter, exceptions from pdfmajor.interpreter import PDFInterpreter
from pdfmajor.execptions import UnicodeNotDefined
CURRENT_FOLDER = Path("./") CURRENT_FOLDER = Path("./")
@@ -9,7 +10,7 @@ class BadUnicode(TestCase):
def test_ensure_failure(self): def test_ensure_failure(self):
pdf = PDFInterpreter(CURRENT_FOLDER / "tests" / "samples" / "pdf" / "bad-unicode.pdf", ignore_bad_chars=False) pdf = PDFInterpreter(CURRENT_FOLDER / "tests" / "samples" / "pdf" / "bad-unicode.pdf", ignore_bad_chars=False)
pages = list(pdf) pages = list(pdf)
with self.assertRaises(exceptions.PDFUnicodeNotDefined): with self.assertRaises(UnicodeNotDefined):
list(pages[2]) list(pages[2])
def test_ensure_no_failure(self): def test_ensure_no_failure(self):
+2 -1
View File
@@ -5,7 +5,8 @@
import logging import logging
from unittest import TestCase, main from unittest import TestCase, main
from io import BytesIO from io import BytesIO
from pdfmajor.parser.PSStackParser import KWD, LIT, PSBaseParser, PSEOF, PSStackParser from pdfmajor.parser.PSStackParser import KWD, LIT, PSBaseParser, PSStackParser
from pdfmajor.execptions import PSEOF
## Simplistic Test cases ## Simplistic Test cases
## ##