Changeset 97267 in vbox for trunk/src/VBox/ValidationKit/analysis/reader.py
- Timestamp:
- Oct 24, 2022 12:09:44 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/analysis/reader.py
r97266 r97267 46 46 import datetime; 47 47 import os; 48 import re; 48 49 import sys; 49 50 import traceback; … … 135 136 return Value(oParentTest, self.sName, self.sUnit, self.sTimestamp, self.lValue); 136 137 138 def matchFilters(self, sPrefix, aoFilters): 139 """ 140 Checks for any substring match between aoFilters (str or re.Pattern) 141 and the value name prefixed by sPrefix. 142 143 Returns True if any of the filters matches. 144 Returns False if none of the filters matches. 145 """ 146 sFullName = sPrefix + self.sName; 147 for oFilter in aoFilters: 148 if oFilter.search(sFullName) is not None if isinstance(oFilter, re.Pattern) else sFullName.find(oFilter) >= 0: 149 return True; 150 return False; 151 137 152 138 153 @staticmethod … … 306 321 return self.getFullNameWorker(cSkipUpper)[0]; 307 322 308 def matchFilters(self, asFilters): 309 """ 310 Checks if the all of the specified filter strings are substrings 311 of the full test name. Returns True / False. 312 """ 313 sName = self.getFullName(); 314 for sFilter in asFilters: 315 if sName.find(sFilter) < 0: 316 return False; 317 return True; 323 def matchFilters(self, aoFilters): 324 """ 325 Checks for any substring match between aoFilters (str or re.Pattern) 326 and the full test name. 327 328 Returns True if any of the filters matches. 329 Returns False if none of the filters matches. 330 """ 331 sFullName = self.getFullName(); 332 for oFilter in aoFilters: 333 if oFilter.search(sFullName) is not None if isinstance(oFilter, re.Pattern) else sFullName.find(oFilter) >= 0: 334 return True; 335 return False; 318 336 319 337 # manipulation 320 338 321 def filterTestsWorker(self, asFilters ):339 def filterTestsWorker(self, asFilters, fReturnOnMatch): 322 340 # depth first 323 341 i = 0; 324 342 while i < len(self.aoChildren): 325 if self.aoChildren[i].filterTestsWorker(asFilters ):343 if self.aoChildren[i].filterTestsWorker(asFilters, fReturnOnMatch): 326 344 i += 1; 327 345 else: … … 332 350 if self.aoChildren: 333 351 return True; 334 return self.matchFilters(asFilters); 352 if self.matchFilters(asFilters): 353 return fReturnOnMatch; 354 return not fReturnOnMatch; 335 355 336 356 def filterTests(self, asFilters): 357 """ Keep tests matching asFilters. """ 337 358 if asFilters: 338 self.filterTestsWorker(asFilters )359 self.filterTestsWorker(asFilters, True); 339 360 return self; 361 362 def filterOutTests(self, asFilters): 363 """ Removes tests matching asFilters. """ 364 if asFilters: 365 self.filterTestsWorker(asFilters, False); 366 return self; 367 368 def filterValuesWorker(self, asFilters, fKeepWhen): 369 # Process children recursively. 370 for oChild in self.aoChildren: 371 oChild.filterValuesWorker(asFilters, fKeepWhen); 372 373 # Filter our values. 374 iValue = len(self.aoValues); 375 if iValue > 0: 376 sFullname = self.getFullName() + ': '; 377 while iValue > 0: 378 iValue -= 1; 379 if self.aoValues[iValue].matchFilters(sFullname, asFilters) != fKeepWhen: 380 del self.aoValues[iValue]; 381 return None; 382 383 def filterValues(self, asFilters): 384 """ Keep values matching asFilters. """ 385 if asFilters: 386 self.filterValuesWorker(asFilters, True); 387 return self; 388 389 def filterOutValues(self, asFilters): 390 """ Removes values matching asFilters. """ 391 if asFilters: 392 self.filterValuesWorker(asFilters, False); 393 return self; 394 395 def filterOutEmptyLeafTests(self): 396 """ 397 Removes any child tests that has neither values nor sub-tests. 398 Returns True if leaf, False if not. 399 """ 400 iChild = len(self.aoChildren); 401 while iChild > 0: 402 iChild -= 1; 403 if self.aoChildren[iChild].filterOutEmptyLeafTests(): 404 del self.aoChildren[iChild]; 405 return not self.aoChildren and not self.aoValues; 340 406 341 407 @staticmethod
Note:
See TracChangeset
for help on using the changeset viewer.