1
0
mirror of https://github.com/arsenetar/dupeguru.git synced 2024-10-31 22:05:58 +00:00

Replace all relative imports

This commit is contained in:
Andrew Senetar 2022-05-09 01:40:08 -05:00
parent f7ed1c801c
commit e382683f66
Signed by: arsenetar
GPG Key ID: C63300DCE48AB2F1
79 changed files with 155 additions and 216 deletions

View File

@ -23,20 +23,20 @@ from hscommon.util import delete_if_empty, first, escape, nonone, allsame
from hscommon.trans import tr from hscommon.trans import tr
from hscommon import desktop from hscommon import desktop
from . import se, me, pe from core import se, me, pe
from .pe.photo import get_delta_dimensions from core.pe.photo import get_delta_dimensions
from .util import cmp_value, fix_surrogate_encoding from core.util import cmp_value, fix_surrogate_encoding
from . import directories, results, export, fs, prioritize from core import directories, results, export, fs, prioritize
from .ignore import IgnoreList from core.ignore import IgnoreList
from .exclude import ExcludeDict as ExcludeList from core.exclude import ExcludeDict as ExcludeList
from .scanner import ScanType from core.scanner import ScanType
from .gui.deletion_options import DeletionOptions from core.gui.deletion_options import DeletionOptions
from .gui.details_panel import DetailsPanel from core.gui.details_panel import DetailsPanel
from .gui.directory_tree import DirectoryTree from core.gui.directory_tree import DirectoryTree
from .gui.ignore_list_dialog import IgnoreListDialog from core.gui.ignore_list_dialog import IgnoreListDialog
from .gui.exclude_list_dialog import ExcludeListDialogCore from core.gui.exclude_list_dialog import ExcludeListDialogCore
from .gui.problem_dialog import ProblemDialog from core.gui.problem_dialog import ProblemDialog
from .gui.stats_label import StatsLabel from core.gui.stats_label import StatsLabel
HAD_FIRST_LAUNCH_PREFERENCE = "HadFirstLaunch" HAD_FIRST_LAUNCH_PREFERENCE = "HadFirstLaunch"
DEBUG_MODE_PREFERENCE = "DebugMode" DEBUG_MODE_PREFERENCE = "DebugMode"

View File

