From cd269a60eeebabcc9530d977cf18ee992fd38cd3 Mon Sep 17 00:00:00 2001 From: Tim Harder Date: Sat, 5 Nov 2016 00:08:14 -0400 Subject: pquery: initial support for reading targets from stdin TODO: Currently this doesn't separate the incoming targets into separate queries which feels wrong. Fixes #226. --- pkgcore/scripts/pquery.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkgcore/scripts/pquery.py b/pkgcore/scripts/pquery.py index e73fbd10..2c87a466 100644 --- a/pkgcore/scripts/pquery.py +++ b/pkgcore/scripts/pquery.py @@ -32,6 +32,7 @@ demandload( 'errno', 'os', 're', + 'sys', 'snakeoil.osutils:sizeof_fmt', 'snakeoil.sequences:iter_stable_unique', 'pkgcore.fs:fs@fs_module,contents@contents_module', @@ -614,6 +615,11 @@ def bind_add_query(*args, **kwds): def matches_finalize(targets, namespace): if not targets: return [] + if len(targets) == 1 and targets[0] == '-': + if not sys.stdin.isatty(): + targets = (x.strip() for x in sys.stdin.readlines() if x.strip() != '') + else: + raise argparser.error("'-' is only valid when piping data in") repos = multiplex.tree(*namespace.repos) restrictions = [] for target in targets: -- cgit v1.2.3-65-gdbad