From 9596f4c0792082129fedd3ad587794d60c45eb0d Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=A9dric=20Aguerre?= Date: Tue, 19 May 2015 10:26:39 +0200 Subject: [PATCH] Remove use of mutable as default parameters --- .../salome_tester/salome_instance.py | 4 +++- bin/runSession.py | 4 +++- bin/runTests.py | 4 +++- bin/salomeContext.py | 20 ++++++++++++++----- bin/salomeContextUtils.py.in | 8 ++++++-- 5 files changed, 30 insertions(+), 10 deletions(-) diff --git a/bin/appliskel/salome_tester/salome_instance.py b/bin/appliskel/salome_tester/salome_instance.py index 811333481..e6d88d27a 100644 --- a/bin/appliskel/salome_tester/salome_instance.py +++ b/bin/appliskel/salome_tester/salome_instance.py @@ -53,7 +53,9 @@ class SalomeInstance(object): return salome_instance # - def __run(self, args=[]): + def __run(self, args=None): + if args is None: + args = [] sys.argv = ['runSalome'] + args if "INGUI" in args: diff --git a/bin/runSession.py b/bin/runSession.py index 5f6cc7822..3e9bc1661 100644 --- a/bin/runSession.py +++ b/bin/runSession.py @@ -56,7 +56,9 @@ class SessionParameters: # # -def configureSession(args=[], exe=None): +def configureSession(args=None, exe=None): + if args is None: + args = [] if exe: usage = "Usage: %s [options] [command] [-- ]"%exe else: diff --git a/bin/runTests.py b/bin/runTests.py index 5d3939f9a..e4ca6482d 100644 --- a/bin/runTests.py +++ b/bin/runTests.py @@ -22,7 +22,9 @@ import sys import select import subprocess -def __configureTests(args=[], exe=None): +def __configureTests(args=None, exe=None): + if args is None: + args = [] if exe: usage = "Usage: %s [options]"%exe else: diff --git a/bin/salomeContext.py b/bin/salomeContext.py index 4c7a45024..84ab538d3 100644 --- a/bin/salomeContext.py +++ b/bin/salomeContext.py @@ -333,7 +333,9 @@ class SalomeContext: sys.path[:0] = pythonpath # - def _runAppli(self, args=[]): + def _runAppli(self, args=None): + if args is None: + args = [] # Initialize SALOME environment sys.argv = ['runSalome'] + args import setenv @@ -363,7 +365,9 @@ class SalomeContext: return proc.communicate() # - def _runSession(self, args=[]): + def _runSession(self, args=None): + if args is None: + args = [] sys.argv = ['runSession'] + args import runSession params, args = runSession.configureSession(args, exe="salome shell") @@ -375,7 +379,9 @@ class SalomeContext: return runSession.runSession(params, args) # - def _runConsole(self, args=[]): + def _runConsole(self, args=None): + if args is None: + args = [] # Initialize SALOME environment sys.argv = ['runConsole'] + args import setenv @@ -386,7 +392,9 @@ class SalomeContext: return proc.communicate() # - def _kill(self, args=[]): + def _kill(self, args=None): + if args is None: + args = [] ports = args if not ports: print "Port number(s) not provided to command: salome kill " @@ -423,7 +431,9 @@ class SalomeContext: pass # - def _runTests(self, args=[]): + def _runTests(self, args=None): + if args is None: + args = [] sys.argv = ['runTests'] import setenv setenv.main(True) diff --git a/bin/salomeContextUtils.py.in b/bin/salomeContextUtils.py.in index 724106a6e..dcd9854e5 100644 --- a/bin/salomeContextUtils.py.in +++ b/bin/salomeContextUtils.py.in @@ -133,7 +133,9 @@ class ScriptAndArgsObjectEncoder(json.JSONEncoder): return json.JSONEncoder.default(self, obj) # -def getShortAndExtraArgs(args=[]): +def getShortAndExtraArgs(args=None): + if args is None: + args = [] try: pos = args.index("--") # raise a ValueError if not found short_args = args[:pos] @@ -147,7 +149,9 @@ def getShortAndExtraArgs(args=[]): # # Return an array of ScriptAndArgs objects -def getScriptsAndArgs(args=[], searchPathList=None): +def getScriptsAndArgs(args=None, searchPathList=None): + if args is None: + args = [] short_args, extra_args = getShortAndExtraArgs(args) args = short_args -- 2.39.2