Returns line age in days
(line)
| 39 | |
| 40 | |
| 41 | def line_age(line): |
| 42 | """Returns line age in days""" |
| 43 | match = _date_reg_exp.search(line) |
| 44 | if not match: |
| 45 | logging.warning("Line had no date, avoid multiple line messages in logs. Line will have its age set to zero.") |
| 46 | return 0 |
| 47 | else: |
| 48 | dt = datetime.strptime(match.group(), '%Y-%m-%d') |
| 49 | td = today - dt |
| 50 | return td.days |
| 51 | |
| 52 | |
| 53 | def main(exclude_testing: bool = False, limit_days: int = 10, limit_lines: int = 10): |