diff options
Diffstat (limited to 'ecomp-portal-FE/client/bower_components/jqTree/_entries/insert.py')
-rw-r--r-- | ecomp-portal-FE/client/bower_components/jqTree/_entries/insert.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/ecomp-portal-FE/client/bower_components/jqTree/_entries/insert.py b/ecomp-portal-FE/client/bower_components/jqTree/_entries/insert.py new file mode 100644 index 00000000..d72ef4b9 --- /dev/null +++ b/ecomp-portal-FE/client/bower_components/jqTree/_entries/insert.py @@ -0,0 +1,46 @@ +import os +import argparse +import re + + +parser = argparse.ArgumentParser() +parser.add_argument('index', type=int) + +args = parser.parse_args() + +insert_index = args.index + +filenames = os.listdir('.') + +file_tuples = [] + +re_file = re.compile(r'^(\d\d)_(.*)$') + +for filename in filenames: + m = re_file.match(filename) + + if m: + i = int(m.groups()[0]) + + t = i, filename + + file_tuples.append(t) + +file_tuples = sorted(file_tuples, key=lambda t: t[0]) + +for i, t in enumerate(file_tuples): + if i + 1 != t[0]: + raise Exception('Expected index %s for %s' % (i, t[1])) + +for i in range(insert_index - 1, len(file_tuples)): + old_filename = file_tuples[i][1] + + m = re_file.match(old_filename) + + filepart = m.groups()[1] + + new_filename = '%02d_%s' % (i + 2, filepart) + + print 'rename %s to %s' % (old_filename, new_filename) + + os.rename(old_filename, new_filename) |