~andrewjbeach/juju-ci-tools/make-local-patcher

« back to all changes in this revision

Viewing changes to logbreakdown.py

Touch up and tests for logbreakdown

Show diffs side-by-side

added added

removed removed

Lines of Context:
105
105
 
106
106
 
107
107
def log_line_within_start_range(line, range_start):
108
 
    datestamp = " ".join(line.split()[0:2])
 
108
    datestamp = extract_date_from_line(line)
109
109
    try:
110
110
        ds = datetime.strptime(datestamp, dt_format)
111
111
    except ValueError:
117
117
    return False
118
118
 
119
119
 
120
 
def log_line_within_end_range(line, range_start):
121
 
    datestamp = " ".join(line.split()[0:2])
 
120
def log_line_within_end_range(line, range_end):
 
121
    datestamp = extract_date_from_line(line)
122
122
    try:
123
123
        ds = datetime.strptime(datestamp, dt_format)
124
124
    except ValueError:
125
 
        # Fine to collect this line as we haven't hit a dated line that is
126
 
        # after our target.
 
125
        # Fine to collect this line as the line doesn't start with a date and
 
126
        # is thus a continuation or undated message.
127
127
        return True
128
128
 
129
 
    if ds < range_start or ds == range_start:
 
129
    if ds < range_end or ds == range_end:
130
130
        return True
131
131
    return False
 
132
 
 
133
 
 
134
def extract_date_from_line(line):
 
135
    return " ".join(line.split()[0:2])