def test_lazy_module_single_instance(module): """Ensure we only create a single instance per module name.""" module_second_import = lazy.import_module(MODULE_NAME) assert module_second_import is module
def module(): """Fixture to return a lazy imported module.""" yield lazy.import_module(MODULE_NAME)
"""Utility functions and classes for exif handling. All exif related tasks are implemented in this module. The heavy lifting is done using one of the supported exif libraries, i.e. * piexif (https://pypi.org/project/piexif/) and * pyexiv2 (https://pypi.org/project/py3exiv2/). """ import contextlib import itertools from typing import Any, Dict, Tuple, NoReturn, Sequence, Iterable from vimiv.utils import log, lazy, is_hex pyexiv2 = lazy.import_module("pyexiv2", optional=True) piexif = lazy.import_module("piexif", optional=True) _logger = log.module_logger(__name__) ExifDictT = Dict[Any, Tuple[str, str]] class UnsupportedExifOperation(NotImplementedError): """Raised if an exif operation is not supported by the used library if any.""" class _ExifHandlerBase: """Handler to load and copy exif information of a single image. This class provides the interface for handling exif support. By default none of the operations are implemented. Instead it is up to a child class which wraps around one
QGraphicsScene, QFrame, QGraphicsItem, QGraphicsPixmapItem, QLabel, ) from PyQt5.QtGui import QMovie, QPixmap from vimiv import api, imutils, utils from vimiv.imutils import slideshow from vimiv.commands.argtypes import Direction, ImageScale, ImageScaleFloat, Zoom from vimiv.config import styles from vimiv.gui import eventhandler from vimiv.utils import lazy QtSvg = lazy.import_module("PyQt5.QtSvg", optional=True) INF = float("inf") class ScrollableImage(eventhandler.EventHandlerMixin, QGraphicsView): """QGraphicsView to display Image or Animation. Connects to the *_loaded signals to create the appropriate child widget. Commands used in image mode are defined here. Class Attributes: MIN_SCALE: Minimum scale to scale an image to. MAX_SCALE: Maximum scale to scale an image to. Attributes:
# This file is part of vimiv. # Copyright 2017-2020 Christian Karl (karlch) <karlch at protonmail dot com> # License: GNU GPL v3, see the "LICENSE" and "AUTHORS" files for details. """Utility functions and classes for exif handling. All exif related tasks are implemented in this module. The heavy lifting is done using piexif (https://github.com/hMatoba/Piexif). """ import contextlib from vimiv.utils import log, lazy from vimiv import api piexif = lazy.import_module("piexif", optional=True) _logger = log.module_logger(__name__) def check_piexif(return_value=None): """Decorator for functions that require the optional piexif module. If piexif is not available, return_value is returned and a debug log message is logged. It it is available, the function is called as usual. Args: return_value: Value to return if piexif is not available. """ def decorator(func):