FS#8043 - rankmirrors should optionally read from stdin

Attached to Project: Pacman
Opened by Pete (tam1138) - Monday, 17 September 2007, 17:13 GMT
Last edited by Dan McGee (toofishes) - Friday, 05 October 2007, 01:15 GMT
Task Type Feature Request
Category General
Status Closed
Assigned To No-one
Architecture All
Severity Low
Priority Normal
Reported Version 3.0.5
Due in Version 3.1.0
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Summary and Info:

It is standard for programs which take file arguments to interpret the argument "-" to mean "read from stdin". This would be particularly useful with rankmirrors, as one could use it as a filter to rewrite one's /etc/pacman.d files with little to no interaction. Eg, in vi command mode: "6,13!rankmirrors -" would replace lines 6 through 13 with the output of rankmirrors fed lines 6-13 on stdin.

Here is a patch to add this feature:

--- rankmirrors.orig 2007-09-17 13:08:11.000000000 -0400
+++ rankmirrors 2007-09-17 13:08:56.000000000 -0400
@@ -112,11 +112,15 @@
print args[0], ':', "%.2f" % serverToTime
sys.exit(0)

- if not os.path.isfile(args[0]):
+ if not os.path.isfile(args[0]) and args[0] != "-":
print >>sys.stderr, 'rankmirrors: file', args[0], 'does not exist.'
sys.exit(1)

- fl = open(args[0], 'r')
+ if args[0] == "-":
+ fl = sys.stdin
+ else:
+ fl = open(args[0], 'r')
+
serverToTime = {}
if options.times:
print 'Querying servers, this may take some time...'
This task depends upon

This task blocks these from closing
 FS#8109 - Pacman 3.1 Release Roadmap 
Closed by  Dan McGee (toofishes)
Friday, 05 October 2007, 01:15 GMT
Reason for closing:  Implemented
Additional comments about closing:  Patch in GIT, to be released in 3.1
Comment by Dan McGee (toofishes) - Tuesday, 18 September 2007, 00:49 GMT
Committed to my local GIT branch, thanks.

Loading...