summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjvoisin2019-05-16 00:31:40 +0200
committerjvoisin2019-05-16 00:31:40 +0200
commit35d550d229b219f5a02cb9194c3bd24329f975ed (patch)
tree83b3617d7d0993ff0313d472adf8abb5a52fa1ac
parentaa52a5c91c1d7f0dc6691fdd972e343fc63f6fc2 (diff)
Use memoization get _*_path() functions
This shouldn't make a big difference in the CLI/extension usage, but might improve the performances of long-running instances, or people misusing the API.
-rw-r--r--libmat2/exiftool.py2
-rw-r--r--libmat2/video.py2
2 files changed, 4 insertions, 0 deletions
diff --git a/libmat2/exiftool.py b/libmat2/exiftool.py
index d18b1fb..2e83f13 100644
--- a/libmat2/exiftool.py
+++ b/libmat2/exiftool.py
@@ -1,3 +1,4 @@
1import functools
1import json 2import json
2import logging 3import logging
3import os 4import os
@@ -56,6 +57,7 @@ class ExiftoolParser(abstract.AbstractParser):
56 return False 57 return False
57 return True 58 return True
58 59
60@functools.lru_cache()
59def _get_exiftool_path() -> str: # pragma: no cover 61def _get_exiftool_path() -> str: # pragma: no cover
60 possible_pathes = { 62 possible_pathes = {
61 '/usr/bin/exiftool', # debian/fedora 63 '/usr/bin/exiftool', # debian/fedora
diff --git a/libmat2/video.py b/libmat2/video.py
index 0060f78..1492ba1 100644
--- a/libmat2/video.py
+++ b/libmat2/video.py
@@ -1,3 +1,4 @@
1import functools
1import os 2import os
2import logging 3import logging
3 4
@@ -130,6 +131,7 @@ class MP4Parser(AbstractFFmpegParser):
130 } 131 }
131 132
132 133
134@functools.lru_cache()
133def _get_ffmpeg_path() -> str: # pragma: no cover 135def _get_ffmpeg_path() -> str: # pragma: no cover
134 ffmpeg_path = '/usr/bin/ffmpeg' 136 ffmpeg_path = '/usr/bin/ffmpeg'
135 if os.path.isfile(ffmpeg_path): 137 if os.path.isfile(ffmpeg_path):