Sort imports with isort

This commit is contained in:
James R. Barlow
2018-12-30 01:28:15 -08:00
parent 06308a22ce
commit 0880b16491
38 changed files with 176 additions and 172 deletions
+15 -18
View File
@@ -16,40 +16,37 @@
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
from tempfile import mkdtemp
from pathlib import Path
import sys
import argparse
import atexit
import logging
import os
import re
import atexit
import sys
import textwrap
import logging
import argparse
from pathlib import Path
from tempfile import mkdtemp
import PIL
import ruffus.ruffus_exceptions as ruffus_exceptions
import ruffus.cmdline as cmdline
import ruffus.proxy_logger as proxy_logger
import ruffus.ruffus_exceptions as ruffus_exceptions
from . import PROGRAM_NAME, VERSION
from . import exceptions as ocrmypdf_exceptions
from ._jobcontext import JobContext, JobContextManager, cleanup_working_files
from ._pipeline import build_pipeline
from .pdfa import file_claims_pdfa
from .helpers import re_symlink, is_file_writable, available_cpu_count
from .exec import tesseract, qpdf, ghostscript
from . import PROGRAM_NAME, VERSION
from ._unicodefun import verify_python3_env
from .exceptions import (
BadArgsError,
ExitCode,
ExitCodeException,
MissingDependencyError,
InputFileError,
BadArgsError,
MissingDependencyError,
OutputFileAccessError,
)
from . import exceptions as ocrmypdf_exceptions
from ._unicodefun import verify_python3_env
from .exec import ghostscript, qpdf, tesseract
from .helpers import available_cpu_count, is_file_writable, re_symlink
from .pdfa import file_claims_pdfa
# -------------
# External dependencies
+2 -2
View File
@@ -15,10 +15,10 @@
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
import shutil
import sys
from contextlib import suppress
from multiprocessing.managers import SyncManager
import sys
import shutil
from .pdfinfo import PdfInfo
+21 -24
View File
@@ -15,39 +15,36 @@
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
from contextlib import suppress
from shutil import copyfileobj, copyfile
from pathlib import Path
from datetime import datetime, timezone
import sys
import os
import re
import sys
from contextlib import suppress
from datetime import datetime, timezone
from pathlib import Path
from shutil import copyfile, copyfileobj
import img2pdf
import pikepdf
from PIL import Image
from ruffus import formatter, regex, Pipeline, suffix
from ruffus import Pipeline, formatter, regex, suffix
import pikepdf
from pikepdf.models.metadata import encode_pdf_date
from .hocrtransform import HocrTransform
from .pdfinfo import PdfInfo, Colorspace
from .pdfa import generate_pdfa_ps
from .helpers import re_symlink, is_iterable_notstr, page_number, flatten_groups
from .exec import ghostscript, tesseract
from .exceptions import (
UnsupportedImageFormatError,
DpiError,
PriorOcrFoundError,
InputFileError,
EncryptedPdfError,
)
from . import leptonica
from . import PROGRAM_NAME, VERSION
from .optimize import optimize
from . import PROGRAM_NAME, VERSION, leptonica
from ._weave import weave_layers
from .exceptions import (
DpiError,
EncryptedPdfError,
InputFileError,
PriorOcrFoundError,
UnsupportedImageFormatError,
)
from .exec import ghostscript, tesseract
from .helpers import flatten_groups, is_iterable_notstr, page_number, re_symlink
from .hocrtransform import HocrTransform
from .optimize import optimize
from .pdfa import generate_pdfa_ps
from .pdfinfo import Colorspace, PdfInfo
VECTOR_PAGE_DPI = 400
+1 -1
View File
@@ -33,9 +33,9 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import codecs
import os
import sys
import codecs
def verify_python3_env(): # pragma: no cover
+2 -2
View File
@@ -15,13 +15,13 @@
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
from pathlib import Path
from itertools import groupby
from pathlib import Path
import pikepdf
from .helpers import flatten_groups, page_number
from .exec import tesseract
from .helpers import flatten_groups, page_number
def _update_page_resources(*, page, font, font_key, procset):
+7 -5
View File
@@ -15,15 +15,17 @@
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
from tempfile import NamedTemporaryFile
from subprocess import run, PIPE, STDOUT
from shutil import copy
from functools import lru_cache
import re
from functools import lru_cache
from os import fspath
from shutil import copy
from subprocess import PIPE, STDOUT, run
from tempfile import NamedTemporaryFile
from PIL import Image
from . import get_version
from ..exceptions import SubprocessOutputError
from os import fspath
@lru_cache(maxsize=1)
+1 -1
View File
@@ -15,8 +15,8 @@
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
from subprocess import run, PIPE
from functools import lru_cache
from subprocess import PIPE, run
from . import get_version
from ..exceptions import MissingDependencyError
+1 -1
View File
@@ -15,8 +15,8 @@
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
from subprocess import run
from functools import lru_cache
from subprocess import run
from . import get_version
from ..exceptions import MissingDependencyError
+2 -2
View File
@@ -15,11 +15,11 @@
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
from subprocess import CalledProcessError, STDOUT, PIPE, run
from functools import lru_cache
from os import fspath
from subprocess import PIPE, STDOUT, CalledProcessError, run
from . import get_version
from os import fspath
@lru_cache(maxsize=1)
+8 -8
View File
@@ -15,26 +15,26 @@
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
import sys
import os
import shutil
from functools import lru_cache
import sys
from collections import namedtuple
from textwrap import dedent
from contextlib import suppress
from functools import lru_cache
from os import fspath
from subprocess import (
PIPE,
STDOUT,
CalledProcessError,
TimeoutExpired,
check_output,
STDOUT,
run,
PIPE,
)
from contextlib import suppress
from os import fspath
from textwrap import dedent
from . import get_version
from ..exceptions import MissingDependencyError, TesseractConfigError
from ..helpers import page_number
from . import get_version
OrientationConfidence = namedtuple('OrientationConfidence', ('angle', 'confidence'))
+5 -5
View File
@@ -18,14 +18,14 @@
# unpaper documentation:
# https://github.com/Flameeyes/unpaper/blob/master/doc/basic-concepts.md
from subprocess import CalledProcessError, STDOUT, check_output
from tempfile import NamedTemporaryFile
import sys
import os
import sys
from functools import lru_cache
from ..exceptions import MissingDependencyError
from . import get_version
from subprocess import STDOUT, CalledProcessError, check_output
from tempfile import NamedTemporaryFile
from . import get_version
from ..exceptions import MissingDependencyError
try:
from PIL import Image
+5 -5
View File
@@ -15,14 +15,14 @@
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
from functools import partial, wraps
import multiprocessing
import os
import sys
import warnings
from collections.abc import Iterable
from contextlib import suppress
from functools import partial, wraps
from pathlib import Path
import sys
import os
import multiprocessing
import warnings
def re_symlink(input_file, soft_link_name, log=None):
+6 -6
View File
@@ -28,14 +28,14 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from reportlab.pdfgen.canvas import Canvas
from reportlab.lib.units import inch
from xml.etree import ElementTree
from collections import namedtuple
from math import atan, sin, cos
import re
import argparse
import re
from collections import namedtuple
from math import atan, cos, sin
from xml.etree import ElementTree
from reportlab.lib.units import inch
from reportlab.pdfgen.canvas import Canvas
Rect = namedtuple('Rect', ['x1', 'y1', 'x2', 'y2'])
+7 -7
View File
@@ -20,20 +20,20 @@
#
# Python FFI wrapper for Leptonica library
from collections.abc import Sequence
from contextlib import suppress
from ctypes.util import find_library
from functools import lru_cache
from io import BytesIO
from tempfile import TemporaryFile
import argparse
import logging
import os
import sys
import warnings
from collections.abc import Sequence
from contextlib import suppress
from ctypes.util import find_library
from functools import lru_cache
from io import BytesIO
from os import fspath
from tempfile import TemporaryFile
from .lib._leptonica import ffi
from os import fspath
# pylint: disable=protected-access
+4 -4
View File
@@ -15,21 +15,21 @@
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see <http://www.gnu.org/licenses/>.
from pathlib import Path
import concurrent.futures
from collections import defaultdict
import logging
import sys
from collections import defaultdict
from os import fspath
from pathlib import Path
from PIL import Image
import pikepdf
from ._jobcontext import JobContext
from . import leptonica
from ._jobcontext import JobContext
from .exec import jbig2enc, pngquant
from .helpers import re_symlink
from .exec import pngquant, jbig2enc
DEFAULT_JPEG_QUALITY = 75
DEFAULT_PNG_QUALITY = 70
+4 -7
View File
@@ -31,22 +31,19 @@ Ghostscript's handling of pdfmark.
"""
import os
from binascii import hexlify
from pathlib import Path
from string import Template
import pkg_resources
import os
import pikepdf
from pikepdf.models.metadata import (
encode_pdf_date as _encode_date,
decode_pdf_date as _decode_date,
)
from pikepdf.models.metadata import decode_pdf_date as _decode_date
from pikepdf.models.metadata import encode_pdf_date as _encode_date
from .helpers import deprecated
ICC_PROFILE_RELPATH = 'data/sRGB.icc'
SRGB_ICC_PROFILE = pkg_resources.resource_filename('ocrmypdf', ICC_PROFILE_RELPATH)
+1 -1
View File
@@ -38,9 +38,9 @@ from pdfminer.pdfdocument import PDFTextExtractionNotAllowed
from pdfminer.pdffont import (
PDFCIDFont,
PDFFont,
PDFSimpleFont,
PDFType3Font,
PDFUnicodeNotDefined,
PDFSimpleFont,
)
from pdfminer.pdfpage import PDFPage
from pdfminer.utils import bbox2str, fsplit, matrix2str