Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: abp/filters/render_script.py

Issue 29824555: Issue #4116: Make infile and outfile parameters of flrender script from python-abp optional (Closed)
Patch Set: Fixed minor flake8 issue Created July 16, 2018, 11:49 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « README.md ('k') | abp/filters/sources.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: abp/filters/render_script.py
diff --git a/abp/filters/render_script.py b/abp/filters/render_script.py
index bfc0c83a9c5b4fb50c74be5f8159760496416083..800c04b307cee22030acd6d6b85e2cc0c6de72ac 100644
--- a/abp/filters/render_script.py
+++ b/abp/filters/render_script.py
@@ -30,8 +30,9 @@ def parse_args():
parser = argparse.ArgumentParser(description='Render a filter list.')
parser.add_argument(
'infile', help='top level filter list fragment from which the '
- 'rendering starts')
- parser.add_argument('outfile', help='output filter list file')
+ 'rendering starts', default='-', nargs='?')
+ parser.add_argument('outfile', help='output filter list file',
+ default='-', nargs='?')
parser.add_argument(
'-i', '--include', action='append', default=[], metavar='NAME=PATH',
help='define include path (could be given multiple times)')
@@ -48,7 +49,6 @@ def main():
'https': WebSource('https'),
}
args = parse_args()
-
if args.verbose:
logging.basicConfig(level=logging.INFO, stream=sys.stderr,
format='%(message)s')
@@ -59,8 +59,12 @@ def main():
try:
lines = render_filterlist(args.infile, sources, TopSource())
- with io.open(args.outfile, 'w', encoding='utf-8') as out_fp:
+ if args.outfile == '-':
for line in lines:
- out_fp.write(line.to_string() + '\n')
+ sys.stdout.write(line.to_string() + '\n')
+ else:
+ with io.open(args.outfile, 'w', encoding='utf-8') as out_fp:
+ for line in lines:
+ out_fp.write(line.to_string() + '\n')
except (MissingHeader, NotFound, IncludeError) as exc:
sys.exit(exc)
« no previous file with comments | « README.md ('k') | abp/filters/sources.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld