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