Added progress display

This commit is contained in:
斟酌 鵬兄 2017-12-01 18:29:55 +08:00
parent 93b1739156
commit 97c3596e5c

View File

@ -8,7 +8,7 @@ parser = argparse.ArgumentParser(
, formatter_class = argparse.RawDescriptionHelpFormatter
, epilog = """
Example:
%(prog)s -d ~/ -p "/(.+)_.+/" -s "\\1"
%(prog)s -d ~/ -p "/(.+)_.+/" -s "\\1" -t
Result:
R ".mysql_history" will be renamed to ".mysql"
@ -114,9 +114,11 @@ class RegReplace:
for root, dirs, files in os.walk( path ):
actions = self._compile_actions( root, files )
sys.stdout.write( bb[ bb_i ] )
sys.stdout.flush()
sys.stdout.write( "\b" )
sys.stdout.write( "\n" )
sys.stdout.write( "\033[K" )
sys.stdout.write( "%s ... %s" % ( bb[ bb_i ], root ) )
sys.stdout.write("\r")
sys.stdout.write( "\033[F" )
bb_i = bb_i + 1
if 3 < bb_i:
bb_i = 0
@ -132,7 +134,6 @@ class RegReplace:
if not self.recursive:
break
sys.stdout.write( " " )
sys.stdout.flush()
def _compile_re( patterns ):