Correct non fonctionnal file pattern search
This commit is contained in:
parent
40b5b80cef
commit
fe51e567ab
1 changed files with 10 additions and 6 deletions
|
@ -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"):
|
||||
|
|
Reference in a new issue