Implemented basic sequence replacement tokens and their reverses, but without formatting field support.
1 parent f4e6dd2 commit 7f31d1fd24cb58a9ccd0a16bb56aea9d1e4c9c29
@tundra tundra authored on 10 Mar 2010
Showing 1 changed file
View
63
tren.py
 
PROGNAME = "tren.py"
BASENAME = PROGNAME.split(".py")[0]
PROGENV = BASENAME.upper()
RCSID = "$Id: tren.py,v 1.181 2010/03/10 01:02:07 tundra Exp $"
RCSID = "$Id: tren.py,v 1.182 2010/03/10 18:29:25 tundra Exp $"
VERSION = RCSID.split()[2]
 
# Copyright Information
 
eNAMESHORT = "Renaming '%s' to new name '%s' too short! (Minimum length is %s.)"
eNOROOTRENAME = "Cannot rename root of file tree!"
eNULLARG = "%s cannot be empty!"
eRENAMEFAIL = "Attempt to rename '%s' to '%s' failed : %s!"
eTOKBADSEQ = "Unknown sequence renaming token, '%s'!"
eTOKDELIM = "Renaming token '%s' missing delimiter!"
eTOKUNKNOWN = "Renaming Token '%s' is unknown type!"
eTOKUNKNOWN = "Renaming token '%s' is unknown type!"
eTOOMANYINC = "Too many includes! (Max is %d) Possible circular reference?" % MAXINCLUDES
 
 
#####
###
elif r[2] != "" and (r[2][0] == TOKASCEND or r[2][0] == TOKDESCEND):
 
for token in self.SortViews:
print token
# Parse the Sequence Renaming Token into the token itself
# and its corresponding formatting field.
token = r[2][1:]
 
found = False
for seqtoken in self.SortViews:
 
if token.startswith(seqtoken):
 
token, field = token[:len(seqtoken)], token[len(seqtoken):]
found = True
break
 
if not found:
ErrorMsg(eTOKBADSEQ % r[2])
 
# Retrieve the ordered list of the requested type,
# adjust for descending order, and plug in the
# sequence number for the current renaming target
# (which is just the index of that filename in the
# list).
 
orderedlist = self.SortViews[token][:]
 
if r[2][0] == TOKDESCEND:
orderedlist.reverse()
 
r[2] = str(orderedlist.index(target))
###
# Unrecognized Renaming Token
###