From e382683f667482f8ce2d951dbce021e0c9baa995 Mon Sep 17 00:00:00 2001 From: Andrew Senetar Date: Mon, 9 May 2022 01:40:08 -0500 Subject: [PATCH] Replace all relative imports --- core/app.py | 28 +++++++-------- core/directories.py | 2 +- core/exclude.py | 2 +- core/gui/details_panel.py | 2 +- core/gui/directory_tree.py | 4 +-- core/gui/exclude_list_dialog.py | 2 +- core/gui/exclude_list_table.py | 2 +- core/gui/ignore_list_dialog.py | 2 +- core/gui/problem_dialog.py | 2 +- core/gui/result_table.py | 2 +- core/gui/stats_label.py | 2 +- core/me/__init__.py | 2 +- core/pe/__init__.py | 3 +- core/pe/block.py | 2 +- core/pe/cache.py | 2 +- core/pe/cache_shelve.py | 2 +- core/pe/cache_sqlite.py | 2 +- core/pe/matchblock.py | 6 ++-- core/pe/photo.py | 2 +- core/pe/scanner.py | 2 +- core/results.py | 4 +-- core/scanner.py | 2 +- core/se/__init__.py | 2 +- core/tests/app_test.py | 8 ++--- core/tests/base.py | 11 +++--- core/tests/block_test.py | 2 +- core/tests/cache_test.py | 6 ++-- core/tests/directories_test.py | 6 ++-- core/tests/engine_test.py | 6 ++-- core/tests/exclude_test.py | 4 +-- core/tests/fs_test.py | 2 +- core/tests/ignore_test.py | 2 +- core/tests/markable_test.py | 2 +- core/tests/prioritize_test.py | 4 +-- core/tests/result_table_test.py | 2 +- core/tests/results_test.py | 7 ++-- core/tests/scanner_test.py | 10 +++--- hscommon/build.py | 2 +- hscommon/gui/column.py | 2 +- hscommon/gui/progress_window.py | 6 ++-- hscommon/gui/selectable_list.py | 2 +- hscommon/gui/table.py | 4 +-- hscommon/gui/text_field.py | 4 +-- hscommon/gui/tree.py | 2 +- hscommon/jobprogress/performer.py | 2 +- hscommon/loc.py | 13 +------ hscommon/sphinxgen.py | 2 +- hscommon/tests/conflict_test.py | 4 +-- hscommon/tests/notify_test.py | 4 +-- hscommon/tests/path_test.py | 2 +- hscommon/tests/selectable_list_test.py | 4 +-- hscommon/tests/sqlite_test.py | 4 +-- hscommon/tests/table_test.py | 4 +-- hscommon/tests/tree_test.py | 4 +-- hscommon/tests/util_test.py | 4 +-- hscommon/testutil.py | 47 -------------------------- hscommon/trans.py | 2 +- hscommon/util.py | 2 +- qt/app.py | 32 +++++++++--------- qt/details_dialog.py | 2 +- qt/directories_dialog.py | 4 +-- qt/exclude_list_dialog.py | 2 +- qt/ignore_list_dialog.py | 2 +- qt/me/details_dialog.py | 4 +-- qt/me/preferences_dialog.py | 2 +- qt/me/results_model.py | 2 +- qt/pe/block.py | 2 +- qt/pe/details_dialog.py | 6 ++-- qt/pe/photo.py | 2 +- qt/pe/preferences_dialog.py | 2 +- qt/pe/results_model.py | 2 +- qt/preferences_dialog.py | 2 +- qt/problem_dialog.py | 2 +- qt/result_window.py | 12 +++---- qt/se/details_dialog.py | 4 +-- qt/se/preferences_dialog.py | 2 +- qt/se/results_model.py | 2 +- qt/tabbed_window.py | 8 ++--- qt/table.py | 2 +- 79 files changed, 155 insertions(+), 216 deletions(-) diff --git a/core/app.py b/core/app.py index bc2ff4e9..656b5413 100644 --- a/core/app.py +++ b/core/app.py @@ -23,20 +23,20 @@ from hscommon.util import delete_if_empty, first, escape, nonone, allsame from hscommon.trans import tr from hscommon import desktop -from . import se, me, pe -from .pe.photo import get_delta_dimensions -from .util import cmp_value, fix_surrogate_encoding -from . import directories, results, export, fs, prioritize -from .ignore import IgnoreList -from .exclude import ExcludeDict as ExcludeList -from .scanner import ScanType -from .gui.deletion_options import DeletionOptions -from .gui.details_panel import DetailsPanel -from .gui.directory_tree import DirectoryTree -from .gui.ignore_list_dialog import IgnoreListDialog -from .gui.exclude_list_dialog import ExcludeListDialogCore -from .gui.problem_dialog import ProblemDialog -from .gui.stats_label import StatsLabel +from core import se, me, pe +from core.pe.photo import get_delta_dimensions +from core.util import cmp_value, fix_surrogate_encoding +from core import directories, results, export, fs, prioritize +from core.ignore import IgnoreList +from core.exclude import ExcludeDict as ExcludeList +from core.scanner import ScanType +from core.gui.deletion_options import DeletionOptions +from core.gui.details_panel import DetailsPanel +from core.gui.directory_tree import DirectoryTree +from core.gui.ignore_list_dialog import IgnoreListDialog +from core.gui.exclude_list_dialog import ExcludeListDialogCore +from core.gui.problem_dialog import ProblemDialog +from core.gui.stats_label import StatsLabel HAD_FIRST_LAUNCH_PREFERENCE = "HadFirstLaunch" DEBUG_MODE_PREFERENCE = "DebugMode" diff --git a/core/directories.py b/core/directories.py index 5cfcf239..3dbf58e0 100644 --- a/core/directories.py +++ b/core/directories.py @@ -13,7 +13,7 @@ from hscommon.jobprogress import job from hscommon.util import FileOrPath from hscommon.trans import tr -from . import fs +from core import fs __all__ = [ "Directories", diff --git a/core/exclude.py b/core/exclude.py index 2482bd7d..e304ef12 100644 --- a/core/exclude.py +++ b/core/exclude.py @@ -2,7 +2,7 @@ # which should be included with this package. The terms are also available at # http://www.gnu.org/licenses/gpl-3.0.html -from .markable import Markable +from core.markable import Markable from xml.etree import ElementTree as ET # TODO: perhaps use regex module for better Unicode support? https://pypi.org/project/regex/ diff --git a/core/gui/details_panel.py b/core/gui/details_panel.py index 9d3923ec..f6a4e820 100644 --- a/core/gui/details_panel.py +++ b/core/gui/details_panel.py @@ -7,7 +7,7 @@ # http://www.gnu.org/licenses/gpl-3.0.html from hscommon.gui.base import GUIObject -from .base import DupeGuruGUIObject +from core.gui.base import DupeGuruGUIObject class DetailsPanel(GUIObject, DupeGuruGUIObject): diff --git a/core/gui/directory_tree.py b/core/gui/directory_tree.py index 1c961c57..e44da9f0 100644 --- a/core/gui/directory_tree.py +++ b/core/gui/directory_tree.py @@ -8,8 +8,8 @@ from hscommon.gui.tree import Tree, Node -from ..directories import DirectoryState -from .base import DupeGuruGUIObject +from core.directories import DirectoryState +from core.gui.base import DupeGuruGUIObject STATE_ORDER = [DirectoryState.NORMAL, DirectoryState.REFERENCE, DirectoryState.EXCLUDED] diff --git a/core/gui/exclude_list_dialog.py b/core/gui/exclude_list_dialog.py index 0f27c735..2769bc67 100644 --- a/core/gui/exclude_list_dialog.py +++ b/core/gui/exclude_list_dialog.py @@ -5,7 +5,7 @@ # which should be included with this package. The terms are also available at # http://www.gnu.org/licenses/gpl-3.0.html -from .exclude_list_table import ExcludeListTable +from core.gui.exclude_list_table import ExcludeListTable from core.exclude import has_sep from os import sep import logging diff --git a/core/gui/exclude_list_table.py b/core/gui/exclude_list_table.py index e5d71b78..30b36505 100644 --- a/core/gui/exclude_list_table.py +++ b/core/gui/exclude_list_table.py @@ -2,7 +2,7 @@ # which should be included with this package. The terms are also available at # http://www.gnu.org/licenses/gpl-3.0.html -from .base import DupeGuruGUIObject +from core.gui.base import DupeGuruGUIObject from hscommon.gui.table import GUITable, Row from hscommon.gui.column import Column, Columns from hscommon.trans import trget diff --git a/core/gui/ignore_list_dialog.py b/core/gui/ignore_list_dialog.py index ca126bf0..9ea67ea8 100644 --- a/core/gui/ignore_list_dialog.py +++ b/core/gui/ignore_list_dialog.py @@ -6,7 +6,7 @@ # http://www.gnu.org/licenses/gpl-3.0.html from hscommon.trans import tr -from .ignore_list_table import IgnoreListTable +from core.gui.ignore_list_table import IgnoreListTable class IgnoreListDialog: diff --git a/core/gui/problem_dialog.py b/core/gui/problem_dialog.py index 872cdad3..35f9ad0e 100644 --- a/core/gui/problem_dialog.py +++ b/core/gui/problem_dialog.py @@ -8,7 +8,7 @@ from hscommon import desktop -from .problem_table import ProblemTable +from core.gui.problem_table import ProblemTable class ProblemDialog: diff --git a/core/gui/result_table.py b/core/gui/result_table.py index e46423fd..5582e467 100644 --- a/core/gui/result_table.py +++ b/core/gui/result_table.py @@ -11,7 +11,7 @@ from operator import attrgetter from hscommon.gui.table import GUITable, Row from hscommon.gui.column import Columns -from .base import DupeGuruGUIObject +from core.gui.base import DupeGuruGUIObject class DupeRow(Row): diff --git a/core/gui/stats_label.py b/core/gui/stats_label.py index 12fb5f7d..fa9fe005 100644 --- a/core/gui/stats_label.py +++ b/core/gui/stats_label.py @@ -6,7 +6,7 @@ # which should be included with this package. The terms are also available at # http://www.gnu.org/licenses/gpl-3.0.html -from .base import DupeGuruGUIObject +from core.gui.base import DupeGuruGUIObject class StatsLabel(DupeGuruGUIObject): diff --git a/core/me/__init__.py b/core/me/__init__.py index 4966ed36..d5476626 100644 --- a/core/me/__init__.py +++ b/core/me/__init__.py @@ -1 +1 @@ -from . import fs, prioritize, result_table, scanner # noqa +from core.me import fs, prioritize, result_table, scanner # noqa diff --git a/core/pe/__init__.py b/core/pe/__init__.py index 9bea07ff..56d45b7b 100644 --- a/core/pe/__init__.py +++ b/core/pe/__init__.py @@ -1,8 +1,7 @@ -from . import ( # noqa +from core.pe import ( # noqa block, cache, exif, - iphoto_plist, matchblock, matchexif, photo, diff --git a/core/pe/block.py b/core/pe/block.py index 15ef1af0..84084e6f 100644 --- a/core/pe/block.py +++ b/core/pe/block.py @@ -6,7 +6,7 @@ # which should be included with this package. The terms are also available at # http://www.gnu.org/licenses/gpl-3.0.html -from ._block import NoBlocksError, DifferentBlockCountError, avgdiff, getblocks2 # NOQA +from core.pe._block import NoBlocksError, DifferentBlockCountError, avgdiff, getblocks2 # NOQA # Converted to C # def getblock(image): diff --git a/core/pe/cache.py b/core/pe/cache.py index 9928f098..31fcb0bb 100644 --- a/core/pe/cache.py +++ b/core/pe/cache.py @@ -4,7 +4,7 @@ # which should be included with this package. The terms are also available at # http://www.gnu.org/licenses/gpl-3.0.html -from ._cache import string_to_colors # noqa +from core.pe._cache import string_to_colors # noqa def colors_to_string(colors): diff --git a/core/pe/cache_shelve.py b/core/pe/cache_shelve.py index d1264a8c..57f42775 100644 --- a/core/pe/cache_shelve.py +++ b/core/pe/cache_shelve.py @@ -10,7 +10,7 @@ import shelve import tempfile from collections import namedtuple -from .cache import string_to_colors, colors_to_string +from core.pe.cache import string_to_colors, colors_to_string def wrap_path(path): diff --git a/core/pe/cache_sqlite.py b/core/pe/cache_sqlite.py index b0dce06b..ebaa8e66 100644 --- a/core/pe/cache_sqlite.py +++ b/core/pe/cache_sqlite.py @@ -9,7 +9,7 @@ import os.path as op import logging import sqlite3 as sqlite -from .cache import string_to_colors, colors_to_string +from core.pe.cache import string_to_colors, colors_to_string class SqliteCache: diff --git a/core/pe/matchblock.py b/core/pe/matchblock.py index 61ebacd7..447d8ae7 100644 --- a/core/pe/matchblock.py +++ b/core/pe/matchblock.py @@ -15,7 +15,7 @@ from hscommon.trans import tr from hscommon.jobprogress import job from core.engine import Match -from .block import avgdiff, DifferentBlockCountError, NoBlocksError +from core.pe.block import avgdiff, DifferentBlockCountError, NoBlocksError # OPTIMIZATION NOTES: # The bottleneck of the matching phase is CPU, which is why we use multiprocessing. However, another @@ -51,11 +51,11 @@ except Exception: def get_cache(cache_path, readonly=False): if cache_path.endswith("shelve"): - from .cache_shelve import ShelveCache + from core.pe.cache_shelve import ShelveCache return ShelveCache(cache_path, readonly=readonly) else: - from .cache_sqlite import SqliteCache + from core.pe.cache_sqlite import SqliteCache return SqliteCache(cache_path, readonly=readonly) diff --git a/core/pe/photo.py b/core/pe/photo.py index b866a744..04225500 100644 --- a/core/pe/photo.py +++ b/core/pe/photo.py @@ -9,7 +9,7 @@ from hscommon.util import get_file_ext, format_size from core.util import format_timestamp, format_perc, format_dupe_count from core import fs -from . import exif +from core.pe import exif # This global value is set by the platform-specific subclasser of the Photo base class PLAT_SPECIFIC_PHOTO_CLASS = None diff --git a/core/pe/scanner.py b/core/pe/scanner.py index f273edf6..e58c4a90 100644 --- a/core/pe/scanner.py +++ b/core/pe/scanner.py @@ -8,7 +8,7 @@ from hscommon.trans import tr from core.scanner import Scanner, ScanType, ScanOption -from . import matchblock, matchexif +from core.pe import matchblock, matchexif class ScannerPE(Scanner): diff --git a/core/results.py b/core/results.py index 6767bae2..3606e38a 100644 --- a/core/results.py +++ b/core/results.py @@ -17,8 +17,8 @@ from hscommon.conflict import get_conflicted_name from hscommon.util import flatten, nonone, FileOrPath, format_size from hscommon.trans import tr -from . import engine -from .markable import Markable +from core import engine +from core.markable import Markable class Results(Markable): diff --git a/core/scanner.py b/core/scanner.py index b03e1bf0..639b1be9 100644 --- a/core/scanner.py +++ b/core/scanner.py @@ -13,7 +13,7 @@ from hscommon.jobprogress import job from hscommon.util import dedupe, rem_file_ext, get_file_ext from hscommon.trans import tr -from . import engine +from core import engine # It's quite ugly to have scan types from all editions all put in the same class, but because there's # there will be some nasty bugs popping up (ScanType is used in core when in should exclusively be diff --git a/core/se/__init__.py b/core/se/__init__.py index 83d1a29f..6d5f677d 100644 --- a/core/se/__init__.py +++ b/core/se/__init__.py @@ -1 +1 @@ -from . import fs, result_table, scanner # noqa +from core.se import fs, result_table, scanner # noqa diff --git a/core/tests/app_test.py b/core/tests/app_test.py index 3c64d30e..bdfb8032 100644 --- a/core/tests/app_test.py +++ b/core/tests/app_test.py @@ -15,10 +15,10 @@ import hscommon.util from hscommon.testutil import eq_, log_calls from hscommon.jobprogress.job import Job -from .base import TestApp -from .results_test import GetTestGroups -from .. import app, fs, engine -from ..scanner import ScanType +from core.tests.base import TestApp +from core.tests.results_test import GetTestGroups +from core import app, fs, engine +from core.scanner import ScanType def add_fake_files_to_directories(directories, files): diff --git a/core/tests/base.py b/core/tests/base.py index 5ab2387e..eeea7d6a 100644 --- a/core/tests/base.py +++ b/core/tests/base.py @@ -10,12 +10,11 @@ from hscommon.util import get_file_ext, format_size from hscommon.gui.column import Column from hscommon.jobprogress.job import nulljob, JobCancelled -from .. import engine -from .. import prioritize -from ..engine import getwords -from ..app import DupeGuru as DupeGuruBase -from ..gui.result_table import ResultTable as ResultTableBase -from ..gui.prioritize_dialog import PrioritizeDialog +from core import engine, prioritize +from core.engine import getwords +from core.app import DupeGuru as DupeGuruBase +from core.gui.result_table import ResultTable as ResultTableBase +from core.gui.prioritize_dialog import PrioritizeDialog class DupeGuruView: diff --git a/core/tests/block_test.py b/core/tests/block_test.py index 1c617638..caec436c 100644 --- a/core/tests/block_test.py +++ b/core/tests/block_test.py @@ -9,7 +9,7 @@ from pytest import raises, skip from hscommon.testutil import eq_ try: - from ..pe.block import avgdiff, getblocks2, NoBlocksError, DifferentBlockCountError + from core.pe.block import avgdiff, getblocks2, NoBlocksError, DifferentBlockCountError except ImportError: skip("Can't import the block module, probably hasn't been compiled.") diff --git a/core/tests/cache_test.py b/core/tests/cache_test.py index 594b61ca..7b11c02c 100644 --- a/core/tests/cache_test.py +++ b/core/tests/cache_test.py @@ -10,9 +10,9 @@ from pytest import raises, skip from hscommon.testutil import eq_ try: - from ..pe.cache import colors_to_string, string_to_colors - from ..pe.cache_sqlite import SqliteCache - from ..pe.cache_shelve import ShelveCache + from core.pe.cache import colors_to_string, string_to_colors + from core.pe.cache_sqlite import SqliteCache + from core.pe.cache_shelve import ShelveCache except ImportError: skip("Can't import the cache module, probably hasn't been compiled.") diff --git a/core/tests/directories_test.py b/core/tests/directories_test.py index 9f57a154..f9837534 100644 --- a/core/tests/directories_test.py +++ b/core/tests/directories_test.py @@ -14,14 +14,14 @@ from pathlib import Path from hscommon.testutil import eq_ from hscommon.plat import ISWINDOWS -from ..fs import File -from ..directories import ( +from core.fs import File +from core.directories import ( Directories, DirectoryState, AlreadyThereError, InvalidPathError, ) -from ..exclude import ExcludeList, ExcludeDict +from core.exclude import ExcludeList, ExcludeDict def create_fake_fs(rootpath): diff --git a/core/tests/engine_test.py b/core/tests/engine_test.py index e55a6e7e..03522d10 100644 --- a/core/tests/engine_test.py +++ b/core/tests/engine_test.py @@ -10,9 +10,9 @@ from hscommon.jobprogress import job from hscommon.util import first from hscommon.testutil import eq_, log_calls -from .base import NamedObject -from .. import engine -from ..engine import ( +from core.tests.base import NamedObject +from core import engine +from core.engine import ( get_match, getwords, Group, diff --git a/core/tests/exclude_test.py b/core/tests/exclude_test.py index 60a2d2a0..64314b97 100644 --- a/core/tests/exclude_test.py +++ b/core/tests/exclude_test.py @@ -10,8 +10,8 @@ from xml.etree import ElementTree as ET from hscommon.testutil import eq_ from hscommon.plat import ISWINDOWS -from .base import DupeGuru -from ..exclude import ExcludeList, ExcludeDict, default_regexes, AlreadyThereException +from core.tests.base import DupeGuru +from core.exclude import ExcludeList, ExcludeDict, default_regexes, AlreadyThereException from re import error diff --git a/core/tests/fs_test.py b/core/tests/fs_test.py index b2e2815c..d0f2634b 100644 --- a/core/tests/fs_test.py +++ b/core/tests/fs_test.py @@ -13,7 +13,7 @@ from pathlib import Path from hscommon.testutil import eq_ from core.tests.directories_test import create_fake_fs -from .. import fs +from core import fs hasher: typing.Callable try: diff --git a/core/tests/ignore_test.py b/core/tests/ignore_test.py index fc8a3943..7e859ceb 100644 --- a/core/tests/ignore_test.py +++ b/core/tests/ignore_test.py @@ -10,7 +10,7 @@ from xml.etree import ElementTree as ET from pytest import raises from hscommon.testutil import eq_ -from ..ignore import IgnoreList +from core.ignore import IgnoreList def test_empty(): diff --git a/core/tests/markable_test.py b/core/tests/markable_test.py index cd8415c5..27ca80d1 100644 --- a/core/tests/markable_test.py +++ b/core/tests/markable_test.py @@ -6,7 +6,7 @@ from hscommon.testutil import eq_ -from ..markable import MarkableList, Markable +from core.markable import MarkableList, Markable def gen(): diff --git a/core/tests/prioritize_test.py b/core/tests/prioritize_test.py index 35c76214..87909a2f 100644 --- a/core/tests/prioritize_test.py +++ b/core/tests/prioritize_test.py @@ -9,8 +9,8 @@ import os.path as op from itertools import combinations -from .base import TestApp, NamedObject, with_app, eq_ -from ..engine import Group, Match +from core.tests.base import TestApp, NamedObject, with_app, eq_ +from core.engine import Group, Match no = NamedObject diff --git a/core/tests/result_table_test.py b/core/tests/result_table_test.py index e3d49b67..3f5e4c65 100644 --- a/core/tests/result_table_test.py +++ b/core/tests/result_table_test.py @@ -6,7 +6,7 @@ # which should be included with this package. The terms are also available at # http://www.gnu.org/licenses/gpl-3.0.html -from .base import TestApp, GetTestGroups +from core.tests.base import TestApp, GetTestGroups def app_with_results(): diff --git a/core/tests/results_test.py b/core/tests/results_test.py index 2a64a054..c83141c7 100644 --- a/core/tests/results_test.py +++ b/core/tests/results_test.py @@ -12,10 +12,9 @@ from xml.etree import ElementTree as ET from pytest import raises from hscommon.testutil import eq_ from hscommon.util import first - -from .. import engine -from .base import NamedObject, GetTestGroups, DupeGuru -from ..results import Results +from core import engine +from core.tests.base import NamedObject, GetTestGroups, DupeGuru +from core.results import Results class TestCaseResultsEmpty: diff --git a/core/tests/scanner_test.py b/core/tests/scanner_test.py index 0354ae3f..e9379246 100644 --- a/core/tests/scanner_test.py +++ b/core/tests/scanner_test.py @@ -10,11 +10,11 @@ from hscommon.jobprogress import job from pathlib import Path from hscommon.testutil import eq_ -from .. import fs -from ..engine import getwords, Match -from ..ignore import IgnoreList -from ..scanner import Scanner, ScanType -from ..me.scanner import ScannerME +from core import fs +from core.engine import getwords, Match +from core.ignore import IgnoreList +from core.scanner import Scanner, ScanType +from core.me.scanner import ScannerME class NamedObject: diff --git a/hscommon/build.py b/hscommon/build.py index e772b0ff..6c37012d 100644 --- a/hscommon/build.py +++ b/hscommon/build.py @@ -21,7 +21,7 @@ import importlib from datetime import datetime import glob -from .plat import ISWINDOWS +from hscommon.plat import ISWINDOWS def print_and_do(cmd): diff --git a/hscommon/gui/column.py b/hscommon/gui/column.py index 5d25c7b6..dfa75981 100644 --- a/hscommon/gui/column.py +++ b/hscommon/gui/column.py @@ -8,7 +8,7 @@ import copy -from .base import GUIObject +from hscommon.gui.base import GUIObject class Column: diff --git a/hscommon/gui/progress_window.py b/hscommon/gui/progress_window.py index f1c07143..7fdf6022 100644 --- a/hscommon/gui/progress_window.py +++ b/hscommon/gui/progress_window.py @@ -4,9 +4,9 @@ # which should be included with this package. The terms are also available at # http://www.gnu.org/licenses/gpl-3.0.html -from ..jobprogress.performer import ThreadedJobPerformer -from .base import GUIObject -from .text_field import TextField +from hscommon.jobprogress.performer import ThreadedJobPerformer +from hscommon.gui.base import GUIObject +from hscommon.gui.text_field import TextField class ProgressWindowView: diff --git a/hscommon/gui/selectable_list.py b/hscommon/gui/selectable_list.py index 58ad3a61..352c4f5b 100644 --- a/hscommon/gui/selectable_list.py +++ b/hscommon/gui/selectable_list.py @@ -8,7 +8,7 @@ from collections.abc import Sequence, MutableSequence -from .base import GUIObject +from hscommon.gui.base import GUIObject class Selectable(Sequence): diff --git a/hscommon/gui/table.py b/hscommon/gui/table.py index cd25e0c1..d4e10083 100644 --- a/hscommon/gui/table.py +++ b/hscommon/gui/table.py @@ -9,8 +9,8 @@ from collections.abc import MutableSequence from collections import namedtuple -from .base import GUIObject -from .selectable_list import Selectable +from hscommon.gui.base import GUIObject +from hscommon.gui.selectable_list import Selectable # We used to directly subclass list, but it caused problems at some point with deepcopy diff --git a/hscommon/gui/text_field.py b/hscommon/gui/text_field.py index 8d82b3d4..31a87a25 100644 --- a/hscommon/gui/text_field.py +++ b/hscommon/gui/text_field.py @@ -5,8 +5,8 @@ # which should be included with this package. The terms are also available at # http://www.gnu.org/licenses/gpl-3.0.html -from .base import GUIObject -from ..util import nonone +from hscommon.gui.base import GUIObject +from hscommon.util import nonone class TextFieldView: diff --git a/hscommon/gui/tree.py b/hscommon/gui/tree.py index ff8499b3..c9fbb048 100644 --- a/hscommon/gui/tree.py +++ b/hscommon/gui/tree.py @@ -6,7 +6,7 @@ from collections.abc import MutableSequence -from .base import GUIObject +from hscommon.gui.base import GUIObject class Node(MutableSequence): diff --git a/hscommon/jobprogress/performer.py b/hscommon/jobprogress/performer.py index 5513eebd..bdb1473a 100644 --- a/hscommon/jobprogress/performer.py +++ b/hscommon/jobprogress/performer.py @@ -9,7 +9,7 @@ from threading import Thread import sys -from .job import Job, JobInProgressError, JobCancelled +from hscommon.jobprogress.job import Job, JobInProgressError, JobCancelled class ThreadedJobPerformer: diff --git a/hscommon/loc.py b/hscommon/loc.py index 35d0d765..a435fc8e 100644 --- a/hscommon/loc.py +++ b/hscommon/loc.py @@ -5,21 +5,10 @@ import tempfile import polib -from . import pygettext +from hscommon import pygettext LC_MESSAGES = "LC_MESSAGES" -# There isn't a 1-on-1 exact fit between .po language codes and cocoa ones -PO2COCOA = { - "pl_PL": "pl", - "pt_BR": "pt-BR", - "zh_CN": "zh-Hans", -} - -COCOA2PO = {v: k for k, v in PO2COCOA.items()} - -STRING_EXT = ".strings" - def get_langs(folder): return [name for name in os.listdir(folder) if op.isdir(op.join(folder, name))] diff --git a/hscommon/sphinxgen.py b/hscommon/sphinxgen.py index d49ae0c6..52c9ea8e 100644 --- a/hscommon/sphinxgen.py +++ b/hscommon/sphinxgen.py @@ -7,7 +7,7 @@ from pathlib import Path import re -from .build import read_changelog_file, filereplace +from hscommon.build import read_changelog_file, filereplace from sphinx.cmd.build import build_main as sphinx_build CHANGELOG_FORMAT = """ diff --git a/hscommon/tests/conflict_test.py b/hscommon/tests/conflict_test.py index 244fba0f..4f2dca85 100644 --- a/hscommon/tests/conflict_test.py +++ b/hscommon/tests/conflict_test.py @@ -8,7 +8,7 @@ import pytest -from ..conflict import ( +from hscommon.conflict import ( get_conflicted_name, get_unconflicted_name, is_conflicted, @@ -16,7 +16,7 @@ from ..conflict import ( smart_move, ) from pathlib import Path -from ..testutil import eq_ +from hscommon.testutil import eq_ class TestCaseGetConflictedName: diff --git a/hscommon/tests/notify_test.py b/hscommon/tests/notify_test.py index 14dbb9fc..062ed5a9 100644 --- a/hscommon/tests/notify_test.py +++ b/hscommon/tests/notify_test.py @@ -4,8 +4,8 @@ # which should be included with this package. The terms are also available at # http://www.gnu.org/licenses/gpl-3.0.html -from ..testutil import eq_ -from ..notify import Broadcaster, Listener, Repeater +from hscommon.testutil import eq_ +from hscommon.notify import Broadcaster, Listener, Repeater class HelloListener(Listener): diff --git a/hscommon/tests/path_test.py b/hscommon/tests/path_test.py index bb89f3d0..d42b33d9 100644 --- a/hscommon/tests/path_test.py +++ b/hscommon/tests/path_test.py @@ -6,7 +6,7 @@ # which should be included with this package. The terms are also available at # http://www.gnu.org/licenses/gpl-3.0.html -from ..path import pathify +from hscommon.path import pathify from pathlib import Path diff --git a/hscommon/tests/selectable_list_test.py b/hscommon/tests/selectable_list_test.py index f9ac5242..5b4c0c95 100644 --- a/hscommon/tests/selectable_list_test.py +++ b/hscommon/tests/selectable_list_test.py @@ -6,8 +6,8 @@ # which should be included with this package. The terms are also available at # http://www.gnu.org/licenses/gpl-3.0.html -from ..testutil import eq_, callcounter, CallLogger -from ..gui.selectable_list import SelectableList, GUISelectableList +from hscommon.testutil import eq_, callcounter, CallLogger +from hscommon.gui.selectable_list import SelectableList, GUISelectableList def test_in(): diff --git a/hscommon/tests/sqlite_test.py b/hscommon/tests/sqlite_test.py index 943bfefd..88afe60c 100644 --- a/hscommon/tests/sqlite_test.py +++ b/hscommon/tests/sqlite_test.py @@ -13,8 +13,8 @@ import sqlite3 as sqlite from pytest import raises -from ..testutil import eq_ -from ..sqlite import ThreadedConn +from hscommon.testutil import eq_ +from hscommon.sqlite import ThreadedConn # Threading is hard to test. In a lot of those tests, a failure means that the test run will # hang forever. Well... I don't know a better alternative. diff --git a/hscommon/tests/table_test.py b/hscommon/tests/table_test.py index 0a33adce..30b8d3ed 100644 --- a/hscommon/tests/table_test.py +++ b/hscommon/tests/table_test.py @@ -6,8 +6,8 @@ # which should be included with this package. The terms are also available at # http://www.gnu.org/licenses/gpl-3.0.html -from ..testutil import CallLogger, eq_ -from ..gui.table import Table, GUITable, Row +from hscommon.testutil import CallLogger, eq_ +from hscommon.gui.table import Table, GUITable, Row class TestRow(Row): diff --git a/hscommon/tests/tree_test.py b/hscommon/tests/tree_test.py index f9d20136..d9a876bf 100644 --- a/hscommon/tests/tree_test.py +++ b/hscommon/tests/tree_test.py @@ -6,8 +6,8 @@ # which should be included with this package. The terms are also available at # http://www.gnu.org/licenses/gpl-3.0.html -from ..testutil import eq_ -from ..gui.tree import Tree, Node +from hscommon.testutil import eq_ +from hscommon.gui.tree import Tree, Node def tree_with_some_nodes(): diff --git a/hscommon/tests/util_test.py b/hscommon/tests/util_test.py index 327c008a..601fa3bb 100644 --- a/hscommon/tests/util_test.py +++ b/hscommon/tests/util_test.py @@ -10,9 +10,9 @@ from io import StringIO from pytest import raises -from ..testutil import eq_ +from hscommon.testutil import eq_ from pathlib import Path -from ..util import ( +from hscommon.util import ( nonone, tryint, first, diff --git a/hscommon/testutil.py b/hscommon/testutil.py index 87338fd5..e4555fd4 100644 --- a/hscommon/testutil.py +++ b/hscommon/testutil.py @@ -8,28 +8,12 @@ import pytest -import threading -import py.path - def eq_(a, b, msg=None): __tracebackhide__ = True assert a == b, msg or "{!r} != {!r}".format(a, b) -def eq_sorted(a, b, msg=None): - """If both a and b are iterable sort them and compare using eq_, otherwise just pass them through to eq_ anyway.""" - try: - eq_(sorted(a), sorted(b), msg) - except TypeError: - eq_(a, b, msg) - - -def assert_almost_equal(a, b, places=7): - __tracebackhide__ = True - assert round(a, ndigits=places) == round(b, ndigits=places) - - def callcounter(): def f(*args, **kwargs): f.callcount += 1 @@ -38,23 +22,6 @@ def callcounter(): return f -class TestData: - def __init__(self, datadirpath): - self.datadirpath = py.path.local(datadirpath) - - def filepath(self, relative_path, *args): - """Returns the path of a file in testdata. - - 'relative_path' can be anything that can be added to a Path - if args is not empty, it will be joined to relative_path - """ - resultpath = self.datadirpath.join(relative_path) - if args: - resultpath = resultpath.join(*args) - assert resultpath.check() - return str(resultpath) - - class CallLogger: """This is a dummy object that logs all calls made to it. @@ -168,20 +135,6 @@ def app(request): return app -def jointhreads(): - """Join all threads to the main thread""" - for thread in threading.enumerate(): - if hasattr(thread, "BUGGY"): - continue - if thread.getName() != "MainThread" and thread.isAlive(): - if hasattr(thread, "close"): - thread.close() - thread.join(1) - if thread.isAlive(): - print("Thread problem. Some thread doesn't want to stop.") - thread.BUGGY = True - - def _unify_args(func, args, kwargs, args_to_ignore=None): """Unify args and kwargs in the same dictionary. diff --git a/hscommon/trans.py b/hscommon/trans.py index 564739c5..fa32510c 100644 --- a/hscommon/trans.py +++ b/hscommon/trans.py @@ -13,7 +13,7 @@ import locale import logging import os.path as op -from .plat import ISLINUX +from hscommon.plat import ISLINUX _trfunc = None _trget = None diff --git a/hscommon/util.py b/hscommon/util.py index a4c3fbd0..39b32a7e 100644 --- a/hscommon/util.py +++ b/hscommon/util.py @@ -8,7 +8,7 @@ from math import ceil from pathlib import Path -from .path import pathify, log_io_error +from hscommon.path import pathify, log_io_error from typing import IO, Any, Callable, Generator, Iterable, List, Tuple, Union diff --git a/qt/app.py b/qt/app.py index 8cc22133..27ac6ed5 100644 --- a/qt/app.py +++ b/qt/app.py @@ -21,22 +21,22 @@ from qt.progress_window import ProgressWindow from core.app import AppMode, DupeGuru as DupeGuruModel import core.pe.photo -from . import platform -from .preferences import Preferences -from .result_window import ResultWindow -from .directories_dialog import DirectoriesDialog -from .problem_dialog import ProblemDialog -from .ignore_list_dialog import IgnoreListDialog -from .exclude_list_dialog import ExcludeListDialog -from .deletion_options import DeletionOptions -from .se.details_dialog import DetailsDialog as DetailsDialogStandard -from .me.details_dialog import DetailsDialog as DetailsDialogMusic -from .pe.details_dialog import DetailsDialog as DetailsDialogPicture -from .se.preferences_dialog import PreferencesDialog as PreferencesDialogStandard -from .me.preferences_dialog import PreferencesDialog as PreferencesDialogMusic -from .pe.preferences_dialog import PreferencesDialog as PreferencesDialogPicture -from .pe.photo import File as PlatSpecificPhoto -from .tabbed_window import TabBarWindow, TabWindow +from qt import platform +from qt.preferences import Preferences +from qt.result_window import ResultWindow +from qt.directories_dialog import DirectoriesDialog +from qt.problem_dialog import ProblemDialog +from qt.ignore_list_dialog import IgnoreListDialog +from qt.exclude_list_dialog import ExcludeListDialog +from qt.deletion_options import DeletionOptions +from qt.se.details_dialog import DetailsDialog as DetailsDialogStandard +from qt.me.details_dialog import DetailsDialog as DetailsDialogMusic +from qt.pe.details_dialog import DetailsDialog as DetailsDialogPicture +from qt.se.preferences_dialog import PreferencesDialog as PreferencesDialogStandard +from qt.me.preferences_dialog import PreferencesDialog as PreferencesDialogMusic +from qt.pe.preferences_dialog import PreferencesDialog as PreferencesDialogPicture +from qt.pe.photo import File as PlatSpecificPhoto +from qt.tabbed_window import TabBarWindow, TabWindow tr = trget("ui") diff --git a/qt/details_dialog.py b/qt/details_dialog.py index a4d467bc..63e41c62 100644 --- a/qt/details_dialog.py +++ b/qt/details_dialog.py @@ -10,7 +10,7 @@ from PyQt5.QtCore import Qt from PyQt5.QtWidgets import QDockWidget, QWidget from qt.util import move_to_screen_center -from .details_table import DetailsModel +from qt.details_table import DetailsModel from hscommon.plat import ISLINUX diff --git a/qt/directories_dialog.py b/qt/directories_dialog.py index f802c63e..272a7514 100644 --- a/qt/directories_dialog.py +++ b/qt/directories_dialog.py @@ -31,8 +31,8 @@ from qt.radio_box import RadioBox from qt.recent import Recent from qt.util import move_to_screen_center, create_actions -from . import platform -from .directories_model import DirectoriesModel, DirectoriesDelegate +from qt import platform +from qt.directories_model import DirectoriesModel, DirectoriesDelegate tr = trget("ui") diff --git a/qt/exclude_list_dialog.py b/qt/exclude_list_dialog.py index 4b2f690d..7b5c9c64 100644 --- a/qt/exclude_list_dialog.py +++ b/qt/exclude_list_dialog.py @@ -16,7 +16,7 @@ from PyQt5.QtWidgets import ( QSizePolicy, QHeaderView, ) -from .exclude_list_table import ExcludeListTable +from qt.exclude_list_table import ExcludeListTable from core.exclude import AlreadyThereException from hscommon.trans import trget diff --git a/qt/ignore_list_dialog.py b/qt/ignore_list_dialog.py index 94abe1d0..1ccdcc47 100644 --- a/qt/ignore_list_dialog.py +++ b/qt/ignore_list_dialog.py @@ -17,7 +17,7 @@ from PyQt5.QtWidgets import ( from hscommon.trans import trget from qt.util import horizontal_wrap -from .ignore_list_table import IgnoreListTable +from qt.ignore_list_table import IgnoreListTable tr = trget("ui") diff --git a/qt/me/details_dialog.py b/qt/me/details_dialog.py index ff36c37b..43619af6 100644 --- a/qt/me/details_dialog.py +++ b/qt/me/details_dialog.py @@ -8,8 +8,8 @@ from PyQt5.QtCore import QSize from PyQt5.QtWidgets import QAbstractItemView from hscommon.trans import trget -from ..details_dialog import DetailsDialog as DetailsDialogBase -from ..details_table import DetailsTable +from qt.details_dialog import DetailsDialog as DetailsDialogBase +from qt.details_table import DetailsTable tr = trget("ui") diff --git a/qt/me/preferences_dialog.py b/qt/me/preferences_dialog.py index fee4409b..abcd7a16 100644 --- a/qt/me/preferences_dialog.py +++ b/qt/me/preferences_dialog.py @@ -18,7 +18,7 @@ from hscommon.trans import trget from core.app import AppMode from core.scanner import ScanType -from ..preferences_dialog import PreferencesDialogBase +from qt.preferences_dialog import PreferencesDialogBase tr = trget("ui") diff --git a/qt/me/results_model.py b/qt/me/results_model.py index 085195d9..e4dafc6d 100644 --- a/qt/me/results_model.py +++ b/qt/me/results_model.py @@ -5,7 +5,7 @@ # http://www.gnu.org/licenses/gpl-3.0.html from qt.column import Column -from ..results_model import ResultsModel as ResultsModelBase +from qt.results_model import ResultsModel as ResultsModelBase class ResultsModel(ResultsModelBase): diff --git a/qt/pe/block.py b/qt/pe/block.py index 9ccfb981..5db5c61c 100644 --- a/qt/pe/block.py +++ b/qt/pe/block.py @@ -6,7 +6,7 @@ # which should be included with this package. The terms are also available at # http://www.gnu.org/licenses/gpl-3.0.html -from ._block_qt import getblocks # NOQA +from qt.pe._block_qt import getblocks # NOQA # Converted to C # def getblock(image): diff --git a/qt/pe/details_dialog.py b/qt/pe/details_dialog.py index b339917d..9f6083b6 100644 --- a/qt/pe/details_dialog.py +++ b/qt/pe/details_dialog.py @@ -8,9 +8,9 @@ from PyQt5.QtCore import Qt, QSize, pyqtSignal, pyqtSlot from PyQt5.QtWidgets import QAbstractItemView, QSizePolicy, QGridLayout, QSplitter, QFrame from PyQt5.QtGui import QResizeEvent from hscommon.trans import trget -from ..details_dialog import DetailsDialog as DetailsDialogBase -from ..details_table import DetailsTable -from .image_viewer import ViewerToolBar, ScrollAreaImageViewer, ScrollAreaController +from qt.details_dialog import DetailsDialog as DetailsDialogBase +from qt.details_table import DetailsTable +from qt.pe.image_viewer import ViewerToolBar, ScrollAreaImageViewer, ScrollAreaController tr = trget("ui") diff --git a/qt/pe/photo.py b/qt/pe/photo.py index 167ef260..53bc8a0f 100644 --- a/qt/pe/photo.py +++ b/qt/pe/photo.py @@ -10,7 +10,7 @@ from PyQt5.QtGui import QImage, QImageReader, QTransform from core.pe.photo import Photo as PhotoBase -from .block import getblocks +from qt.pe.block import getblocks class File(PhotoBase): diff --git a/qt/pe/preferences_dialog.py b/qt/pe/preferences_dialog.py index 79dc0120..2ded026d 100644 --- a/qt/pe/preferences_dialog.py +++ b/qt/pe/preferences_dialog.py @@ -12,7 +12,7 @@ from qt.radio_box import RadioBox from core.scanner import ScanType from core.app import AppMode -from ..preferences_dialog import PreferencesDialogBase +from qt.preferences_dialog import PreferencesDialogBase tr = trget("ui") diff --git a/qt/pe/results_model.py b/qt/pe/results_model.py index 40e8e61c..5ebfa8c4 100644 --- a/qt/pe/results_model.py +++ b/qt/pe/results_model.py @@ -5,7 +5,7 @@ # http://www.gnu.org/licenses/gpl-3.0.html from qt.column import Column -from ..results_model import ResultsModel as ResultsModelBase +from qt.results_model import ResultsModel as ResultsModelBase class ResultsModel(ResultsModelBase): diff --git a/qt/preferences_dialog.py b/qt/preferences_dialog.py index 6e2999ae..caa6eb00 100644 --- a/qt/preferences_dialog.py +++ b/qt/preferences_dialog.py @@ -37,7 +37,7 @@ from qt.util import horizontal_wrap, move_to_screen_center from qt.preferences import get_langnames from enum import Flag, auto -from .preferences import Preferences +from qt.preferences import Preferences tr = trget("ui") diff --git a/qt/problem_dialog.py b/qt/problem_dialog.py index 522c76aa..38c0515f 100644 --- a/qt/problem_dialog.py +++ b/qt/problem_dialog.py @@ -21,7 +21,7 @@ from PyQt5.QtWidgets import ( from qt.util import move_to_screen_center from hscommon.trans import trget -from .problem_table import ProblemTable +from qt.problem_table import ProblemTable tr = trget("ui") diff --git a/qt/result_window.py b/qt/result_window.py index 266c63e2..284391e3 100644 --- a/qt/result_window.py +++ b/qt/result_window.py @@ -28,12 +28,12 @@ from qt.util import move_to_screen_center, horizontal_wrap, create_actions from qt.search_edit import SearchEdit from core.app import AppMode -from .results_model import ResultsView -from .stats_label import StatsLabel -from .prioritize_dialog import PrioritizeDialog -from .se.results_model import ResultsModel as ResultsModelStandard -from .me.results_model import ResultsModel as ResultsModelMusic -from .pe.results_model import ResultsModel as ResultsModelPicture +from qt.results_model import ResultsView +from qt.stats_label import StatsLabel +from qt.prioritize_dialog import PrioritizeDialog +from qt.se.results_model import ResultsModel as ResultsModelStandard +from qt.me.results_model import ResultsModel as ResultsModelMusic +from qt.pe.results_model import ResultsModel as ResultsModelPicture tr = trget("ui") diff --git a/qt/se/details_dialog.py b/qt/se/details_dialog.py index c30c4b90..ea59c7c2 100644 --- a/qt/se/details_dialog.py +++ b/qt/se/details_dialog.py @@ -8,8 +8,8 @@ from PyQt5.QtCore import QSize from PyQt5.QtWidgets import QAbstractItemView from hscommon.trans import trget -from ..details_dialog import DetailsDialog as DetailsDialogBase -from ..details_table import DetailsTable +from qt.details_dialog import DetailsDialog as DetailsDialogBase +from qt.details_table import DetailsTable tr = trget("ui") diff --git a/qt/se/preferences_dialog.py b/qt/se/preferences_dialog.py index e6a9f537..d3a69fe5 100644 --- a/qt/se/preferences_dialog.py +++ b/qt/se/preferences_dialog.py @@ -20,7 +20,7 @@ from hscommon.trans import trget from core.app import AppMode from core.scanner import ScanType -from ..preferences_dialog import PreferencesDialogBase +from qt.preferences_dialog import PreferencesDialogBase tr = trget("ui") diff --git a/qt/se/results_model.py b/qt/se/results_model.py index ce580ad4..23f872fa 100644 --- a/qt/se/results_model.py +++ b/qt/se/results_model.py @@ -5,7 +5,7 @@ # http://www.gnu.org/licenses/gpl-3.0.html from qt.column import Column -from ..results_model import ResultsModel as ResultsModelBase +from qt.results_model import ResultsModel as ResultsModelBase class ResultsModel(ResultsModelBase): diff --git a/qt/tabbed_window.py b/qt/tabbed_window.py index aabbaa86..58ac996d 100644 --- a/qt/tabbed_window.py +++ b/qt/tabbed_window.py @@ -15,10 +15,10 @@ from PyQt5.QtWidgets import ( ) from hscommon.trans import trget from qt.util import move_to_screen_center, create_actions -from .directories_dialog import DirectoriesDialog -from .result_window import ResultWindow -from .ignore_list_dialog import IgnoreListDialog -from .exclude_list_dialog import ExcludeListDialog +from qt.directories_dialog import DirectoriesDialog +from qt.result_window import ResultWindow +from qt.ignore_list_dialog import IgnoreListDialog +from qt.exclude_list_dialog import ExcludeListDialog tr = trget("ui") diff --git a/qt/table.py b/qt/table.py index 881e7b4d..17aeb1a3 100644 --- a/qt/table.py +++ b/qt/table.py @@ -15,7 +15,7 @@ from PyQt5.QtCore import ( QItemSelection, ) -from .column import Columns, Column +from qt.column import Columns, Column class Table(QAbstractTableModel):