summaryrefslogtreecommitdiff
path: root/lorry.zip-importer
diff options
context:
space:
mode:
authorBen Hutchings <ben.hutchings@codethink.co.uk>2020-05-04 19:28:48 +0100
committerBen Hutchings <ben.hutchings@codethink.co.uk>2020-05-29 20:35:30 +0100
commit2234eae5baddeee7f41b41b40cf5cfb5d61436a1 (patch)
treef1f3edd98371398393557e25e8d6bcbdf489bd81 /lorry.zip-importer
parentc64348cc872907fc711b756dbc73693402ee2fa1 (diff)
downloadlorry-2234eae5baddeee7f41b41b40cf5cfb5d61436a1.tar.gz
lorry.{g,}zip-importer: Only import modules and classes into module scope
Currently these scripts import a bunch of functions into module scope, which is a bit confusing. Change them to access functions through their enclosing module names. In lorry.gzip-importer, hexversion and stderr weren't used at all.
Diffstat (limited to 'lorry.zip-importer')
-rwxr-xr-xlorry.zip-importer27
1 files changed, 14 insertions, 13 deletions
diff --git a/lorry.zip-importer b/lorry.zip-importer
index 836e46f..c1b511c 100755
--- a/lorry.zip-importer
+++ b/lorry.zip-importer
@@ -10,27 +10,28 @@
## python import-zips.py *.zip
## git log --stat import-zips
-from os import popen, path
-from os.path import splitext
-from sys import argv, exit
-from time import mktime
+import os
+import os.path
+import sys
+import time
from zipfile import ZipFile
-if len(argv) < 2:
- print('usage:', argv[0], '<zipfile>...')
- exit(1)
+
+if len(sys.argv) < 2:
+ print('usage:', sys.argv[0], '<zipfile>...')
+ sys.exit(1)
branch_name = 'master'
branch_ref = 'refs/heads/%s' % branch_name
committer_name = 'Lorry Zip Importer'
committer_email = 'lorry-zip-importer@lorry'
-fast_import = popen('git fast-import --quiet', 'w')
+fast_import = os.popen('git fast-import --quiet', 'w')
def printlines(list):
for str in list:
fast_import.write(str + "\n")
-for zipfile in argv[1:]:
+for zipfile in sys.argv[1:]:
commit_time = 0
next_mark = 1
common_prefix = None
@@ -59,9 +60,9 @@ for zipfile in argv[1:]:
fast_import.write(zip.read(name) + "\n")
committer = committer_name + ' <' + committer_email + '> %d +0000' % \
- mktime(commit_time + (0, 0, 0))
+ time.mktime(commit_time + (0, 0, 0))
- zipfile_basename = path.basename(zipfile)
+ zipfile_basename = os.path.basename(zipfile)
printlines(('commit ' + branch_ref, 'committer ' + committer, \
'data <<EOM', 'Imported from ' + zipfile_basename + '.', 'EOM', \
'', 'deleteall'))
@@ -70,11 +71,11 @@ for zipfile in argv[1:]:
fast_import.write('M 100644 ' + mark[name] + ' ' +
name[len(common_prefix):] + "\n")
- zipname, _ = splitext(zipfile_basename)
+ zipname, _ = os.path.splitext(zipfile_basename)
printlines(('', 'tag ' + zipname, \
'from ' + branch_ref, 'tagger ' + committer, \
'data <<EOM', 'Package ' + zipfile, 'EOM', ''))
if fast_import.close():
- exit(1)
+ sys.exit(1)