Coding style cleanup

Fix the following issues reported by pylint:

C0321: More than one statement on a single line
W0622: Redefining built-in 'name'
W0612: Unused variable 'name'
W0613: Unused argument 'name'
W0102: Dangerous default value 'value' as argument
W0105: String statement has no effect

Also fixed a few cases of inconsistent indentation.

Change-Id: Ie0db839e7c57d576cff12d8c055fe87030d00744
diff --git a/subcmds/branches.py b/subcmds/branches.py
index a4f8d36..81aa5b1 100644
--- a/subcmds/branches.py
+++ b/subcmds/branches.py
@@ -140,12 +140,12 @@
         fmt = out.write
         paths = []
         if in_cnt < project_cnt - in_cnt: 
-          type = 'in'
+          in_type = 'in'
           for b in i.projects:
             paths.append(b.project.relpath)
         else:
           fmt = out.notinproject
-          type = 'not in'
+          in_type = 'not in'
           have = set()
           for b in i.projects:
             have.add(b.project)
@@ -153,11 +153,11 @@
             if not p in have:
               paths.append(p.relpath)
 
-        s = ' %s %s' % (type, ', '.join(paths))
+        s = ' %s %s' % (in_type, ', '.join(paths))
         if width + 7 + len(s) < 80:
           fmt(s)
         else:
-          fmt(' %s:' % type)
+          fmt(' %s:' % in_type)
           for p in paths:
             out.nl()
             fmt(width*' ' + '          %s' % p)
diff --git a/subcmds/forall.py b/subcmds/forall.py
index 9436f4e..76a0268 100644
--- a/subcmds/forall.py
+++ b/subcmds/forall.py
@@ -208,7 +208,6 @@
             return self.fd.fileno()
 
         empty = True
-        didout = False
         errbuf = ''
 
         p.stdin.close()
@@ -220,7 +219,7 @@
           fcntl.fcntl(s.fd, fcntl.F_SETFL, flags | os.O_NONBLOCK)
 
         while s_in:
-          in_ready, out_ready, err_ready = select.select(s_in, [], [])
+          in_ready, _out_ready, _err_ready = select.select(s_in, [], [])
           for s in in_ready:
             buf = s.fd.read(4096)
             if not buf:
@@ -229,9 +228,7 @@
               continue
 
             if not opt.verbose:
-              if s.fd == p.stdout:
-                didout = True
-              else:
+              if s.fd != p.stdout:
                 errbuf += buf
                 continue
 
diff --git a/subcmds/help.py b/subcmds/help.py
index 0df3c14..375d04d 100644
--- a/subcmds/help.py
+++ b/subcmds/help.py
@@ -120,8 +120,8 @@
           m = asciidoc_hdr.match(para)
           if m:
             title = m.group(1)
-            type = m.group(2)
-            if type[0] in ('=', '-'):
+            section_type = m.group(2)
+            if section_type[0] in ('=', '-'):
               p = self.heading
             else:
               def _p(fmt, *args):
@@ -131,7 +131,7 @@
 
             p('%s', title)
             self.nl()
-            p('%s', ''.ljust(len(title),type[0]))
+            p('%s', ''.ljust(len(title),section_type[0]))
             self.nl()
             continue
 
diff --git a/subcmds/init.py b/subcmds/init.py
index 9a4f711..697d6be 100644
--- a/subcmds/init.py
+++ b/subcmds/init.py
@@ -213,8 +213,6 @@
       sys.exit(1)
 
   def _Prompt(self, prompt, value):
-    mp = self.manifest.manifestProject
-
     sys.stdout.write('%-10s [%s]: ' % (prompt, value))
     a = sys.stdin.readline().strip()
     if a == '':
@@ -328,9 +326,9 @@
     self._ConfigureDepth(opt)
 
     if self.manifest.IsMirror:
-      type = 'mirror '
+      init_type = 'mirror '
     else:
-      type = ''
+      init_type = ''
 
     print ''
-    print 'repo %sinitialized in %s' % (type, self.manifest.topdir)
+    print 'repo %sinitialized in %s' % (init_type, self.manifest.topdir)
diff --git a/subcmds/manifest.py b/subcmds/manifest.py
index 4388765..5592a37 100644
--- a/subcmds/manifest.py
+++ b/subcmds/manifest.py
@@ -35,14 +35,14 @@
 
   @property
   def helpDescription(self):
-    help = self._helpDescription + '\n'
+    helptext = self._helpDescription + '\n'
     r = os.path.dirname(__file__)
     r = os.path.dirname(r)
     fd = open(os.path.join(r, 'docs', 'manifest-format.txt'))
     for line in fd:
-      help += line
+      helptext += line
     fd.close()
