MCPcopy Create free account
hub / github.com/bleachbit/bleachbit / CompiledSearch

Class CompiledSearch

bleachbit/DeepScan.py:63–92  ·  view source on GitHub ↗

Compiled search condition

Source from the content-addressed store, hash-verified

61
62
63class CompiledSearch:
64 """Compiled search condition"""
65
66 def __init__(self, search):
67 self.command = search.command
68
69 def re_compile(regex):
70 return re.compile(regex, fs_scan_re_flags) if regex else None
71
72 self.regex = re_compile(search.regex)
73 self.nregex = re_compile(search.nregex)
74 self.wholeregex = re_compile(search.wholeregex)
75 self.nwholeregex = re_compile(search.nwholeregex)
76
77 def match(self, dirpath, filename):
78 full_path = os.path.join(dirpath, filename)
79
80 if self.regex and not self.regex.search(filename):
81 return None
82
83 if self.nregex and self.nregex.search(filename):
84 return None
85
86 if self.wholeregex and not self.wholeregex.search(full_path):
87 return None
88
89 if self.nwholeregex and self.nwholeregex.search(full_path):
90 return None
91
92 return full_path
93
94
95class DeepScan:

Callers 1

scanMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected