File tree 8 files changed +51
-18
lines changed
8 files changed +51
-18
lines changed Original file line number Diff line number Diff line change 1
1
#
2
- # This file is autogenerated by pip-compile with python 3.11
3
- # To update, run :
2
+ # This file is autogenerated by pip-compile with Python 3.11
3
+ # by the following command :
4
4
#
5
5
# pip-compile .github/workflows/ci.in
6
6
#
7
- pydantic==1.10.4
8
- # via -r .github/workflows/ci.in
9
- pypdf==3.3 .0
7
+ annotated-types==0.6.0
8
+ # via pydantic
9
+ pydantic==2.5 .0
10
10
# via -r .github/workflows/ci.in
11
- typing-extensions==4.4.0
11
+ pydantic-core==2.14.1
12
12
# via pydantic
13
+ pypdf==3.17.0
14
+ # via -r .github/workflows/ci.in
15
+ typing-extensions==4.8.0
16
+ # via
17
+ # pydantic
18
+ # pydantic-core
Original file line number Diff line number Diff line change 1
1
import datetime
2
2
import json
3
+ import logging
3
4
import sys
4
5
from pathlib import Path
5
6
6
7
from pydantic import BaseModel , NonNegativeInt
7
8
8
9
from pypdf import PdfReader
9
10
11
+ logger = logging .getLogger ()
12
+
13
+ logger .level = logging .ERROR
14
+
10
15
11
16
class AnnotationCount (BaseModel ):
12
- Highlight : int | None
13
- Ink : int | None
14
- Link : int | None
15
- Text : int | None
16
- Widget : int | None
17
+ Highlight : int | None = None
18
+ Ink : int | None = None
19
+ Link : int | None = None
20
+ Text : int | None = None
21
+ Widget : int | None = None
17
22
18
23
def items (self ) -> list [tuple [str , int ]]:
19
24
return [
@@ -47,7 +52,7 @@ def main() -> None:
47
52
"""Check the consistency of the JSON metadata file."""
48
53
with open ("files.json" ) as f :
49
54
data = json .load (f )
50
- main_pdf = MainPdfFile .parse_obj (data )
55
+ main_pdf = MainPdfFile .model_validate (data )
51
56
registered_pdfs = []
52
57
53
58
seen_failure = False
Original file line number Diff line number Diff line change 1
1
# pre-commit run --all-files
2
2
repos :
3
3
- repo : https://github.com/pre-commit/pre-commit-hooks
4
- rev : v4.1 .0
4
+ rev : v4.5 .0
5
5
hooks :
6
6
- id : check-ast
7
7
- id : check-case-conflict
@@ -20,21 +20,21 @@ repos:
20
20
hooks :
21
21
- id : isort
22
22
- repo : https://github.com/psf/black
23
- rev : 22.1 .0
23
+ rev : 22.3 .0
24
24
hooks :
25
25
- id : black
26
26
- repo : https://github.com/asottile/pyupgrade
27
- rev : v2.31.1
27
+ rev : v3.15.0
28
28
hooks :
29
29
- id : pyupgrade
30
30
args : [--py39-plus]
31
31
- repo : https://github.com/asottile/blacken-docs
32
- rev : v1.12.1
32
+ rev : 1.16.0
33
33
hooks :
34
34
- id : blacken-docs
35
35
additional_dependencies : [black==22.1.0]
36
36
- repo : https://github.com/charliermarsh/ruff-pre-commit
37
- rev : ' v0.0.280 '
37
+ rev : ' v0.1.5 '
38
38
hooks :
39
39
- id : ruff
40
40
args : ['--fix']
Original file line number Diff line number Diff line change
1
+ from pypdf import PdfReader , PdfWriter
2
+
3
+ reader = PdfReader ("../001-trivial/minimal-document.pdf" )
4
+ writer = PdfWriter ()
5
+ writer .append_pages_from_reader (reader )
6
+
7
+ with open ("image.png" , "rb" ) as file :
8
+ writer .add_attachment ("image.png" , file .read ())
9
+ with open ("with-attachment.pdf" , "wb" ) as file :
10
+ writer .write (file )
Original file line number Diff line number Diff line change
1
+ maint :
2
+ pip-compile .github/workflows/ci.in --upgrade
Original file line number Diff line number Diff line change 317
317
"Highlight" : 1 ,
318
318
"Ink" : 1
319
319
}
320
+ },
321
+ {
322
+ "path" : " 025-attachment/with-attachment.pdf" ,
323
+ "producer" : " pypdf" ,
324
+ "creation_date" : null ,
325
+ "encrypted" : false ,
326
+ "pages" : 1 ,
327
+ "images" : 1 ,
328
+ "forms" : 0 ,
329
+ "annotations" : {}
320
330
}
321
331
]
322
- }
332
+ }
You can’t perform that action at this time.
0 commit comments