-    return help
+    return helptext
 
   def _Options(self, p):
     p.add_option('-r', '--revision-as-HEAD',
diff --git a/subcmds/overview.py b/subcmds/overview.py
index 96fa93d..a509bd9 100644
--- a/subcmds/overview.py
+++ b/subcmds/overview.py
@@ -38,16 +38,16 @@
                  help="Consider only checked out branches")
 
   def Execute(self, opt, args):
-    all = []
+    all_branches = []
     for project in self.GetProjects(args):
       br = [project.GetUploadableBranch(x)
             for x in project.GetBranches().keys()]
       br = [x for x in br if x]
       if opt.current_branch:
         br = [x for x in br if x.name == project.CurrentBranch]
-      all.extend(br)
+      all_branches.extend(br)
 
-    if not all:
+    if not all_branches:
       return
 
     class Report(Coloring):
@@ -55,13 +55,13 @@
         Coloring.__init__(self, config, 'status')
         self.project = self.printer('header', attr='bold')
 
-    out = Report(all[0].project.config)
+    out = Report(all_branches[0].project.config)
     out.project('Projects Overview')
     out.nl()
 
     project = None
 
-    for branch in all:
+    for branch in all_branches:
       if project != branch.project:
         project = branch.project
         out.nl()
diff --git a/subcmds/prune.py b/subcmds/prune.py
index f412bd4..c50a550 100644
--- a/subcmds/prune.py
+++ b/subcmds/prune.py
@@ -24,11 +24,11 @@
 """
 
   def Execute(self, opt, args):
-    all = []
+    all_branches = []
     for project in self.GetProjects(args):
-      all.extend(project.PruneHeads())
+      all_branches.extend(project.PruneHeads())
 
-    if not all:
+    if not all_branches:
       return
 
     class Report(Coloring):
@@ -36,13 +36,13 @@
         Coloring.__init__(self, config, 'status')
         self.project = self.printer('header', attr='bold')
 
-    out = Report(all[0].project.config)
+    out = Report(all_branches[0].project.config)
     out.project('Pending Branches')
     out.nl()
 
     project = None
 
-    for branch in all:
+    for branch in all_branches:
       if project != branch.project:
         project = branch.project
         out.nl()
diff --git a/subcmds/rebase.py b/subcmds/rebase.py
index 2c1752d..a8d58cd 100644
--- a/subcmds/rebase.py
+++ b/subcmds/rebase.py
@@ -55,14 +55,14 @@
                  help='Stash local modifications before starting')
 
   def Execute(self, opt, args):
-    all = self.GetProjects(args)
-    one_project = len(all) == 1
+    all_projects = self.GetProjects(args)
+    one_project = len(all_projects) == 1
 
     if opt.interactive and not one_project:
       print >>sys.stderr, 'error: interactive rebase not supported with multiple projects'
       return -1
 
-    for project in all:
+    for project in all_projects:
       cb = project.CurrentBranch
       if not cb:
         if one_project:
diff --git a/subcmds/stage.py b/subcmds/stage.py
index 4c221db..2ec4806 100644
--- a/subcmds/stage.py
+++ b/subcmds/stage.py
@@ -48,8 +48,8 @@
       self.Usage()
 
   def _Interactive(self, opt, args):
-    all = filter(lambda x: x.IsDirty(), self.GetProjects(args))
-    if not all:
+    all_projects = filter(lambda x: x.IsDirty(), self.GetProjects(args))
+    if not all_projects:
       print >>sys.stderr,'no projects have uncommitted modifications'
       return
 
@@ -58,8 +58,8 @@
       out.header('        %s', 'project')
       out.nl()
 
-      for i in xrange(0, len(all)):
-        p = all[i]
+      for i in xrange(0, len(all_projects)):
+        p = all_projects[i]
         out.write('%3d:    %s', i + 1, p.relpath + '/')
         out.nl()
       out.nl()
@@ -93,11 +93,11 @@
       if a_index is not None:
         if a_index == 0:
           break
-        if 0 < a_index and a_index <= len(all):
-          _AddI(all[a_index - 1])
+        if 0 < a_index and a_index <= len(all_projects):
+          _AddI(all_projects[a_index - 1])
           continue
 
-      p = filter(lambda x: x.name == a or x.relpath == a, all)
+      p = filter(lambda x: x.name == a or x.relpath == a, all_projects)
       if len(p) == 1:
         _AddI(p[0])
         continue
diff --git a/subcmds/start.py b/subcmds/start.py
index 0088507..be64531 100644
--- a/subcmds/start.py
+++ b/subcmds/start.py
@@ -52,10 +52,10 @@
         print >>sys.stderr, "error: at least one project must be specified"
         sys.exit(1)
 
-    all = self.GetProjects(projects)
+    all_projects = self.GetProjects(projects)
 
-    pm = Progress('Starting %s' % nb, len(all))
-    for project in all:
+    pm = Progress('Starting %s' % nb, len(all_projects))
+    for project in all_projects:
       pm.update()
       # If the current revision is a specific SHA1 then we can't push back
       # to it so substitute the manifest default revision instead.
diff --git a/subcmds/status.py b/subcmds/status.py
index 75d68eb..7611621 100644
--- a/subcmds/status.py
+++ b/subcmds/status.py
@@ -98,18 +98,18 @@
       sem.release()
 
   def Execute(self, opt, args):
-    all = self.GetProjects(args)
+    all_projects = self.GetProjects(args)
     counter = itertools.count()
 
     if opt.jobs == 1:
-      for project in all:
+      for project in all_projects:
         state = project.PrintWorkTreeStatus()
         if state == 'CLEAN':
           counter.next()
     else:
       sem = _threading.Semaphore(opt.jobs)
       threads_and_output = []
-      for project in all:
+      for project in all_projects:
         sem.acquire()
 
         class BufList(StringIO.StringIO):
@@ -128,5 +128,5 @@
         t.join()
         output.dump(sys.stdout)
         output.close()
-    if len(all) == counter.next():
+    if len(all_projects) == counter.next():
       print 'nothing to commit (working directory clean)'
diff --git a/subcmds/sync.py b/subcmds/sync.py
index b84d169..1b71635 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -316,8 +316,7 @@
         if not path:
           continue
         if path not in new_project_paths:
-          """If the path has already been deleted, we don't need to do it
-          """
+          # If the path has already been deleted, we don't need to do it
           if os.path.exists(self.manifest.topdir + '/' + path):
               project = Project(
                              manifest = self.manifest,
@@ -495,16 +494,16 @@
       self.manifest._Unload()
       if opt.jobs is None:
         self.jobs = self.manifest.default.sync_j
-    all = self.GetProjects(args, missing_ok=True)
+    all_projects = self.GetProjects(args, missing_ok=True)
 
     if not opt.local_only:
       to_fetch = []
       now = time.time()
       if (24 * 60 * 60) <= (now - rp.LastFetch):
         to_fetch.append(rp)
-      to_fetch.extend(all)
+      to_fetch.extend(all_projects)
 
-      fetched = self._Fetch(to_fetch, opt)
+      self._Fetch(to_fetch, opt)
       _PostRepoFetch(rp, opt.no_repo_verify)
       if opt.network_only:
         # bail out now; the rest touches the working tree
@@ -519,8 +518,8 @@
 
     syncbuf = SyncBuffer(mp.config,
                          detach_head = opt.detach_head)
-    pm = Progress('Syncing work tree', len(all))
-    for project in all:
+    pm = Progress('Syncing work tree', len(all_projects))
+    for project in all_projects:
       pm.update()
       if project.worktree:
         project.Sync_LocalHalf(syncbuf)
diff --git a/subcmds/upload.py b/subcmds/upload.py
index c931297..685e342 100644
--- a/subcmds/upload.py
+++ b/subcmds/upload.py
@@ -40,8 +40,8 @@
 
 def _SplitEmails(values):
   result = []
-  for str in values:
-    result.extend([s.strip() for s in str.split(',')])
+  for value in values:
+    result.extend([s.strip() for s in value.split(',')])
   return result
 
 class Upload(InteractiveCommand):
@@ -174,15 +174,15 @@
 
     if answer is None:
       date = branch.date
-      list = branch.commits
+      commit_list = branch.commits
 
       print 'Upload project %s/ to remote branch %s:' % (project.relpath, project.revisionExpr)
       print '  branch %s (%2d commit%s, %s):' % (
                     name,
-                    len(list),
-                    len(list) != 1 and 's' or '',
+                    len(commit_list),
+                    len(commit_list) != 1 and 's' or '',
                     date)
-      for commit in list:
+      for commit in commit_list:
         print '         %s' % commit
 
       sys.stdout.write('to %s (y/N)? ' % remote.review)
@@ -212,17 +212,17 @@
       for branch in avail:
         name = branch.name
         date = branch.date
-        list = branch.commits
+        commit_list = branch.commits
 
         if b:
           script.append('#')
         script.append('#  branch %s (%2d commit%s, %s) to remote branch %s:' % (
                       name,
-                      len(list),
-                      len(list) != 1 and 's' or '',
+                      len(commit_list),
+                      len(commit_list) != 1 and 's' or '',
                       date,
                       project.revisionExpr))
-        for commit in list:
+        for commit in commit_list:
           script.append('#         %s' % commit)
         b[name] = branch