(self, sel, list, msg)
| 329 | # Optional "amount" is either a line count, or a percentage of lines. |
| 330 | |
| 331 | def eval_print_amount(self, sel, list, msg): |
| 332 | new_list = list |
| 333 | if isinstance(sel, str): |
| 334 | try: |
| 335 | rex = re.compile(sel) |
| 336 | except re.PatternError: |
| 337 | msg += " <Invalid regular expression %r>\n" % sel |
| 338 | return new_list, msg |
| 339 | new_list = [] |
| 340 | for func in list: |
| 341 | if rex.search(func_std_string(func)): |
| 342 | new_list.append(func) |
| 343 | else: |
| 344 | count = len(list) |
| 345 | if isinstance(sel, float) and 0.0 <= sel < 1.0: |
| 346 | count = int(count * sel + .5) |
| 347 | new_list = list[:count] |
| 348 | elif isinstance(sel, int) and 0 <= sel < count: |
| 349 | count = sel |
| 350 | new_list = list[:count] |
| 351 | if len(list) != len(new_list): |
| 352 | msg += " List reduced from %r to %r due to restriction <%r>\n" % ( |
| 353 | len(list), len(new_list), sel) |
| 354 | |
| 355 | return new_list, msg |
| 356 | |
| 357 | def get_stats_profile(self): |
| 358 | """This method returns an instance of StatsProfile, which contains a mapping |
no test coverage detected