Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix code related to import statements with isort #1178

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dev/analyze_profile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pstats

p = pstats.Stats('profile')
p.strip_dirs()
p.sort_stats('tottime')
Expand Down
3 changes: 2 additions & 1 deletion dev/groupid_to_structmap.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env python

from sys import argv
from os.path import isfile
from sys import argv

from ocrd.model import OcrdMets

fname = argv[1]
Expand Down
10 changes: 5 additions & 5 deletions src/ocrd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

"""

from ocrd.processor.base import run_processor, run_cli, Processor
from ocrd_models import OcrdMets, OcrdExif, OcrdFile, OcrdAgent
from ocrd.mets_server import OcrdMetsServer
from ocrd.processor.base import Processor, run_cli, run_processor
from ocrd.resolver import Resolver
from ocrd_validators import *
from ocrd.resource_manager import OcrdResourceManager
from ocrd.workspace import Workspace
from ocrd.workspace_backup import WorkspaceBackupManager
from ocrd.resource_manager import OcrdResourceManager
from ocrd.mets_server import OcrdMetsServer
from ocrd_models import OcrdAgent, OcrdExif, OcrdFile, OcrdMets
from ocrd_validators import *
10 changes: 6 additions & 4 deletions src/ocrd/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
:nested: short
"""
import re

import click

from ocrd_utils import config
Expand Down Expand Up @@ -68,16 +69,17 @@ def get_help(self, ctx):

return CommandWithReplacedHelp

from ocrd.cli.bashlib import bashlib_cli
from ocrd.cli.ocrd_tool import ocrd_tool_cli
from ocrd.cli.workspace import workspace_cli
from ocrd.cli.process import process_cli
from ocrd.cli.bashlib import bashlib_cli
from ocrd.cli.validate import validate_cli
from ocrd.cli.resmgr import resmgr_cli
from ocrd.cli.validate import validate_cli
from ocrd.cli.workspace import workspace_cli
from ocrd.decorators import ocrd_loglevel
from .zip import zip_cli

from .log import log_cli
from .network import network_cli
from .zip import zip_cli


@click.group(epilog=_epilog)
Expand Down
25 changes: 10 additions & 15 deletions src/ocrd/cli/bashlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,24 @@

"""
from __future__ import print_function

import sys
from os.path import isfile

import click

from ocrd.constants import BASHLIB_FILENAME
import ocrd.constants
import ocrd_utils.constants
from ocrd_utils.constants import DEFAULT_METS_BASENAME
import ocrd_models.constants
import ocrd_utils.constants
import ocrd_validators.constants
from ocrd.decorators import (
parameter_option,
parameter_override_option,
ocrd_loglevel
)
from ocrd_utils import (
is_local_filename,
get_local_filename,
initLogging,
make_file_id
)
from ocrd.resolver import Resolver
from ocrd.constants import BASHLIB_FILENAME
from ocrd.decorators import (ocrd_loglevel, parameter_option,
parameter_override_option)
from ocrd.processor import Processor
from ocrd.resolver import Resolver
from ocrd_utils import (get_local_filename, initLogging, is_local_filename,
make_file_id)
from ocrd_utils.constants import DEFAULT_METS_BASENAME

# ----------------------------------------------------------------------
# ocrd bashlib
Expand Down
7 changes: 5 additions & 2 deletions src/ocrd/cli/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
:prog: ocrd log
:nested: full
"""
import click
from ocrd_utils import initLogging, getLogger, getLevelName
import logging

import click

from ocrd_utils import getLevelName, getLogger, initLogging


class LogCtx():

def __init__(self, name):
Expand Down
12 changes: 5 additions & 7 deletions src/ocrd/cli/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@
:nested: full
"""

import click
import logging

import click

from ocrd_network.cli import (client_cli, processing_server_cli,
processing_worker_cli, processor_server_cli)
from ocrd_utils import initLogging
from ocrd_network.cli import (
client_cli,
processing_server_cli,
processing_worker_cli,
processor_server_cli,
)


@click.group("network")
Expand Down
18 changes: 9 additions & 9 deletions src/ocrd/cli/ocrd_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@
:nested: full

"""
from inspect import getmodule
from json import dumps
import codecs
import sys
import os
import sys
from inspect import getmodule
from json import dumps

