| |
---|
| | |
---|
| | PROGNAME = "tren.py" |
---|
| | BASENAME = PROGNAME.split(".py")[0] |
---|
| | PROGENV = BASENAME.upper() |
---|
| | RCSID = "$Id: tren.py,v 1.173 2010/03/08 16:41:23 tundra Exp $" |
---|
| | RCSID = "$Id: tren.py,v 1.174 2010/03/08 19:29:52 tundra Exp $" |
---|
| | VERSION = RCSID.split()[2] |
---|
| | |
---|
| | # Copyright Information |
---|
| | |
---|
| |
---|
| | """ |
---|
| | |
---|
| | def __ResolveRenameTokens(self, target, renstring): |
---|
| | |
---|
| | # Find all token delimiters |
---|
| | # Find all token delimiters but ignore any that might appear |
---|
| | # inside a command execution replacement token string. |
---|
| | |
---|
| | rentokens = [] |
---|
| | td = re.finditer(TOKDELIM, renstring) |
---|
| | |
---|
| | # Build list of begin/end delimiter pairs |
---|
| | |
---|
| | odd = True |
---|
| | for i in td: |
---|
| | |
---|
| | if odd: |
---|
| | rentokens.append([i.start()]) |
---|
| | |
---|
| | else: |
---|
| | rentokens[-1].append(i.start()) |
---|
| | |
---|
| | odd = not odd |
---|
| | |
---|
| | incmdexec = False |
---|
| | |
---|
| | i=0 |
---|
| | while i < len(renstring): |
---|
| | |
---|
| | if renstring[i] == TOKCMDEXEC: |
---|
| | incmdexec = not incmdexec |
---|
| | |
---|
| | elif renstring[i] == TOKDELIM: |
---|
| | |
---|
| | if incmdexec: |
---|
| | pass |
---|
| | |
---|
| | elif odd: |
---|
| | |
---|
| | rentokens.append([i]) |
---|
| | odd = not odd |
---|
| | |
---|
| | else: |
---|
| | |
---|
| | rentokens[-1].append(i) |
---|
| | odd = not odd |
---|
| | |
---|
| | |
---|
| | i += 1 |
---|
| | |
---|
| | # There must be an even number of token delimiters |
---|
| | # or the renaming token is malformed |
---|
| | |
---|
| | |
---|
| | if rentokens and len(rentokens[-1]) != 2: |
---|
| | ErrorMsg(eTOKDELIM % renstring) |
---|
| | |
---|
| | # Now add the renaming token contents. This will be used to |
---|
| |
---|
| | |