Skip to content

Commit

Permalink
Rename imutils.exif to imutils.metadata
Browse files Browse the repository at this point in the history
Renaming is done as this file handles all metadata related
functionalities and not just exif metadata.
  • Loading branch information
jcjgraf committed Jan 8, 2023
1 parent 4f829cb commit ee3613d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions vimiv/gui/metadatawidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
from PyQt5.QtWidgets import QLabel, QSizePolicy, QWidget

from vimiv import api, utils
from vimiv.imutils import exif
from vimiv.imutils import metadata
from vimiv.config import styles

_logger = utils.log.module_logger(__name__)


# TODO: conditional fails as this file is imported before plugins are loaded
# if exif.has_get_metadata():
# if metadata.has_get_metadata():
if True:
class MetadataWidget(QLabel):
"""Overlay widget to display image metadata.
Expand Down Expand Up @@ -59,18 +59,18 @@ def __init__(self, parent: QWidget):
self._mainwindow_width = 0
self._path = ""
self._current_set = ""
self._handler: Optional[exif.MetadataHandler] = None
self._handler: Optional[metadata.MetadataHandler] = None

api.signals.new_image_opened.connect(self._on_image_opened)
api.settings.metadata.current_keyset.changed.connect(self._update_text)

self.hide()

@property
def handler(self) -> exif.MetadataHandler:
def handler(self) -> metadata.MetadataHandler:
"""Return the MetadataHandler for the current path."""
if self._handler is None:
self._handler = exif.MetadataHandler(self._path)
self._handler = metadata.MetadataHandler(self._path)
return self._handler

@api.keybindings.register("i", "metadata", mode=api.modes.IMAGE)
Expand Down
2 changes: 1 addition & 1 deletion vimiv/imutils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
the appropriate Qt widget.
"""

from vimiv.imutils import exif
from vimiv.imutils import metadata
from vimiv.imutils.edit_handler import EditHandler
from vimiv.imutils.filelist import current, pathlist
from vimiv.imutils.filelist import SignalHandler as _FilelistSignalHandler
Expand Down
8 changes: 4 additions & 4 deletions vimiv/imutils/_file_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def write_pixmap(pixmap, path, original_path):
Args:
pixmap: The QPixmap to write.
path: Path to write the pixmap to.
original_path: Original path of the opened pixmap to retrieve exif information.
original_path: Original path of the opened pixmap to retrieve metadata information.
"""
try:
_can_write(pixmap, path)
Expand Down Expand Up @@ -210,10 +210,10 @@ def _write(pixmap, path, original_path):
handle, filename = tempfile.mkstemp(suffix=ext)
os.close(handle)
pixmap.save(filename)
# Copy exif info from original file to new file
# Copy metadata info from original file to new file
try:
imutils.exif.MetadataHandler(original_path).copy_metadata(filename)
except imutils.exif.UnsupportedMetadataOperation:
imutils.metadata.MetadataHandler(original_path).copy_metadata(filename)
except imutils.metadata.UnsupportedMetadataOperation:
pass
shutil.move(filename, path)
# Check if valid image was created
Expand Down
4 changes: 2 additions & 2 deletions vimiv/imutils/filelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ def exif_date_time() -> str:
be used as basis to work with.
"""
try:
return imutils.exif.MetadataHandler(current()).get_date_time()
except imutils.exif.UnsupportedMetadataOperation:
return imutils.metadata.MetadataHandler(current()).get_date_time()
except imutils.metadata.UnsupportedMetadataOperation:
return ""


Expand Down
File renamed without changes.

0 comments on commit ee3613d

Please sign in to comment.