Merge core_{se,me,pe} into core.{se,me,pe}

This commit is contained in:
Virgil Dupras 2016-05-31 22:32:37 -04:00
parent d4919054f9
commit a65077f871
39 changed files with 55 additions and 75 deletions

View File

@ -113,7 +113,7 @@ def build_xibless(dest='cocoa/autogen'):
def build_cocoa(dev): def build_cocoa(dev):
print("Creating OS X app structure") print("Creating OS X app structure")
app = cocoa_app() app = cocoa_app()
app_version = get_module_version('core_se') app_version = get_module_version('core')
cocoa_project_path = 'cocoa/se' cocoa_project_path = 'cocoa/se'
filereplace(op.join(cocoa_project_path, 'InfoTemplate.plist'), op.join('build', 'Info.plist'), version=app_version) filereplace(op.join(cocoa_project_path, 'InfoTemplate.plist'), op.join('build', 'Info.plist'), version=app_version)
app.create(op.join('build', 'Info.plist')) 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') shutil.copy(op.join(cocoa_project_path, 'dg_cocoa.py'), 'build')
appscript_pkgs = ['appscript', 'aem', 'mactypes', 'osax'] appscript_pkgs = ['appscript', 'aem', 'mactypes', 'osax']
tocopy = [ tocopy = [
'core', 'core_se', 'core_me', 'core_pe', 'hscommon', 'cocoa/inter', 'cocoalib/cocoa', 'core', 'hscommon', 'cocoa/inter', 'cocoalib/cocoa', 'objp', 'send2trash', 'hsaudiotag',
'objp', 'send2trash', 'hsaudiotag',
] + appscript_pkgs ] + appscript_pkgs
copy_packages(tocopy, pydep_folder, create_links=dev) copy_packages(tocopy, pydep_folder, create_links=dev)
sys.path.insert(0, 'build') sys.path.insert(0, 'build')
@ -217,10 +216,9 @@ def build_updatepot():
loc.generate_cocoa_strings_from_code('cocoa', 'cocoa/base/en.lproj') loc.generate_cocoa_strings_from_code('cocoa', 'cocoa/base/en.lproj')
print("Building .pot files from source files") print("Building .pot files from source files")
print("Building core.pot") print("Building core.pot")
all_cores = ['core', 'core_se', 'core_me', 'core_pe'] loc.generate_pot(['core'], op.join('locale', 'core.pot'), ['tr'])
loc.generate_pot(all_cores, op.join('locale', 'core.pot'), ['tr'])
print("Building columns.pot") 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") print("Building ui.pot")
# When we're not under OS X, we don't want to overwrite ui.pot because it contains Cocoa locs # 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. # 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): def build_pe_modules(ui):
print("Building PE Modules") print("Building PE Modules")
exts = [ exts = [
Extension("_block", [op.join('core_pe', 'modules', 'block.c'), op.join('core_pe', 'modules', 'common.c')]), Extension(
Extension("_cache", [op.join('core_pe', 'modules', 'cache.c'), op.join('core_pe', 'modules', 'common.c')]), "_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': if ui == 'qt':
exts.append(Extension("_block_qt", [op.join('qt', 'pe', 'modules', 'block.c')])) exts.append(Extension("_block_qt", [op.join('qt', 'pe', 'modules', 'block.c')]))
elif ui == 'cocoa': elif ui == 'cocoa':
exts.append(Extension( 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=[ extra_link_args=[
"-framework", "CoreFoundation", "-framework", "CoreFoundation",
"-framework", "Foundation", "-framework", "Foundation",
@ -326,8 +331,8 @@ def build_pe_modules(ui):
ext_modules=exts, ext_modules=exts,
) )
move_all('_block_qt*', op.join('qt', 'pe')) move_all('_block_qt*', op.join('qt', 'pe'))
move_all('_block*', 'core_pe') move_all('_block*', op.join('core', 'pe'))
move_all('_cache*', 'core_pe') move_all('_cache*', op.join('core', 'pe'))
def build_normal(ui, dev): def build_normal(ui, dev):
print("Building dupeGuru with UI {}".format(ui)) print("Building dupeGuru with UI {}".format(ui))

View File

@ -21,18 +21,8 @@ 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
import core_se.fs from . import se, me, pe
import core_se.result_table from .pe.photo import get_delta_dimensions
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 .util import cmp_value, fix_surrogate_encoding from .util import cmp_value, fix_surrogate_encoding
from . import directories, results, export, fs, prioritize from . import directories, results, export, fs, prioritize
from .ignore import IgnoreList from .ignore import IgnoreList
@ -166,11 +156,11 @@ class DupeGuru(Broadcaster):
#--- Private #--- Private
def _create_result_table(self): def _create_result_table(self):
if self.app_mode == AppMode.Picture: 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: elif self.app_mode == AppMode.Music:
return core_me.result_table.ResultTable(self) return me.result_table.ResultTable(self)
else: 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): def _get_dupe_sort_key(self, dupe, get_group, key, delta):
if self.app_mode in (AppMode.Music, AppMode.Picture): if self.app_mode in (AppMode.Music, AppMode.Picture):
@ -335,9 +325,9 @@ class DupeGuru(Broadcaster):
#--- Protected #--- Protected
def _prioritization_categories(self): def _prioritization_categories(self):
if self.app_mode == AppMode.Picture: if self.app_mode == AppMode.Picture:
return core_pe.prioritize.all_categories() return pe.prioritize.all_categories()
elif self.app_mode == AppMode.Music: elif self.app_mode == AppMode.Music:
return core_me.prioritize.all_categories() return me.prioritize.all_categories()
else: else:
return prioritize.all_categories() return prioritize.all_categories()
@ -393,8 +383,7 @@ class DupeGuru(Broadcaster):
path = path.parent() path = path.parent()
def clear_picture_cache(self): def clear_picture_cache(self):
from core_pe.cache import Cache cache = pe.cache.Cache(self.options['cache_path'])
cache = Cache(self.options['cache_path'])
cache.clear() cache.clear()
cache.close() cache.close()
@ -754,7 +743,7 @@ class DupeGuru(Broadcaster):
def do(j): def do(j):
j.set_progress(0, tr("Collecting files to scan")) j.set_progress(0, tr("Collecting files to scan"))
if scanner.scan_type == ScanType.Folders: 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: else:
files = list(self.directories.get_files(fileclasses=self.fileclasses, j=j)) files = list(self.directories.get_files(fileclasses=self.fileclasses, j=j))
if self.options['ignore_hardlink_matches']: if self.options['ignore_hardlink_matches']:
@ -806,20 +795,20 @@ class DupeGuru(Broadcaster):
@property @property
def fileclasses(self): def fileclasses(self):
if self.app_mode == AppMode.Picture: 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: elif self.app_mode == AppMode.Music:
return [core_me.fs.MusicFile] return [me.fs.MusicFile]
else: else:
return [core_se.fs.File] return [se.fs.File]
@property @property
def SCANNER_CLASS(self): def SCANNER_CLASS(self):
if self.app_mode == AppMode.Picture: if self.app_mode == AppMode.Picture:
return core_pe.scanner.ScannerPE return pe.scanner.ScannerPE
elif self.app_mode == AppMode.Music: elif self.app_mode == AppMode.Music:
return core_me.scanner.ScannerME return me.scanner.ScannerME
else: else:
return core_se.scanner.ScannerSE return se.scanner.ScannerSE
@property @property
def METADATA_TO_READ(self): def METADATA_TO_READ(self):

1
core/me/__init__.py Normal file
View File

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

1
core/pe/__init__.py Normal file
View File

@ -0,0 +1 @@
from . import block, cache, exif, iphoto_plist, matchblock, matchexif, photo, prioritize, result_table, scanner # noqa

1
core/se/__init__.py Normal file
View File

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

View File

@ -9,7 +9,7 @@ from pytest import raises, skip
from hscommon.testutil import eq_ from hscommon.testutil import eq_
try: try:
from ..block import avgdiff, getblocks2, NoBlocksError, DifferentBlockCountError from ..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,7 +10,7 @@ from pytest import raises, skip
from hscommon.testutil import eq_ from hscommon.testutil import eq_
try: try:
from ..cache import Cache, colors_to_string, string_to_colors from ..pe.cache import Cache, colors_to_string, string_to_colors
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

@ -12,6 +12,7 @@ from .. import fs
from ..engine import getwords, Match from ..engine import getwords, Match
from ..ignore import IgnoreList from ..ignore import IgnoreList
from ..scanner import Scanner, ScanType from ..scanner import Scanner, ScanType
from ..me.scanner import ScannerME
class NamedObject: class NamedObject:
def __init__(self, name="foobar", size=1, path=None): 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 o2.is_ref = True
eq_(len(s.get_dupe_groups([o1, o2, o3])), 1) eq_(len(s.get_dupe_groups([o1, o2, o3])), 1)
eq_(s.discarded_file_count, 0) 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

View File

View File

@ -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

View File

View File

View File

@ -44,17 +44,16 @@ def copy_files_to_package(destpath, packages, with_so):
compileall.compile_dir(destpath) compileall.compile_dir(destpath)
def package_debian_distribution(distribution): def package_debian_distribution(distribution):
app_version = get_module_version('core_se') app_version = get_module_version('core')
version = '{}~{}'.format(app_version, distribution) version = '{}~{}'.format(app_version, distribution)
destpath = op.join('build', 'dupeguru-{}'.format(version)) destpath = op.join('build', 'dupeguru-{}'.format(version))
srcpath = op.join(destpath, 'src') srcpath = op.join(destpath, 'src')
packages = [ packages = [
'hscommon', 'core', 'core_se', 'core_me', 'core_pe', 'qtlib', 'qt', 'send2trash', 'hscommon', 'core', 'qtlib', 'qt', 'send2trash', 'hsaudiotag'
'hsaudiotag'
] ]
copy_files_to_package(srcpath, packages, with_so=False) copy_files_to_package(srcpath, packages, with_so=False)
os.mkdir(op.join(destpath, 'modules')) 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('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')) copy(op.join('pkg', 'debian', 'build_pe_modules.py'), op.join(destpath, 'build_pe_modules.py'))
debdest = op.join(destpath, 'debian') debdest = op.join(destpath, 'debian')
@ -92,8 +91,7 @@ def package_arch():
print("Packaging for Arch") print("Packaging for Arch")
srcpath = op.join('build', 'dupeguru-arch') srcpath = op.join('build', 'dupeguru-arch')
packages = [ packages = [
'hscommon', 'core', 'core_se', 'core_me', 'core_pe', 'qtlib', 'qt', 'send2trash', 'hscommon', 'core', 'qtlib', 'qt', 'send2trash', 'hsaudiotag',
'hsaudiotag',
] ]
copy_files_to_package(srcpath, packages, with_so=True) copy_files_to_package(srcpath, packages, with_so=True)
shutil.copy(op.join('images', 'dgse_logo_128.png'), srcpath) shutil.copy(op.join('images', 'dgse_logo_128.png'), srcpath)
@ -105,7 +103,7 @@ def package_source_tgz():
print("Downloading PyPI dependencies") print("Downloading PyPI dependencies")
print_and_do('./download_deps.sh') print_and_do('./download_deps.sh')
print("Creating git archive") print("Creating git archive")
app_version = get_module_version('core_se') app_version = get_module_version('core')
name = 'dupeguru-src-{}.tar'.format(app_version) name = 'dupeguru-src-{}.tar'.format(app_version)
dest = op.join('build', name) dest = op.join('build', name)
print_and_do('git archive -o {} HEAD'.format(dest)) print_and_do('git archive -o {} HEAD'.format(dest))

View File

@ -20,7 +20,7 @@ from qtlib.util import createActions
from qtlib.progress_window import ProgressWindow from qtlib.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 . import platform
from .preferences import Preferences from .preferences import Preferences
from .result_window import ResultWindow from .result_window import ResultWindow
@ -51,7 +51,7 @@ class DupeGuru(QObject):
#--- Private #--- Private
def _setup(self): def _setup(self):
core_pe.photo.PLAT_SPECIFIC_PHOTO_CLASS = PlatSpecificPhoto core.pe.photo.PLAT_SPECIFIC_PHOTO_CLASS = PlatSpecificPhoto
self._setupActions() self._setupActions()
self._update_options() self._update_options()
self.recentResults = Recent(self, 'recentResults') self.recentResults = Recent(self, 'recentResults')

View File

@ -8,7 +8,7 @@ import logging
from PyQt5.QtGui import QImage, QImageReader, QTransform 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 .block import getblocks