Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/pikepdf/__init__.py: 95%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

19 statements  

1# SPDX-FileCopyrightText: 2022 James R. Barlow 

2# SPDX-License-Identifier: MPL-2.0 

3 

4"""A library for manipulating PDFs.""" 

5 

6# isort:skip_file 

7 

8from __future__ import annotations 

9 

10from pikepdf._version import __version__ 

11 

12try: 

13 from pikepdf import _core 

14except ImportError as _e: # pragma: no cover 

15 _msg = "pikepdf's extension library failed to import" 

16 raise ImportError(_msg) from _e 

17 

18from pikepdf._core import ( 

19 AccessMode, 

20 AcroForm, 

21 AcroFormField, 

22 Annotation, 

23 AnnotationFlag, 

24 AttachedFileSpec, 

25 ContentStreamInlineImage, 

26 ContentStreamInstruction, 

27 DataDecodingError, 

28 DeletedObjectError, 

29 ForeignObjectError, 

30 FormFieldFlag, 

31 Job, 

32 JobUsageError, 

33 Matrix, 

34 NameTree, 

35 NumberTree, 

36 ObjectHelper, 

37 ObjectStreamMode, 

38 Page, 

39 PasswordError, 

40 Pdf, 

41 PdfError, 

42 Rectangle, 

43 StreamDecodeLevel, 

44 Token, 

45 TokenFilter, 

46 TokenType, 

47) 

48from pikepdf.exceptions import ( 

49 DependencyError, 

50 OutlineStructureError, 

51 UnsupportedImageTypeError, 

52) 

53from pikepdf.objects import ( 

54 Array, 

55 Dictionary, 

56 Name, 

57 Object, 

58 ObjectType, 

59 Operator, 

60 Stream, 

61 String, 

62) 

63from pikepdf.models import ( 

64 Encryption, 

65 Outline, 

66 OutlineItem, 

67 PageLocation, 

68 PdfImage, 

69 PdfInlineImage, 

70 Permissions, 

71 make_page_destination, 

72 parse_content_stream, 

73 unparse_content_stream, 

74) 

75 

76from pikepdf.models.ctm import ( 

77 get_objects_with_ctm, 

78) 

79 

80 

81# Importing these will monkeypatch classes defined in C++ and register a new 

82# pdfdoc codec 

83# While _cpphelpers is intended to be called from our C++ code only, explicitly 

84# importing helps introspection tools like PyInstaller figure out that the module 

85# is necessary. 

86from pikepdf import _cpphelpers, _methods, codec # noqa: F401, F841 

87from pikepdf import settings 

88from pikepdf import exceptions 

89 

90__libqpdf_version__: str = _core.qpdf_version() 

91 

92# Provide pikepdf.{open, new} -> pikepdf.Pdf.{open, new} 

93open = Pdf.open # pylint: disable=redefined-builtin 

94new = Pdf.new 

95 

96# Exclude .open, .new here from to make sure from pikepdf import * does not clobber 

97# builtins.open() 

98# Exclude codec, objects, jbig2 because we import the interesting bits from them 

99# directly to here. 

100_exclude_from__all__ = {'open', 'new', 'codec', 'objects', 'jbig2'} 

101 

102__all__ = [ 

103 '__libqpdf_version__', 

104 '__version__', 

105 'AccessMode', 

106 'AcroForm', 

107 'AcroFormField', 

108 'Annotation', 

109 'AnnotationFlag', 

110 'Array', 

111 'AttachedFileSpec', 

112 'ContentStreamInlineImage', 

113 'ContentStreamInstruction', 

114 'DataDecodingError', 

115 'DeletedObjectError', 

116 'DependencyError', 

117 'Dictionary', 

118 'Encryption', 

119 'exceptions', 

120 'ForeignObjectError', 

121 'FormFieldFlag', 

122 'get_objects_with_ctm', 

123 'HifiPrintImageNotTranscodableError', 

124 'InvalidPdfImageError', 

125 'Job', 

126 'JobUsageError', 

127 'make_page_destination', 

128 'Matrix', 

129 'models', 

130 'Name', 

131 'NameTree', 

132 'NumberTree', 

133 'Object', 

134 'ObjectHelper', 

135 'ObjectStreamMode', 

136 'ObjectType', 

137 'Operator', 

138 'Outline', 

139 'OutlineItem', 

140 'OutlineStructureError', 

141 'Page', 

142 'PageLocation', 

143 'parse_content_stream', 

144 'PasswordError', 

145 'Pdf', 

146 'PdfError', 

147 'PdfImage', 

148 'PdfInlineImage', 

149 'Permissions', 

150 'Rectangle', 

151 'settings', 

152 'Stream', 

153 'StreamDecodeLevel', 

154 'String', 

155 'Token', 

156 'TokenFilter', 

157 'TokenType', 

158 'unparse_content_stream', 

159 'UnsupportedImageTypeError', 

160]