| |
---|
| | |
---|
| | PROGNAME = "tren.py" |
---|
| | BASENAME = PROGNAME.split(".py")[0] |
---|
| | PROGENV = BASENAME.upper() |
---|
| | RCSID = "$Id: tren.py,v 1.141 2010/02/04 19:55:27 tundra Exp $" |
---|
| | RCSID = "$Id: tren.py,v 1.142 2010/02/05 03:00:24 tundra Exp $" |
---|
| | VERSION = RCSID.split()[2] |
---|
| | |
---|
| | # Copyright Information |
---|
| | |
---|
| |
---|
| | for renrequest in self.RenRequests: |
---|
| | |
---|
| | old, new = self.ResolveRenameStrings(renrequest[OLD], renrequest[NEW]) |
---|
| | |
---|
| | # Handle global vs. 1st occurence replacement |
---|
| | |
---|
| | oldstrings = [] |
---|
| | |
---|
| | # Build a list of indexes to every occurence of the old string |
---|
| | |
---|
| | i = newname.find(old) |
---|
| | while i >= 0: |
---|
| | |
---|
| | oldstrings.append(i) |
---|
| | # Build a list of indexes to every occurence of the old string, |
---|
| | # taking case sensitivity into account |
---|
| | |
---|
| | # Handle the case when old = "". |
---|
| | # This means to *replace the entire* old name with new. |
---|
| | |
---|
| | i = newname.find(old, i + len(old)) |
---|
| | if not old: |
---|
| | oldstrings = [0,] |
---|
| | newname = "" |
---|
| | |
---|
| | # Handle case where an old is non-null |
---|
| | else: |
---|
| | name = newname |
---|
| | |
---|
| | # Collapse case if requested |
---|
| | if not renrequest[CASESENSITIVE]: |
---|
| | |
---|
| | name = name.lower() |
---|
| | old = old.lower() |
---|
| | |
---|
| | i = name.find(old) |
---|
| | while i >= 0: |
---|
| | |
---|
| | oldstrings.append(i) |
---|
| | i = name.find(old, i + len(old)) |
---|
| | |
---|
| | # If we found any maching strings, replace them |
---|
| | |
---|
| | if oldstrings: |
---|
| | |
---|
| | # Only process leftmost occurence if global replace is off |
---|
| |
---|
| | |