autotest: Extract _parse_status_log

BUG=chromium:833988
TEST=None

Change-Id: I2294017636fe23c467bca047f59f8405acb1b8ff
Reviewed-on: https://chromium-review.googlesource.com/1018586
Commit-Ready: Prathmesh Prabhu <pprabhu@chromium.org>
Tested-by: Prathmesh Prabhu <pprabhu@chromium.org>
Reviewed-by: Prathmesh Prabhu <pprabhu@chromium.org>
Reviewed-by: Xixuan Wu <xixuan@chromium.org>
diff --git a/tko/parse.py b/tko/parse.py
index 4118060..ef8bf34 100755
--- a/tko/parse.py
+++ b/tko/parse.py
@@ -341,24 +341,12 @@
 
     parser = parser_lib.parser(status_version)
     job = parser.make_job(path)
-    status_log = _find_status_log_path(path)
-    if not status_log:
+    tko_utils.dprint("+ Parsing dir=%s, jobname=%s" % (path, jobname))
+    status_log_path = _find_status_log_path(path)
+    if not status_log_path:
         tko_utils.dprint("! Unable to parse job, no status file")
         return
-
-    # parse the status logs
-    tko_utils.dprint("+ Parsing dir=%s, jobname=%s" % (path, jobname))
-    status_lines = open(status_log).readlines()
-    parser.start(job)
-    tests = parser.end(status_lines)
-
-    # parser.end can return the same object multiple times, so filter out dups
-    job.tests = []
-    already_added = set()
-    for test in tests:
-        if test not in already_added:
-            already_added.add(test)
-            job.tests.append(test)
+    _parse_status_log(parser, job, status_log_path)
 
     # try and port test_idx over from the old tests, but if old tests stop
     # matching up with new ones just give up
@@ -570,6 +558,20 @@
     return ""
 
 
+def _parse_status_log(parser, job, status_log_path):
+    status_lines = open(status_log_path).readlines()
+    parser.start(job)
+    tests = parser.end(status_lines)
+
+    # parser.end can return the same object multiple times, so filter out dups
+    job.tests = []
+    already_added = set()
+    for test in tests:
+        if test not in already_added:
+            already_added.add(test)
+            job.tests.append(test)
+
+
 def _get_job_subdirs(path):
     """
     Returns a list of job subdirectories at path. Returns None if the test