import click

from ocrd.decorators import parameter_option, parameter_override_option
from ocrd.processor import Processor
from ocrd_utils import (
set_json_key_value_overrides,
VERSION as OCRD_VERSION,
parse_json_string_with_comments as loads
)
from ocrd_validators import ParameterValidator, OcrdToolValidator
from ocrd_utils import VERSION as OCRD_VERSION
from ocrd_utils import parse_json_string_with_comments as loads
from ocrd_utils import set_json_key_value_overrides
from ocrd_validators import OcrdToolValidator, ParameterValidator


class OcrdToolCtx():

Expand Down
3 changes: 2 additions & 1 deletion src/ocrd/cli/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
"""
import click

from ocrd_utils import getLogger, initLogging, DEFAULT_METS_BASENAME
from ocrd.task_sequence import run_tasks
from ocrd_utils import DEFAULT_METS_BASENAME, getLogger, initLogging

from ..decorators import ocrd_loglevel


# ----------------------------------------------------------------------
# ocrd process
# ----------------------------------------------------------------------
Expand Down
17 changes: 6 additions & 11 deletions src/ocrd/cli/resmgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,20 @@
:nested: full
"""
import sys
from pathlib import Path
from distutils.spawn import find_executable as which
from yaml import safe_load, safe_dump
from pathlib import Path

import requests
import click
import requests
from yaml import safe_dump, safe_load

from ocrd_utils import (
initLogging,
directory_size,
getLogger,
get_ocrd_tool_json,
get_moduledir,
RESOURCE_LOCATIONS,
)
from ocrd.constants import RESOURCE_USER_LIST_COMMENT
from ocrd_utils import (RESOURCE_LOCATIONS, directory_size, get_moduledir,
get_ocrd_tool_json, getLogger, initLogging)

from ..resource_manager import OcrdResourceManager


def print_resources(executable, reslist, resmgr):
print('%s' % executable)
for resdict in reslist:
Expand Down
17 changes: 7 additions & 10 deletions src/ocrd/cli/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,20 @@
:prog: ocrd validate
:nested: full
"""
import codecs
import sys
from json import loads

import click
from json import loads
import codecs

from ocrd import Resolver, Workspace
from ocrd.task_sequence import ProcessorTask, validate_tasks
from ocrd_utils import (DEFAULT_METS_BASENAME, initLogging,
parse_json_string_or_file)
from ocrd_validators import (OcrdToolValidator, OcrdZipValidator,
PageValidator, ParameterValidator,
WorkspaceValidator)

from ocrd_utils import initLogging, parse_json_string_or_file, DEFAULT_METS_BASENAME
from ocrd_validators import (
OcrdToolValidator,
OcrdZipValidator,
PageValidator,
ParameterValidator,
WorkspaceValidator,
)

def _inform_of_result(report):
if not report.is_valid:
Expand Down
24 changes: 14 additions & 10 deletions src/ocrd/cli/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,26 @@
:nested: full
"""
import os
from os import getcwd
from os.path import relpath, exists, join, isabs
from pathlib import Path
from json import loads, dumps
import sys
from glob import glob # XXX pathlib.Path.glob does not support absolute globs
import re
import sys
import time
import numpy as np
from glob import glob # XXX pathlib.Path.glob does not support absolute globs
from json import dumps, loads
from os import getcwd
from os.path import exists, isabs, join, relpath
from pathlib import Path

import click
import numpy as np

from ocrd import Resolver, Workspace, WorkspaceValidator, WorkspaceBackupManager
from ocrd.mets_server import OcrdMetsServer
from ocrd_utils import getLogger, initLogging, pushd_popd, EXT_TO_MIME, safe_filename, parse_json_string_or_file, partition_list, DEFAULT_METS_BASENAME
from ocrd import (Resolver, Workspace, WorkspaceBackupManager,
WorkspaceValidator)
from ocrd.decorators import mets_find_options
from ocrd.mets_server import OcrdMetsServer
from ocrd_utils import (DEFAULT_METS_BASENAME, EXT_TO_MIME, getLogger,
initLogging, parse_json_string_or_file, partition_list,
pushd_popd, safe_filename)

