If there are no required arguments the else block isn't required.
Signed-off-by: Prasanna Santhanam <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/26ea0811 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/26ea0811 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/26ea0811 Branch: refs/heads/marvin_refactor Commit: 26ea08112a63efa2a02bdb1e260f756341fd9bd1 Parents: bf67e58 Author: Prasanna Santhanam <[email protected]> Authored: Wed May 8 17:28:25 2013 +0530 Committer: Prasanna Santhanam <[email protected]> Committed: Wed May 8 17:28:25 2013 +0530 ---------------------------------------------------------------------- tools/marvin/marvin/cs_entity_generator.py | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/26ea0811/tools/marvin/marvin/cs_entity_generator.py ---------------------------------------------------------------------- diff --git a/tools/marvin/marvin/cs_entity_generator.py b/tools/marvin/marvin/cs_entity_generator.py index 3bf3169..06076f9 100644 --- a/tools/marvin/marvin/cs_entity_generator.py +++ b/tools/marvin/marvin/cs_entity_generator.py @@ -243,9 +243,10 @@ def write_entity_classes(entities, module=None): body.append(tabspace * 2 + 'if factory:') body.append( tabspace * 3 + '[setattr(cmd, factoryKey, factoryValue) for factoryKey, factoryValue in factory.__dict__.iteritems()]') - body.append(tabspace * 2 + 'else:') - for arg in details["args"]: - body.append(tabspace * 3 + "cmd.%s = %s" % (arg, arg)) + if len(details["args"]) > 0: + body.append(tabspace * 2 + 'else:') + for arg in details["args"]: + body.append(tabspace * 3 + "cmd.%s = %s" % (arg, arg)) body.append(tabspace * 2 + '[setattr(cmd, key, value) for key, value in kwargs.iteritems()]') body.append(tabspace * 2 + '%s = apiclient.%s(cmd)' % (entity.lower(), details['apimodule'])) body.append(
