Skip to content

Commit f5a501a

Browse files
authored
Merge branch 'main' into issue-64
2 parents e862aae + 00356c0 commit f5a501a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1441
-271
lines changed

.github/scripts/check_pr_title.py

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
"""Check that all PR titles follow the desired scheme."""
2+
3+
import os
4+
import sys
5+
6+
KNOWN_PREFIXES = (
7+
"SEC: ",
8+
"BUG: ",
9+
"ENH: ",
10+
"DEP: ",
11+
"PI: ",
12+
"ROB: ",
13+
"DOC: ",
14+
"TST: ",
15+
"DEV: ",
16+
"STY: ",
17+
"MAINT: ",
18+
"REL: ",
19+
)
20+
PR_TITLE = os.getenv("PR_TITLE", "")
21+
22+
if (
23+
not PR_TITLE.startswith(KNOWN_PREFIXES)
24+
or not PR_TITLE.split(": ", maxsplit=1)[1]
25+
):
26+
sys.stderr.write(
27+
f"The PR title '{PR_TITLE}' does not follow the projects naming scheme: "
28+
"https://pdfly.readthedocs.io/en/latest/dev/intro.html#commit-messages\n",
29+
)
30+
sys.stderr.write(
31+
"If you do not know which one to choose or if multiple apply, make a best guess. "
32+
"Nobody will complain if it does not quite fit :-)\n",
33+
)
34+
sys.exit(1)
35+
else:
36+
sys.stdout.write(f"PR title '{PR_TITLE}' appears to be valid.\n")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Check for Gitignored Files
2+
3+
on:
4+
push:
5+
branches:
6+
- '**' # Run on all branches
7+
pull_request:
8+
9+
jobs:
10+
check-gitignored-files:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v3
16+
17+
- name: Check for gitignored files in commit
18+
run: |
19+
# List all files in the commit
20+
git diff --name-only --cached > committed_files.txt
21+
22+
# Check if any of the committed files are ignored by .gitignore
23+
git check-ignore -v $(cat committed_files.txt) > ignored_files.txt || true
24+
25+
# Fail if there are any ignored files
26+
if [[ -s ignored_files.txt ]]; then
27+
echo "The following files are gitignored but committed:"
28+
cat ignored_files.txt
29+
exit 1
30+
fi

.github/workflows/github-ci.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
runs-on: ubuntu-20.04
2323
strategy:
2424
matrix:
25-
python-version: ["3.8", "3.9", "3.10", "3.11"]
25+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
2626

2727
steps:
2828
- name: Checkout Code
@@ -73,7 +73,7 @@ jobs:
7373
- name: Test with ruff
7474
run: |
7575
echo `ruff --version`
76-
ruff pdfly/
76+
ruff check pdfly/
7777
7878
package:
7979
name: Build & verify package

.github/workflows/title-check.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: 'PR Title Check'
2+
on:
3+
pull_request:
4+
# check when PR
5+
# * is created,
6+
# * title is edited, and
7+
# * new commits are added (to ensure failing title blocks merging)
8+
types: [opened, reopened, edited, synchronize]
9+
10+
jobs:
11+
title-check:
12+
name: Title check
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout Code
16+
uses: actions/checkout@v4
17+
- name: Check PR title
18+
env:
19+
PR_TITLE: ${{ github.event.pull_request.title }}
20+
run: python .github/scripts/check_pr_title.py

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ venv.bak/
114114
.spyderproject
115115
.spyproject
116116

117+
# IntelliJ
118+
.idea
119+
117120
# Rope project settings
118121
.ropeproject
119122

.pre-commit-config.yaml

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# pre-commit run --all-files
22
repos:
33
- repo: https://github.com/pre-commit/pre-commit-hooks
4-
rev: v4.5.0
4+
rev: v5.0.0
55
hooks:
66
- id: check-ast
77
- id: check-byte-order-marker
@@ -18,34 +18,34 @@ repos:
1818
- id: check-added-large-files
1919
args: ['--maxkb=1000']
2020
- repo: https://github.com/psf/black
21-
rev: 23.12.0
21+
rev: 24.10.0
2222
hooks:
2323
- id: black
2424
args: [--target-version, py36]
2525
- repo: https://github.com/asottile/blacken-docs
26-
rev: 1.16.0
26+
rev: 1.19.1
2727
hooks:
2828
- id: blacken-docs
2929
additional_dependencies: [black==22.1.0]
3030
- repo: https://github.com/astral-sh/ruff-pre-commit
31-
rev: v0.1.8
31+
rev: v0.7.4
3232
hooks:
3333
- id: ruff
3434
args: ['--fix']
3535
exclude: "tests/"
3636
- repo: https://github.com/asottile/pyupgrade
37-
rev: v3.15.0
37+
rev: v3.19.0
3838
hooks:
3939
- id: pyupgrade
4040
args: [--py36-plus]
4141
- repo: https://github.com/pycqa/flake8
42-
rev: 6.1.0
42+
rev: 7.1.1
4343
hooks:
4444
- id: flake8
4545
args: ["--ignore", "E,W,F"]
4646

