diff options
author | Emanuel Haupt <ehaupt@FreeBSD.org> | 2019-05-09 14:14:57 +0000 |
---|---|---|
committer | Emanuel Haupt <ehaupt@FreeBSD.org> | 2019-05-09 14:14:57 +0000 |
commit | 7ac8ff76a2cc098a5e1f686e67bae14d5b35f4bc (patch) | |
tree | b16c2790d6df7aa3100faf1582803e43c77d58c1 /print/pdf-redact-tools | |
parent | f1435d2b6321d13a2d8113806c4cc8fba2db8b4a (diff) | |
download | ports-7ac8ff76a2cc098a5e1f686e67bae14d5b35f4bc.tar.gz ports-7ac8ff76a2cc098a5e1f686e67bae14d5b35f4bc.zip |
- Provide a patch to work with python 3.6
- Pacify portlint
Notes
Notes:
svn path=/head/; revision=501097
Diffstat (limited to 'print/pdf-redact-tools')
-rw-r--r-- | print/pdf-redact-tools/Makefile | 7 | ||||
-rw-r--r-- | print/pdf-redact-tools/files/patch-pdf-redact-tools | 132 |
2 files changed, 136 insertions, 3 deletions
diff --git a/print/pdf-redact-tools/Makefile b/print/pdf-redact-tools/Makefile index a633cf2ab979..1b2cea508b8b 100644 --- a/print/pdf-redact-tools/Makefile +++ b/print/pdf-redact-tools/Makefile @@ -3,9 +3,10 @@ PORTNAME= pdf-redact-tools PORTVERSION= 0.1.2 -PORTREVISION= 1 DISTVERSIONPREFIX= v +PORTREVISION= 2 CATEGORIES= print +PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX} MAINTAINER= ehaupt@FreeBSD.org COMMENT= Securely redact and strip metadata from PDF files @@ -16,9 +17,9 @@ LICENSE_FILE= ${WRKSRC}/LICENSE RUN_DEPENDS= exiftool:graphics/p5-Image-ExifTool \ convert:graphics/ImageMagick6 -USES= python:2.7 +USES= python USE_GITHUB= yes -USE_PYTHON= autoplist distutils +USE_PYTHON= autoplist concurrent distutils NO_ARCH= yes diff --git a/print/pdf-redact-tools/files/patch-pdf-redact-tools b/print/pdf-redact-tools/files/patch-pdf-redact-tools new file mode 100644 index 000000000000..973838eb9374 --- /dev/null +++ b/print/pdf-redact-tools/files/patch-pdf-redact-tools @@ -0,0 +1,132 @@ +--- pdf-redact-tools.orig 2017-06-21 21:42:06 UTC ++++ pdf-redact-tools +@@ -18,6 +18,9 @@ GNU General Public License for more details. + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + """ ++ ++from __future__ import print_function ++ + import sys, os, subprocess, argparse, shutil + + class PDFRedactTools(object): +@@ -39,18 +42,18 @@ class PDFRedactTools(object): + + def explode(self, achromatic = False): + if not self.pdf_filename: +- print 'Error: you must call set_pdf_filename before calling explode' ++ print('Error: you must call set_pdf_filename before calling explode') + return False + + # make dir for pages + if os.path.isdir(self.pages_dirname): +- print 'Error: the directory {} already exists, you must delete it before exploding'.format(self.pages_dirname) ++ print('Error: the directory {} already exists, you must delete it before exploding'.format(self.pages_dirname)) + return False + else: +- os.makedirs(self.pages_dirname, 0700) ++ os.makedirs(self.pages_dirname, 0o700) + + # convert PDF to PNGs +- print 'Converting PDF to PNGs' ++ print('Converting PDF to PNGs') + subprocess.call([ 'convert', + '-density', '128', + self.pdf_filename, +@@ -59,7 +62,7 @@ class PDFRedactTools(object): + self.transparent_filename]) + + # flatten all the PNGs, so they don't have transparent backgrounds +- print 'Flattening PNGs' ++ print('Flattening PNGs') + filenames = os.listdir(self.pages_dirname) + for filename in filenames: + if os.path.splitext(filename)[1].lower() == '.png': +@@ -78,7 +81,7 @@ class PDFRedactTools(object): + + # convert images to achromatic to remove printer dots + if achromatic: +- print 'Converting colors to achromatic' ++ print('Converting colors to achromatic') + filenames = os.listdir(self.pages_dirname) + for filename in filenames: + if os.path.splitext(filename)[1].lower() == '.png': +@@ -114,22 +117,22 @@ class PDFRedactTools(object): + + def merge(self): + if not self.pdf_filename: +- print 'Error: you must call set_pdf_filename before calling merge' ++ print('Error: you must call set_pdf_filename before calling merge') + return False + + # make sure pages directory exists + if not os.path.isdir(self.pages_dirname): +- print "Error: {} is not a directory".format(pages_dirname) ++ print("Error: {} is not a directory".format(pages_dirname)) + return False + + # convert PNGs to PDF +- print "Converting PNGs to PDF" ++ print("Converting PNGs to PDF") + subprocess.call(['convert', + os.path.join(self.pages_dirname, 'page-*.png'), + self.output_filename]) + + # strip metadata +- print "Stripping ImageMagick metadata" ++ print("Stripping ImageMagick metadata") + subprocess.call(['exiftool', '-Title=', '-Producer=', self.output_filename]) + os.remove('{0}_original'.format(self.output_filename)) + +@@ -164,11 +167,12 @@ def parse_arguments(): + args = parser.parse_args() + return args + ++ + def valid_pdf(filename): +- return subprocess.check_output(['file', +- '-b', +- '--mime-type', +- filename]).strip() == 'application/pdf' ++ if sys.version_info.major > 2: ++ return subprocess.check_output(['file', '-b', '--mime-type', filename], encoding='UTF-8').strip() == 'application/pdf' ++ else: ++ return subprocess.check_output(['file', '-b', '--mime-type', filename]).strip() == 'application/pdf' + + + def main(): +@@ -186,18 +190,18 @@ def main(): + if valid_pdf(explode_filename): + pdfrt.set_pdf_filename(explode_filename) + if pdfrt.explode(achromatic): +- print 'All done, now go edit PNGs in {} to redact and then run: pdf-redact-tools -m {}'.format(pdfrt.pages_dirname, pdfrt.pdf_filename) ++ print('All done, now go edit PNGs in {} to redact and then run: pdf-redact-tools -m {}'.format(pdfrt.pages_dirname, pdfrt.pdf_filename)) + else: +- print explode_filename,' does not appear to be a PDF file, will not process' ++ print(explode_filename,' does not appear to be a PDF file, will not process') + + # merge + if merge_filename: + if valid_pdf(merge_filename): + pdfrt.set_pdf_filename(merge_filename) + if pdfrt.merge(): +- print "All done, your final output is {}".format(pdfrt.output_filename) ++ print("All done, your final output is {}".format(pdfrt.output_filename)) + else: +- print merge_filename,' does not appear to be a PDF file, will not process' ++ print(merge_filename,' does not appear to be a PDF file, will not process') + + # sanitize + if sanitize_filename: +@@ -208,9 +212,9 @@ def main(): + # delete temp files + shutil.rmtree(pdfrt.pages_dirname) + +- print "All done, your final output is {}".format(pdfrt.output_filename) ++ print("All done, your final output is {}".format(pdfrt.output_filename)) + else: +- print sanitize_filename,' does not appear to be a PDF file, will not process' ++ print(sanitize_filename,' does not appear to be a PDF file, will not process') + + if __name__ == '__main__': + main() |