@ -13,7 +13,7 @@ from hscommon.jobprogress import job
from hscommon.util import FileOrPath from hscommon.util import FileOrPath
from hscommon.trans import tr from hscommon.trans import tr
from . import fs from core import fs
__all__ = [ __all__ = [
"Directories", "Directories",

View File

@ -2,7 +2,7 @@
# which should be included with this package. The terms are also available at # which should be included with this package. The terms are also available at
# http://www.gnu.org/licenses/gpl-3.0.html # 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 from xml.etree import ElementTree as ET
# TODO: perhaps use regex module for better Unicode support? https://pypi.org/project/regex/ # TODO: perhaps use regex module for better Unicode support? https://pypi.org/project/regex/

View File

@ -7,7 +7,7 @@
# http://www.gnu.org/licenses/gpl-3.0.html # http://www.gnu.org/licenses/gpl-3.0.html
from hscommon.gui.base import GUIObject from hscommon.gui.base import GUIObject
from .base import DupeGuruGUIObject from core.gui.base import DupeGuruGUIObject
class DetailsPanel(GUIObject, DupeGuruGUIObject): class DetailsPanel(GUIObject, DupeGuruGUIObject):

View File

@ -8,8 +8,8 @@
from hscommon.gui.tree import Tree, Node from hscommon.gui.tree import Tree, Node
from ..directories import DirectoryState from core.directories import DirectoryState
from .base import DupeGuruGUIObject from core.gui.base import DupeGuruGUIObject
STATE_ORDER = [DirectoryState.NORMAL, DirectoryState.REFERENCE, DirectoryState.EXCLUDED] STATE_ORDER = [DirectoryState.NORMAL, DirectoryState.REFERENCE, DirectoryState.EXCLUDED]

View File

@ -5,7 +5,7 @@
# which should be included with this package. The terms are also available at # which should be included with this package. The terms are also available at
# http://www.gnu.org/licenses/gpl-3.0.html # 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 core.exclude import has_sep
from os import sep from os import sep
import logging import logging

View File

@ -2,7 +2,7 @@
# which should be included with this package. The terms are also available at # which should be included with this package. The terms are also available at
# http://www.gnu.org/licenses/gpl-3.0.html # 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.table import GUITable, Row
from hscommon.gui.column import Column, Columns from hscommon.gui.column import Column, Columns
from hscommon.trans import trget from hscommon.trans import trget

View File

@ -6,7 +6,7 @@
# http://www.gnu.org/licenses/gpl-3.0.html # http://www.gnu.org/licenses/gpl-3.0.html
from hscommon.trans import tr from hscommon.trans import tr
from .ignore_list_table import IgnoreListTable from core.gui.ignore_list_table import IgnoreListTable
class IgnoreListDialog: class IgnoreListDialog:

View File

@ -8,7 +8,7 @@
from hscommon import desktop from hscommon import desktop
from .problem_table import ProblemTable from core.gui.problem_table import ProblemTable
class ProblemDialog: class ProblemDialog:

View File

@ -11,7 +11,7 @@ from operator import attrgetter
from hscommon.gui.table import GUITable, Row from hscommon.gui.table import GUITable, Row
from hscommon.gui.column import Columns from hscommon.gui.column import Columns
from .base import DupeGuruGUIObject from core.gui.base import DupeGuruGUIObject
class DupeRow(Row): class DupeRow(Row):

View File

@ -6,7 +6,7 @@
# which should be included with this package. The terms are also available at # which should be included with this package. The terms are also available at
# http://www.gnu.org/licenses/gpl-3.0.html # http://www.gnu.org/licenses/gpl-3.0.html
from .base import DupeGuruGUIObject from core.gui.base import DupeGuruGUIObject
class StatsLabel(DupeGuruGUIObject): class StatsLabel(DupeGuruGUIObject):

View File

@ -1 +1 @@
from . import fs, prioritize, result_table, scanner # noqa from core.me import fs, prioritize, result_table, scanner # noqa

View File

@ -1,8 +1,7 @@
from . import ( # noqa from core.pe import ( # noqa
block, block,
cache, cache,
exif, exif,
iphoto_plist,
matchblock, matchblock,
matchexif, matchexif,
photo, photo,

View File

@ -6,7 +6,7 @@
# which should be included with this package. The terms are also available at # which should be included with this package. The terms are also available at
# http://www.gnu.org/licenses/gpl-3.0.html # 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 # Converted to C
# def getblock(image): # def getblock(image):

View File

@ -4,7 +4,7 @@
# which should be included with this package. The terms are also available at # which should be included with this package. The terms are also available at
# http://www.gnu.org/licenses/gpl-3.0.html # 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): def colors_to_string(colors):

View File

@ -10,7 +10,7 @@ import shelve
import tempfile import tempfile
from collections import namedtuple 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): def wrap_path(path):

View File

@ -9,7 +9,7 @@ import os.path as op
import logging import logging
import sqlite3 as sqlite 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: class SqliteCache:

View File

@ -15,7 +15,7 @@ from hscommon.trans import tr
from hscommon.jobprogress import job from hscommon.jobprogress import job
from core.engine import Match from core.engine import Match
from .block import avgdiff, DifferentBlockCountError, NoBlocksError from core.pe.block import avgdiff, DifferentBlockCountError, NoBlocksError
# OPTIMIZATION NOTES: # OPTIMIZATION NOTES:
# The bottleneck of the matching phase is CPU, which is why we use multiprocessing. However, another # 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): def get_cache(cache_path, readonly=False):
if cache_path.endswith("shelve"): if cache_path.endswith("shelve"):
from .cache_shelve import ShelveCache from core.pe.cache_shelve import ShelveCache
return ShelveCache(cache_path, readonly=readonly) return ShelveCache(cache_path, readonly=readonly)
else: else:
from .cache_sqlite import SqliteCache from core.pe.cache_sqlite import SqliteCache
return SqliteCache(cache_path, readonly=readonly) return SqliteCache(cache_path, readonly=readonly)

View File

@ -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.util import format_timestamp, format_perc, format_dupe_count
from core import fs 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 # This global value is set by the platform-specific subclasser of the Photo base class
PLAT_SPECIFIC_PHOTO_CLASS = None PLAT_SPECIFIC_PHOTO_CLASS = None

View File

@ -8,7 +8,7 @@ from hscommon.trans import tr
from core.scanner import Scanner, ScanType, ScanOption from core.scanner import Scanner, ScanType, ScanOption
from . import matchblock, matchexif from core.pe import matchblock, matchexif
class ScannerPE(Scanner): class ScannerPE(Scanner):

View File

@ -17,8 +17,8 @@ from hscommon.conflict import get_conflicted_name
from hscommon.util import flatten, nonone, FileOrPath, format_size from hscommon.util import flatten, nonone, FileOrPath, format_size
from hscommon.trans import tr from hscommon.trans import tr
from . import engine from core import engine
from .markable import Markable from core.markable import Markable
class Results(Markable): class Results(Markable):

View File

@ -13,7 +13,7 @@ from hscommon.jobprogress import job
from hscommon.util import dedupe, rem_file_ext, get_file_ext from hscommon.util import dedupe, rem_file_ext, get_file_ext
from hscommon.trans import tr 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 # 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 # there will be some nasty bugs popping up (ScanType is used in core when in should exclusively be

View File

@ -1 +1 @@
from . import fs, result_table, scanner # noqa from core.se import fs, result_table, scanner # noqa

View File

@ -15,10 +15,10 @@ import hscommon.util
from hscommon.testutil import eq_, log_calls from hscommon.testutil import eq_, log_calls
from hscommon.jobprogress.job import Job from hscommon.jobprogress.job import Job
from .base import TestApp from core.tests.base import TestApp
from .results_test import GetTestGroups from core.tests.results_test import GetTestGroups
from .. import app, fs, engine from core import app, fs, engine
from ..scanner import ScanType from core.scanner import ScanType
def add_fake_files_to_directories(directories, files): def add_fake_files_to_directories(directories, files):

View File

@ -10,12 +10,11 @@ from hscommon.util import get_file_ext, format_size
from hscommon.gui.column import Column from hscommon.gui.column import Column
from hscommon.jobprogress.job import nulljob, JobCancelled from hscommon.jobprogress.job import nulljob, JobCancelled
from .. import engine from core import engine, prioritize
from .. import prioritize from core.engine import getwords
from ..engine import getwords from core.app import DupeGuru as DupeGuruBase
from ..app import DupeGuru as DupeGuruBase from core.gui.result_table import ResultTable as ResultTableBase
from ..gui.result_table import ResultTable as ResultTableBase from core.gui.prioritize_dialog import PrioritizeDialog
from ..gui.prioritize_dialog import PrioritizeDialog
class DupeGuruView: class DupeGuruView:

View File

@ -9,7 +9,7 @@ from pytest import raises, skip
from hscommon.testutil import eq_ from hscommon.testutil import eq_
try: try:
from ..pe.block import avgdiff, getblocks2, NoBlocksError, DifferentBlockCountError from core.pe.block import avgdiff, getblocks2, NoBlocksError, DifferentBlockCountError
except ImportError: except ImportError:
skip("Can't import the block module, probably hasn't been compiled.") skip("Can't import the block module, probably hasn't been compiled.")

View File

@ -10,9 +10,9 @@ from pytest import raises, skip
from hscommon.testutil import eq_ from hscommon.testutil import eq_
try: try:
from ..pe.cache import colors_to_string, string_to_colors from core.pe.cache import colors_to_string, string_to_colors
from ..pe.cache_sqlite import SqliteCache from core.pe.cache_sqlite import SqliteCache
from ..pe.cache_shelve import ShelveCache from core.pe.cache_shelve import ShelveCache
except ImportError: except ImportError:
skip("Can't import the cache module, probably hasn't been compiled.") skip("Can't import the cache module, probably hasn't been compiled.")

View File

@ -14,14 +14,14 @@ from pathlib import Path
from hscommon.testutil import eq_ from hscommon.testutil import eq_
from hscommon.plat import ISWINDOWS from hscommon.plat import ISWINDOWS
from ..fs import File from core.fs import File
from ..directories import ( from core.directories import (
Directories, Directories,
DirectoryState, DirectoryState,
AlreadyThereError, AlreadyThereError,
InvalidPathError, InvalidPathError,
) )
from ..exclude import ExcludeList, ExcludeDict from core.exclude import ExcludeList, ExcludeDict
def create_fake_fs(rootpath): def create_fake_fs(rootpath):

View File

@ -10,9 +10,9 @@ from hscommon.jobprogress import job
from hscommon.util import first from hscommon.util import first
from hscommon.testutil import eq_, log_calls from hscommon.testutil import eq_, log_calls
from .base import NamedObject from core.tests.base import NamedObject
from .. import engine from core import engine
from ..engine import ( from core.engine import (
get_match, get_match,
getwords, getwords,
Group, Group,

View File

@ -10,8 +10,8 @@ from xml.etree import ElementTree as ET
from hscommon.testutil import eq_ from hscommon.testutil import eq_
from hscommon.plat import ISWINDOWS from hscommon.plat import ISWINDOWS
from .base import DupeGuru from core.tests.base import DupeGuru
from ..exclude import ExcludeList, ExcludeDict, default_regexes, AlreadyThereException from core.exclude import ExcludeList, ExcludeDict, default_regexes, AlreadyThereException
from re import error from re import error

View File

@ -13,7 +13,7 @@ from pathlib import Path
from hscommon.testutil import eq_ from hscommon.testutil import eq_
from core.tests.directories_test import create_fake_fs from core.tests.directories_test import create_fake_fs
from .. import fs from core import fs
hasher: typing.Callable hasher: typing.Callable
try: try:

View File

@ -10,7 +10,7 @@ from xml.etree import ElementTree as ET
from pytest import raises from pytest import raises
from hscommon.testutil import eq_ from hscommon.testutil import eq_
from ..ignore import IgnoreList from core.ignore import IgnoreList
def test_empty(): def test_empty():

View File

@ -6,7 +6,7 @@
from hscommon.testutil import eq_ from hscommon.testutil import eq_
from ..markable import MarkableList, Markable from core.markable import MarkableList, Markable
def gen(): def gen():

View File

@ -9,8 +9,8 @@
import os.path as op import os.path as op
from itertools import combinations from itertools import combinations
from .base import TestApp, NamedObject, with_app, eq_ from core.tests.base import TestApp, NamedObject, with_app, eq_
from ..engine import Group, Match from core.engine import Group, Match
no = NamedObject no = NamedObject

View File

@ -6,7 +6,7 @@
# which should be included with this package. The terms are also available at # which should be included with this package. The terms are also available at
# http://www.gnu.org/licenses/gpl-3.0.html # 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(): def app_with_results():

View File

@ -12,10 +12,9 @@ from xml.etree import ElementTree as ET
from pytest import raises from pytest import raises
from hscommon.testutil import eq_ from hscommon.testutil import eq_
from hscommon.util import first from hscommon.util import first
from core import engine
from .. import engine from core.tests.base import NamedObject, GetTestGroups, DupeGuru
from .base import NamedObject, GetTestGroups, DupeGuru from core.results import Results
from ..results import Results
class TestCaseResultsEmpty: class TestCaseResultsEmpty:

View File

@ -10,11 +10,11 @@ from hscommon.jobprogress import job
from pathlib import Path from pathlib import Path
from hscommon.testutil import eq_ from hscommon.testutil import eq_
from .. import fs from core import fs
from ..engine import getwords, Match from core.engine import getwords, Match
from ..ignore import IgnoreList from core.ignore import IgnoreList
from ..scanner import Scanner, ScanType from core.scanner import Scanner, ScanType
from ..me.scanner import ScannerME from core.me.scanner import ScannerME
class NamedObject: class NamedObject:

View File

@ -21,7 +21,7 @@ import importlib
from datetime import datetime from datetime import datetime
import glob import glob
from .plat import ISWINDOWS from hscommon.plat import ISWINDOWS
def print_and_do(cmd): def print_and_do(cmd):

View File

@ -8,7 +8,7 @@
import copy import copy
from .base import GUIObject from hscommon.gui.base import GUIObject
class Column: class Column:

View File

@ -4,9 +4,9 @@
# which should be included with this package. The terms are also available at # which should be included with this package. The terms are also available at
# http://www.gnu.org/licenses/gpl-3.0.html # http://www.gnu.org/licenses/gpl-3.0.html
from ..jobprogress.performer import ThreadedJobPerformer from hscommon.jobprogress.performer import ThreadedJobPerformer
from .base import GUIObject from hscommon.gui.base import GUIObject
from .text_field import TextField from hscommon.gui.text_field import TextField
class ProgressWindowView: class ProgressWindowView:

View File

@ -8,7 +8,7 @@
from collections.abc import Sequence, MutableSequence from collections.abc import Sequence, MutableSequence
from .base import GUIObject from hscommon.gui.base import GUIObject
class Selectable(Sequence): class Selectable(Sequence):

View File

@ -9,8 +9,8 @@
from collections.abc import MutableSequence from collections.abc import MutableSequence
from collections import namedtuple from collections import namedtuple
from .base import GUIObject from hscommon.gui.base import GUIObject
from .selectable_list import Selectable from hscommon.gui.selectable_list import Selectable
# We used to directly subclass list, but it caused problems at some point with deepcopy # We used to directly subclass list, but it caused problems at some point with deepcopy

View File

@ -5,8 +5,8 @@
# which should be included with this package. The terms are also available at # which should be included with this package. The terms are also available at
# http://www.gnu.org/licenses/gpl-3.0.html # http://www.gnu.org/licenses/gpl-3.0.html
from .base import GUIObject from hscommon.gui.base import GUIObject
from ..util import nonone from hscommon.util import nonone
class TextFieldView: class TextFieldView:

View File

@ -6,7 +6,7 @@
from collections.abc import MutableSequence from collections.abc import MutableSequence
from .base import GUIObject from hscommon.gui.base import GUIObject
class Node(MutableSequence): class Node(MutableSequence):

View File

@ -9,7 +9,7 @@
from threading import Thread from threading import Thread
import sys import sys
from .job import Job, JobInProgressError, JobCancelled from hscommon.jobprogress.job import Job, JobInProgressError, JobCancelled
class ThreadedJobPerformer: class ThreadedJobPerformer:

View File

@ -5,21 +5,10 @@ import tempfile
import polib import polib
from . import pygettext from hscommon import pygettext
LC_MESSAGES = "LC_MESSAGES" 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): def get_langs(folder):
return [name for name in os.listdir(folder) if op.isdir(op.join(folder, name))] return [name for name in os.listdir(folder) if op.isdir(op.join(folder, name))]

View File

@ -7,7 +7,7 @@
from pathlib import Path from pathlib import Path
import re 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 from sphinx.cmd.build import build_main as sphinx_build
CHANGELOG_FORMAT = """ CHANGELOG_FORMAT = """

View File

@ -8,7 +8,7 @@
import pytest import pytest
from ..conflict import ( from hscommon.conflict import (
get_conflicted_name, get_conflicted_name,
get_unconflicted_name, get_unconflicted_name,
is_conflicted, is_conflicted,
@ -16,7 +16,7 @@ from ..conflict import (
smart_move, smart_move,
) )
from pathlib import Path from pathlib import Path
from ..testutil import eq_ from hscommon.testutil import eq_
class TestCaseGetConflictedName: class TestCaseGetConflictedName:

View File

@ -4,8 +4,8 @@
# which should be included with this package. The terms are also available at # which should be included with this package. The terms are also available at
# http://www.gnu.org/licenses/gpl-3.0.html # http://www.gnu.org/licenses/gpl-3.0.html
from ..testutil import eq_ from hscommon.testutil import eq_
from ..notify import Broadcaster, Listener, Repeater from hscommon.notify import Broadcaster, Listener, Repeater
class HelloListener(Listener): class HelloListener(Listener):

View File

@ -6,7 +6,7 @@
# which should be included with this package. The terms are also available at # which should be included with this package. The terms are also available at
# http://www.gnu.org/licenses/gpl-3.0.html # http://www.gnu.org/licenses/gpl-3.0.html
from ..path import pathify from hscommon.path import pathify
from pathlib import Path from pathlib import Path

View File

@ -6,8 +6,8 @@
# which should be included with this package. The terms are also available at # which should be included with this package. The terms are also available at
# http://www.gnu.org/licenses/gpl-3.0.html # http://www.gnu.org/licenses/gpl-3.0.html
from ..testutil import eq_, callcounter, CallLogger from hscommon.testutil import eq_, callcounter, CallLogger
from ..gui.selectable_list import SelectableList, GUISelectableList from hscommon.gui.selectable_list import SelectableList, GUISelectableList
def test_in(): def test_in():

View File

@ -13,8 +13,8 @@ import sqlite3 as sqlite
from pytest import raises from pytest import raises
from ..testutil import eq_ from hscommon.testutil import eq_
from ..sqlite import ThreadedConn from hscommon.sqlite import ThreadedConn
# Threading is hard to test. In a lot of those tests, a failure means that the test run will # 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. # hang forever. Well... I don't know a better alternative.

View File

@ -6,8 +6,8 @@
# which should be included with this package. The terms are also available at # which should be included with this package. The terms are also available at
# http://www.gnu.org/licenses/gpl-3.0.html # http://www.gnu.org/licenses/gpl-3.0.html
from ..testutil import CallLogger, eq_ from hscommon.testutil import CallLogger, eq_
from ..gui.table import Table, GUITable, Row from hscommon.gui.table import Table, GUITable, Row
class TestRow(Row): class TestRow(Row):

View File

@ -6,8 +6,8 @@
# which should be included with this package. The terms are also available at # which should be included with this package. The terms are also available at
# http://www.gnu.org/licenses/gpl-3.0.html # http://www.gnu.org/licenses/gpl-3.0.html
from ..testutil import eq_ from hscommon.testutil import eq_
from ..gui.tree import Tree, Node from hscommon.gui.tree import Tree, Node
def tree_with_some_nodes(): def tree_with_some_nodes():

View File

@ -10,9 +10,9 @@ from io import StringIO
from pytest import raises from pytest import raises
from ..testutil import eq_ from hscommon.testutil import eq_
from pathlib import Path from pathlib import Path
from ..util import ( from hscommon.util import (
nonone, nonone,
tryint, tryint,
first, first,

View File

@ -8,28 +8,12 @@
import pytest import pytest
import threading
import py.path
def eq_(a, b, msg=None): def eq_(a, b, msg=None):
__tracebackhide__ = True __tracebackhide__ = True
assert a == b, msg or "{!r} != {!r}".format(a, b) 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 callcounter():
def f(*args, **kwargs): def f(*args, **kwargs):
f.callcount += 1 f.callcount += 1
@ -38,23 +22,6 @@ def callcounter():
return f 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: class CallLogger:
"""This is a dummy object that logs all calls made to it. """This is a dummy object that logs all calls made to it.
@ -168,20 +135,6 @@ def app(request):
return app 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): def _unify_args(func, args, kwargs, args_to_ignore=None):
"""Unify args and kwargs in the same dictionary. """Unify args and kwargs in the same dictionary.

View File

@ -13,7 +13,7 @@ import locale
import logging import logging
import os.path as op import os.path as op
from .plat import ISLINUX from hscommon.plat import ISLINUX
_trfunc = None _trfunc = None
_trget = None _trget = None

View File

@ -8,7 +8,7 @@
from math import ceil from math import ceil
from pathlib import Path 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 from typing import IO, Any, Callable, Generator, Iterable, List, Tuple, Union

View File

@ -21,22 +21,22 @@ from qt.progress_window import ProgressWindow
from core.app import AppMode, DupeGuru as DupeGuruModel from core.app import AppMode, DupeGuru as DupeGuruModel
import core.pe.photo import core.pe.photo
from . import platform from qt import platform
from .preferences import Preferences from qt.preferences import Preferences
from .result_window import ResultWindow from qt.result_window import ResultWindow
from .directories_dialog import DirectoriesDialog from qt.directories_dialog import DirectoriesDialog
from .problem_dialog import ProblemDialog from qt.problem_dialog import ProblemDialog
from .ignore_list_dialog import IgnoreListDialog from qt.ignore_list_dialog import IgnoreListDialog
from .exclude_list_dialog import ExcludeListDialog from qt.exclude_list_dialog import ExcludeListDialog
from .deletion_options import DeletionOptions from qt.deletion_options import DeletionOptions
from .se.details_dialog import DetailsDialog as DetailsDialogStandard from qt.se.details_dialog import DetailsDialog as DetailsDialogStandard
from .me.details_dialog import DetailsDialog as DetailsDialogMusic from qt.me.details_dialog import DetailsDialog as DetailsDialogMusic
from .pe.details_dialog import DetailsDialog as DetailsDialogPicture from qt.pe.details_dialog import DetailsDialog as DetailsDialogPicture
from .se.preferences_dialog import PreferencesDialog as PreferencesDialogStandard from qt.se.preferences_dialog import PreferencesDialog as PreferencesDialogStandard
from .me.preferences_dialog import PreferencesDialog as PreferencesDialogMusic from qt.me.preferences_dialog import PreferencesDialog as PreferencesDialogMusic
from .pe.preferences_dialog import PreferencesDialog as PreferencesDialogPicture from qt.pe.preferences_dialog import PreferencesDialog as PreferencesDialogPicture
from .pe.photo import File as PlatSpecificPhoto from qt.pe.photo import File as PlatSpecificPhoto
from .tabbed_window import TabBarWindow, TabWindow from qt.tabbed_window import TabBarWindow, TabWindow
tr = trget("ui") tr = trget("ui")

View File

@ -10,7 +10,7 @@ from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QDockWidget, QWidget from PyQt5.QtWidgets import QDockWidget, QWidget
from qt.util import move_to_screen_center from qt.util import move_to_screen_center
from .details_table import DetailsModel from qt.details_table import DetailsModel
from hscommon.plat import ISLINUX from hscommon.plat import ISLINUX

View File

@ -31,8 +31,8 @@ from qt.radio_box import RadioBox
from qt.recent import Recent from qt.recent import Recent
from qt.util import move_to_screen_center, create_actions from qt.util import move_to_screen_center, create_actions
from . import platform from qt import platform
from .directories_model import DirectoriesModel, DirectoriesDelegate from qt.directories_model import DirectoriesModel, DirectoriesDelegate
tr = trget("ui") tr = trget("ui")

View File

@ -16,7 +16,7 @@ from PyQt5.QtWidgets import (
QSizePolicy, QSizePolicy,
QHeaderView, QHeaderView,
) )
from .exclude_list_table import ExcludeListTable from qt.exclude_list_table import ExcludeListTable
from core.exclude import AlreadyThereException from core.exclude import AlreadyThereException
from hscommon.trans import trget from hscommon.trans import trget

View File

@ -17,7 +17,7 @@ from PyQt5.QtWidgets import (
from hscommon.trans import trget from hscommon.trans import trget
from qt.util import horizontal_wrap from qt.util import horizontal_wrap
from .ignore_list_table import IgnoreListTable from qt.ignore_list_table import IgnoreListTable
tr = trget("ui") tr = trget("ui")

View File

@ -8,8 +8,8 @@ from PyQt5.QtCore import QSize
from PyQt5.QtWidgets import QAbstractItemView from PyQt5.QtWidgets import QAbstractItemView
from hscommon.trans import trget from hscommon.trans import trget
from ..details_dialog import DetailsDialog as DetailsDialogBase from qt.details_dialog import DetailsDialog as DetailsDialogBase
from ..details_table import DetailsTable from qt.details_table import DetailsTable
tr = trget("ui") tr = trget("ui")

View File

@ -18,7 +18,7 @@ from hscommon.trans import trget
from core.app import AppMode from core.app import AppMode
from core.scanner import ScanType from core.scanner import ScanType
from ..preferences_dialog import PreferencesDialogBase from qt.preferences_dialog import PreferencesDialogBase
tr = trget("ui") tr = trget("ui")

View File

@ -5,7 +5,7 @@
# http://www.gnu.org/licenses/gpl-3.0.html # http://www.gnu.org/licenses/gpl-3.0.html
from qt.column import Column from qt.column import Column
from ..results_model import ResultsModel as ResultsModelBase from qt.results_model import ResultsModel as ResultsModelBase
class ResultsModel(ResultsModelBase): class ResultsModel(ResultsModelBase):

View File

@ -6,7 +6,7 @@
# which should be included with this package. The terms are also available at # which should be included with this package. The terms are also available at
# http://www.gnu.org/licenses/gpl-3.0.html # 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 # Converted to C
# def getblock(image): # def getblock(image):

View File

@ -8,9 +8,9 @@ from PyQt5.QtCore import Qt, QSize, pyqtSignal, pyqtSlot
from PyQt5.QtWidgets import QAbstractItemView, QSizePolicy, QGridLayout, QSplitter, QFrame from PyQt5.QtWidgets import QAbstractItemView, QSizePolicy, QGridLayout, QSplitter, QFrame
from PyQt5.QtGui import QResizeEvent from PyQt5.QtGui import QResizeEvent
from hscommon.trans import trget from hscommon.trans import trget
from ..details_dialog import DetailsDialog as DetailsDialogBase from qt.details_dialog import DetailsDialog as DetailsDialogBase
from ..details_table import DetailsTable from qt.details_table import DetailsTable
from .image_viewer import ViewerToolBar, ScrollAreaImageViewer, ScrollAreaController from qt.pe.image_viewer import ViewerToolBar, ScrollAreaImageViewer, ScrollAreaController
tr = trget("ui") tr = trget("ui")

View File

@ -10,7 +10,7 @@ from PyQt5.QtGui import QImage, QImageReader, QTransform
from core.pe.photo import Photo as PhotoBase from core.pe.photo import Photo as PhotoBase
from .block import getblocks from qt.pe.block import getblocks
class File(PhotoBase): class File(PhotoBase):

View File

@ -12,7 +12,7 @@ from qt.radio_box import RadioBox
from core.scanner import ScanType from core.scanner import ScanType
from core.app import AppMode from core.app import AppMode
from ..preferences_dialog import PreferencesDialogBase from qt.preferences_dialog import PreferencesDialogBase
tr = trget("ui") tr = trget("ui")

View File

@ -5,7 +5,7 @@
# http://www.gnu.org/licenses/gpl-3.0.html # http://www.gnu.org/licenses/gpl-3.0.html
from qt.column import Column from qt.column import Column
from ..results_model import ResultsModel as ResultsModelBase from qt.results_model import ResultsModel as ResultsModelBase
class ResultsModel(ResultsModelBase): class ResultsModel(ResultsModelBase):

View File

@ -37,7 +37,7 @@ from qt.util import horizontal_wrap, move_to_screen_center
from qt.preferences import get_langnames from qt.preferences import get_langnames
from enum import Flag, auto from enum import Flag, auto
from .preferences import Preferences from qt.preferences import Preferences
tr = trget("ui") tr = trget("ui")

View File

@ -21,7 +21,7 @@ from PyQt5.QtWidgets import (
from qt.util import move_to_screen_center from qt.util import move_to_screen_center
from hscommon.trans import trget from hscommon.trans import trget
from .problem_table import ProblemTable from qt.problem_table import ProblemTable
tr = trget("ui") tr = trget("ui")

View File

@ -28,12 +28,12 @@ from qt.util import move_to_screen_center, horizontal_wrap, create_actions
from qt.search_edit import SearchEdit from qt.search_edit import SearchEdit
from core.app import AppMode from core.app import AppMode
from .results_model import ResultsView from qt.results_model import ResultsView
from .stats_label import StatsLabel from qt.stats_label import StatsLabel
from .prioritize_dialog import PrioritizeDialog from qt.prioritize_dialog import PrioritizeDialog
from .se.results_model import ResultsModel as ResultsModelStandard from qt.se.results_model import ResultsModel as ResultsModelStandard
from .me.results_model import ResultsModel as ResultsModelMusic from qt.me.results_model import ResultsModel as ResultsModelMusic
from .pe.results_model import ResultsModel as ResultsModelPicture from qt.pe.results_model import ResultsModel as ResultsModelPicture
tr = trget("ui") tr = trget("ui")

View File

@ -8,8 +8,8 @@ from PyQt5.QtCore import QSize
from PyQt5.QtWidgets import QAbstractItemView from PyQt5.QtWidgets import QAbstractItemView
from hscommon.trans import trget from hscommon.trans import trget
from ..details_dialog import DetailsDialog as DetailsDialogBase from qt.details_dialog import DetailsDialog as DetailsDialogBase
from ..details_table import DetailsTable from qt.details_table import DetailsTable
tr = trget("ui") tr = trget("ui")

View File

@ -20,7 +20,7 @@ from hscommon.trans import trget
from core.app import AppMode from core.app import AppMode
from core.scanner import ScanType from core.scanner import ScanType
from ..preferences_dialog import PreferencesDialogBase from qt.preferences_dialog import PreferencesDialogBase
tr = trget("ui") tr = trget("ui")

View File

@ -5,7 +5,7 @@
# http://www.gnu.org/licenses/gpl-3.0.html # http://www.gnu.org/licenses/gpl-3.0.html
from qt.column import Column from qt.column import Column
from ..results_model import ResultsModel as ResultsModelBase from qt.results_model import ResultsModel as ResultsModelBase
class ResultsModel(ResultsModelBase): class ResultsModel(ResultsModelBase):

View File

@ -15,10 +15,10 @@ from PyQt5.QtWidgets import (
) )
from hscommon.trans import trget from hscommon.trans import trget
from qt.util import move_to_screen_center, create_actions from qt.util import move_to_screen_center, create_actions
from .directories_dialog import DirectoriesDialog from qt.directories_dialog import DirectoriesDialog
from .result_window import ResultWindow from qt.result_window import ResultWindow
from .ignore_list_dialog import IgnoreListDialog from qt.ignore_list_dialog import IgnoreListDialog
from .exclude_list_dialog import ExcludeListDialog from qt.exclude_list_dialog import ExcludeListDialog
tr = trget("ui") tr = trget("ui")

View File

@ -15,7 +15,7 @@ from PyQt5.QtCore import (
QItemSelection, QItemSelection,
) )
from .column import Columns, Column from qt.column import Columns, Column
class Table(QAbstractTableModel): class Table(QAbstractTableModel):