Rename pageinfo to pdfinfo

This commit is contained in:
James R. Barlow
2017-05-19 15:48:23 -07:00
parent 532ef38157
commit 08e47117a3
6 changed files with 16 additions and 16 deletions
+2 -2
View File
@@ -129,7 +129,7 @@ def run_ocrmypdf(input_file, output_file, *args, env=None):
@pytest.helpers.register
def first_page_dimensions(pdf):
from ocrmypdf import pageinfo
info = pageinfo.PdfInfo(pdf)
from ocrmypdf import pdfinfo
info = pdfinfo.PdfInfo(pdf)
page0 = info[0]
return (page0['width_inches'], page0['height_inches'])
+1 -1
View File
@@ -5,7 +5,7 @@ from subprocess import Popen, PIPE, check_output, check_call, DEVNULL
import os
import shutil
import pytest
from ocrmypdf.pageinfo import PdfInfo, Colorspace, Encoding
from ocrmypdf.pdfinfo import PdfInfo, Colorspace, Encoding
import PyPDF2 as pypdf
from ocrmypdf.exceptions import ExitCode
from ocrmypdf import leptonica
+8 -8
View File
@@ -1,12 +1,12 @@
#!/usr/bin/env python3
# © 2015 James R. Barlow: github.com/jbarlow83
from ocrmypdf import pageinfo
from ocrmypdf import pdfinfo
from reportlab.pdfgen.canvas import Canvas
from PIL import Image
from tempfile import NamedTemporaryFile
from math import isclose
from ocrmypdf.pageinfo import Colorspace, Encoding
from ocrmypdf.pdfinfo import Colorspace, Encoding
from contextlib import suppress
import os
import shutil
@@ -28,7 +28,7 @@ def test_single_page_text(outdir):
pdf.showPage()
pdf.save()
pdfinfo = pageinfo.PdfInfo(filename)
pdfinfo = pdfinfo.PdfInfo(filename)
assert len(pdfinfo) == 1
page = pdfinfo[0]
@@ -55,7 +55,7 @@ def test_single_page_image(outdir):
layout_fun=layout_fun)
filename.write_bytes(pdf_bytes)
pdfinfo = pageinfo.PdfInfo(filename)
pdfinfo = pdfinfo.PdfInfo(filename)
assert len(pdfinfo) == 1
page = pdfinfo[0]
@@ -85,7 +85,7 @@ def test_single_page_inline_image(outdir):
pdf.showPage()
pdf.save()
pdfinfo = pageinfo.PdfInfo(filename)
pdfinfo = pdfinfo.PdfInfo(filename)
print(pdfinfo)
pdfimage = pdfinfo[0].images[0]
assert isclose(pdfimage.xres, 8)
@@ -96,7 +96,7 @@ def test_single_page_inline_image(outdir):
def test_jpeg(resources, outdir):
filename = resources / 'c02-22.pdf'
pdfinfo = pageinfo.PdfInfo(filename)
pdfinfo = pdfinfo.PdfInfo(filename)
pdfimage = pdfinfo[0].images[0]
assert pdfimage.enc == Encoding.jpeg
@@ -106,7 +106,7 @@ def test_jpeg(resources, outdir):
def test_form_xobject(resources):
filename = resources / 'formxobject.pdf'
pdfinfo = pageinfo.PdfInfo(filename)
pdfinfo = pdfinfo.PdfInfo(filename)
pdfimage = pdfinfo[0].images[0]
assert pdfimage.width == 50
@@ -114,6 +114,6 @@ def test_form_xobject(resources):
def test_no_contents(resources):
filename = resources / 'no_contents.pdf'
pdfinfo = pageinfo.PdfInfo(filename)
pdfinfo = pdfinfo.PdfInfo(filename)
assert len(pdfinfo[0].images) == 0
assert pdfinfo[0].has_text == False
+4 -4
View File
@@ -4,7 +4,7 @@
import pytest
from ocrmypdf.exceptions import ExitCode
from ocrmypdf.exec import tesseract
from ocrmypdf import pageinfo
from ocrmypdf import pdfinfo
import sys
import os
import PyPDF2 as pypdf
@@ -96,9 +96,9 @@ def test_skip_pages_does_not_replicate(
env=ensure_tess4
)
info_in = pageinfo.PdfInfo(infile)
info_in = pdfinfo.PdfInfo(infile)
info = pageinfo.PdfInfo(outpdf)
info = pdfinfo.PdfInfo(outpdf)
for page in info:
assert len(page['images']) == 1, "skipped page was replicated"
@@ -115,6 +115,6 @@ def test_content_preservation(ensure_tess4, resources, outpdf):
env=ensure_tess4
)
info = pageinfo.PdfInfo(outpdf)
info = pdfinfo.PdfInfo(outpdf)
page = info[0]
assert len(page.images) > 1, "masked were rasterized"