summaryrefslogtreecommitdiff
path: root/dev-python/stapler
diff options
context:
space:
mode:
authorV3n3RiX <venerix@koprulu.sector>2022-12-28 20:13:26 +0000
committerV3n3RiX <venerix@koprulu.sector>2022-12-28 20:13:26 +0000
commitd7ef5a07f47da6898dcb2d1503790c59b0470571 (patch)
treed11b9a210e75a7369cb3f644657b94b951109c58 /dev-python/stapler
parentebadb1bcdd3c4fdd2e1a569a04d2cd8c5049b64d (diff)
gentoo auto-resync : 28:12:2022 - 20:13:25
Diffstat (limited to 'dev-python/stapler')
-rw-r--r--dev-python/stapler/Manifest6
-rw-r--r--dev-python/stapler/files/stapler-1.0.0_p20220330-fix-tests-for-PyPDF2-2.x.patch13
-rw-r--r--dev-python/stapler/files/stapler-1.0.0_p20220330-port-to-PyPDF2-3.0.0.patch302
-rw-r--r--dev-python/stapler/files/stapler-1.0.0_p20220330-use-poetry-core-backend-for-PEP517.patch32
-rw-r--r--dev-python/stapler/stapler-1.0.0_p20220330-r1.ebuild (renamed from dev-python/stapler/stapler-1.0.0_p20220330.ebuild)4
-rw-r--r--dev-python/stapler/stapler-1.0.0_p20220330-r2.ebuild29
6 files changed, 383 insertions, 3 deletions
diff --git a/dev-python/stapler/Manifest b/dev-python/stapler/Manifest
index 18bc2b2aa098..68747d923237 100644
--- a/dev-python/stapler/Manifest
+++ b/dev-python/stapler/Manifest
@@ -1,3 +1,7 @@
+AUX stapler-1.0.0_p20220330-fix-tests-for-PyPDF2-2.x.patch 317 BLAKE2B 7000903663d5843388203d4cb4984a93c93cd1524a877df0c1d8a474805b4b85701f903ab813b0afa9ef8b8bef3faae771822b6e28522e17cda014299b933d16 SHA512 c7f35ae69db4eb5d61d63a2a56e15315444696168a080dc81d2839f815d975c2da92cdf36f39e7bd8a38958889b1f588dce38c435fcec7fc5e7cd62e3b25befe
+AUX stapler-1.0.0_p20220330-port-to-PyPDF2-3.0.0.patch 11876 BLAKE2B bcb22eece9e360e32bc6ef40ccdaac176fa6c2b265d962c52b399497f8347291f597a6a3b806fdf315937509d32b68bed79ccc580b2b4eb4789a5b7d4fbba2a6 SHA512 698cdbf12d36549c7e35c636b76e98bffe0f5b826bda8872f6a06a0cdb815bd855a63dc250a4f30aeb459d572db4fd54af81371664fd48cbf35aaf9b3f759061
+AUX stapler-1.0.0_p20220330-use-poetry-core-backend-for-PEP517.patch 1080 BLAKE2B 6342f8cc0931736aa6868749552da18d1c41656815f954826c6e9b2b1be0a18b45f8a8baac95d3e0f364c7c53ec7c6efb888a67b162134a9165f387e6d0c7824 SHA512 26b8d141dd765be117e9df42b78d79f68f1593e09420badb10793df007d031189627d2b3bab36635228a4337bb5b9c199472be41953be3973dd20bdddbffed11
DIST stapler-1.0.0_p20220330.tar.gz 43659 BLAKE2B 10c24868d51086b37dd2d517aa84e3c3fc0b6becc7a29ebf496646bdd65494eb0c43488f725241d7bd7b3083ce5703538db3e05de9976a2e5029731fc2e645d2 SHA512 acd2dfec0dfab46b2cf6b440cba6c0db5399be2ba2194ca12530c311c6c5a8028614164af45b850061e7d22cbec33458ceff7757f1b104c722228dc2d02cae0a
-EBUILD stapler-1.0.0_p20220330.ebuild 772 BLAKE2B 2aa6b23c568e71eefa094778df9b4682b584626c1a123a6e45abde791a712a8a2779e846b6234881b5fba15c6587a183ae53593e0718969b083f3d72f92e315f SHA512 a3ee15f9f513044c3f0aca35e1cd9aa7caee4b3fd8d8c979becfc67a978945e93580dd52e4104670c7042a82f11643a3e63bfe97385260dfc2619089a78a3ad2
+EBUILD stapler-1.0.0_p20220330-r1.ebuild 778 BLAKE2B 85f68550da515ac0c356dabb10758fab37efea3eff6b9c00689d560b60079b38f37a2ea32666a40696039dbbd51d5caf8d4b5266920a2b63c61ec0cdb55735fe SHA512 aad862b317e8179a6700af6eb3e838b2d9b5fcc06b6eaa11373d42329355524106ce262f14ebaf5ebfb1becc1d520acaefe53e8487ebaad2eb40fe4a248eb764
+EBUILD stapler-1.0.0_p20220330-r2.ebuild 861 BLAKE2B 9efdd79049bb7758f55202bf183fa967c680135d5879aabd25d50e535a883945018f788e11aeddd61cbd89501397b7ffa53944ada83321e97baacd29b97e52ce SHA512 fae04dac057c79b38cecdb1004a9495b3a3665f2ffc4a6aee0f5622fa02ed2a7bb4b8b34216c289fdb5458c1bf488ace17a935110f09356d45c6a09122919869
MISC metadata.xml 398 BLAKE2B 3c566702150e77dd0ba58f667336f57c0347422496edeb4fdd53e0f131cb966d15781a5d5b5e13211b2385e410a1d12c064c3ffe66056395b6eeeccdcca1cc72 SHA512 802c118d28a07f7fba6558aaa8f60aef0ebf137395af566e273ba1d218712d1835c74f82c5160f12d120d8776cbaf4fe7d09827a84c1a5e234fef307e0835a18
diff --git a/dev-python/stapler/files/stapler-1.0.0_p20220330-fix-tests-for-PyPDF2-2.x.patch b/dev-python/stapler/files/stapler-1.0.0_p20220330-fix-tests-for-PyPDF2-2.x.patch
new file mode 100644
index 000000000000..125b06a7735a
--- /dev/null
+++ b/dev-python/stapler/files/stapler-1.0.0_p20220330-fix-tests-for-PyPDF2-2.x.patch
@@ -0,0 +1,13 @@
+diff --git a/staplelib/tests.py b/staplelib/tests.py
+index 4d59153..447d48a 100755
+--- a/staplelib/tests.py
++++ b/staplelib/tests.py
+@@ -5,7 +5,7 @@ import shutil
+ import tempfile
+ import unittest
+
+-from PyPDF2.pdf import PdfFileReader
++from PyPDF2 import PdfFileReader
+
+ from staplelib import main, CommandError
+
diff --git a/dev-python/stapler/files/stapler-1.0.0_p20220330-port-to-PyPDF2-3.0.0.patch b/dev-python/stapler/files/stapler-1.0.0_p20220330-port-to-PyPDF2-3.0.0.patch
new file mode 100644
index 000000000000..91eea95ae217
--- /dev/null
+++ b/dev-python/stapler/files/stapler-1.0.0_p20220330-port-to-PyPDF2-3.0.0.patch
@@ -0,0 +1,302 @@
+From 48d6ab21369f1e71dc57890f9bf78fff66c00a90 Mon Sep 17 00:00:00 2001
+From: Ben Kohler <bkohler@gentoo.org>
+Date: Wed, 28 Dec 2022 10:08:30 -0600
+Subject: [PATCH 2/2] Port to PyPDF2-3.0.0
+
+Lots of functions got renamed in the recent PyPDF2-3.0.0 release
+
+Signed-off-by: Ben Kohler <bkohler@gentoo.org>
+---
+ staplelib/commands.py | 46 +++++++++++++++++++++----------------------
+ staplelib/iohelper.py | 12 +++++------
+ staplelib/tests.py | 34 ++++++++++++++++----------------
+ 3 files changed, 46 insertions(+), 46 deletions(-)
+
+diff --git a/staplelib/commands.py b/staplelib/commands.py
+index d37bfa7..caf75f9 100644
+--- a/staplelib/commands.py
++++ b/staplelib/commands.py
+@@ -4,9 +4,9 @@ import math
+ import os
+
+ try:
+- from PyPDF2 import PdfFileWriter, PdfFileReader
++ from PyPDF2 import PdfWriter, PdfReader
+ except:
+- from pyPdf import PdfFileWriter, PdfFileReader
++ from pyPdf import PdfWriter, PdfReader
+
+ from . import CommandError, iohelper
+ import staplelib
+@@ -33,7 +33,7 @@ def select(args, inverse=False):
+ if not filesandranges or not outputfilename:
+ raise CommandError("Both input and output filenames are required.")
+
+- output = PdfFileWriter()
++ output = PdfWriter()
+ try:
+ for input in filesandranges:
+ pdf = input['pdf']
+@@ -44,21 +44,21 @@ def select(args, inverse=False):
+ if not inverse:
+ pagerange = input['pages'] or [
+ (p, iohelper.ROTATION_NONE) for p in
+- range(1, pdf.getNumPages() + 1)]
++ range(1, len(pdf.pages) + 1)]
+ else:
+ excluded = [p for p, r in input['pages']]
+ pagerange = [(p, iohelper.ROTATION_NONE) for p in
+- range(1, pdf.getNumPages() + 1) if
++ range(1, len(pdf.pages) + 1) if
+ p not in excluded]
+
+ for pageno, rotate in pagerange:
+- if 1 <= pageno <= pdf.getNumPages():
++ if 1 <= pageno <= len(pdf.pages):
+ if verbose:
+ print("Using page: {} (rotation: {} deg.)".format(
+ pageno, rotate))
+
+- output.addPage(pdf.getPage(pageno-1)
+- .rotateClockwise(rotate))
++ output.add_page(pdf.pages[pageno-1]
++ .rotate(rotate))
+ else:
+ raise CommandError("Page {} not found in {}.".format(
+ pageno, input['name']))
+@@ -98,14 +98,14 @@ def split(args):
+ base,
+ '_',
+ '%0',
+- str(math.ceil(math.log10(input.getNumPages()))),
++ str(math.ceil(math.log10(len(input.pages)))),
+ 'd',
+ ext
+ ])
+
+- for pageno in range(input.getNumPages()):
+- output = PdfFileWriter()
+- output.addPage(input.getPage(pageno))
++ for pageno in range(len(input.pages)):
++ output = PdfWriter()
++ output.add_page(input.pages[pageno])
+
+ outputname = output_template % (pageno + 1)
+ if verbose:
+@@ -150,17 +150,17 @@ def zip_pdf_pages(filesandranges, verbose):
+ # empty range means "include all pages"
+ pagerange = input['pages'] or [
+ (p, iohelper.ROTATION_NONE) for p in
+- range(1, pdf.getNumPages() + 1)]
++ range(1, len(pdf.pages) + 1)]
+
+ pagestozip = []
+ for pageno, rotate in pagerange:
+- if 1 <= pageno <= pdf.getNumPages():
++ if 1 <= pageno <= len(pdf.pages):
+ if verbose:
+ print("Using page: {} (rotation: {} deg.)".format(
+ pageno, rotate))
+
+- pagestozip.append(pdf.getPage(pageno-1)
+- .rotateClockwise(rotate))
++ pagestozip.append(pdf.pages[pageno-1]
++ .rotate(rotate))
+ else:
+ raise CommandError("Page {} not found in {}.".format(
+ pageno, input['name']))
+@@ -181,7 +181,7 @@ def background(args):
+ try:
+ filestozip = zip_pdf_pages(filesandranges, verbose)
+
+- output = PdfFileWriter()
++ output = PdfWriter()
+ for pageno in range(max(map(len, filestozip))):
+ page = None
+ for listno in range(len(filestozip)):
+@@ -190,8 +190,8 @@ def background(args):
+ if not page:
+ page = p
+ else:
+- page.mergePage(p)
+- output.addPage(page)
++ page.merge_page(p)
++ output.add_page(page)
+
+ except Exception as e:
+ import sys
+@@ -213,11 +213,11 @@ def zip(args):
+ filestozip = zip_pdf_pages(filesandranges, verbose)
+
+ # Interweave pages.
+- output = PdfFileWriter()
++ output = PdfWriter()
+ for pageno in range(max(map(len, filestozip))):
+ for listno in range(len(filestozip)):
+ if pageno < len(filestozip[listno]):
+- output.addPage(filestozip[listno][pageno])
++ output.add_page(filestozip[listno][pageno])
+
+ _write_output(output, outputfilename)
+
+@@ -266,7 +266,7 @@ def pdf_page_enumeration(pdf):
+ pagelabels = pdf.trailer["/Root"]["/PageLabels"]
+ except:
+ # ("No /Root/PageLabels object"), so infer the list.
+- return range(1, pdf.getNumPages() + 1)
++ return range(1, len(pdf.pages) + 1)
+
+ # """Select the item that is most likely to contain the information you desire; e.g.
+ # {'/Nums': [0, IndirectObject(42, 0)]}
+@@ -292,7 +292,7 @@ def pdf_page_enumeration(pdf):
+ style = '/D'
+ prefix = ''
+ next_pageno = 1
+- for i in range(0, pdf.getNumPages()):
++ for i in range(0, len(pdf.pages)):
+ if len(pagelabels_nums_list) > 0 and i >= pagelabels_nums_list[0]:
+ pagelabels_nums_list.pop(0) # discard index
+ pnle = pagelabels_nums_list.pop(0)
+diff --git a/staplelib/iohelper.py b/staplelib/iohelper.py
+index 959e900..8df365c 100644
+--- a/staplelib/iohelper.py
++++ b/staplelib/iohelper.py
+@@ -7,9 +7,9 @@ import re
+ import sys
+
+ try:
+- from PyPDF2 import PdfFileWriter, PdfFileReader
++ from PyPDF2 import PdfWriter, PdfReader
+ except ImportError:
+- from pyPdf import PdfFileWriter, PdfFileReader
++ from pyPdf import PdfWriter, PdfReader
+
+
+ from . import CommandError
+@@ -31,8 +31,8 @@ def read_pdf(filename):
+ """Open a PDF file with PyPDF2."""
+ if not os.path.exists(filename):
+ raise CommandError("{} does not exist".format(filename))
+- pdf = PdfFileReader(open(filename, "rb"))
+- if pdf.isEncrypted:
++ pdf = PdfReader(open(filename, "rb"))
++ if pdf.is_encrypted:
+ while True:
+ pw = prompt_for_pw(filename)
+ matched = pdf.decrypt(pw)
+@@ -46,7 +46,7 @@ def read_pdf(filename):
+ def write_pdf(pdf, filename):
+ force = staplelib.OPTIONS.force
+
+- """Write the content of a PdfFileWriter object to a file."""
++ """Write the content of a PdfWriter object to a file."""
+ if os.path.exists(filename) and not force:
+ raise CommandError("File already exists: {}".format(filename))
+
+@@ -123,7 +123,7 @@ def parse_ranges(handles_files_and_ranges):
+ "page range '{}'".format(handle_key, inputname))
+
+ current = operations[-1]
+- max_page = current['pdf'].getNumPages()
++ max_page = len(current['pdf'].pages)
+ # allow "end" as alias for the last page
+ replace_end = lambda page: (
+ max_page if page.lower() == 'end' else int(page))
+diff --git a/staplelib/tests.py b/staplelib/tests.py
+index 4d59153..3350dfc 100755
+--- a/staplelib/tests.py
++++ b/staplelib/tests.py
+@@ -5,7 +5,7 @@ import shutil
+ import tempfile
+ import unittest
+
+-from PyPDF2 import PdfFileReader
++from PyPDF2 import PdfReader
+
+ from staplelib import main, CommandError
+
+@@ -38,40 +38,40 @@ class TestStapler(unittest.TestCase):
+ self.outputfile])
+ self.assertTrue(os.path.isfile(self.outputfile))
+ with open(self.outputfile, 'rb') as outputfile:
+- pdf = PdfFileReader(outputfile)
+- self.assertEqual(pdf.getNumPages(), 6)
++ pdf = PdfReader(outputfile)
++ self.assertEqual(len(pdf.pages), 6)
+
+ def test_sel_one_page(self):
+ """Test select of a one page from a PDF file."""
+ run_stapler(['sel', 'A=' + FIVEPAGE_PDF, 'A2', self.outputfile])
+ self.assertTrue(os.path.isfile(self.outputfile))
+ with open(self.outputfile, 'rb') as outputfile:
+- pdf = PdfFileReader(outputfile)
+- self.assertEqual(pdf.getNumPages(), 1)
++ pdf = PdfReader(outputfile)
++ self.assertEqual(len(pdf.pages), 1)
+
+ def test_sel_range(self):
+ """Test select of more pages from a PDF file."""
+ run_stapler(['cat', 'A=' + FIVEPAGE_PDF, 'A2-4', self.outputfile])
+ self.assertTrue(os.path.isfile(self.outputfile))
+ with open(self.outputfile, 'rb') as outputfile:
+- pdf = PdfFileReader(outputfile)
+- self.assertEqual(pdf.getNumPages(), 3)
++ pdf = PdfReader(outputfile)
++ self.assertEqual(len(pdf.pages), 3)
+
+ def test_del_one_page(self):
+ """Test del command for inverse select of one page."""
+ run_stapler(['del', 'A=' + FIVEPAGE_PDF, 'A1', self.outputfile])
+ self.assertTrue(os.path.isfile(self.outputfile))
+ with open(self.outputfile, 'rb') as outputfile:
+- pdf = PdfFileReader(outputfile)
+- self.assertEqual(pdf.getNumPages(), 4)
++ pdf = PdfReader(outputfile)
++ self.assertEqual(len(pdf.pages), 4)
+
+ def test_del_range(self):
+ """Test del command for inverse select multiple pages."""
+ run_stapler(['del', 'A=' + FIVEPAGE_PDF, 'A2-4', self.outputfile])
+ self.assertTrue(os.path.isfile(self.outputfile))
+ with open(self.outputfile, 'rb') as outputfile:
+- pdf = PdfFileReader(outputfile)
+- self.assertEqual(pdf.getNumPages(), 2)
++ pdf = PdfReader(outputfile)
++ self.assertEqual(len(pdf.pages), 2)
+
+ def test_split(self):
+ """Make sure a file is properly split into pages."""
+@@ -81,24 +81,24 @@ class TestStapler(unittest.TestCase):
+ self.assertEqual(len(filelist), 5)
+ for f in os.listdir(self.tmpdir):
+ with open(os.path.join(self.tmpdir, f), 'rb') as pdf_file:
+- pdf = PdfFileReader(pdf_file)
+- self.assertEqual(pdf.getNumPages(), 1)
++ pdf = PdfReader(pdf_file)
++ self.assertEqual(len(pdf.pages), 1)
+
+ def test_background(self):
+ """Test background."""
+ run_stapler(['background', ONEPAGE_PDF, FIVEPAGE_PDF, self.outputfile])
+ self.assertTrue(os.path.isfile(self.outputfile))
+ with open(self.outputfile, 'rb') as outputfile:
+- pdf = PdfFileReader(outputfile)
+- self.assertEqual(pdf.getNumPages(), 5)
++ pdf = PdfReader(outputfile)
++ self.assertEqual(len(pdf.pages), 5)
+
+ def test_zip(self):
+ """Test zip."""
+ run_stapler(['zip', ONEPAGE_PDF, FIVEPAGE_PDF, self.outputfile])
+ self.assertTrue(os.path.isfile(self.outputfile))
+ with open(self.outputfile, 'rb') as outputfile:
+- pdf = PdfFileReader(outputfile)
+- self.assertEqual(pdf.getNumPages(), 6)
++ pdf = PdfReader(outputfile)
++ self.assertEqual(len(pdf.pages), 6)
+
+ def test_output_file_already_exists(self):
+ """Test zip."""
+--
+2.39.0
+
diff --git a/dev-python/stapler/files/stapler-1.0.0_p20220330-use-poetry-core-backend-for-PEP517.patch b/dev-python/stapler/files/stapler-1.0.0_p20220330-use-poetry-core-backend-for-PEP517.patch
new file mode 100644
index 000000000000..276df746791f
--- /dev/null
+++ b/dev-python/stapler/files/stapler-1.0.0_p20220330-use-poetry-core-backend-for-PEP517.patch
@@ -0,0 +1,32 @@
+From 3907d86f515ff0e9f042df7111515205e9abaa11 Mon Sep 17 00:00:00 2001
+From: Ben Kohler <bkohler@gentoo.org>
+Date: Thu, 26 May 2022 13:33:38 -0500
+Subject: [PATCH 1/2] pyproject.toml: use poetry-core backend for PEP517
+
+Per poetry upstream, "If your pyproject.toml file still references
+poetry directly as a build backend, you should update it to reference
+poetry-core instead."
+
+https://python-poetry.org/docs/pyproject/#poetry-and-pep-517
+https://projects.gentoo.org/python/guide/distutils.html#deprecated-pep-517-backends
+
+Signed-off-by: Ben Kohler <bkohler@gentoo.org>
+---
+ pyproject.toml | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/pyproject.toml b/pyproject.toml
+index efa98ea..d34823e 100644
+--- a/pyproject.toml
++++ b/pyproject.toml
+@@ -28,5 +28,5 @@ pdf-stapler = 'staplelib:main'
+
+ # this section is for PEP517 compliance. It is technically unnecessary if using Poetry
+ [build-system]
+-requires = ["poetry>=1.0"]
+-build-backend = "poetry.masonry.api"
++requires = ["poetry-core>=1.0.0"]
++build-backend = "poetry.core.masonry.api"
+--
+2.39.0
+
diff --git a/dev-python/stapler/stapler-1.0.0_p20220330.ebuild b/dev-python/stapler/stapler-1.0.0_p20220330-r1.ebuild
index 4f7a695bcf35..ba151de7317e 100644
--- a/dev-python/stapler/stapler-1.0.0_p20220330.ebuild
+++ b/dev-python/stapler/stapler-1.0.0_p20220330-r1.ebuild
@@ -19,8 +19,8 @@ LICENSE="BSD"
SLOT="0"
KEYWORDS="~amd64 ~x86"
-DEPEND="test? ( dev-python/PyPDF2[${PYTHON_USEDEP}] )"
-RDEPEND="dev-python/PyPDF2[${PYTHON_USEDEP}]"
+DEPEND="test? ( <dev-python/PyPDF2-3[${PYTHON_USEDEP}] )"
+RDEPEND="<dev-python/PyPDF2-3[${PYTHON_USEDEP}]"
distutils_enable_tests unittest
diff --git a/dev-python/stapler/stapler-1.0.0_p20220330-r2.ebuild b/dev-python/stapler/stapler-1.0.0_p20220330-r2.ebuild
new file mode 100644
index 000000000000..93ca68b5fcee
--- /dev/null
+++ b/dev-python/stapler/stapler-1.0.0_p20220330-r2.ebuild
@@ -0,0 +1,29 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+PYTHON_COMPAT=( python3_{9..11} )
+DISTUTILS_USE_PEP517=poetry
+
+inherit distutils-r1
+
+COMMIT="382f1edc62296e071093a5419811a2fca9d78d93"
+
+DESCRIPTION="Suite of tools for PDF files manipulation written in Python"
+HOMEPAGE="https://github.com/hellerbarde/stapler"
+SRC_URI="https://github.com/hellerbarde/${PN}/archive/${COMMIT}.tar.gz -> ${P}.tar.gz"
+S="${WORKDIR}/${PN}-${COMMIT}"
+
+LICENSE="BSD"
+SLOT="0"
+KEYWORDS="~amd64 ~x86"
+
+DEPEND="test? ( >=dev-python/PyPDF2-3.0.0[${PYTHON_USEDEP}] )"
+RDEPEND=">=dev-python/PyPDF2-3.0.0[${PYTHON_USEDEP}]"
+
+distutils_enable_tests unittest
+
+PATCHES=( "${FILESDIR}"/${P}-fix-tests-for-PyPDF2-2.x.patch
+ "${FILESDIR}"/${P}-port-to-PyPDF2-3.0.0.patch
+ "${FILESDIR}"/${P}-use-poetry-core-backend-for-PEP517.patch )