Finalize ‘exec’ migration and make it backward compatibility for now

This commit is contained in:
James R. Barlow
2017-01-18 17:40:50 -08:00
parent f246779b8e
commit 6e27ecd2b9
4 changed files with 15 additions and 6 deletions

View File

@@ -1,4 +1,3 @@
import os
import pkg_resources
PROGRAM_NAME = 'ocrmypdf'
@@ -6,5 +5,11 @@ PROGRAM_NAME = 'ocrmypdf'
VERSION = pkg_resources.get_distribution('ocrmypdf').version
def page_number(input_file):
return int(os.path.basename(input_file)[0:6])
# These imports are for v4.x backward compatibility for consumers of ocrmypdf
# (if any). They are deprecated and will be removed in v5.x.
from .exec import ghostscript, qpdf, tesseract, unpaper, get_program
from .exceptions import ExitCode
from .helpers import page_number, is_iterable_notstr

View File

@@ -7,7 +7,7 @@ import re
import shutil
from functools import lru_cache
from ..exceptions import MissingDependencyError
from .. import page_number
from ..helpers import page_number
from . import get_program
from collections import namedtuple
from textwrap import dedent

View File

@@ -49,3 +49,7 @@ def re_symlink(input_file, soft_link_name, log=None):
def is_iterable_notstr(thing):
return isinstance(thing, Iterable) and not isinstance(thing, str)
def page_number(input_file):
return int(os.path.basename(input_file)[0:6])

View File

@@ -24,11 +24,11 @@ from ruffus import formatter, regex, Pipeline, suffix
from .hocrtransform import HocrTransform
from .pageinfo import pdf_get_all_pageinfo
from .pdfa import generate_pdfa_def, file_claims_pdfa
from .helpers import re_symlink, is_iterable_notstr
from .helpers import re_symlink, is_iterable_notstr, page_number
from .exec import ghostscript, tesseract, qpdf
from .exceptions import *
from . import leptonica
from . import page_number, PROGRAM_NAME, VERSION
from . import PROGRAM_NAME, VERSION
VECTOR_PAGE_DPI = 400