Commit c66ee8c
authored
DEP: PEP8-style module, class, and method names (#867)
This commit strives to make the usage for new PyPDF2 users easier by following
PEP8 naming schemes. It's mostly about camelCase method names being converted to
snake_case. Other changes make the public interface of PyPDF2 smaller and thus
easier to discover.
This commit does not introduce any breaking changes as the old modules /
classes / method signatures are still present. They have now deprecation
warnings and the docs show that those are considered deprecated.
If a property and a getter-method are both present, use the property.
Module level changes
--------------------
- utils ➔ _utils: The module is renamed to '_utils' to indicate that it should
not be used by PyPDF2 users. It's only meant for PyPDF2 itself.
- The 'pdf' module was removed. Most classes / functions are now either in
'_utils' or in 'generic'.
Core classes
------------
- PdfFileReader➔ PdfReader (strict=False is new default)
- PdfFileWriter➔ PdfWriter
- PdfFileMerger➔ PdfMerger (strict=False is new default)
PdfReader
---------
- writer.getPage(pageNumber) ➔ writer.pages[page_number]
- writer.getNumPages() ➔ len(writer.pages)
- getPageLayout / pageLayout ➔ page_layout
- getPageMode / pageMode ➔ page_mode
- getIsEncrypted / isEncrypted ➔ is_encrypted
- getDocumentInfo ➔ metadata
PdfWriter
---------
- writer.getPage(pageNumber) ➔ writer.pages[page_number]
- writer.getNumPages() ➔ len(writer.pages)
- getPageLayout / setPageLayout / pageLayout ➔ page_layout
- getPageMode / setPageMode / pageMode ➔ page_mode
Page
----
- mediabox / trimbox / cropbox / bleedbox / artbox:
- getWidth, getHeight ➔ width / height
- getLowerLeft_x / getUpperLeft_x ➔ left
- getUpperRight_x / getLowerRight_x ➔ right
- getLowerLeft_y / getLowerRight_y ➔ bottom
- getUpperRight_y / getUpperLeft_y ➔ top
- getLowerLeft / setLowerLeft ➔ lower_left property
- upperRight ➔ upper_right
- Add Transformation class to make it easy to create transformation matrices
- add_transformation and merge_page should be used instead of:
- mergeTransformedPage
- mergeScaledPage
- mergeRotatedPage
- mergeTranslatedPage
- mergeRotatedTranslatedPage
- mergeRotatedScaledPage
- mergeScaledTranslatedPage
- mergeRotatedScaledTranslatedPage
See the CHANGELOG for a full list of changes1 parent a791ef1 commit c66ee8c
File tree
59 files changed
+3524
-1491
lines changed- .github/ISSUE_TEMPLATE
- PyPDF2
- Scripts
- Tests
- docs
- modules
- user
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
59 files changed
+3524
-1491
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
1 | 129 | | |
2 | 130 | | |
3 | 131 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
| 1 | + | |
3 | 2 | | |
4 | | - | |
5 | | - | |
| 3 | + | |
| 4 | + | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
| 8 | + | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| 14 | + | |
13 | 15 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
18 | 23 | | |
0 commit comments