diff --git a/build.py b/build.py index 6f74c349..56a0584e 100644 --- a/build.py +++ b/build.py @@ -113,7 +113,7 @@ def build_xibless(dest='cocoa/autogen'): def build_cocoa(dev): print("Creating OS X app structure") app = cocoa_app() - app_version = get_module_version('core_se') + app_version = get_module_version('core') cocoa_project_path = 'cocoa/se' filereplace(op.join(cocoa_project_path, 'InfoTemplate.plist'), op.join('build', 'Info.plist'), version=app_version) app.create(op.join('build', 'Info.plist')) @@ -133,8 +133,7 @@ def build_cocoa(dev): shutil.copy(op.join(cocoa_project_path, 'dg_cocoa.py'), 'build') appscript_pkgs = ['appscript', 'aem', 'mactypes', 'osax'] tocopy = [ - 'core', 'core_se', 'core_me', 'core_pe', 'hscommon', 'cocoa/inter', 'cocoalib/cocoa', - 'objp', 'send2trash', 'hsaudiotag', + 'core', 'hscommon', 'cocoa/inter', 'cocoalib/cocoa', 'objp', 'send2trash', 'hsaudiotag', ] + appscript_pkgs copy_packages(tocopy, pydep_folder, create_links=dev) sys.path.insert(0, 'build') @@ -217,10 +216,9 @@ def build_updatepot(): loc.generate_cocoa_strings_from_code('cocoa', 'cocoa/base/en.lproj') print("Building .pot files from source files") print("Building core.pot") - all_cores = ['core', 'core_se', 'core_me', 'core_pe'] - loc.generate_pot(all_cores, op.join('locale', 'core.pot'), ['tr']) + loc.generate_pot(['core'], op.join('locale', 'core.pot'), ['tr']) print("Building columns.pot") - loc.generate_pot(all_cores, op.join('locale', 'columns.pot'), ['coltr']) + loc.generate_pot(['core'], op.join('locale', 'columns.pot'), ['coltr']) print("Building ui.pot") # When we're not under OS X, we don't want to overwrite ui.pot because it contains Cocoa locs # We want to merge the generated pot with the old pot in the most preserving way possible. @@ -307,14 +305,21 @@ def build_cocoa_bridging_interfaces(): def build_pe_modules(ui): print("Building PE Modules") exts = [ - Extension("_block", [op.join('core_pe', 'modules', 'block.c'), op.join('core_pe', 'modules', 'common.c')]), - Extension("_cache", [op.join('core_pe', 'modules', 'cache.c'), op.join('core_pe', 'modules', 'common.c')]), + Extension( + "_block", + [op.join('core', 'pe', 'modules', 'block.c'), op.join('core', 'pe', 'modules', 'common.c')] + ), + Extension( + "_cache", + [op.join('core', 'pe', 'modules', 'cache.c'), op.join('core', 'pe', 'modules', 'common.c')] + ), ] if ui == 'qt': exts.append(Extension("_block_qt", [op.join('qt', 'pe', 'modules', 'block.c')])) elif ui == 'cocoa': exts.append(Extension( - "_block_osx", [op.join('core_pe', 'modules', 'block_osx.m'), op.join('core_pe', 'modules', 'common.c')], + "_block_osx", + [op.join('core', 'pe', 'modules', 'block_osx.m'), op.join('core', 'pe', 'modules', 'common.c')], extra_link_args=[ "-framework", "CoreFoundation", "-framework", "Foundation", @@ -326,8 +331,8 @@ def build_pe_modules(ui): ext_modules=exts, ) move_all('_block_qt*', op.join('qt', 'pe')) - move_all('_block*', 'core_pe') - move_all('_cache*', 'core_pe') + move_all('_block*', op.join('core', 'pe')) + move_all('_cache*', op.join('core', 'pe')) def build_normal(ui, dev): print("Building dupeGuru with UI {}".format(ui)) diff --git a/core/app.py b/core/app.py index abcf163d..a5fcedde 100644 --- a/core/app.py +++ b/core/app.py @@ -21,18 +21,8 @@ from hscommon.util import delete_if_empty, first, escape, nonone, allsame from hscommon.trans import tr from hscommon import desktop -import core_se.fs -import core_se.result_table -import core_se.scanner -import core_me.fs -import core_me.prioritize -import core_me.result_table -import core_me.scanner -import core_pe.photo -import core_pe.prioritize -import core_pe.result_table -import core_pe.scanner -from core_pe.photo import get_delta_dimensions +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 @@ -166,11 +156,11 @@ class DupeGuru(Broadcaster): #--- Private def _create_result_table(self): if self.app_mode == AppMode.Picture: - return core_pe.result_table.ResultTable(self) + return pe.result_table.ResultTable(self) elif self.app_mode == AppMode.Music: - return core_me.result_table.ResultTable(self) + return me.result_table.ResultTable(self) else: - return core_se.result_table.ResultTable(self) + return se.result_table.ResultTable(self) def _get_dupe_sort_key(self, dupe, get_group, key, delta): if self.app_mode in (AppMode.Music, AppMode.Picture): @@ -335,9 +325,9 @@ class DupeGuru(Broadcaster): #--- Protected def _prioritization_categories(self): if self.app_mode == AppMode.Picture: - return core_pe.prioritize.all_categories() + return pe.prioritize.all_categories() elif self.app_mode == AppMode.Music: - return core_me.prioritize.all_categories() + return me.prioritize.all_categories() else: return prioritize.all_categories() @@ -393,8 +383,7 @@ class DupeGuru(Broadcaster): path = path.parent() def clear_picture_cache(self): - from core_pe.cache import Cache - cache = Cache(self.options['cache_path']) + cache = pe.cache.Cache(self.options['cache_path']) cache.clear() cache.close() @@ -754,7 +743,7 @@ class DupeGuru(Broadcaster): def do(j): j.set_progress(0, tr("Collecting files to scan")) if scanner.scan_type == ScanType.Folders: - files = list(self.directories.get_folders(folderclass=core_se.fs.folder, j=j)) + files = list(self.directories.get_folders(folderclass=se.fs.folder, j=j)) else: files = list(self.directories.get_files(fileclasses=self.fileclasses, j=j)) if self.options['ignore_hardlink_matches']: @@ -806,20 +795,20 @@ class DupeGuru(Broadcaster): @property def fileclasses(self): if self.app_mode == AppMode.Picture: - return [core_pe.photo.PLAT_SPECIFIC_PHOTO_CLASS] + return [pe.photo.PLAT_SPECIFIC_PHOTO_CLASS] elif self.app_mode == AppMode.Music: - return [core_me.fs.MusicFile] + return [me.fs.MusicFile] else: - return [core_se.fs.File] + return [se.fs.File] @property def SCANNER_CLASS(self): if self.app_mode == AppMode.Picture: - return core_pe.scanner.ScannerPE + return pe.scanner.ScannerPE elif self.app_mode == AppMode.Music: - return core_me.scanner.ScannerME + return me.scanner.ScannerME else: - return core_se.scanner.ScannerSE + return se.scanner.ScannerSE @property def METADATA_TO_READ(self): diff --git a/core/me/__init__.py b/core/me/__init__.py new file mode 100644 index 00000000..03f4e58c --- /dev/null +++ b/core/me/__init__.py @@ -0,0 +1 @@ +from . import fs, prioritize, result_table, scanner # noqa diff --git a/core_me/fs.py b/core/me/fs.py similarity index 100% rename from core_me/fs.py rename to core/me/fs.py diff --git a/core_me/prioritize.py b/core/me/prioritize.py similarity index 100% rename from core_me/prioritize.py rename to core/me/prioritize.py diff --git a/core_me/result_table.py b/core/me/result_table.py similarity index 100% rename from core_me/result_table.py rename to core/me/result_table.py diff --git a/core_me/scanner.py b/core/me/scanner.py similarity index 100% rename from core_me/scanner.py rename to core/me/scanner.py diff --git a/core/pe/__init__.py b/core/pe/__init__.py new file mode 100644 index 00000000..9cac7a5f --- /dev/null +++ b/core/pe/__init__.py @@ -0,0 +1 @@ +from . import block, cache, exif, iphoto_plist, matchblock, matchexif, photo, prioritize, result_table, scanner # noqa diff --git a/core_pe/block.py b/core/pe/block.py similarity index 100% rename from core_pe/block.py rename to core/pe/block.py diff --git a/core_pe/cache.py b/core/pe/cache.py similarity index 100% rename from core_pe/cache.py rename to core/pe/cache.py diff --git a/core_pe/exif.py b/core/pe/exif.py similarity index 100% rename from core_pe/exif.py rename to core/pe/exif.py diff --git a/core_pe/iphoto_plist.py b/core/pe/iphoto_plist.py similarity index 100% rename from core_pe/iphoto_plist.py rename to core/pe/iphoto_plist.py diff --git a/core_pe/matchblock.py b/core/pe/matchblock.py similarity index 100% rename from core_pe/matchblock.py rename to core/pe/matchblock.py diff --git a/core_pe/matchexif.py b/core/pe/matchexif.py similarity index 100% rename from core_pe/matchexif.py rename to core/pe/matchexif.py diff --git a/core_pe/modules/block.c b/core/pe/modules/block.c similarity index 100% rename from core_pe/modules/block.c rename to core/pe/modules/block.c diff --git a/core_pe/modules/block_osx.m b/core/pe/modules/block_osx.m similarity index 100% rename from core_pe/modules/block_osx.m rename to core/pe/modules/block_osx.m diff --git a/core_pe/modules/cache.c b/core/pe/modules/cache.c similarity index 100% rename from core_pe/modules/cache.c rename to core/pe/modules/cache.c diff --git a/core_pe/modules/common.c b/core/pe/modules/common.c similarity index 100% rename from core_pe/modules/common.c rename to core/pe/modules/common.c diff --git a/core_pe/modules/common.h b/core/pe/modules/common.h similarity index 100% rename from core_pe/modules/common.h rename to core/pe/modules/common.h diff --git a/core_pe/photo.py b/core/pe/photo.py similarity index 100% rename from core_pe/photo.py rename to core/pe/photo.py diff --git a/core_pe/prioritize.py b/core/pe/prioritize.py similarity index 100% rename from core_pe/prioritize.py rename to core/pe/prioritize.py diff --git a/core_pe/result_table.py b/core/pe/result_table.py similarity index 100% rename from core_pe/result_table.py rename to core/pe/result_table.py diff --git a/core_pe/scanner.py b/core/pe/scanner.py similarity index 100% rename from core_pe/scanner.py rename to core/pe/scanner.py diff --git a/core/se/__init__.py b/core/se/__init__.py new file mode 100644 index 00000000..b627d223 --- /dev/null +++ b/core/se/__init__.py @@ -0,0 +1 @@ +from . import fs, result_table, scanner # noqa diff --git a/core_se/fs.py b/core/se/fs.py similarity index 100% rename from core_se/fs.py rename to core/se/fs.py diff --git a/core_se/result_table.py b/core/se/result_table.py similarity index 100% rename from core_se/result_table.py rename to core/se/result_table.py diff --git a/core_se/scanner.py b/core/se/scanner.py similarity index 100% rename from core_se/scanner.py rename to core/se/scanner.py diff --git a/core_pe/tests/block_test.py b/core/tests/block_test.py similarity index 99% rename from core_pe/tests/block_test.py rename to core/tests/block_test.py index d281d518..187e9129 100644 --- a/core_pe/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 ..block import avgdiff, getblocks2, NoBlocksError, DifferentBlockCountError + from ..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_pe/tests/cache_test.py b/core/tests/cache_test.py similarity index 98% rename from core_pe/tests/cache_test.py rename to core/tests/cache_test.py index 4c06ba26..3dbcd16d 100644 --- a/core_pe/tests/cache_test.py +++ b/core/tests/cache_test.py @@ -10,7 +10,7 @@ from pytest import raises, skip from hscommon.testutil import eq_ try: - from ..cache import Cache, colors_to_string, string_to_colors + from ..pe.cache import Cache, colors_to_string, string_to_colors except ImportError: skip("Can't import the cache module, probably hasn't been compiled.") diff --git a/core/tests/scanner_test.py b/core/tests/scanner_test.py index 04d1de77..dc1e8998 100644 --- a/core/tests/scanner_test.py +++ b/core/tests/scanner_test.py @@ -12,6 +12,7 @@ from .. import fs from ..engine import getwords, Match from ..ignore import IgnoreList from ..scanner import Scanner, ScanType +from ..me.scanner import ScannerME class NamedObject: def __init__(self, name="foobar", size=1, path=None): @@ -528,3 +529,13 @@ def test_dont_count_ref_files_as_discarded(fake_fileexists): o2.is_ref = True eq_(len(s.get_dupe_groups([o1, o2, o3])), 1) eq_(s.discarded_file_count, 0) + +def test_priorize_me(fake_fileexists): + # in ScannerME, bitrate goes first (right after is_ref) in priorization + s = ScannerME() + o1, o2 = no('foo', path='p1'), no('foo', path='p2') + o1.bitrate = 1 + o2.bitrate = 2 + [group] = s.get_dupe_groups([o1, o2]) + assert group.ref is o2 + diff --git a/core_me/__init__.py b/core_me/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/core_me/tests/__init__.py b/core_me/tests/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/core_me/tests/scanner_test.py b/core_me/tests/scanner_test.py deleted file mode 100644 index 609570b6..00000000 --- a/core_me/tests/scanner_test.py +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright 2016 Hardcoded Software (http://www.hardcoded.net) -# -# This software is licensed under the "GPLv3" License as described in the "LICENSE" file, -# which should be included with this package. The terms are also available at -# http://www.gnu.org/licenses/gpl-3.0.html - -from hscommon.path import Path - -from core.tests.scanner_test import no -from ..scanner import ScannerME - -def pytest_funcarg__fake_fileexists(request): - # This is a hack to avoid invalidating all previous tests since the scanner started to test - # for file existence before doing the match grouping. - monkeypatch = request.getfuncargvalue('monkeypatch') - monkeypatch.setattr(Path, 'exists', lambda _: True) - -def test_priorize_me(fake_fileexists): - # in ScannerME, bitrate goes first (right after is_ref) in priorization - s = ScannerME() - o1, o2 = no('foo', path='p1'), no('foo', path='p2') - o1.bitrate = 1 - o2.bitrate = 2 - [group] = s.get_dupe_groups([o1, o2]) - assert group.ref is o2 - diff --git a/core_pe/__init__.py b/core_pe/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/core_pe/tests/__init__.py b/core_pe/tests/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/core_se/__init__.py b/core_se/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/package.py b/package.py index 6a9253b0..84473884 100644 --- a/package.py +++ b/package.py @@ -44,17 +44,16 @@ def copy_files_to_package(destpath, packages, with_so): compileall.compile_dir(destpath) def package_debian_distribution(distribution): - app_version = get_module_version('core_se') + app_version = get_module_version('core') version = '{}~{}'.format(app_version, distribution) destpath = op.join('build', 'dupeguru-{}'.format(version)) srcpath = op.join(destpath, 'src') packages = [ - 'hscommon', 'core', 'core_se', 'core_me', 'core_pe', 'qtlib', 'qt', 'send2trash', - 'hsaudiotag' + 'hscommon', 'core', 'qtlib', 'qt', 'send2trash', 'hsaudiotag' ] copy_files_to_package(srcpath, packages, with_so=False) os.mkdir(op.join(destpath, 'modules')) - copy_all(op.join('core_pe', 'modules', '*.*'), op.join(destpath, 'modules')) + copy_all(op.join('core', 'pe', 'modules', '*.*'), op.join(destpath, 'modules')) copy(op.join('qt', 'pe', 'modules', 'block.c'), op.join(destpath, 'modules', 'block_qt.c')) copy(op.join('pkg', 'debian', 'build_pe_modules.py'), op.join(destpath, 'build_pe_modules.py')) debdest = op.join(destpath, 'debian') @@ -92,8 +91,7 @@ def package_arch(): print("Packaging for Arch") srcpath = op.join('build', 'dupeguru-arch') packages = [ - 'hscommon', 'core', 'core_se', 'core_me', 'core_pe', 'qtlib', 'qt', 'send2trash', - 'hsaudiotag', + 'hscommon', 'core', 'qtlib', 'qt', 'send2trash', 'hsaudiotag', ] copy_files_to_package(srcpath, packages, with_so=True) shutil.copy(op.join('images', 'dgse_logo_128.png'), srcpath) @@ -105,7 +103,7 @@ def package_source_tgz(): print("Downloading PyPI dependencies") print_and_do('./download_deps.sh') print("Creating git archive") - app_version = get_module_version('core_se') + app_version = get_module_version('core') name = 'dupeguru-src-{}.tar'.format(app_version) dest = op.join('build', name) print_and_do('git archive -o {} HEAD'.format(dest)) diff --git a/qt/app.py b/qt/app.py index 077c8034..aa2a382b 100644 --- a/qt/app.py +++ b/qt/app.py @@ -20,7 +20,7 @@ from qtlib.util import createActions from qtlib.progress_window import ProgressWindow from core.app import AppMode, DupeGuru as DupeGuruModel -import core_pe.photo +import core.pe.photo from . import platform from .preferences import Preferences from .result_window import ResultWindow @@ -51,7 +51,7 @@ class DupeGuru(QObject): #--- Private def _setup(self): - core_pe.photo.PLAT_SPECIFIC_PHOTO_CLASS = PlatSpecificPhoto + core.pe.photo.PLAT_SPECIFIC_PHOTO_CLASS = PlatSpecificPhoto self._setupActions() self._update_options() self.recentResults = Recent(self, 'recentResults') diff --git a/qt/pe/photo.py b/qt/pe/photo.py index 16caf338..da1b2d93 100644 --- a/qt/pe/photo.py +++ b/qt/pe/photo.py @@ -8,7 +8,7 @@ import logging 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