Skip to content

Commit

Permalink
Bug 1188444 - Return earlier when a parser is marked as complete
Browse files Browse the repository at this point in the history
Once a parser has declared itself complete, there is no need to
increment the line number or trim the line to the max line length.
  • Loading branch information
Ed Morley committed Aug 18, 2015
1 parent 095fc79 commit ea546c1
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions treeherder/log_parser/artifactbuilders.py
Expand Up @@ -44,18 +44,19 @@ def __init__(self, url=None):

def parse_line(self, line):
"""Parse a single line of the log."""
# The parser may only need to run until it has seen a specific line.
# Once that's occurred, it can mark itself as complete, to save
# being run against later log lines.
if self.parser.complete:
return

# Talos data is stored in a json structure contained in a single line,
# if the MAX_LINE_LENGTH is applied the data structure could be truncated,
# preventing it from being ingested.
if "TALOSDATA" not in line and 'TalosResult' not in line:
line = line[:self.MAX_LINE_LENGTH]

# The parser may only need to run until it has seen a specific line.
# Once that's occurred, it can mark itself as complete, to save
# being run against later log lines.
if not self.parser.complete:
self.parser.parse_line(line, self.lineno)

self.parser.parse_line(line, self.lineno)
self.lineno += 1

def get_artifact(self):
Expand Down

0 comments on commit ea546c1

Please sign in to comment.