[cedar-backup-svn] SF.net SVN: cedar-backup:[963] cedar-backup2/trunk
Brought to you by:
pronovic
|
From: <pro...@us...> - 2010-01-10 23:57:22
|
Revision: 963
http://cedar-backup.svn.sourceforge.net/cedar-backup/?rev=963&view=rev
Author: pronovic
Date: 2010-01-10 23:57:16 +0000 (Sun, 10 Jan 2010)
Log Message:
-----------
Properly handle config.options.overrides=None
Modified Paths:
--------------
cedar-backup2/trunk/CedarBackup2/config.py
cedar-backup2/trunk/test/configtests.py
cedar-backup2/trunk/test/customizetests.py
Modified: cedar-backup2/trunk/CedarBackup2/config.py
===================================================================
--- cedar-backup2/trunk/CedarBackup2/config.py 2010-01-10 23:24:37 UTC (rev 962)
+++ cedar-backup2/trunk/CedarBackup2/config.py 2010-01-10 23:57:16 UTC (rev 963)
@@ -2628,13 +2628,17 @@
@param command: Name of command to be overridden.
@param absolutePath: Absolute path of the overrridden command.
"""
- exists = False
- for object in self.overrides:
- if object.command == command:
- exists = True
- break
- if not exists:
- self.overrides.append(CommandOverride(command, absolutePath))
+ override = CommandOverride(command, absolutePath)
+ if self.overrides is None:
+ self.overrides = [ override, ]
+ else:
+ exists = False
+ for object in self.overrides:
+ if object.command == override.command:
+ exists = True
+ break
+ if not exists:
+ self.overrides.append(override)
def replaceOverride(self, command, absolutePath):
"""
@@ -2642,14 +2646,18 @@
@param command: Name of command to be overridden.
@param absolutePath: Absolute path of the overrridden command.
"""
- exists = False
- for object in self.overrides:
- if object.command == command:
- exists = True
- object.absolutePath = absolutePath
- break
- if not exists:
- self.overrides.append(CommandOverride(command, absolutePath))
+ override = CommandOverride(command, absolutePath)
+ if self.overrides is None:
+ self.overrides = [ override, ]
+ else:
+ exists = False
+ for object in self.overrides:
+ if object.command == override.command:
+ exists = True
+ object.absolutePath = override.absolutePath
+ break
+ if not exists:
+ self.overrides.append(override)
def _setStartingDay(self, value):
"""
Modified: cedar-backup2/trunk/test/configtests.py
===================================================================
--- cedar-backup2/trunk/test/configtests.py 2010-01-10 23:24:37 UTC (rev 962)
+++ cedar-backup2/trunk/test/configtests.py 2010-01-10 23:57:16 UTC (rev 963)
@@ -6040,7 +6040,6 @@
Test addOverride() with no existing overrides.
"""
options = OptionsConfig();
- options.overrides = []
options.addOverride("cdrecord", "/usr/bin/wodim")
self.failUnlessEqual([ CommandOverride("cdrecord", "/usr/bin/wodim"), ], options.overrides);
@@ -6067,7 +6066,6 @@
Test replaceOverride() with no existing overrides.
"""
options = OptionsConfig();
- options.overrides = []
options.replaceOverride("cdrecord", "/usr/bin/wodim")
self.failUnlessEqual([ CommandOverride("cdrecord", "/usr/bin/wodim"), ], options.overrides);
Modified: cedar-backup2/trunk/test/customizetests.py
===================================================================
--- cedar-backup2/trunk/test/customizetests.py 2010-01-10 23:24:37 UTC (rev 962)
+++ cedar-backup2/trunk/test/customizetests.py 2010-01-10 23:57:16 UTC (rev 963)
@@ -77,14 +77,13 @@
"""
config = Config()
options = OptionsConfig();
- options.overrides = []
if PLATFORM == "standard":
config.options = options
customizeOverrides(config)
- self.failUnlessEqual([], options.overrides);
+ self.failUnlessEqual(None, options.overrides);
config.options = options
customizeOverrides(config, platform="standard")
- self.failUnlessEqual([], options.overrides);
+ self.failUnlessEqual(None, options.overrides);
def testCustomizeOverrides_002(self):
"""
@@ -137,7 +136,6 @@
"""
config = Config()
options = OptionsConfig();
- options.overrides = []
if PLATFORM == "debian":
config.options = options
customizeOverrides(config)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|