Fixed bug that allowed the RAND precision specification to be one character too long.
Fixed testmode so that it now properly reports any backup renamings the program *would* do even when the filenames are newly generated by the program itself.
1 parent 289fafd commit 0b01c96a1163b2786c220300bad3f3049451ac03
@tundra tundra authored on 10 Mar 2010
Showing 1 changed file
View
14
tren.py
 
PROGNAME = "tren.py"
BASENAME = PROGNAME.split(".py")[0]
PROGENV = BASENAME.upper()
RCSID = "$Id: tren.py,v 1.184 2010/03/10 22:18:20 tundra Exp $"
RCSID = "$Id: tren.py,v 1.185 2010/03/10 23:37:27 tundra Exp $"
VERSION = RCSID.split()[2]
 
# Copyright Information
 
#####
 
def __init__(self, targs):
 
# Keep track of all the new filenames we write (or would have)
# 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 = []
 
# 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):
if os.path.exists(fullnew) or fullnew in self.NewNames:
 
if ProgramOptions[FORCERENAME]:
 
# Create the backup
doit = False
 
if doit:
 
self.NewNames.append(fullnew)
InfoMsg(indent + iRENAMING % (fullold, fullnew))
 
if not ProgramOptions[TESTMODE]:
 
 
if precision < 1:
ErrorMsg(eTOKRANDIG % str(precision))
fmt = '"%0' + str(precision) + 'd" % random.randint(0, pow(10, precision))'
fmt = '"%0' + str(precision) + 'd" % random.randint(0, pow(10, precision)-1)'
r[2] = eval(fmt)
 
###
# Sequence Renaming Tokens