def two_duplicates_same_size(): return [ FileItem( file=Path('/Users/jo/dev/exify/tests/data/duplicates/set1/IMG-20140831-WA0002.jpg') ), FileItem( file=Path('/Users/jo/dev/exify/tests/data/duplicates/set1/IMG-20140901-WA0000.jpg') ) ]
async def test_duplicates(self): # arrange items = [ FileItem(file=expand_to_absolute_path(DuplicatesExample().first)), FileItem(file=expand_to_absolute_path(DuplicatesExample().second)), FileItem(file=expand_to_absolute_path(DuplicatesExample().third)) ] finder = DuplicateFinder(items=items) # act await finder.run() # assert assert len(finder._images_by_hash) == 1
def too_much_deviations(self): return FileItem( file=Path('some-file.jpg'), timestamps=Timestamps( file_name=utcnow() + timedelta(minutes=1), file_created=utcnow(), file_modified=utcnow(), exif={ ExifTimestampAttribute.datetime: utcnow() }), results=AnalysisResults() )
async def test_no_exif_found(self, examples): # arrange item = FileItem( file=expand_to_absolute_path(examples.no_exif) ) analyzer = await WhatsappImageAnalyzer.create(item) # act await analyzer.get_timestamp() # assert assert not analyzer._item.timestamps.exif
async def run(settings: ExifySettings): logger.info(f'Settings: {settings}') ok = [] updated = [] errors = [] for file in await _find_files(settings.base_dir): filename = expand_to_absolute_path(file) if not is_whatsapp_file(filename) or not is_image(filename): continue item = FileItem( file=filename ) try: item = await _analyze_file(item, settings) except ExifyError as err: item.errors.append(err) errors.append(item) if await _all_ok(item.results): ok.append(item) else: try: if not item.results.exif_timestamp_exists: await _write_exif_data(item) if not item.results.deviation_ok: await _write_file_time_stamp(item) updated.append(item) except ExifyError as err: item.errors.append(err) errors.append(item) logger.info(f'OK: {len(ok)}, UPDATED: {len(updated)}, ERRORS: {len(errors)}') for failed in errors: logger.warning(f'Process failed for {failed.file}: {failed.errors}')
def item(self, test_path, test_file): return FileItem( file=test_path / test_file.name )