-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move Metadata Support to Pluginspace #467
Commits on Jun 24, 2023
-
NEW: move metadata support to plugin space
This commit is still very VIP - Clients can register implementations of the metadata handler using @exif.register(exif.Methods.XXX) - For copy_metadata, get_raw_metadata, get_formatted_metadata, and get_keys all registered implementations are run, and the output combined, for get_date_time, only the last registered one is used - Two internal plugins for metadata support, using piexif and py3exiv2 respectively, were added
Configuration menu - View commit details
-
Copy full SHA for d66107d - Browse repository at this point
Copy the full SHA d66107dView commit details -
Add convenience functions to determine metadata support
Module functions indicate whether any implementations for the Methods have been registered, and hence, what functionality MetadataHandler is able to provide.
Configuration menu - View commit details
-
Copy full SHA for 9de230d - Browse repository at this point
Copy the full SHA 9de230dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 6f3d885 - Browse repository at this point
Copy the full SHA 6f3d885View commit details -
Remove get_raw_md, cleanup and docstrings
- MetadataHandler no longer has two operations that distinguish between formatted and raw metadata. Such a functionality can be added later if needed. - exif.Methods was renamed to exif.Operations - Docstrings were added - Minor fixes
Configuration menu - View commit details
-
Copy full SHA for 9fb1155 - Browse repository at this point
Copy the full SHA 9fb1155View commit details -
Improve metadata handler by operations.
Consecutive calls using the same arguments are cached and served from cache. This applies for the backend setup, get_metadata and get_keys, as these are rather expensive calls. This may be problematic if metadata is written to the image in-between calls.
Configuration menu - View commit details
-
Copy full SHA for 26cf2b6 - Browse repository at this point
Copy the full SHA 26cf2b6View commit details -
Rename
imutils.exif
toimutils.metadata
Renaming is done as this file handles all metadata related functionalities and not just exif metadata.
Configuration menu - View commit details
-
Copy full SHA for 50cb581 - Browse repository at this point
Copy the full SHA 50cb581View commit details -
Refactor registry to make client subclass MetadataPlugin
Clients no longer register individual functions, but they subclass `MetadataPlugin`, and overwrite whatever methods the plugin offers. In addition, clients are required to set the `name` and `version` field of `MetadataPlugin`. The subclass is registered using the register function.
Configuration menu - View commit details
-
Copy full SHA for f0740e5 - Browse repository at this point
Copy the full SHA f0740e5View commit details -
Configuration menu - View commit details
-
Copy full SHA for 824fe8e - Browse repository at this point
Copy the full SHA 824fe8eView commit details -
Fix pyexiv2 plugin to conform to refactoring
Also rename plugin from py3exiv2 to pyexiv2 to prevent confusion.
Configuration menu - View commit details
-
Copy full SHA for f2af1de - Browse repository at this point
Copy the full SHA f2af1deView commit details -
Refactor MetadataPlugin to be an abstract class
Changing MetadataPlugin to a abstract class: - Enforces the client to set both, `get_metadata` and `get_keys` - `copy_metadata` and `get_date_time` is optional to implement - Enforces the client to set `name` and `version` - Both are now a property. Prevents the loading of plugins if not used. Additional changes: - Simplified `_registry` to be a simple list. There is no need for a dict. Also, the additional `_has_...` properties are no longer needed. - Got rid of all module level `has_...` functions, and added `has_metadata_support` instead. Fine-grain control is not needed.
Configuration menu - View commit details
-
Copy full SHA for 23c8fd1 - Browse repository at this point
Copy the full SHA 23c8fd1View commit details -
Configuration menu - View commit details
-
Copy full SHA for 2bd2ded - Browse repository at this point
Copy the full SHA 2bd2dedView commit details -
Configuration menu - View commit details
-
Copy full SHA for e2e9c4a - Browse repository at this point
Copy the full SHA e2e9c4aView commit details -
Fix conftest for metadata redesign and test version
This is a first attempt on fixing the tests for the redesign of the metadata handling: - The metadata_markers (old exif_markers) have been adapted. However, I do not think that they make sense. For `metadata` and `nometadata` the condition only indicates whether the current instance of vimiv has metadata support (or not). For `piexif` and `pyexiv2`they indicate if the backend package is installed. - In addition, having condition `metadata_pyexiv2.pyexiv2 is not None` fails for mark `pyexiv2`. I am not sure why that is the case. - Fixtures `metadata_support`, `no_metadata_support`, `piexif` and `pyexiv2` have been added and implemented. They bring `metadata._registry` into the respective state, and make use of `reset_metadata_registration`, to undo the changes after each tests. - Updated `test_version`. Am I required to set for each testcase the mark, as well as appropriated fixture (i.e. `@mark.piexif` and specify `test_XXX(piexif)`. This seems a bit tedious.
Configuration menu - View commit details
-
Copy full SHA for 446f4bd - Browse repository at this point
Copy the full SHA 446f4bdView commit details -
Make piexif / pyexiv2 lazy imports optional
While they are absolutely required to run the plugin - and I thus thought they could stay required - running the test suite without piexif / pyexiv2 is very messy with them not being optional. We need to be able to compare to None there.
Configuration menu - View commit details
-
Copy full SHA for b610237 - Browse repository at this point
Copy the full SHA b610237View commit details -
Temporarily shorten metadata (integration) test
As we now rely on a plugin infrastructure, the old unit test no longer makes sense. Thus the test is now moved to integration and can be expanded in the next steps.
Configuration menu - View commit details
-
Copy full SHA for 2d98a51 - Browse repository at this point
Copy the full SHA 2d98a51View commit details -
Remove metadata-related version unit tests
With the new plugin structure, adding this information directly to --version is no longer simple and up for discussion.
Configuration menu - View commit details
-
Copy full SHA for fd6f951 - Browse repository at this point
Copy the full SHA fd6f951View commit details -
Configuration menu - View commit details
-
Copy full SHA for 6bc1742 - Browse repository at this point
Copy the full SHA 6bc1742View commit details -
Add plugins_loaded signal to api.signals
The signal is emitted when plugins have been loaded. This allows the mainwindow to initialize the metadatawidget afterwards, and only if metadata related plugins have been loaded.
Configuration menu - View commit details
-
Copy full SHA for 65fcb20 - Browse repository at this point
Copy the full SHA 65fcb20View commit details -
Remove metadata information from --version
As these are now plugins, they are not available this early in the loading process. Instead plugin information should be added in :version explicitly.
Configuration menu - View commit details
-
Copy full SHA for 56c88df - Browse repository at this point
Copy the full SHA 56c88dfView commit details -
Tests: rewrite metadata markers
Unfortunately using metadata.has_metadata_support() does not work this early in the code, as we import conftest much before loading plugins and actually registering the metadata handlers.
Configuration menu - View commit details
-
Copy full SHA for 8a93af6 - Browse repository at this point
Copy the full SHA 8a93af6View commit details -
Update metadatawidget end2end test
Avoid importing the widget without metadata support as this registers the :metadata command.
Configuration menu - View commit details
-
Copy full SHA for 53e12e7 - Browse repository at this point
Copy the full SHA 53e12e7View commit details -
Fix bug in piexif's copy_metadata implementation
The metadata is stored in self._metadata, while metadata is the actual module.
Configuration menu - View commit details
-
Copy full SHA for 99d29ad - Browse repository at this point
Copy the full SHA 99d29adView commit details -
This allows loading metadata support by default, as is the current behaviour. We can consider deprecating this over time, but we should definitely keep metadata support by default as it is currently the case for now.
Configuration menu - View commit details
-
Copy full SHA for 01fa41d - Browse repository at this point
Copy the full SHA 01fa41dView commit details -
Extend metadata integration test and markers
- Simple tests to check if piexif / pyexiv2 correctly register the metadata handler - Correct skipping of fixtures with pytest.mark.piexif / pytest.mark.pyexiv2
Configuration menu - View commit details
-
Copy full SHA for 1555d20 - Browse repository at this point
Copy the full SHA 1555d20View commit details -
Configuration menu - View commit details
-
Copy full SHA for a0fcb6b - Browse repository at this point
Copy the full SHA a0fcb6bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 4448981 - Browse repository at this point
Copy the full SHA 4448981View commit details -
Change name/version property of MetadataPlugin to static method
While a property is well suited to get this data, having to call these properties on an instance of MetadataPlugin does not really make sense. While it is possible to implement classproperties, `abc` cannot enforce their implementation out-of-the-box. Therefore, the properties were changed to static methods.
Configuration menu - View commit details
-
Copy full SHA for 0aa4f8b - Browse repository at this point
Copy the full SHA 0aa4f8bView commit details -
Cleanup of supression of exception which is never raised
`get_metadata/get_keys` do not raise NotImplementedError. This is a leftover from before refactoring MetadataPlugin into an abstract class
Configuration menu - View commit details
-
Copy full SHA for b3206b8 - Browse repository at this point
Copy the full SHA b3206b8View commit details -
Configuration menu - View commit details
-
Copy full SHA for 03fc90f - Browse repository at this point
Copy the full SHA 03fc90fView commit details -
Configuration menu - View commit details
-
Copy full SHA for 5507de9 - Browse repository at this point
Copy the full SHA 5507de9View commit details -
Make all MetadataHandle methods raise exceptions
Changed the `UnsupportedMetadataOperation` exception to a more general `MetadataError`. It gets called when a `MetadataHandler` method is called without any metadata plugin registered, or if none of the registered one provides support for `get_date_time`/`copy_metadata`.
Configuration menu - View commit details
-
Copy full SHA for 1132667 - Browse repository at this point
Copy the full SHA 1132667View commit details -
Change metadat_pyexiv to require full keys
Remove backward compatibility: Someone having the old piexif keys defined in their config, but wanting to use the pyexiv2 backend. Maintaining this backward compatibility required ugly guessing of potential key prefixes.
Configuration menu - View commit details
-
Copy full SHA for 409c804 - Browse repository at this point
Copy the full SHA 409c804View commit details -
Assert earlier if piexif is available
Assertion in `add_exif_inforamtion_bdd` is not reached when piexif is not available. The fixture `exif_content` fails before with an AttributeError NoneType.
Configuration menu - View commit details
-
Copy full SHA for 89dd893 - Browse repository at this point
Copy the full SHA 89dd893View commit details -
Make widget displaying images in the requested order
Make sure that the extracted metadata is displayed in the same order, as specified in the config.
Configuration menu - View commit details
-
Copy full SHA for aa6a80a - Browse repository at this point
Copy the full SHA aa6a80aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 37d9809 - Browse repository at this point
Copy the full SHA 37d9809View commit details -
Fix piexif data not displayed in widget
The dict returned by `get_metadata` was keyed by the *truncated* metadata key, and not the original one. As the metadata widget uses the original keys to read out the data, nothing was displayed if long keys are used in the config.
Configuration menu - View commit details
-
Copy full SHA for 7b3e2ee - Browse repository at this point
Copy the full SHA 7b3e2eeView commit details -
Configuration menu - View commit details
-
Copy full SHA for 1820813 - Browse repository at this point
Copy the full SHA 1820813View commit details -
I did not replace the link with one to `metadata.rst` as this lead to a weird error. I also do not think that this link is super relevant.
Configuration menu - View commit details
-
Copy full SHA for a22982f - Browse repository at this point
Copy the full SHA a22982fView commit details -
Ensure backward compatibility but allow overwriting
If no metadata plugin has been specified, the default `metadata` plugins loads one of `metadata_pyexiv` or `metadata_piexif` (depending on the installed backend). If a specific backend is configured, they it is ensured that `metadata` does not interfere. This is achieved by deferring the loading of the `metadata` plugin to the end of all plugins. At that point `metadata` can check if another metadata plugin has been loaded, and if so, do nothing.
Configuration menu - View commit details
-
Copy full SHA for fb66610 - Browse repository at this point
Copy the full SHA fb66610View commit details
Commits on Jul 5, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 9266928 - Browse repository at this point
Copy the full SHA 9266928View commit details -
Configuration menu - View commit details
-
Copy full SHA for db95c4b - Browse repository at this point
Copy the full SHA db95c4bView commit details -
Refactor (metadata) plugin loading
User plugins are now loaded before app plugins, and not overridden. This allows metadata (and any other app plugins) to be loaded later and access any user-specific information. In this case, the user can deactivate auto-loading by passing metadata = none in the plugins section of the config.
Configuration menu - View commit details
-
Copy full SHA for 1cbba4a - Browse repository at this point
Copy the full SHA 1cbba4aView commit details -
Also make them Title Case, as in other pasts of the docs
Configuration menu - View commit details
-
Copy full SHA for c3c1654 - Browse repository at this point
Copy the full SHA c3c1654View commit details -
Configuration menu - View commit details
-
Copy full SHA for 2040326 - Browse repository at this point
Copy the full SHA 2040326View commit details -
Configuration menu - View commit details
-
Copy full SHA for b9fb5dd - Browse repository at this point
Copy the full SHA b9fb5ddView commit details -
Configuration menu - View commit details
-
Copy full SHA for 1062817 - Browse repository at this point
Copy the full SHA 1062817View commit details -
Configuration menu - View commit details
-
Copy full SHA for 2d16f89 - Browse repository at this point
Copy the full SHA 2d16f89View commit details -
Configuration menu - View commit details
-
Copy full SHA for ebfd9d6 - Browse repository at this point
Copy the full SHA ebfd9d6View commit details -
Configuration menu - View commit details
-
Copy full SHA for 816dc32 - Browse repository at this point
Copy the full SHA 816dc32View commit details -
Configuration menu - View commit details
-
Copy full SHA for bff129b - Browse repository at this point
Copy the full SHA bff129bView commit details