[cedar-backup-svn] SF.net SVN: cedar-backup:[997] cedar-backup2/trunk
Brought to you by:
pronovic
|
From: <pro...@us...> - 2010-07-07 20:08:27
|
Revision: 997
http://cedar-backup.svn.sourceforge.net/cedar-backup/?rev=997&view=rev
Author: pronovic
Date: 2010-07-07 19:34:11 +0000 (Wed, 07 Jul 2010)
Log Message:
-----------
Convert to use @staticmethod
Modified Paths:
--------------
cedar-backup2/trunk/CedarBackup2/cli.py
cedar-backup2/trunk/CedarBackup2/config.py
cedar-backup2/trunk/CedarBackup2/extend/capacity.py
cedar-backup2/trunk/CedarBackup2/extend/encrypt.py
cedar-backup2/trunk/CedarBackup2/extend/mbox.py
cedar-backup2/trunk/CedarBackup2/extend/mysql.py
cedar-backup2/trunk/CedarBackup2/extend/postgresql.py
cedar-backup2/trunk/CedarBackup2/extend/split.py
cedar-backup2/trunk/CedarBackup2/extend/subversion.py
cedar-backup2/trunk/CedarBackup2/filesystem.py
cedar-backup2/trunk/CedarBackup2/peer.py
cedar-backup2/trunk/CedarBackup2/util.py
cedar-backup2/trunk/CedarBackup2/writers/cdwriter.py
cedar-backup2/trunk/CedarBackup2/writers/dvdwriter.py
cedar-backup2/trunk/CedarBackup2/writers/util.py
cedar-backup2/trunk/Changelog
cedar-backup2/trunk/doc/future/prune.py
Modified: cedar-backup2/trunk/CedarBackup2/cli.py
===================================================================
--- cedar-backup2/trunk/CedarBackup2/cli.py 2010-07-07 19:31:34 UTC (rev 996)
+++ cedar-backup2/trunk/CedarBackup2/cli.py 2010-07-07 19:34:11 UTC (rev 997)
@@ -546,6 +546,7 @@
_ActionSet._validateActions(actions, extensionNames)
self.actionSet = _ActionSet._buildActionSet(actions, actionMap)
+ @staticmethod
def _deriveExtensionNames(extensions):
"""
Builds a list of extended actions that are available in configuration.
@@ -557,8 +558,8 @@
for action in extensions.actions:
extensionNames.append(action.name)
return extensionNames
- _deriveExtensionNames = staticmethod(_deriveExtensionNames)
+ @staticmethod
def _buildHookMaps(hooks):
"""
Build two mappings from action name to configured C{ActionHook}.
@@ -574,8 +575,8 @@
elif hook.after:
postHookMap[hook.action] = hook
return (preHookMap, postHookMap)
- _buildHookMaps = staticmethod(_buildHookMaps)
+ @staticmethod
def _buildFunctionMap(extensions):
"""
Builds a mapping from named action to action function.
@@ -594,8 +595,8 @@
for action in extensions.actions:
functionMap[action.name] = getFunctionReference(action.module, action.function)
return functionMap
- _buildFunctionMap = staticmethod(_buildFunctionMap)
+ @staticmethod
def _buildIndexMap(extensions):
"""
Builds a mapping from action name to proper execution index.
@@ -681,8 +682,8 @@
logger.error("Extensions configuration is invalid (check for loops).")
raise ValueError("Unable to determine proper action order due to dependency recursion.")
return indexMap
- _buildIndexMap = staticmethod(_buildIndexMap)
+ @staticmethod
def _buildActionMap(managed, local, extensionNames, functionMap, indexMap, preHookMap, postHookMap, peerMap):
"""
Builds a mapping from action name to list of action items.
@@ -724,8 +725,8 @@
actionMap[name].append(_ManagedActionItem(index, name, peerMap[name]))
actionMap['all'] = actionMap['collect'] + actionMap['stage'] + actionMap['store'] + actionMap['purge']
return actionMap
- _buildActionMap = staticmethod(_buildActionMap)
+ @staticmethod
def _buildPeerMap(options, peers):
"""
Build a mapping from action name to list of remote peers.
@@ -756,8 +757,8 @@
else:
peerMap[managedAction] = [ remotePeer, ]
return peerMap
- _buildPeerMap = staticmethod(_buildPeerMap)
+ @staticmethod
def _deriveHooks(action, preHookDict, postHookDict):
"""
Derive pre- and post-action hooks, if any, associated with named action.
@@ -773,8 +774,8 @@
if postHookDict.has_key(action):
postHook = postHookDict[action]
return (preHook, postHook)
- _deriveHooks = staticmethod(_deriveHooks)
+ @staticmethod
def _validateActions(actions, extensionNames):
"""
Validate that the set of specified actions is sensible.
@@ -796,8 +797,8 @@
for action in NONCOMBINE_ACTIONS:
if action in actions and actions != [ action, ]:
raise ValueError("Action [%s] may not be combined with other actions." % action)
- _validateActions = staticmethod(_validateActions)
+ @staticmethod
def _buildActionSet(actions, actionMap):
"""
Build set of actions to be executed.
@@ -818,7 +819,6 @@
actionSet.extend(actionMap[action])
actionSet.sort() # sort the actions in order by index
return actionSet
- _buildActionSet = staticmethod(_buildActionSet)
def executeActions(self, configPath, options, config):
"""
@@ -839,6 +839,7 @@
for actionItem in self.actionSet:
actionItem.executeAction(configPath, options, config)
+ @staticmethod
def _getRemoteUser(options, remotePeer):
"""
Gets the remote user associated with a remote peer.
@@ -850,8 +851,8 @@
if remotePeer.remoteUser is None:
return options.backupUser
return remotePeer.remoteUser
- _getRemoteUser = staticmethod(_getRemoteUser)
+ @staticmethod
def _getRshCommand(options, remotePeer):
"""
Gets the RSH command associated with a remote peer.
@@ -863,8 +864,8 @@
if remotePeer.rshCommand is None:
return options.rshCommand
return remotePeer.rshCommand
- _getRshCommand = staticmethod(_getRshCommand)
+ @staticmethod
def _getCbackCommand(options, remotePeer):
"""
Gets the cback command associated with a remote peer.
@@ -876,8 +877,8 @@
if remotePeer.cbackCommand is None:
return options.cbackCommand
return remotePeer.cbackCommand
- _getCbackCommand = staticmethod(_getCbackCommand)
+ @staticmethod
def _getManagedActions(options, remotePeer):
"""
Gets the managed actions list associated with a remote peer.
@@ -889,7 +890,6 @@
if remotePeer.managedActions is None:
return options.managedActions
return remotePeer.managedActions
- _getManagedActions = staticmethod(_getManagedActions)
#######################################################################
Modified: cedar-backup2/trunk/CedarBackup2/config.py
===================================================================
--- cedar-backup2/trunk/CedarBackup2/config.py 2010-07-07 19:31:34 UTC (rev 996)
+++ cedar-backup2/trunk/CedarBackup2/config.py 2010-07-07 19:34:11 UTC (rev 997)
@@ -4427,6 +4427,7 @@
self._store = Config._parseStore(parentNode)
self._purge = Config._parsePurge(parentNode)
+ @staticmethod
def _parseReference(parentNode):
"""
Parses a reference configuration section.
@@ -4452,8 +4453,8 @@
reference.description = readString(sectionNode, "description")
reference.generator = readString(sectionNode, "generator")
return reference
- _parseReference = staticmethod(_parseReference)
+ @staticmethod
def _parseExtensions(parentNode):
"""
Parses an extensions configuration section.
@@ -4484,8 +4485,8 @@
extensions.orderMode = readString(sectionNode, "order_mode")
extensions.actions = Config._parseExtendedActions(sectionNode)
return extensions
- _parseExtensions = staticmethod(_parseExtensions)
+ @staticmethod
def _parseOptions(parentNode):
"""
Parses a options configuration section.
@@ -4533,8 +4534,8 @@
managedActions = readString(sectionNode, "managed_actions")
options.managedActions = Config._parseCommaSeparatedString(managedActions)
return options
- _parseOptions = staticmethod(_parseOptions)
+ @staticmethod
def _parsePeers(parentNode):
"""
Parses a peers configuration section.
@@ -4558,8 +4559,8 @@
peers = PeersConfig()
(peers.localPeers, peers.remotePeers) = Config._parsePeerList(sectionNode)
return peers
- _parsePeers = staticmethod(_parsePeers)
+ @staticmethod
def _parseCollect(parentNode):
"""
Parses a collect configuration section.
@@ -4600,8 +4601,8 @@
collect.collectFiles = Config._parseCollectFiles(sectionNode)
collect.collectDirs = Config._parseCollectDirs(sectionNode)
return collect
- _parseCollect = staticmethod(_parseCollect)
+ @staticmethod
def _parseStage(parentNode):
"""
Parses a stage configuration section.
@@ -4630,8 +4631,8 @@
stage.targetDir = readString(sectionNode, "staging_dir")
(stage.localPeers, stage.remotePeers) = Config._parsePeerList(sectionNode)
return stage
- _parseStage = staticmethod(_parseStage)
+ @staticmethod
def _parseStore(parentNode):
"""
Parses a store configuration section.
@@ -4674,8 +4675,8 @@
store.blankBehavior = Config._parseBlankBehavior(sectionNode)
store.refreshMediaDelay = readInteger(sectionNode, "refresh_media_delay")
return store
- _parseStore = staticmethod(_parseStore)
+ @staticmethod
def _parsePurge(parentNode):
"""
Parses a purge configuration section.
@@ -4698,8 +4699,8 @@
purge = PurgeConfig()
purge.purgeDirs = Config._parsePurgeDirs(sectionNode)
return purge
- _parsePurge = staticmethod(_parsePurge)
+ @staticmethod
def _parseExtendedActions(parentNode):
"""
Reads extended actions data from immediately beneath the parent.
@@ -4732,8 +4733,8 @@
if lst == []:
lst = None
return lst
- _parseExtendedActions = staticmethod(_parseExtendedActions)
+ @staticmethod
def _parseExclusions(parentNode):
"""
Reads exclusions data from immediately beneath the parent.
@@ -4763,8 +4764,8 @@
relative = readStringList(sectionNode, "rel_path")
patterns = readStringList(sectionNode, "pattern")
return (absolute, relative, patterns)
- _parseExclusions = staticmethod(_parseExclusions)
+ @staticmethod
def _parseOverrides(parentNode):
"""
Reads a list of C{CommandOverride} objects from immediately beneath the parent.
@@ -4789,8 +4790,8 @@
if lst == []:
lst = None
return lst
- _parseOverrides = staticmethod(_parseOverrides)
+ @staticmethod
def _parseHooks(parentNode):
"""
Reads a list of C{ActionHook} objects from immediately beneath the parent.
@@ -4821,8 +4822,8 @@
if lst == []:
lst = None
return lst
- _parseHooks = staticmethod(_parseHooks)
+ @staticmethod
def _parseCollectFiles(parentNode):
"""
Reads a list of C{CollectFile} objects from immediately beneath the parent.
@@ -4856,8 +4857,8 @@
if lst == []:
lst = None
return lst
- _parseCollectFiles = staticmethod(_parseCollectFiles)
+ @staticmethod
def _parseCollectDirs(parentNode):
"""
Reads a list of C{CollectDir} objects from immediately beneath the parent.
@@ -4907,8 +4908,8 @@
if lst == []:
lst = None
return lst
- _parseCollectDirs = staticmethod(_parseCollectDirs)
+ @staticmethod
def _parsePurgeDirs(parentNode):
"""
Reads a list of C{PurgeDir} objects from immediately beneath the parent.
@@ -4933,8 +4934,8 @@
if lst == []:
lst = None
return lst
- _parsePurgeDirs = staticmethod(_parsePurgeDirs)
+ @staticmethod
def _parsePeerList(parentNode):
"""
Reads remote and local peer data from immediately beneath the parent.
@@ -4996,8 +4997,8 @@
if remotePeers == []:
remotePeers = None
return (localPeers, remotePeers)
- _parsePeerList = staticmethod(_parsePeerList)
+ @staticmethod
def _parseDependencies(parentNode):
"""
Reads extended action dependency information from a parent node.
@@ -5029,8 +5030,8 @@
beforeList = Config._parseCommaSeparatedString(runBefore)
afterList = Config._parseCommaSeparatedString(runAfter)
return ActionDependencies(beforeList, afterList)
- _parseDependencies = staticmethod(_parseDependencies)
+ @staticmethod
def _parseCommaSeparatedString(commaString):
"""
Parses a list of values out of a comma-separated string.
@@ -5052,8 +5053,8 @@
if len(item) > 0:
pass2.append(item)
return pass2
- _parseCommaSeparatedString = staticmethod(_parseCommaSeparatedString)
+ @staticmethod
def _parseBlankBehavior(parentNode):
"""
Reads a single C{BlankBehavior} object from immediately beneath the parent.
@@ -5075,7 +5076,6 @@
blankBehavior.blankMode = readString(sectionNode, "mode")
blankBehavior.blankFactor = readString(sectionNode, "factor")
return blankBehavior
- _parseBlankBehavior = staticmethod(_parseBlankBehavior)
########################################
@@ -5108,6 +5108,7 @@
xmlDom.unlink()
return xmlData
+ @staticmethod
def _addReference(xmlDom, parentNode, referenceConfig):
"""
Adds a <reference> configuration section as the next child of a parent.
@@ -5131,8 +5132,8 @@
addStringNode(xmlDom, sectionNode, "revision", referenceConfig.revision)
addStringNode(xmlDom, sectionNode, "description", referenceConfig.description)
addStringNode(xmlDom, sectionNode, "generator", referenceConfig.generator)
- _addReference = staticmethod(_addReference)
+ @staticmethod
def _addExtensions(xmlDom, parentNode, extensionsConfig):
"""
Adds an <extensions> configuration section as the next child of a parent.
@@ -5159,8 +5160,8 @@
if extensionsConfig.actions is not None:
for action in extensionsConfig.actions:
Config._addExtendedAction(xmlDom, sectionNode, action)
- _addExtensions = staticmethod(_addExtensions)
+ @staticmethod
def _addOptions(xmlDom, parentNode, optionsConfig):
"""
Adds a <options> configuration section as the next child of a parent.
@@ -5209,8 +5210,8 @@
if optionsConfig.hooks is not None:
for hook in optionsConfig.hooks:
Config._addHook(xmlDom, sectionNode, hook)
- _addOptions = staticmethod(_addOptions)
+ @staticmethod
def _addPeers(xmlDom, parentNode, peersConfig):
"""
Adds a <peers> configuration section as the next child of a parent.
@@ -5238,8 +5239,8 @@
if peersConfig.remotePeers is not None:
for remotePeer in peersConfig.remotePeers:
Config._addRemotePeer(xmlDom, sectionNode, remotePeer)
- _addPeers = staticmethod(_addPeers)
+ @staticmethod
def _addCollect(xmlDom, parentNode, collectConfig):
"""
Adds a <collect> configuration section as the next child of a parent.
@@ -5289,8 +5290,8 @@
if collectConfig.collectDirs is not None:
for collectDir in collectConfig.collectDirs:
Config._addCollectDir(xmlDom, sectionNode, collectDir)
- _addCollect = staticmethod(_addCollect)
+ @staticmethod
def _addStage(xmlDom, parentNode, stageConfig):
"""
Adds a <stage> configuration section as the next child of a parent.
@@ -5323,8 +5324,8 @@
if stageConfig.remotePeers is not None:
for remotePeer in stageConfig.remotePeers:
Config._addRemotePeer(xmlDom, sectionNode, remotePeer)
- _addStage = staticmethod(_addStage)
+ @staticmethod
def _addStore(xmlDom, parentNode, storeConfig):
"""
Adds a <store> configuration section as the next child of a parent.
@@ -5365,8 +5366,8 @@
addBooleanNode(xmlDom, sectionNode, "no_eject", storeConfig.noEject)
addIntegerNode(xmlDom, sectionNode, "refresh_media_delay", storeConfig.refreshMediaDelay)
Config._addBlankBehavior(xmlDom, sectionNode, storeConfig.blankBehavior)
- _addStore = staticmethod(_addStore)
+ @staticmethod
def _addPurge(xmlDom, parentNode, purgeConfig):
"""
Adds a <purge> configuration section as the next child of a parent.
@@ -5388,8 +5389,8 @@
if purgeConfig.purgeDirs is not None:
for purgeDir in purgeConfig.purgeDirs:
Config._addPurgeDir(xmlDom, sectionNode, purgeDir)
- _addPurge = staticmethod(_addPurge)
+ @staticmethod
def _addExtendedAction(xmlDom, parentNode, action):
"""
Adds an extended action container as the next child of a parent.
@@ -5421,8 +5422,8 @@
addStringNode(xmlDom, sectionNode, "function", action.function)
addIntegerNode(xmlDom, sectionNode, "index", action.index)
Config._addDependencies(xmlDom, sectionNode, action.dependencies)
- _addExtendedAction = staticmethod(_addExtendedAction)
+ @staticmethod
def _addOverride(xmlDom, parentNode, override):
"""
Adds a command override container as the next child of a parent.
@@ -5446,8 +5447,8 @@
sectionNode = addContainerNode(xmlDom, parentNode, "override")
addStringNode(xmlDom, sectionNode, "command", override.command)
addStringNode(xmlDom, sectionNode, "abs_path", override.absolutePath)
- _addOverride = staticmethod(_addOverride)
+ @staticmethod
def _addHook(xmlDom, parentNode, hook):
"""
Adds an action hook container as the next child of a parent.
@@ -5482,8 +5483,8 @@
sectionNode = addContainerNode(xmlDom, parentNode, "post_action_hook")
addStringNode(xmlDom, sectionNode, "action", hook.action)
addStringNode(xmlDom, sectionNode, "command", hook.command)
- _addHook = staticmethod(_addHook)
+ @staticmethod
def _addCollectFile(xmlDom, parentNode, collectFile):
"""
Adds a collect file container as the next child of a parent.
@@ -5512,8 +5513,8 @@
addStringNode(xmlDom, sectionNode, "abs_path", collectFile.absolutePath)
addStringNode(xmlDom, sectionNode, "collect_mode", collectFile.collectMode)
addStringNode(xmlDom, sectionNode, "archive_mode", collectFile.archiveMode)
- _addCollectFile = staticmethod(_addCollectFile)
+ @staticmethod
def _addCollectDir(xmlDom, parentNode, collectDir):
"""
Adds a collect directory container as the next child of a parent.
@@ -5568,8 +5569,8 @@
if collectDir.excludePatterns is not None:
for pattern in collectDir.excludePatterns:
addStringNode(xmlDom, excludeNode, "pattern", pattern)
- _addCollectDir = staticmethod(_addCollectDir)
+ @staticmethod
def _addLocalPeer(xmlDom, parentNode, localPeer):
"""
Adds a local peer container as the next child of a parent.
@@ -5599,8 +5600,8 @@
addStringNode(xmlDom, sectionNode, "type", "local")
addStringNode(xmlDom, sectionNode, "collect_dir", localPeer.collectDir)
addStringNode(xmlDom, sectionNode, "ignore_failures", localPeer.ignoreFailureMode)
- _addLocalPeer = staticmethod(_addLocalPeer)
+ @staticmethod
def _addRemotePeer(xmlDom, parentNode, remotePeer):
"""
Adds a remote peer container as the next child of a parent.
@@ -5644,8 +5645,8 @@
addBooleanNode(xmlDom, sectionNode, "managed", remotePeer.managed)
managedActions = Config._buildCommaSeparatedString(remotePeer.managedActions)
addStringNode(xmlDom, sectionNode, "managed_actions", managedActions)
- _addRemotePeer = staticmethod(_addRemotePeer)
+ @staticmethod
def _addPurgeDir(xmlDom, parentNode, purgeDir):
"""
Adds a purge directory container as the next child of a parent.
@@ -5669,8 +5670,8 @@
sectionNode = addContainerNode(xmlDom, parentNode, "dir")
addStringNode(xmlDom, sectionNode, "abs_path", purgeDir.absolutePath)
addIntegerNode(xmlDom, sectionNode, "retain_days", purgeDir.retainDays)
- _addPurgeDir = staticmethod(_addPurgeDir)
+ @staticmethod
def _addDependencies(xmlDom, parentNode, dependencies):
"""
Adds a extended action dependencies to parent node.
@@ -5692,8 +5693,8 @@
runAfter = Config._buildCommaSeparatedString(dependencies.afterList)
addStringNode(xmlDom, sectionNode, "run_before", runBefore)
addStringNode(xmlDom, sectionNode, "run_after", runAfter)
- _addDependencies = staticmethod(_addDependencies)
+ @staticmethod
def _buildCommaSeparatedString(valueList):
"""
Creates a comma-separated string from a list of values.
@@ -5708,8 +5709,8 @@
if valueList is None:
return None
return ",".join(valueList)
- _buildCommaSeparatedString = staticmethod(_buildCommaSeparatedString)
+ @staticmethod
def _addBlankBehavior(xmlDom, parentNode, blankBehavior):
"""
Adds a blanking behavior container as the next child of a parent.
@@ -5732,7 +5733,6 @@
sectionNode = addContainerNode(xmlDom, parentNode, "blank_behavior")
addStringNode(xmlDom, sectionNode, "mode", blankBehavior.blankMode)
addStringNode(xmlDom, sectionNode, "factor", blankBehavior.blankFactor)
- _addBlankBehavior = staticmethod(_addBlankBehavior)
#################################################
@@ -6018,6 +6018,7 @@
# Utility methods used for validating content
##############################################
+ @staticmethod
def _checkUnique(prefix, values):
"""
Checks that all values are unique.
@@ -6038,7 +6039,6 @@
duplicates.append(values[i])
if duplicates:
raise ValueError("%s %s" % (prefix, duplicates))
- _checkUnique = staticmethod(_checkUnique)
########################################################################
Modified: cedar-backup2/trunk/CedarBackup2/extend/capacity.py
===================================================================
--- cedar-backup2/trunk/CedarBackup2/extend/capacity.py 2010-07-07 19:31:34 UTC (rev 996)
+++ cedar-backup2/trunk/CedarBackup2/extend/capacity.py 2010-07-07 19:34:11 UTC (rev 997)
@@ -435,6 +435,7 @@
(xmlDom, parentNode) = createInputDom(xmlData)
self._capacity = LocalConfig._parseCapacity(parentNode)
+ @staticmethod
def _parseCapacity(parentNode):
"""
Parses a capacity configuration section.
@@ -456,8 +457,8 @@
capacity.maxPercentage = LocalConfig._readPercentageQuantity(section, "max_percentage")
capacity.minBytes = readByteQuantity(section, "min_bytes")
return capacity
- _parseCapacity = staticmethod(_parseCapacity)
+ @staticmethod
def _readPercentageQuantity(parent, name):
"""
Read a percentage quantity value from an XML document.
@@ -469,8 +470,8 @@
if quantity is None:
return None
return PercentageQuantity(quantity)
- _readPercentageQuantity = staticmethod(_readPercentageQuantity)
+ @staticmethod
def _addPercentageQuantity(xmlDom, parentNode, nodeName, percentageQuantity):
"""
Adds a text node as the next child of a parent, to contain a percentage quantity.
@@ -486,7 +487,6 @@
"""
if percentageQuantity is not None:
addStringNode(xmlDom, parentNode, nodeName, percentageQuantity.quantity)
- _addPercentageQuantity = staticmethod(_addPercentageQuantity)
########################################################################
Modified: cedar-backup2/trunk/CedarBackup2/extend/encrypt.py
===================================================================
--- cedar-backup2/trunk/CedarBackup2/extend/encrypt.py 2010-07-07 19:31:34 UTC (rev 996)
+++ cedar-backup2/trunk/CedarBackup2/extend/encrypt.py 2010-07-07 19:34:11 UTC (rev 997)
@@ -350,6 +350,7 @@
(xmlDom, parentNode) = createInputDom(xmlData)
self._encrypt = LocalConfig._parseEncrypt(parentNode)
+ @staticmethod
def _parseEncrypt(parent):
"""
Parses an encrypt configuration section.
@@ -371,7 +372,6 @@
encrypt.encryptMode = readString(section, "encrypt_mode")
encrypt.encryptTarget = readString(section, "encrypt_target")
return encrypt
- _parseEncrypt = staticmethod(_parseEncrypt)
########################################################################
Modified: cedar-backup2/trunk/CedarBackup2/extend/mbox.py
===================================================================
--- cedar-backup2/trunk/CedarBackup2/extend/mbox.py 2010-07-07 19:31:34 UTC (rev 996)
+++ cedar-backup2/trunk/CedarBackup2/extend/mbox.py 2010-07-07 19:34:11 UTC (rev 997)
@@ -833,6 +833,7 @@
(xmlDom, parentNode) = createInputDom(xmlData)
self._mbox = LocalConfig._parseMbox(parentNode)
+ @staticmethod
def _parseMbox(parent):
"""
Parses an mbox configuration section.
@@ -865,8 +866,8 @@
mbox.mboxFiles = LocalConfig._parseMboxFiles(section)
mbox.mboxDirs = LocalConfig._parseMboxDirs(section)
return mbox
- _parseMbox = staticmethod(_parseMbox)
+ @staticmethod
def _parseMboxFiles(parent):
"""
Reads a list of C{MboxFile} objects from immediately beneath the parent.
@@ -893,8 +894,8 @@
if lst == []:
lst = None
return lst
- _parseMboxFiles = staticmethod(_parseMboxFiles)
+ @staticmethod
def _parseMboxDirs(parent):
"""
Reads a list of C{MboxDir} objects from immediately beneath the parent.
@@ -930,8 +931,8 @@
if lst == []:
lst = None
return lst
- _parseMboxDirs = staticmethod(_parseMboxDirs)
+ @staticmethod
def _parseExclusions(parentNode):
"""
Reads exclusions data from immediately beneath the parent.
@@ -955,8 +956,8 @@
relative = readStringList(section, "rel_path")
patterns = readStringList(section, "pattern")
return (relative, patterns)
- _parseExclusions = staticmethod(_parseExclusions)
+ @staticmethod
def _addMboxFile(xmlDom, parentNode, mboxFile):
"""
Adds an mbox file container as the next child of a parent.
@@ -982,8 +983,8 @@
addStringNode(xmlDom, sectionNode, "abs_path", mboxFile.absolutePath)
addStringNode(xmlDom, sectionNode, "collect_mode", mboxFile.collectMode)
addStringNode(xmlDom, sectionNode, "compress_mode", mboxFile.compressMode)
- _addMboxFile = staticmethod(_addMboxFile)
+ @staticmethod
def _addMboxDir(xmlDom, parentNode, mboxDir):
"""
Adds an mbox directory container as the next child of a parent.
@@ -1023,7 +1024,6 @@
if mboxDir.excludePatterns is not None:
for pattern in mboxDir.excludePatterns:
addStringNode(xmlDom, excludeNode, "pattern", pattern)
- _addMboxDir = staticmethod(_addMboxDir)
########################################################################
Modified: cedar-backup2/trunk/CedarBackup2/extend/mysql.py
===================================================================
--- cedar-backup2/trunk/CedarBackup2/extend/mysql.py 2010-07-07 19:31:34 UTC (rev 996)
+++ cedar-backup2/trunk/CedarBackup2/extend/mysql.py 2010-07-07 19:34:11 UTC (rev 997)
@@ -479,6 +479,7 @@
(xmlDom, parentNode) = createInputDom(xmlData)
self._mysql = LocalConfig._parseMysql(parentNode)
+ @staticmethod
def _parseMysql(parentNode):
"""
Parses a mysql configuration section.
@@ -510,7 +511,6 @@
mysql.all = readBoolean(section, "all")
mysql.databases = readStringList(section, "database")
return mysql
- _parseMysql = staticmethod(_parseMysql)
########################################################################
Modified: cedar-backup2/trunk/CedarBackup2/extend/postgresql.py
===================================================================
--- cedar-backup2/trunk/CedarBackup2/extend/postgresql.py 2010-07-07 19:31:34 UTC (rev 996)
+++ cedar-backup2/trunk/CedarBackup2/extend/postgresql.py 2010-07-07 19:34:11 UTC (rev 997)
@@ -444,6 +444,7 @@
(xmlDom, parentNode) = createInputDom(xmlData)
self._postgresql = LocalConfig._parsePostgresql(parentNode)
+ @staticmethod
def _parsePostgresql(parent):
"""
Parses a postgresql configuration section.
@@ -473,7 +474,6 @@
postgresql.all = readBoolean(section, "all")
postgresql.databases = readStringList(section, "database")
return postgresql
- _parsePostgresql = staticmethod(_parsePostgresql)
########################################################################
Modified: cedar-backup2/trunk/CedarBackup2/extend/split.py
===================================================================
--- cedar-backup2/trunk/CedarBackup2/extend/split.py 2010-07-07 19:31:34 UTC (rev 996)
+++ cedar-backup2/trunk/CedarBackup2/extend/split.py 2010-07-07 19:34:11 UTC (rev 997)
@@ -358,6 +358,7 @@
(xmlDom, parentNode) = createInputDom(xmlData)
self._split = LocalConfig._parseSplit(parentNode)
+ @staticmethod
def _parseSplit(parent):
"""
Parses an split configuration section.
@@ -379,7 +380,6 @@
split.sizeLimit = readByteQuantity(section, "size_limit")
split.splitSize = readByteQuantity(section, "split_size")
return split
- _parseSplit = staticmethod(_parseSplit)
########################################################################
Modified: cedar-backup2/trunk/CedarBackup2/extend/subversion.py
===================================================================
--- cedar-backup2/trunk/CedarBackup2/extend/subversion.py 2010-07-07 19:31:34 UTC (rev 996)
+++ cedar-backup2/trunk/CedarBackup2/extend/subversion.py 2010-07-07 19:34:11 UTC (rev 997)
@@ -852,6 +852,7 @@
(xmlDom, parentNode) = createInputDom(xmlData)
self._subversion = LocalConfig._parseSubversion(parentNode)
+ @staticmethod
def _parseSubversion(parent):
"""
Parses a subversion configuration section.
@@ -884,8 +885,8 @@
subversion.repositories = LocalConfig._parseRepositories(section)
subversion.repositoryDirs = LocalConfig._parseRepositoryDirs(section)
return subversion
- _parseSubversion = staticmethod(_parseSubversion)
+ @staticmethod
def _parseRepositories(parent):
"""
Reads a list of C{Repository} objects from immediately beneath the parent.
@@ -917,8 +918,8 @@
if lst == []:
lst = None
return lst
- _parseRepositories = staticmethod(_parseRepositories)
+ @staticmethod
def _addRepository(xmlDom, parentNode, repository):
"""
Adds a repository container as the next child of a parent.
@@ -946,8 +947,8 @@
addStringNode(xmlDom, sectionNode, "abs_path", repository.repositoryPath)
addStringNode(xmlDom, sectionNode, "collect_mode", repository.collectMode)
addStringNode(xmlDom, sectionNode, "compress_mode", repository.compressMode)
- _addRepository = staticmethod(_addRepository)
+ @staticmethod
def _parseRepositoryDirs(parent):
"""
Reads a list of C{RepositoryDir} objects from immediately beneath the parent.
@@ -988,8 +989,8 @@
if lst == []:
lst = None
return lst
- _parseRepositoryDirs = staticmethod(_parseRepositoryDirs)
+ @staticmethod
def _parseExclusions(parentNode):
"""
Reads exclusions data from immediately beneath the parent.
@@ -1013,8 +1014,8 @@
relative = readStringList(section, "rel_path")
patterns = readStringList(section, "pattern")
return (relative, patterns)
- _parseExclusions = staticmethod(_parseExclusions)
+ @staticmethod
def _addRepositoryDir(xmlDom, parentNode, repositoryDir):
"""
Adds a repository dir container as the next child of a parent.
@@ -1056,7 +1057,6 @@
if repositoryDir.excludePatterns is not None:
for pattern in repositoryDir.excludePatterns:
addStringNode(xmlDom, excludeNode, "pattern", pattern)
- _addRepositoryDir = staticmethod(_addRepositoryDir)
########################################################################
Modified: cedar-backup2/trunk/CedarBackup2/filesystem.py
===================================================================
--- cedar-backup2/trunk/CedarBackup2/filesystem.py 2010-07-07 19:31:34 UTC (rev 996)
+++ cedar-backup2/trunk/CedarBackup2/filesystem.py 2010-07-07 19:34:11 UTC (rev 997)
@@ -876,6 +876,7 @@
table[entry] = BackupFileList._generateDigest(entry)
return table
+ @staticmethod
def _generateDigest(path):
"""
Generates an SHA digest for a given file on disk.
@@ -927,7 +928,6 @@
digest = s.hexdigest()
logger.debug("Generated digest [%s] for file [%s]." % (digest, path))
return digest
- _generateDigest = staticmethod(_generateDigest)
def generateFitted(self, capacity, algorithm="worst_fit"):
"""
@@ -1016,6 +1016,7 @@
table[entry] = (entry, size)
return table
+ @staticmethod
def _getKnapsackFunction(algorithm):
"""
Returns a reference to the function associated with an algorithm name.
@@ -1034,7 +1035,6 @@
return alternateFit
else:
raise ValueError("Algorithm [%s] is invalid." % algorithm)
- _getKnapsackFunction = staticmethod(_getKnapsackFunction)
def generateTarfile(self, path, mode='tar', ignore=False, flat=False):
"""
Modified: cedar-backup2/trunk/CedarBackup2/peer.py
===================================================================
--- cedar-backup2/trunk/CedarBackup2/peer.py 2010-07-07 19:31:34 UTC (rev 996)
+++ cedar-backup2/trunk/CedarBackup2/peer.py 2010-07-07 19:34:11 UTC (rev 997)
@@ -316,6 +316,7 @@
# Private methods
##################
+ @staticmethod
def _copyLocalDir(sourceDir, targetDir, ownership=None, permissions=None):
"""
Copies files from the source directory to the target directory.
@@ -357,8 +358,8 @@
LocalPeer._copyLocalFile(sourceFile, targetFile, ownership, permissions)
filesCopied += 1
return filesCopied
- _copyLocalDir = staticmethod(_copyLocalDir)
+ @staticmethod
def _copyLocalFile(sourceFile=None, targetFile=None, ownership=None, permissions=None, overwrite=True):
"""
Copies a source file to a target file.
@@ -414,7 +415,6 @@
os.chown(targetFile, ownership[0], ownership[1])
if permissions is not None:
os.chmod(targetFile, permissions)
- _copyLocalFile = staticmethod(_copyLocalFile)
########################################################################
@@ -916,6 +916,7 @@
# Private methods
##################
+ @staticmethod
def _getDirContents(path):
"""
Returns the contents of a directory in terms of a Set.
@@ -938,8 +939,8 @@
except:
import sets
return sets.Set(contents)
- _getDirContents = staticmethod(_getDirContents)
+ @staticmethod
def _copyRemoteDir(remoteUser, localUser, remoteHost, rcpCommand, rcpCommandList,
sourceDir, targetDir, ownership=None, permissions=None):
"""
@@ -1036,8 +1037,8 @@
if permissions is not None:
os.chmod(targetFile, permissions)
return len(differenceSet)
- _copyRemoteDir = staticmethod(_copyRemoteDir)
+ @staticmethod
def _copyRemoteFile(remoteUser, localUser, remoteHost,
rcpCommand, rcpCommandList,
sourceFile, targetFile, ownership=None,
@@ -1123,8 +1124,8 @@
os.chown(targetFile, ownership[0], ownership[1])
if permissions is not None:
os.chmod(targetFile, permissions)
- _copyRemoteFile = staticmethod(_copyRemoteFile)
+ @staticmethod
def _pushLocalFile(remoteUser, localUser, remoteHost,
rcpCommand, rcpCommandList,
sourceFile, targetFile, overwrite=True):
@@ -1188,8 +1189,8 @@
result = executeCommand(command, [sourceFile.replace(" ", "\\ "), copyTarget])[0]
if result != 0:
raise IOError("Error (%d) copying [%s] to remote host." % (result, sourceFile))
- _pushLocalFile = staticmethod(_pushLocalFile)
+ @staticmethod
def _executeRemoteCommand(remoteUser, localUser, remoteHost, rshCommand, rshCommandList, remoteCommand):
"""
Executes a command on the peer via remote shell.
@@ -1229,8 +1230,8 @@
result = executeCommand(command, ["%s@%s" % (remoteUser, remoteHost), "%s" % remoteCommand])[0]
if result != 0:
raise IOError("Command failed [%s]" % (actualCommand))
- _executeRemoteCommand = staticmethod(_executeRemoteCommand)
+ @staticmethod
def _buildCbackCommand(cbackCommand, action, fullBackup):
"""
Builds a Cedar Backup command line for the named action.
@@ -1252,5 +1253,4 @@
return "%s --full %s" % (cbackCommand, action)
else:
return "%s %s" % (cbackCommand, action)
- _buildCbackCommand = staticmethod(_buildCbackCommand)
Modified: cedar-backup2/trunk/CedarBackup2/util.py
===================================================================
--- cedar-backup2/trunk/CedarBackup2/util.py 2010-07-07 19:31:34 UTC (rev 996)
+++ cedar-backup2/trunk/CedarBackup2/util.py 2010-07-07 19:34:11 UTC (rev 997)
@@ -1037,6 +1037,7 @@
lines.append(line)
return lines
+ @staticmethod
def _getMaxLength(values):
"""
Get the maximum length from among a list of strings.
@@ -1046,7 +1047,6 @@
if len(value) > tmax:
tmax = len(value)
return tmax
- _getMaxLength = staticmethod(_getMaxLength)
def _getVersion(self):
"""
Modified: cedar-backup2/trunk/CedarBackup2/writers/cdwriter.py
===================================================================
--- cedar-backup2/trunk/CedarBackup2/writers/cdwriter.py 2010-07-07 19:31:34 UTC (rev 996)
+++ cedar-backup2/trunk/CedarBackup2/writers/cdwriter.py 2010-07-07 19:34:11 UTC (rev 997)
@@ -685,6 +685,7 @@
logger.debug("Returning disc boundaries: (%d, %d)" % (boundaries[0], boundaries[1]))
return boundaries
+ @staticmethod
def _calculateCapacity(media, boundaries):
"""
Calculates capacity for the media in terms of boundaries.
@@ -713,7 +714,6 @@
bytesAvailable = convertSize(sectorsAvailable, UNIT_SECTORS, UNIT_BYTES)
logger.debug("Used [%s], available [%s]." % (displayBytes(bytesUsed), displayBytes(bytesAvailable)))
return MediaCapacity(bytesUsed, bytesAvailable, boundaries)
- _calculateCapacity = staticmethod(_calculateCapacity)
#######################################################
@@ -986,6 +986,7 @@
# Methods used to parse command output
#######################################
+ @staticmethod
def _parsePropertiesOutput(output):
"""
Parses the output from a C{cdrecord} properties command.
@@ -1059,8 +1060,8 @@
deviceCanEject = True
logger.info("Device can eject its media.")
return (deviceType, deviceVendor, deviceId, deviceBufferSize, deviceSupportsMulti, deviceHasTray, deviceCanEject)
- _parsePropertiesOutput = staticmethod(_parsePropertiesOutput)
+ @staticmethod
def _parseBoundariesOutput(output):
"""
Parses the output from a C{cdrecord} capacity command.
@@ -1102,13 +1103,13 @@
except TypeError:
raise IOError("Unable to parse output of boundaries command.")
return boundaries
- _parseBoundariesOutput = staticmethod(_parseBoundariesOutput)
#################################
# Methods used to build commands
#################################
+ @staticmethod
def _buildOpenTrayArgs(device):
"""
Builds a list of arguments to be passed to a C{eject} command.
@@ -1124,8 +1125,8 @@
args = []
args.append(device)
return args
- _buildOpenTrayArgs = staticmethod(_buildOpenTrayArgs)
+ @staticmethod
def _buildCloseTrayArgs(device):
"""
Builds a list of arguments to be passed to a C{eject} command.
@@ -1142,8 +1143,8 @@
args.append("-t")
args.append(device)
return args
- _buildCloseTrayArgs = staticmethod(_buildCloseTrayArgs)
+ @staticmethod
def _buildPropertiesArgs(hardwareId):
"""
Builds a list of arguments to be passed to a C{cdrecord} command.
@@ -1159,8 +1160,8 @@
args.append("-prcap")
args.append("dev=%s" % hardwareId)
return args
- _buildPropertiesArgs = staticmethod(_buildPropertiesArgs)
+ @staticmethod
def _buildBoundariesArgs(hardwareId):
"""
Builds a list of arguments to be passed to a C{cdrecord} command.
@@ -1177,8 +1178,8 @@
args.append("-msinfo")
args.append("dev=%s" % hardwareId)
return args
- _buildBoundariesArgs = staticmethod(_buildBoundariesArgs)
+ @staticmethod
def _buildBlankArgs(hardwareId, driveSpeed=None):
"""
Builds a list of arguments to be passed to a C{cdrecord} command.
@@ -1200,8 +1201,8 @@
args.append("speed=%d" % driveSpeed)
args.append("dev=%s" % hardwareId)
return args
- _buildBlankArgs = staticmethod(_buildBlankArgs)
+ @staticmethod
def _buildWriteArgs(hardwareId, imagePath, driveSpeed=None, writeMulti=True):
"""
Builds a list of arguments to be passed to a C{cdrecord} command.
@@ -1230,5 +1231,4 @@
args.append("-data")
args.append(imagePath)
return args
- _buildWriteArgs = staticmethod(_buildWriteArgs)
Modified: cedar-backup2/trunk/CedarBackup2/writers/dvdwriter.py
===================================================================
--- cedar-backup2/trunk/CedarBackup2/writers/dvdwriter.py 2010-07-07 19:31:34 UTC (rev 996)
+++ cedar-backup2/trunk/CedarBackup2/writers/dvdwriter.py 2010-07-07 19:34:11 UTC (rev 997)
@@ -747,6 +747,7 @@
raise IOError("Error (%d) executing command to write disc." % result)
self.refreshMedia()
+ @staticmethod
def _getEstimatedImageSize(entries):
"""
Gets the estimated size of a set of image entries.
@@ -773,7 +774,6 @@
image.addEntry(path, entries[path], override=False, contentsOnly=True)
estimatedSize = image.getEstimatedSize() + fudgeFactor
return estimatedSize
- _getEstimatedImageSize = staticmethod(_getEstimatedImageSize)
def _retrieveSectorsUsed(self):
"""
@@ -808,6 +808,7 @@
os.rmdir(tempdir)
except: pass
+ @staticmethod
def _parseSectorsUsed(output):
"""
Parse sectors used information out of C{growisofs} output.
@@ -838,8 +839,8 @@
raise ValueError("Unable to parse sectors used out of growisofs output.")
logger.warn("Unable to read disc (might not be initialized); returning zero sectors used.")
return 0.0
- _parseSectorsUsed = staticmethod(_parseSectorsUsed)
+ @staticmethod
def _searchForOverburn(output):
"""
Search for an "overburn" error message in C{growisofs} output.
@@ -874,8 +875,8 @@
except ValueError:
logger.error("Image does not fit in available capacity (no useful capacity info available).")
raise IOError("Media does not contain enough capacity to store image.")
- _searchForOverburn = staticmethod(_searchForOverburn)
+ @staticmethod
def _buildWriteArgs(newDisc, hardwareId, driveSpeed, imagePath, entries, mediaLabel=None, dryRun=False):
"""
Builds a list of arguments to be passed to a C{growisofs} command.
@@ -941,5 +942,4 @@
else:
args.append("%s/=%s" % (entries[key].strip("/"), key))
return args
- _buildWriteArgs = staticmethod(_buildWriteArgs)
Modified: cedar-backup2/trunk/CedarBackup2/writers/util.py
===================================================================
--- cedar-backup2/trunk/CedarBackup2/writers/util.py 2010-07-07 19:31:34 UTC (rev 996)
+++ cedar-backup2/trunk/CedarBackup2/writers/util.py 2010-07-07 19:34:11 UTC (rev 997)
@@ -608,6 +608,7 @@
# Methods used to build mkisofs commands
#########################################
+ @staticmethod
def _buildDirEntries(entries):
"""
Uses an entries dictionary to build a list of directory locations for use
@@ -629,7 +630,6 @@
else:
dirEntries.append("%s/=%s" % (entries[key].strip("/"), key))
return dirEntries
- _buildDirEntries = staticmethod(_buildDirEntries)
def _buildGeneralArgs(self):
"""
Modified: cedar-backup2/trunk/Changelog
===================================================================
--- cedar-backup2/trunk/Changelog 2010-07-07 19:31:34 UTC (rev 996)
+++ cedar-backup2/trunk/Changelog 2010-07-07 19:34:11 UTC (rev 997)
@@ -1,8 +1,10 @@
-Version 2.19.7 01 Jul 2010
+Version 2.19.7 unreleased
* Make cback script more robust in the case of a bad interpreter version.
* Remove "Translate [x:y] into [a:b]" debug message for uid/gid translation.
- * Refactor out isRunningAsRoot() to replace scattered os.getuid() calls.
+ * Refactor out util.isRunningAsRoot() to replace scattered os.getuid() calls.
+ * Switch to minimum Python version of 2.5 (everyone should have it now).
+ - Convert to use @staticmethod rather than x = staticmethod(x)
* Configure pylint and execute it against the entire codebase.
- Fix a variety of minor warnings and suggestions from pylint
- Move unit tests into testcase folder to avoid test.py naming conflict
Modified: cedar-backup2/trunk/doc/future/prune.py
===================================================================
--- cedar-backup2/trunk/doc/future/prune.py 2010-07-07 19:31:34 UTC (rev 996)
+++ cedar-backup2/trunk/doc/future/prune.py 2010-07-07 19:34:11 UTC (rev 997)
@@ -94,6 +94,7 @@
return prunedEntries
raise IOError("Unable to prune image to fit the capacity after four tries.")
+ @staticmethod
def _calculateSizes(entries):
"""
Calculates sizes for files in an entries dictionary.
@@ -121,8 +122,8 @@
else:
table[entry] = (entry, 0)
return (table, total)
- _calculateSizes = staticmethod(_calculateSizes)
+ @staticmethod
def _buildEntries(entries, items):
"""
Builds an entries dictionary.
@@ -143,8 +144,8 @@
for i in items:
newEntries[i] = entries[i]
return newEntries
- _buildEntries = staticmethod(_buildEntries)
+ @staticmethod
def _expandEntries(entries):
"""
Expands entries in an image to include only files.
@@ -209,5 +210,4 @@
graft = os.path.join(entries[entry].strip(os.sep), subdir.strip(os.sep), os.path.basename(item))
newEntries[item] = graft.strip(os.sep)
return newEntries
- _expandEntries = staticmethod(_expandEntries)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|