def upgrade_0_5_4(dataRoot): "Webman : init.py now named init.wmi" todo_rename = [] for (root,dirs,files) in os.walk(dataRoot): for fn in files: if fn == "init.py": todo_rename.append((op.join(root,fn), op.join(root,"init.wmi"))) for (src,dest) in todo_rename: print "rename %s to %s" % (src,dest) if not confirm("okay"): return False for (src,dest) in todo_rename: os.rename(src,dest) return True
def upgrade_0_5_4(dataRoot): "Webman : init.py now named init.wmi" todo_rename = [] for (root, dirs, files) in os.walk(dataRoot): for fn in files: if fn == "init.py": todo_rename.append((op.join(root, fn), op.join(root, "init.wmi"))) for (src, dest) in todo_rename: print "rename %s to %s" % (src, dest) if not confirm("okay"): return False for (src, dest) in todo_rename: os.rename(src, dest) return True
if o in ("-q", "--quiet"): VERBOSE=False if len(args) == 0: collect_upper(".") else: for root in args: collect_upper(root) if len(upperDirnames)+len(upperFilenames) == 0: if VERBOSE: print "Nothing to do" sys.exit() if confirm( "Okay to rename %d directories and %d files [Yn]?" % (len(upperDirnames),len(upperFilenames))): for (o,n) in upperDirnames: os.rename(o,n) if VERBOSE: print "%d directories renamed" % len(upperDirnames) for (o,n) in upperFilenames: os.rename(o,n) if VERBOSE: print "%d files renamed" % len(upperFilenames)
if __name__ == "__main__": print "Lino Publish" print copyleft(year='2002-2004') # collect names of files or directories containing uppercase # characters # os.path.walk(".",collect_upper,None) collect_upper() if len(upperDirnames)+len(upperFilenames) > 0 and confirm( "Okay to rename %d directories and %d files [Yn]?" % (len(upperDirnames),len(upperFilenames))): for (o,n) in upperFilenames: os.rename(o,n) print "%d files renamed" % len(upperFilenames) for (o,n) in upperDirnames: os.rename(o,n) print "%d directories renamed" % len(upperDirnames) # collect names of image files collect_images() if len(imgFilenames) > 0 and confirm(\
if __name__ == "__main__": print "Lino Publish" print copyleft(year='2002-2004') # collect names of files or directories containing uppercase # characters # os.path.walk(".",collect_upper,None) collect_upper() if len(upperDirnames) + len(upperFilenames) > 0 and confirm( "Okay to rename %d directories and %d files [Yn]?" % (len(upperDirnames), len(upperFilenames))): for (o, n) in upperFilenames: os.rename(o, n) print "%d files renamed" % len(upperFilenames) for (o, n) in upperDirnames: os.rename(o, n) print "%d directories renamed" % len(upperDirnames) # collect names of image files collect_images() if len(imgFilenames) > 0 and confirm(\ "Okay to create %d thumbnails [Yn]?" % len(imgFilenames)):
if o in ("-?", "-h", "--help"): print __doc__ sys.exit() if o in ("-q", "--quiet"): VERBOSE = False if len(args) == 0: collect_upper(".") else: for root in args: collect_upper(root) if len(upperDirnames) + len(upperFilenames) == 0: if VERBOSE: print "Nothing to do" sys.exit() if confirm("Okay to rename %d directories and %d files [Yn]?" % (len(upperDirnames), len(upperFilenames))): for (o, n) in upperDirnames: os.rename(o, n) if VERBOSE: print "%d directories renamed" % len(upperDirnames) for (o, n) in upperFilenames: os.rename(o, n) if VERBOSE: print "%d files renamed" % len(upperFilenames)