in ees_network_drive/indexing_rule.py [0:0]
def follows_indexing_rule(self, filtertype, pattern, file_details, pattern_type):
"""Applies filters on the file and returns True or False based on whether
it follows the pattern or not
:filtertype: denotes the type of filter used: size/path_template
:param pattern: include/ exclude pattern provided for matching
:param file_details: dictionary containing file properties
:param pattern_type: include/exclude
"""
if pattern:
for value in pattern:
if filtertype == 'size':
initial = re.match('[><=!]=?', value)
result = self.filter_size(file_details, initial[0], re.findall("[0-9]+", value)[0])
else:
result = glob.globmatch(file_details['file_path'], value, flags=glob.GLOBSTAR)
if (pattern_type == 'include' and result) or (pattern_type == 'exclude' and not(result)):
return True
return False