chrome_committer: Refactor arg passing.

Pass args individually instead of the arg array.

BUG=chromium:1019968
TEST=lib/chrome_committer_unittest; scripts/chrome_chromeos_lkgm_unittest

Change-Id: I8eb20de1fb5c6cebc2929a163a1be93ba08bbcb6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/1959094
Commit-Queue: Achuith Bhandarkar <achuith@chromium.org>
Tested-by: Achuith Bhandarkar <achuith@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/lib/chrome_committer.py b/lib/chrome_committer.py
index 171e41d..466757f 100644
--- a/lib/chrome_committer.py
+++ b/lib/chrome_committer.py
@@ -24,16 +24,14 @@
 class ChromeCommitter(object):
   """Committer object responsible for committing a git change."""
 
-  def __init__(self, args):
-    self._checkout_dir = args.workdir
-    self._dryrun = args.dryrun
-    self._git_committer_args = ['-c', 'user.email=%s' % args.user_email,
-                                '-c', 'user.name=%s' % args.user_email]
+  def __init__(self, user_email, workdir, dryrun=False):
+    logging.info('user_email=%s, checkout_dir=%s', user_email, workdir)
+    self.author = user_email
+    self._checkout_dir = workdir
+    self._git_committer_args = ['-c', 'user.email=%s' % user_email,
+                                '-c', 'user.name=%s' % user_email]
     self._commit_msg = ''
-    self.author = args.user_email
-
-    logging.info('user_email=%s', args.user_email)
-    logging.info('checkout_dir=%s', args.workdir)
+    self._dryrun = dryrun
 
   def __del__(self):
     self.Cleanup()
@@ -129,7 +127,7 @@
     """Returns parser for ChromeCommitter.
 
     Returns:
-      Dictionary of parsed command line args.
+      Parser for ChromeCommitter.
     """
     # We need to use the account used by the builder to upload git CLs when
     # generating CLs.
diff --git a/lib/chrome_committer_unittest.py b/lib/chrome_committer_unittest.py
index e1b5a40..49b26a9 100644
--- a/lib/chrome_committer_unittest.py
+++ b/lib/chrome_committer_unittest.py
@@ -18,14 +18,6 @@
                             cros_test_lib.MockTempDirTestCase):
   """Test cros_chromeos_lkgm.Committer."""
 
-  class Args(object):
-    """Class for ChromeComitter args."""
-    def __init__(self, workdir):
-      self.workdir = workdir
-      self.dryrun = False
-      self.user_email = 'user@test.org'
-
-
   def setUp(self):
     """Common set up method for all tests."""
     osutils.SafeMakedirs(os.path.join(self.tempdir, '.git', 'info'))
@@ -34,7 +26,7 @@
     osutils.WriteFile(os.path.join(self.tempdir, 'chromeos', 'BUILD.gn'),
                       'assert(is_chromeos)')
     self.committer = chrome_committer.ChromeCommitter(
-        ChromeCommitterTester.Args(self.tempdir))
+        'user@test.org', self.tempdir)
 
   def _assertCommand(self, git_cmd):
     self.assertCommandContains(git_cmd.split(' '))
diff --git a/scripts/chrome_chromeos_lkgm.py b/scripts/chrome_chromeos_lkgm.py
index 1496e00..33eef86 100644
--- a/scripts/chrome_chromeos_lkgm.py
+++ b/scripts/chrome_chromeos_lkgm.py
@@ -49,17 +49,17 @@
       'tools/translation/TRANSLATION_OWNERS',
   ]
 
-  def __init__(self, args):
-    self._committer = chrome_committer.ChromeCommitter(args)
+  def __init__(self, user_email, workdir, lkgm, dryrun=False):
+    self._committer = chrome_committer.ChromeCommitter(
+        user_email, workdir, dryrun)
 
     # Strip any chrome branch from the lkgm version.
-    self._lkgm = manifest_version.VersionInfo(args.lkgm).VersionString()
+    self._lkgm = manifest_version.VersionInfo(lkgm).VersionString()
     self._old_lkgm = None
 
     if not self._lkgm:
       raise LKGMNotValid('LKGM not provided.')
-
-    logging.info('lkgm=%s', self._lkgm)
+    logging.info('lkgm=%s', lkgm)
 
   def Run(self):
     self.CloseOldLKGMRolls()
@@ -133,14 +133,14 @@
                            self.ComposeCommitMsg())
 
 
-def GetArgs(argv):
-  """Returns a dictionary of parsed args.
+def GetOpts(argv):
+  """Returns a dictionary of parsed options.
 
   Args:
     argv: raw command line.
 
   Returns:
-    Dictionary of parsed args.
+    Dictionary of parsed options.
   """
   committer_parser = chrome_committer.ChromeCommitter.GetParser()
   parser = commandline.ArgumentParser(description=__doc__,
@@ -151,5 +151,8 @@
   return parser.parse_args(argv)
 
 def main(argv):
-  ChromeLKGMCommitter(GetArgs(argv)).Run()
+  opts = GetOpts(argv)
+  committer = ChromeLKGMCommitter(opts.user_email, opts.workdir,
+                                  opts.lkgm, opts.dryrun)
+  committer.Run()
   return 0
diff --git a/scripts/chrome_chromeos_lkgm_unittest.py b/scripts/chrome_chromeos_lkgm_unittest.py
index 30d2873..a9b5d69 100644
--- a/scripts/chrome_chromeos_lkgm_unittest.py
+++ b/scripts/chrome_chromeos_lkgm_unittest.py
@@ -21,19 +21,10 @@
                                 cros_test_lib.MockTempDirTestCase):
   """Test cros_chromeos_lkgm.Committer."""
 
-  class Args(object):
-    """Class for ChromeLKGMComitter args."""
-    def __init__(self, workdir, lkgm):
-      self.workdir = workdir
-      self.lkgm = lkgm
-      self.dryrun = False
-      self.user_email = 'user@test.org'
-
-
   def setUp(self):
     """Common set up method for all tests."""
     self.committer = chrome_chromeos_lkgm.ChromeLKGMCommitter(
-        ChromeLKGMCommitterTester.Args(self.tempdir, '1001.0.0'))
+        'user@test.org', self.tempdir, '1001.0.0')
     self.lkgm_file = os.path.join(self.tempdir, constants.PATH_TO_CHROME_LKGM)
     self.old_lkgm = None
 
@@ -87,7 +78,7 @@
   def testVersionWithChromeBranch(self):
     """Tests passing a version with a chrome branch strips the branch."""
     self.committer = chrome_chromeos_lkgm.ChromeLKGMCommitter(
-        ChromeLKGMCommitterTester.Args(self.tempdir, '1003.0.0-rc2'))
+        'user@test.org', self.tempdir, '1003.0.0-rc2')
 
     self.old_lkgm = '1002.0.0'
     self.rc.AddCmdResult(partial_mock.In('remote'), returncode=0,