| |
---|
| | |
---|
| | PROGNAME = "tren.py" |
---|
| | BASENAME = PROGNAME.split(".py")[0] |
---|
| | PROGENV = BASENAME.upper() |
---|
| | RCSID = "$Id: tren.py,v 1.149 2010/02/05 21:25:31 tundra Exp $" |
---|
| | RCSID = "$Id: tren.py,v 1.150 2010/02/05 21:35:47 tundra Exp $" |
---|
| | VERSION = RCSID.split()[2] |
---|
| | |
---|
| | # Copyright Information |
---|
| | |
---|
| |
---|
| | ##### |
---|
| | # Informational Messages |
---|
| | ##### |
---|
| | |
---|
| | iRENEXISTING = "Forced rename existing '%s' to '%s' !" |
---|
| | iSKIPPING = "Skipping '%s' - Newname '%s' Exists!" |
---|
| | iRENEXISTING = "Forced rename of existing '%s' to '%s' !" |
---|
| | iSKIPPING = "Skipping rename of '%s' - Newname '%s' Exists!" |
---|
| | |
---|
| | |
---|
| | ##### |
---|
| | # Usage Prompts |
---|
| |
---|
| | |
---|
| | # Now that we have a new name, attempt the actual renaming |
---|
| | # operation |
---|
| | |
---|
| | # First make sure the new name meets length constraints |
---|
| | |
---|
| | RenamingError = False |
---|
| | newname = pathname + basename |
---|
| | |
---|
| | # First make sure the new name meets length constraints |
---|
| | |
---|
| | if len(basename) < MINNAMELEN: |
---|
| | ErrorMsg(eNAMESHORT% (target, basename, MINNAMELEN), EXIT=not ProgramOptions[ERRORCONTINUE]) |
---|
| | RenamingError = True |
---|
| | |
---|
| | if len(basename) > MAXNAMELEN: |
---|
| | ErrorMsg(eNAMELONG % (target, basename, MAXNAMELEN), EXIT=not ProgramOptions[ERRORCONTINUE]) |
---|
| | RenamingError = True |
---|
| | |
---|
| | |
---|
| | newname = pathname + basename |
---|
| | if (target != newname) and not RenamingError: |
---|
| | |
---|
| | # Figure out if the newname already exists |
---|
| | |
---|
| | newexists = False |
---|
| | if os.path.exists(newname): |
---|
| | newexists = True |
---|
| | renameexisting = newname + ProgramOptions[EXISTSUFFIX] |
---|
| | |
---|
| | # Just show what we would do |
---|
| | |
---|
| | if ProgramOptions[TESTMODE]: |
---|
| | |
---|
| | if newexists: |
---|
| | |
---|
| | # Forced renaming of existing targets |
---|
| | if ProgramOptions[FORCERENAM]: |
---|
| | |
---|
| | renameexisting = newname + ProgramOptions[EXISTSUFFIX] |
---|
| | InfoMsg(iRENEXISTING % (newname, renameexisting), TESTMODE) |
---|
| | |
---|
| | # Skip renaming if target already exists |
---|
| | else: |
---|
| | |
---|
| | InfoMsg(iSKIPPING % (target, newname), TESTMODE) |
---|
| | |
---|
| | # Target does not exist, do the rename |
---|
| | else: |
---|
| | |
---|
| | InfoMsg(ColumnPad([target + " %s " % ARROW, newname]), TESTMODE) |
---|
| | |
---|
| | # Actually do the renaming |
---|
| | else: |
---|
| | |
---|
| | print target + "---->"+ newname |
---|
| | |
---|
| | # End of 'Rename()' |
---|
| | |
---|
| |
---|
| | |