Skip to content

Commit d6e2881

Browse files
committed
improve exiftool_runner
1 parent c1489ed commit d6e2881

1 file changed

Lines changed: 5 additions & 24 deletions

File tree

mapillary_tools/exiftool_runner.py

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
from __future__ import annotations
22

3-
import platform
4-
import shutil
53
import subprocess
64
import typing as T
75
from pathlib import Path
@@ -12,32 +10,15 @@ class ExiftoolRunner:
1210
Wrapper around ExifTool to run it in a subprocess
1311
"""
1412

15-
def __init__(self, exiftool_path: str | None = None, recursive: bool = False):
16-
if exiftool_path is None:
17-
exiftool_path = self._search_preferred_exiftool_path()
18-
self.exiftool_path = exiftool_path
13+
def __init__(self, exiftool_executable: str = "exiftool", recursive: bool = False):
14+
if exiftool_executable is None:
15+
exiftool_executable = self._search_preferred_exiftool_path()
16+
self.exiftool_executable = exiftool_executable
1917
self.recursive = recursive
2018

21-
def _search_preferred_exiftool_path(self) -> str:
22-
system = platform.system()
23-
24-
if system and system.lower() == "windows":
25-
exiftool_paths = ["exiftool.exe", "exiftool"]
26-
else:
27-
exiftool_paths = ["exiftool", "exiftool.exe"]
28-
29-
for path in exiftool_paths:
30-
full_path = shutil.which(path)
31-
if full_path:
32-
return path
33-
34-
# Always return the prefered one, even if it is not found,
35-
# and let the subprocess.run figure out the error later
36-
return exiftool_paths[0]
37-
3819
def _build_args_read_stdin(self) -> list[str]:
3920
args: list[str] = [
40-
self.exiftool_path,
21+
self.exiftool_executable,
4122
"-fast",
4223
"-q",
4324
"-n", # Disable print conversion

0 commit comments

Comments
 (0)