From cad5b2c2bbbac7015f3f2bf66f8af01bdbf943f8 Mon Sep 17 00:00:00 2001 From: Ben Brown Date: Sat, 5 Feb 2022 15:47:35 +0000 Subject: Commit changes from from black and isort --- lorry.gzip-importer | 70 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 27 deletions(-) (limited to 'lorry.gzip-importer') diff --git a/lorry.gzip-importer b/lorry.gzip-importer index 5c0c6d0..4f4fb61 100755 --- a/lorry.gzip-importer +++ b/lorry.gzip-importer @@ -4,65 +4,81 @@ # gzip archive frontend for git-fast-import -from gzip import GzipFile import os.path import struct import subprocess import sys +from gzip import GzipFile - -branch_name = 'master' -branch_ref = 'refs/heads/%s' % branch_name -committer_name = 'Lorry Gzip Importer' -committer_email = 'lorry-gzip-importer@lorry' +branch_name = "master" +branch_ref = "refs/heads/%s" % branch_name +committer_name = "Lorry Gzip Importer" +committer_email = "lorry-gzip-importer@lorry" # The size of a gzip file is stored in the last 4 bytes def uncompressedsize(filename): - with open(filename, 'rb') as f: + with open(filename, "rb") as f: f.seek(-4, 2) - return struct.unpack('I', f.read(4))[0] + return struct.unpack("I", f.read(4))[0] def export(zipfile, fast_import): def printlines(list): for str in list: - fast_import.write(str.encode('utf-8') + b"\n") + fast_import.write(str.encode("utf-8") + b"\n") # Gzip does have an encoded mtime, however Python's GzipFile # just ignores it, so we just yank the mtime of the zip file itself. - mtime = os.path.getmtime(zipfile); - file_size = uncompressedsize (zipfile); - zip = GzipFile(zipfile, 'rb') + mtime = os.path.getmtime(zipfile) + file_size = uncompressedsize(zipfile) + zip = GzipFile(zipfile, "rb") - printlines(('blob', 'mark :1', 'data ' + str(file_size))) + printlines(("blob", "mark :1", "data " + str(file_size))) fast_import.write(zip.read() + b"\n") - committer = committer_name + ' <' + committer_email + '> %d +0000' % \ - mtime + committer = committer_name + " <" + committer_email + "> %d +0000" % mtime zipfile_basename = os.path.basename(zipfile) - printlines(('commit ' + branch_ref, 'committer ' + committer, \ - 'data <...') + print("usage:", sys.argv[0], "...") sys.exit(1) - with subprocess.Popen('git fast-import --quiet', shell=True, - stdin=subprocess.PIPE) as import_proc: + with subprocess.Popen( + "git fast-import --quiet", shell=True, stdin=subprocess.PIPE + ) as import_proc: for zipfile in sys.argv[1:]: export(zipfile, import_proc.stdin) import_proc.stdin.close() -- cgit v1.2.1