From 5c6eeac8f0350fd6b14cf226ffcff655f1dd9582 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Thu, 11 Oct 2012 16:44:48 +0900 Subject: More coding style cleanup Fixing more issues found with pylint. Some that were supposed to have been fixed in the previous sweep (Ie0db839e) but were missed: C0321: More than one statement on a single line W0622: Redefining built-in 'name' And some more: W0631: Using possibly undefined loop variable 'name' W0223: Method 'name' is abstract in class 'name' but is not overridden W0231: __init__ method from base class 'name' is not called Change-Id: Ie119183708609d6279e973057a385fde864230c3 --- subcmds/__init__.py | 8 ++++---- subcmds/abandon.py | 6 +++--- subcmds/branches.py | 12 ++++++------ subcmds/checkout.py | 6 +++--- subcmds/forall.py | 6 +++++- 5 files changed, 21 insertions(+), 17 deletions(-) (limited to 'subcmds') diff --git a/subcmds/__init__.py b/subcmds/__init__.py index a2286e78..1fac802e 100644 --- a/subcmds/__init__.py +++ b/subcmds/__init__.py @@ -15,7 +15,7 @@ import os -all = {} +all_commands = {} my_dir = os.path.dirname(__file__) for py in os.listdir(my_dir): @@ -43,7 +43,7 @@ for py in os.listdir(my_dir): name = name.replace('_', '-') cmd.NAME = name - all[name] = cmd + all_commands[name] = cmd -if 'help' in all: - all['help'].commands = all +if 'help' in all_commands: + all_commands['help'].commands = all_commands diff --git a/subcmds/abandon.py b/subcmds/abandon.py index 42abb2ff..e17ab2b6 100644 --- a/subcmds/abandon.py +++ b/subcmds/abandon.py @@ -42,10 +42,10 @@ It is equivalent to "git branch -D ". nb = args[0] err = [] success = [] - all = self.GetProjects(args[1:]) + all_projects = self.GetProjects(args[1:]) - pm = Progress('Abandon %s' % nb, len(all)) - for project in all: + pm = Progress('Abandon %s' % nb, len(all_projects)) + for project in all_projects: pm.update() status = project.AbandonBranch(nb) diff --git a/subcmds/branches.py b/subcmds/branches.py index 81aa5b18..a7ba3d6d 100644 --- a/subcmds/branches.py +++ b/subcmds/branches.py @@ -93,17 +93,17 @@ is shown, then the branch appears in all projects. def Execute(self, opt, args): projects = self.GetProjects(args) out = BranchColoring(self.manifest.manifestProject.config) - all = {} + all_branches = {} project_cnt = len(projects) for project in projects: for name, b in project.GetBranches().iteritems(): b.project = project - if name not in all: - all[name] = BranchInfo(name) - all[name].add(b) + if name not in all_branches: + all_branches[name] = BranchInfo(name) + all_branches[name].add(b) - names = all.keys() + names = all_branches.keys() names.sort() if not names: @@ -116,7 +116,7 @@ is shown, then the branch appears in all projects. width = len(name) for name in names: - i = all[name] + i = all_branches[name] in_cnt = len(i.projects) if i.IsCurrent: diff --git a/subcmds/checkout.py b/subcmds/checkout.py index 533d20e1..bfbe9921 100644 --- a/subcmds/checkout.py +++ b/subcmds/checkout.py @@ -39,10 +39,10 @@ The command is equivalent to: nb = args[0] err = [] success = [] - all = self.GetProjects(args[1:]) + all_projects = self.GetProjects(args[1:]) - pm = Progress('Checkout %s' % nb, len(all)) - for project in all: + pm = Progress('Checkout %s' % nb, len(all_projects)) + for project in all_projects: pm.update() status = project.CheckoutBranch(nb) diff --git a/subcmds/forall.py b/subcmds/forall.py index 76a02688..2ece95ed 100644 --- a/subcmds/forall.py +++ b/subcmds/forall.py @@ -141,12 +141,16 @@ terminal and are not redirected. for cn in cmd[1:]: if not cn.startswith('-'): break - if cn in _CAN_COLOR: + else: + cn = None + # pylint: disable-msg=W0631 + if cn and cn in _CAN_COLOR: class ColorCmd(Coloring): def __init__(self, config, cmd): Coloring.__init__(self, config, cmd) if ColorCmd(self.manifest.manifestProject.config, cn).is_on: cmd.insert(cmd.index(cn) + 1, '--color') + # pylint: enable-msg=W0631 mirror = self.manifest.IsMirror out = ForallColoring(self.manifest.manifestProject.config) -- cgit v1.2.3-54-g00ecf