]> git.pld-linux.org Git - packages/rpm-build-tools.git/commitdiff
sort-pkgs: read packages from stdin if no filename was passed
authorJan Palus <atler@pld-linux.org>
Wed, 4 Jan 2023 21:34:38 +0000 (22:34 +0100)
committerJan Palus <atler@pld-linux.org>
Wed, 4 Jan 2023 21:34:38 +0000 (22:34 +0100)
sort-pkgs

index a4115db946cf5ada0c0d7c931f8acbbe396c8e3b..28a3572d49c07a7f9b4be8d52a97e0976ffe2f4e 100755 (executable)
--- 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)
This page took 0.081696 seconds and 4 git commands to generate.