Commit 0dc7caf5 authored by Nicolas Wavrant's avatar Nicolas Wavrant

resilient: exclude files using fnmatch instead of regexp

As mentionned by @jerome in 2848a965
fnmatch allows more natural definitions for path manipulations
parent 47d9bf42
...@@ -2,9 +2,9 @@ from __future__ import print_function ...@@ -2,9 +2,9 @@ from __future__ import print_function
import argparse import argparse
import os import os
import subprocess
import re import re
from fnmatch import fnmatch
from .runner_utils import * from .runner_utils import *
def parseArgumentList(): def parseArgumentList():
...@@ -25,11 +25,10 @@ def calculateSignature(): ...@@ -25,11 +25,10 @@ def calculateSignature():
result = re.match('^\.\/runner\/instance\/slappart(\d)', file_list[0]) result = re.match('^\.\/runner\/instance\/slappart(\d)', file_list[0])
base_relative_path = result.group() base_relative_path = result.group()
excluded_path_list = ['./' + os.path.relpath(os.path.join(base_relative_path, path)) for path in args.exclude_path] excluded_path_list = ['./' + os.path.relpath(os.path.join(base_relative_path, path)) for path in args.exclude_path]
excluded_path_regex_list = [re.compile(excluded_path) for excluded_path in excluded_path_list]
filtered_file_list = [ filtered_file_list = [
x for x in file_list x for x in file_list
if not any([re.match(excluded_path_regex, x) for excluded_path_regex in excluded_path_regex_list]) if not any([fnmatch(x, excluded_path) for excluded_path in excluded_path_list])
] ]
print('\n'.join(getSha256Sum(filtered_file_list))) print('\n'.join(getSha256Sum(filtered_file_list)))
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment