From fe51e567abb75756dded7477473413d63e3e03e7 Mon Sep 17 00:00:00 2001 From: Yorick Date: Wed, 9 Dec 2015 12:08:19 +0100 Subject: [PATCH] Correct non fonctionnal file pattern search --- export-video.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/export-video.py b/export-video.py index c3e7dfd..0c81634 100755 --- a/export-video.py +++ b/export-video.py @@ -5,7 +5,6 @@ Little scrip to export video file for The Internet :D """ import sys import getopt -import re import os import subprocess import logging @@ -41,7 +40,7 @@ params = { ], "webm_acommand": ["-strict", "experimental"], "verbose": True, - "pattern": "", + "pattern": "*", "twopass": False, "recursive": False} @@ -81,7 +80,12 @@ def list_file(directory, pattern, recursive): pattern (string) : regex used to found files recursive (boolean) : should i serach on sub-folder? """ - logging.info('searching in directory %s', directory) + logging.info( + 'searching in directory %s with pattern %s recursive : %s', + directory, + pattern, + recursive + ) files_list = [] try: dirs = os.listdir(directory) @@ -91,7 +95,7 @@ def list_file(directory, pattern, recursive): for i in dirs: logging.debug(' working on file / dir %s', i) - if os.path.isdir(directory + "/" + i) and recursive: + if os.path.isdir(os.path.join(directory, i)) and recursive: logging.info('directory found : %s', i) files_list.extend(list_file( os.path.join(directory, i), @@ -99,7 +103,7 @@ def list_file(directory, pattern, recursive): recursive )) else: - if re.search(pattern, i) is not None: + if i.endswith("." + pattern): logging.info('file found : %s', i) files_list.append(directory + "/" + i) return files_list @@ -148,7 +152,7 @@ def process_arg(sysarg): if opt in ("-i", "--input"): params["file_input"] = arg if opt in ("-p", "--pattern"): - params["pattern"] = "^\\w*."+arg+"$" + params["pattern"] = arg if opt in ("-a", "--abitrate"): params["abitrate"] = arg if opt in ("-v", "--vbitrate"):