Reformat NBI to standardized format
[osm/NBI.git] / osm_nbi / tests / upload.py
index d256801..dfd7302 100755 (executable)
@@ -41,8 +41,11 @@ def usage():
 if __name__ == "__main__":
     try:
         # load parameters and configuration
-        opts, args = getopt.getopt(sys.argv[1:], "hvu:s:f:t:",
-                                   ["url=", "help", "version", "verbose", "file=", "chunk-size=", "token="])
+        opts, args = getopt.getopt(
+            sys.argv[1:],
+            "hvu:s:f:t:",
+            ["url=", "help", "version", "verbose", "file=", "chunk-size=", "token="],
+        )
         url = None
         chunk_size = 500
         pkg_file = None
@@ -51,7 +54,7 @@ if __name__ == "__main__":
 
         for o, a in opts:
             if o == "--version":
-                print("upload version " + __version__ + ' ' + version_date)
+                print("upload version " + __version__ + " " + version_date)
                 sys.exit()
             elif o in ("-v", "--verbose"):
                 verbose += 1
@@ -72,7 +75,7 @@ if __name__ == "__main__":
         index = 0
         transaction_id = None
         file_md5 = md5()
-        with open(pkg_file, 'rb') as f:
+        with open(pkg_file, "rb") as f:
             headers = {
                 "Content-type": "application/gzip",
                 "Content-Filename": basename(pkg_file),
@@ -87,10 +90,12 @@ if __name__ == "__main__":
                 #            "chunk_size": chunk_size}
                 if transaction_id:
                     headers["Transaction-Id"] = transaction_id
-                if index+len(chunk_data) == total_size:
+                if index + len(chunk_data) == total_size:
                     headers["Content-File-MD5"] = file_md5.hexdigest()
                 #    payload["id"] = transaction_id
-                headers["Content-range"] = "bytes {}-{}/{}".format(index, index+len(chunk_data)-1, total_size)
+                headers["Content-range"] = "bytes {}-{}/{}".format(
+                    index, index + len(chunk_data) - 1, total_size
+                )
                 # refers to rfc2616:  https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
                 if verbose:
                     print("TX chunk Headers: {}".format(headers))