4747
- repo: https://github.com/pre-commit/mirrors-mypy
48-
rev: 'v1.7.1'
48+
rev: 'v1.13.0'
4949
hooks:
5050
- id: mypy
5151
files: ^pdfly/.*

.readthedocs.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ version: 2
55
build:
66
os: ubuntu-22.04
77
tools:
8-
python: "3.11"
8+
python: "3.12"
99

1010
# Build documentation in the docs/ directory with Sphinx
1111
sphinx:

CHANGELOG.md

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,28 @@
11
# CHANGELOG
22

3+
## Version 0.4.0, 2024-12-08
4+
5+
### New Features (ENH)
6+
- New `booklet` command to adjust offsets and lengths ([PR #77](https://github.com/py-pdf/pdfly/pull/77))
7+
- New `uncompress` command ([PR #75](https://github.com/py-pdf/pdfly/pull/75))
8+
- New `update-offsets` command to adjust offsets and lengths ([PR #15](https://github.com/py-pdf/pdfly/pull/15))
9+
- New `rm` command ([PR #59](https://github.com/py-pdf/pdfly/pull/59))
10+
- `metadata`: now also displaying CreationDate, Creator, Keywords & Subject ([PR #73](https://github.com/py-pdf/pdfly/pull/73))
11+
- Add warning for out-of-bounds page range in pdfly `cat` command ([PR #58](https://github.com/py-pdf/pdfly/pull/58))
12+
13+
### Bug Fixes (BUG)
14+
- `2-up` command, that only showed one page per sheet, on the left side, with blank space on the right ([PR #78](https://github.com/py-pdf/pdfly/pull/78))
15+
16+
[Full Changelog](https://github.com/py-pdf/pdfly/compare/0.3.3...0.4.0)
17+
18+
319
## Version 0.3.3, 2024-04-14
420

521
### Developer Experience (DEV)
622
- Chain workflows
723

8-
[Full Changelog](https://github.com/py-pdf/pdfly/compare/0.3.1...0.3.2)
24+
[Full Changelog](https://github.com/py-pdf/pdfly/compare/0.3.2...0.3.3)
25+
926

1027
## Version 0.3.2, 2024-04-14
1128

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ upload:
1515
clean:
1616
python setup.py clean --all
1717
pyclean .
18-
rm -rf Tests/__pycache__ pypdf/__pycache__ Image9.png htmlcov docs/_build dist dont_commit_merged.pdf dont_commit_writer.pdf pypdf.egg-info pypdf_pdfLocation.txt
18+
rm -rf tests/__pycache__ pdfly/__pycache__ Image9.png htmlcov docs/_build dist dont_commit_merged.pdf dont_commit_writer.pdf pdfly.egg-info
1919

2020
test:
21-
pytest Tests --cov --cov-report term-missing -vv --cov-report html --durations=3 --timeout=30
21+
pytest tests --cov --cov-report term-missing -vv --cov-report html --durations=3 --timeout=30
2222

2323
mutation-test:
2424
mutmut run

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,13 @@ $ pdfly --help
3434
│ 2-up Create a booklet-style PDF from a single input. │
3535
│ cat Concatenate pages from PDF files into a single PDF file. │
3636
│ compress Compress a PDF. │
37+
| uncompress Uncompresses a PDF. │
3738
│ extract-images Extract images from PDF without resampling or altering. │
3839
│ extract-text Extract text from a PDF file. │
3940
│ meta Show metadata of a PDF file │
4041
│ pagemeta Give details about a single page. │
42+
│ rm Remove pages from PDF files. │
43+
│ update-offsets Updates offsets and lengths in a simple PDF file. │
4144
│ x2pdf Convert one or more files to PDF. Each file is a page. │
4245
╰─────────────────────────────────────────────────────────────────────────────╯
4346
```

docs/conf.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
For a full list see the documentation:
66
https://www.sphinx-doc.org/en/master/usage/configuration.html
77
"""
8+
89
# -- Path setup --------------------------------------------------------------
910

1011
# If extensions (or modules to document with autodoc) are in another directory,

docs/dev/intro.md

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Developer Intro
2+
3+
pdfly is an application and thus non-developers
4+
might also use it.
5+
6+
## Installing Requirements
7+
8+
```
9+
pip install -r requirements/dev.txt
10+
```
11+
12+
## Running Tests
13+
14+
See [testing pdfly with pytest](testing.md)
15+
16+
## Tools: git and pre-commit
17+
18+
Git is a command line application for version control. If you don't know it,
19+
you can [play ohmygit](https://ohmygit.org/) to learn it.
20+
21+
GitHub is the service where the pdfly project is hosted. While git is free and
22+
open source, GitHub is a paid service by Microsoft, but free in a lot of
23+
cases.
24+
25+
[pre-commit](https://pypi.org/project/pre-commit/) is a command line application
26+
that uses git hooks to automatically execute code. This allows you to avoid
27+
style issues and other code quality issues. After you entered `pre-commit install`
28+
once in your local copy of pdfly, it will automatically be executed when
29+
you `git commit`.
30+
31+
## Commit Messages
32+
33+
Having a clean commit message helps people to quickly understand what the commit
34+
is about, without actually looking at the changes. The first line of the
35+
commit message is used to [auto-generate the CHANGELOG](https://github.com/py-pdf/pdfly/blob/main/make_release.py).
36+
For this reason, the format should be:
37+
38+
```
39+
PREFIX: DESCRIPTION
40+
41+
BODY
42+
```
43+
44+
The `PREFIX` can be:
45+
46+
* `SEC`: Security improvements. Typically an infinite loop that was possible.
47+
* `BUG`: A bug was fixed. Likely there is one or multiple issues. Then write in
48+
the `BODY`: `Closes #123` where 123 is the issue number on GitHub.
49+
It would be absolutely amazing if you could write a regression test in those
50+
cases. That is a test that would fail without the fix.
51+
A bug is always an issue for pdfly users - test code or CI that was fixed is
52+
not considered a bug here.
53+
* `ENH`: A new feature! Describe in the body what it can be used for.
54+
* `DEP`: A deprecation. Either marking something as "this is going to be removed"
55+
or actually removing it.
56+
* `PI`: A performance improvement. This could also be a reduction in the
57+
file size of PDF files generated by pdfly.
58+
* `ROB`: A robustness change. Dealing better with broken PDF files.
59+
* `DOC`: A documentation change.
60+
* `TST`: Adding or adjusting tests.
61+
* `DEV`: Developer experience improvements, e.g. pre-commit or setting up CI.
62+
* `MAINT`: Quite a lot of different stuff. Performance improvements are for sure
63+
the most interesting changes in here. Refactorings as well.
64+
* `STY`: A style change. Something that makes pdfly code more consistent.
65+
Typically a small change. It could also be better error messages for
66+
end users.
67+
68+
The prefix is used to generate the CHANGELOG. Every PR must have exactly one -
69+
if you feel like several match, take the top one from this list that matches for
70+
your PR.
71+
72+
## Pull Request Size
73+
74+
Smaller Pull Requests (PRs) are preferred as it's typically easier to merge
75+
them. For example, if you have some typos, a few code-style changes, a new
76+
feature, and a bug-fix, that could be 3 or 4 PRs.
77+
78+
A PR must be complete. That means if you introduce a new feature it must be
79+
finished within the PR and have a test for that feature.

docs/dev/testing.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Testing
2+
3+
pdfly uses [`pytest`](https://docs.pytest.org/en/latest/) for testing.
4+
5+
To run the tests you need to install the CI (Continuous Integration) requirements by running `pip install -r requirements/ci.txt`.

docs/index.rst

+8-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@ pdfly is a command line tool to get informaiton about PDF documents and to manip
1919

2020

2121
.. toctree::
22-
:caption: About pypdf
22+
:caption: Developer Guide
23+
:maxdepth: 1
24+
25+
dev/intro
26+
dev/testing
27+
28+
.. toctree::
29+
:caption: About pdfly
2330
:maxdepth: 1
2431

2532
meta/CHANGELOG

docs/user/installation.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ There are several ways to install pdfly. The most common option is to use pip.
77
pdfly requires Python 3.6+ to run.
88

99
Typically Python comes with `pip`, a package installer. Using it you can
10-
install pypdf:
10+
install pdfly:
1111

1212
```bash
1313
pip install pdfly
1414
```
1515

1616
If you are not a super-user (a system administrator / root), you can also just
17-
install pypdf for your current user:
17+
install pdfly for your current user:
1818

1919
```bash
2020
pip install --user pdfly

0 commit comments

Comments
 (0)