[packages/rpm-build-tools] sort-pkgs: read packages from stdin if no filename was passed

atler atler at pld-linux.org
Wed Jan 4 22:36:31 CET 2023


commit 1481cd8ea6ac35a07e8280abaa0a4fbe55941da9
Author: Jan Palus <atler at pld-linux.org>
Date:   Wed Jan 4 22:34:38 2023 +0100

    sort-pkgs: read packages from stdin if no filename was passed

 sort-pkgs | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
---
diff --git a/sort-pkgs b/sort-pkgs
index a4115db..28a3572 100755
--- a/sort-pkgs
+++ b/sort-pkgs
@@ -2,7 +2,7 @@
 
 """
 This script tries to set ordering in which packages ought to be sent to builders.
-Input: file with names of packages. One package name per line.
+Input: file with names of packages. If not given packages are read from stdin. One package name per line.
 Output: sorted packages on stdout.
 
 If the script goes in a infinite loop, that means there is a cycle or other bug.
@@ -76,10 +76,7 @@ def print_spec(spec):
 
 
 if __name__ == "__main__":
-    if len(sys.argv) < 2:
-        print("Usage: %s filename" % sys.argv[0])
-        sys.exit(1)
-    with open(sys.argv[1], 'r') as f:
+    with (len(sys.argv) > 1 and open(sys.argv[1], 'r') or sys.stdin) as f:
         for line in f:
             spec = os.path.basename(os.path.normpath(line.rstrip())).removesuffix('.spec')
             parse_spec(spec)
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/rpm-build-tools.git/commitdiff/1481cd8ea6ac35a07e8280abaa0a4fbe55941da9



More information about the pld-cvs-commit mailing list