From 8ee6b2aca9aedcf6a7d1ce4c1f65e15bae397de6 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sat, 23 Jan 2021 17:34:31 -0800 Subject: [PATCH] Add pipeable support. --- breplace.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/breplace.py b/breplace.py index 3deea49..7b1c264 100644 --- a/breplace.py +++ b/breplace.py @@ -11,11 +11,16 @@ import argparse import brename import sys +from voussoirkit import pipeable + def breplace_argparse(args): + replace_from = ' '.join(pipeable.input(args.replace_from)) + replace_to = ' '.join(pipeable.input(args.replace_to)) + if args.regex: - command = f're.sub(r"{args.replace_from}", r"{args.replace_to}", x)' + command = f're.sub(r"{replace_from}", r"{replace_to}", x)' else: - command = f'x.replace("{args.replace_from}", "{args.replace_to}")' + command = f'x.replace("{replace_from}", "{replace_to}")' brename.brename(command, autoyes=args.autoyes, recurse=args.recurse) def main(argv):