Commit e0d24aac authored by Henke's avatar Henke
Browse files

Allow for overwriting files

parent 1759ed11
...@@ -103,6 +103,8 @@ if __name__ == '__main__': ...@@ -103,6 +103,8 @@ if __name__ == '__main__':
parser.add_argument('--beesource', help='Specify source for bee movie script') parser.add_argument('--beesource', help='Specify source for bee movie script')
parser.add_argument('--exceptions', action='store_const', parser.add_argument('--exceptions', action='store_const',
const=True, default=False, help='Raise exceptions for long lines') const=True, default=False, help='Raise exceptions for long lines')
parser.add_argument('--overwrite', action='store_const',
const=True, default=False, help='Overwrite input files')
parser.add_argument('--comment-l', type=str, default='', dest='L', parser.add_argument('--comment-l', type=str, default='', dest='L',
help='Use this as left side of inline comment.') help='Use this as left side of inline comment.')
parser.add_argument('--comment-r', type=str, default='', dest='R', parser.add_argument('--comment-r', type=str, default='', dest='R',
...@@ -122,7 +124,9 @@ if __name__ == '__main__': ...@@ -122,7 +124,9 @@ if __name__ == '__main__':
print(line) print(line)
else: else:
for fname in args.filename: for fname in args.filename:
beefname = beeify_filename(fname) beefname = fname
if not args.overwrite:
beefname = beeify_filename(fname)
lines, text_ptr = beeify_file(fname, args.width, args.comment, text_ptr, L, R) lines, text_ptr = beeify_file(fname, args.width, args.comment, text_ptr, L, R)
with open(beefname, 'w') as f: with open(beefname, 'w') as f:
for line in lines: for line in lines:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment