15370: Fix flaky test.
[arvados.git] / sdk / python / bin / arv-normalize
index 0506381272c856bbc4e1b933aef6f474752d3667..effcd7edae0b0c1533717535a9b5b686e50e3ff6 100755 (executable)
@@ -1,4 +1,7 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: Apache-2.0
 
 import argparse
 import hashlib
@@ -6,20 +9,23 @@ import os
 import re
 import string
 import sys
-import logging
 
-logger = logging.getLogger(os.path.basename(sys.argv[0]))
+import arvados
+from arvados._version import __version__
 
 parser = argparse.ArgumentParser(
     description='Read manifest on standard input and put normalized manifest on standard output.')
 
-parser.add_argument('--extract', type=str, help="The file to extract from the input manifest")
-parser.add_argument('--strip', action='store_true', help="Strip authorization tokens")
+parser.add_argument('--extract', type=str,
+                    help="The file to extract from the input manifest")
+parser.add_argument('--strip', action='store_true',
+                    help="Strip authorization tokens")
+parser.add_argument('--version', action='version',
+                    version="%s %s" % (sys.argv[0], __version__),
+                    help='Print version and exit.')
 
 args = parser.parse_args()
 
-import arvados
-
 r = sys.stdin.read()
 
 cr = arvados.CollectionReader(r)
@@ -37,4 +43,4 @@ if args.extract:
             if fn in s.files():
                 sys.stdout.write(s.files()[fn].as_manifest())
 else:
-    sys.stdout.write(cr.manifest_text(args.strip))
+    sys.stdout.write(cr.manifest_text(strip=args.strip, normalize=True))