diff options
author | Jesús Eduardo <heckyel@hyperbola.info> | 2018-01-12 18:30:38 -0500 |
---|---|---|
committer | Jesús Eduardo <heckyel@hyperbola.info> | 2018-01-12 18:30:38 -0500 |
commit | d1f373ed4e99c13fa20f53c14247762fab58d56d (patch) | |
tree | d8b2a0e6ff091b7557b846d4f9987dacec3df1e0 /lvc/settings.py | |
parent | 694e11a5e27a35077753c6aafddeb90acba9fda7 (diff) | |
download | librevideoconverter-d1f373ed4e99c13fa20f53c14247762fab58d56d.tar.lz librevideoconverter-d1f373ed4e99c13fa20f53c14247762fab58d56d.tar.xz librevideoconverter-d1f373ed4e99c13fa20f53c14247762fab58d56d.zip |
pep 8 en lvc/settings.py
Diffstat (limited to 'lvc/settings.py')
-rw-r--r-- | lvc/settings.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lvc/settings.py b/lvc/settings.py index a9b8266..64be4dc 100644 --- a/lvc/settings.py +++ b/lvc/settings.py @@ -7,13 +7,16 @@ from lvc import execute ffmpeg_version = None _search_path_extra = [] + + def add_to_search_path(directory): """Add a path to the list of paths that which() searches.""" _search_path_extra.append(directory) + def which(name): if sys.platform == 'win32': - name = name + '.exe' # we're looking for ffmpeg.exe in this case + name = name + '.exe' # we're looking for ffmpeg.exe in this case if sys.platform == 'darwin' and 'Contents/Resources' in __file__: # look for a bundled version path = os.path.join(os.path.dirname(__file__), @@ -28,24 +31,28 @@ def which(name): if os.path.exists(fullpath): return fullpath logging.warn("Can't find path to %s (searched in %s)", name, - dirs_to_search) + dirs_to_search) + def memoize(func): cache = [] + def wrapper(): if not cache: cache.append(func()) return cache[0] return wrapper + @memoize def get_ffmpeg_executable_path(): return which("ffmpeg") avconv = which('avconv') if avconv is not None: - return avconv + return avconv return which("ffmpeg") + def get_ffmpeg_version(): global ffmpeg_version if ffmpeg_version is None: @@ -54,6 +61,7 @@ def get_ffmpeg_version(): stdout, _ = p.communicate() lines = stdout.split('\n') version = lines[0].rsplit(' ', 1)[1].split('.') + def maybe_int(v): try: return int(v) @@ -62,6 +70,7 @@ def get_ffmpeg_version(): ffmpeg_version = tuple(maybe_int(v) for v in version) return ffmpeg_version + def customize_ffmpeg_parameters(params): """Takes a list of parameters and modifies it based on platform-specific issues. Returns the newly modified list of |