from . import command_with_replaced_help


Expand Down
3 changes: 2 additions & 1 deletion src/ocrd/cli/zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@

import click

from ocrd_utils import initLogging, DEFAULT_METS_BASENAME
from ocrd_utils import DEFAULT_METS_BASENAME, initLogging
from ocrd_validators import OcrdZipValidator

from ..resolver import Resolver
from ..workspace import Workspace
from ..workspace_bagger import WorkspaceBagger


@click.group("zip")
def zip_cli():
"""
Expand Down
26 changes: 10 additions & 16 deletions src/ocrd/decorators/__init__.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
import sys

from ocrd_utils import (
config,
initLogging,
is_local_filename,
get_local_filename,
getLogger,
parse_json_string_with_comments,
set_json_key_value_overrides,
)
from ocrd_network import (NETWORK_AGENT_SERVER, NETWORK_AGENT_WORKER,
ProcessingWorker, ProcessorServer)
from ocrd_utils import (config, get_local_filename, getLogger, initLogging,
is_local_filename, parse_json_string_with_comments,
set_json_key_value_overrides)
from ocrd_validators import WorkspaceValidator
from ocrd_network import ProcessingWorker, ProcessorServer, NETWORK_AGENT_SERVER, NETWORK_AGENT_WORKER

from ..resolver import Resolver
from ..processor.base import run_processor

from ..resolver import Resolver
from .loglevel_option import ocrd_loglevel
from .parameter_option import parameter_option, parameter_override_option
from .ocrd_cli_options import ocrd_cli_options
from .mets_find_options import mets_find_options
from .ocrd_cli_options import ocrd_cli_options
from .parameter_option import parameter_option, parameter_override_option

SUBCOMMANDS = [NETWORK_AGENT_WORKER, NETWORK_AGENT_SERVER]

Expand Down Expand Up @@ -113,10 +107,10 @@ def ocrd_cli_wrap_processor(
if not profile_file and config.is_set('OCRD_PROFILE_FILE'):
profile_file = config.OCRD_PROFILE_FILE
if profile or profile_file:
import atexit
import cProfile
import pstats
import io
import atexit
import pstats
print("Profiling...")
pr = cProfile.Profile()
pr.enable()
Expand Down
1 change: 1 addition & 0 deletions src/ocrd/decorators/loglevel_option.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import click

from ocrd_utils.logging import setOverrideLogLevel

__all__ = ['ocrd_loglevel']
Expand Down
1 change: 1 addition & 0 deletions src/ocrd/decorators/mets_find_options.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from click import option


def mets_find_options(f):
for opt in [
option('-G', '--file-grp', help="fileGrp USE", metavar='FILTER'),
Expand Down
15 changes: 7 additions & 8 deletions src/ocrd/decorators/ocrd_cli_options.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import click
from click import option, Path, group, command, argument
from click import Path, argument, command, group, option

from ocrd_network import (NETWORK_AGENT_SERVER, NETWORK_AGENT_WORKER,
DatabaseParamType, QueueServerParamType,
ServerAddressParamType)
from ocrd_utils import DEFAULT_METS_BASENAME
from ocrd_network import NETWORK_AGENT_SERVER, NETWORK_AGENT_WORKER
from .parameter_option import parameter_option, parameter_override_option

from .loglevel_option import loglevel_option
from ocrd_network import (
DatabaseParamType,
ServerAddressParamType,
QueueServerParamType
)
from .parameter_option import parameter_option, parameter_override_option


def ocrd_cli_options(f):
Expand Down
1 change: 1 addition & 0 deletions src/ocrd/decorators/parameter_option.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from click import option

from ocrd_utils import parse_json_string_or_file

__all__ = ['parameter_option', 'parameter_override_option']
Expand Down
Loading
Loading