[autotest] Extract use_batch logic

This frees up a parameter that we dont have to pass around later.

BUG=chromium:672348
TEST=None

Change-Id: I4a568fe244fc87d4a512740dc5f7919c696cd3a4
Reviewed-on: https://chromium-review.googlesource.com/447789
Commit-Ready: Allen Li <ayatane@chromium.org>
Tested-by: Allen Li <ayatane@chromium.org>
Reviewed-by: Prathmesh Prabhu <pprabhu@chromium.org>
diff --git a/server/cros/dynamic_suite/suite.py b/server/cros/dynamic_suite/suite.py
index f9b10a6..0268350 100644
--- a/server/cros/dynamic_suite/suite.py
+++ b/server/cros/dynamic_suite/suite.py
@@ -346,10 +346,7 @@
     """
     logging.debug('Getting control file list for suite: %s', suite_name)
     tests = {}
-    use_batch = (ENABLE_CONTROLS_IN_BATCH
-                 and isinstance(cf_getter,
-                                control_file_getter.DevServerGetter))
-    if use_batch:
+    if _should_batch_with(cf_getter):
         suite_info = cf_getter.get_suite_info(suite_name=suite_name)
         files = suite_info.keys()
     else:
@@ -359,7 +356,7 @@
     logging.debug('Parsing control files ...')
     matcher = re.compile(r'[^/]+/(deps|profilers)/.+')
     for file in filter(lambda f: not matcher.match(f), files):
-        if use_batch:
+        if _should_batch_with(cf_getter):
             text = suite_info[file]
         else:
             text = cf_getter.get_control_file_contents(file)
@@ -385,6 +382,18 @@
     return tests
 
 
+def _should_batch_with(cf_getter):
+    """Return whether control files should be fetched in batch.
+
+    This depends on the control file getter and configuration options.
+
+    @param cf_getter: a control_file_getter.ControlFileGetter used to list
+           and fetch the content of control files
+    """
+    return (ENABLE_CONTROLS_IN_BATCH
+            and isinstance(cf_getter, control_file_getter.DevServerGetter))
+
+
 class Suite(object):
     """
     A suite of tests, defined by some predicate over control file variables.