Corrected test mode so it properly tracks existing and newly created files as they would occur.
1 parent ac7fd3f commit ac0f579a1908786e3c5d0977f6bdca6d2031d51b
@tundra tundra authored on 23 Mar 2010
Showing 1 changed file
View
26
tren.py
 
PROGNAME = "tren.py"
BASENAME = PROGNAME.split(".py")[0]
PROGENV = BASENAME.upper()
RCSID = "$Id: tren.py,v 1.207 2010/03/19 17:50:22 tundra Exp $"
RCSID = "$Id: tren.py,v 1.208 2010/03/23 17:53:29 tundra Exp $"
VERSION = RCSID.split()[2]
 
# Copyright Information
 
# so test mode can correctly report just what the the progam
# *would* do. Without this, backup generation is not properly
# reported in test mode.
 
self.NewNames = []
self.RenamedFiles = []
self.NewFiles = []
 
# Dictionary of all rename targets and their stat info
 
self.RenNames = {}
# ourselves so that filename length limits are observed and
# backups-of-backups are preserved.
 
doit = True
if os.path.exists(fullnew) or fullnew in self.NewNames:
newexists = os.path.exists(fullnew)
 
if (not ProgramOptions[TESTMODE] and newexists) or \
(ProgramOptions[TESTMODE] and fullnew not in self.RenamedFiles and (newexists or fullnew in self.NewFiles)):
 
if ProgramOptions[FORCERENAME]:
 
# Create the backup
# In test mode, track file names that would be produced.
if ProgramOptions[TESTMODE]:
self.NewNames.append(fullnew)
 
self.NewFiles.append(fullnew)
self.RenamedFiles.append(fullold)
if fullold in self.NewFiles:
self.NewFiles.remove(fullold)
if fullnew in self.RenamedFiles:
self.RenamedFiles.remove(fullnew)
 
InfoMsg(indent + iRENAMING % (fullold, fullnew))
 
if not ProgramOptions[TESTMODE]: