aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Harder <radhermit@gmail.com>2016-11-05 00:08:14 -0400
committerTim Harder <radhermit@gmail.com>2016-11-05 00:08:14 -0400
commitcd269a60eeebabcc9530d977cf18ee992fd38cd3 (patch)
treee9b6baf60119ff84185b965bbd19b1854c1973be
parentvarious whitespace and indentation consistency (diff)
downloadpkgcore-pquery-stdin.tar.gz
pkgcore-pquery-stdin.tar.bz2
pkgcore-pquery-stdin.zip
pquery: initial support for reading targets from stdinpquery-stdin
TODO: Currently this doesn't separate the incoming targets into separate queries which feels wrong. Fixes #226.
-rw-r--r--pkgcore/scripts/pquery.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/pkgcore/scripts/pquery.py b/pkgcore/scripts/pquery.py
index e73fbd103..2c87a466c 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: