diff options
author | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2020-11-26 01:08:07 -0800 |
---|---|---|
committer | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2020-11-26 01:08:07 -0800 |
commit | 7a9da11d8b2b2f06c0904d397864f216bd7c1e14 (patch) | |
tree | 96f127eb316525e47179e61f4fae940864045419 | |
parent | a3ae05cc9f5e92cab86098a094a518badac8ce92 (diff) | |
download | pugixml-7a9da11d8b2b2f06c0904d397864f216bd7c1e14.zip pugixml-7a9da11d8b2b2f06c0904d397864f216bd7c1e14.tar.gz pugixml-7a9da11d8b2b2f06c0904d397864f216bd7c1e14.tar.bz2 |
scripts: Convert archive.py to Python 3v1.11
The changes are mostly mechanically converting str to bytes.
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | scripts/archive.py | 12 |
2 files changed, 7 insertions, 7 deletions
@@ -77,7 +77,7 @@ docs: docs/quickstart.html docs/manual.html build/pugixml-%: .FORCE | $(RELEASE) @mkdir -p $(BUILD) - TIMESTAMP=`git show v$(VERSION) -s --format=%ct` && python scripts/archive.py $@ pugixml-$(VERSION) $$TIMESTAMP $| + TIMESTAMP=`git show v$(VERSION) -s --format=%ct` && python3 scripts/archive.py $@ pugixml-$(VERSION) $$TIMESTAMP $| $(EXECUTABLE): $(OBJECTS) $(CXX) $(OBJECTS) $(LDFLAGS) -o $@ diff --git a/scripts/archive.py b/scripts/archive.py index d102d05..e4fb7d4 100644 --- a/scripts/archive.py +++ b/scripts/archive.py @@ -1,18 +1,18 @@ +import io import os.path import sys import tarfile import time import zipfile -import StringIO def read_file(path, use_crlf): with open(path, 'rb') as file: data = file.read() - if '\0' not in data: - data = data.replace('\r', '') + if b'\0' not in data: + data = data.replace(b'\r', b'') if use_crlf: - data = data.replace('\n', '\r\n') + data = data.replace(b'\n', b'\r\n') return data @@ -24,7 +24,7 @@ def write_zip(target, arcprefix, timestamp, sources): info = zipfile.ZipInfo(path) info.date_time = time.localtime(timestamp) info.compress_type = zipfile.ZIP_DEFLATED - info.external_attr = 0644 << 16L + info.external_attr = 0o644 << 16 archive.writestr(info, data) def write_tar(target, arcprefix, timestamp, sources, compression): @@ -35,7 +35,7 @@ def write_tar(target, arcprefix, timestamp, sources, compression): info = tarfile.TarInfo(path) info.size = len(data) info.mtime = timestamp - archive.addfile(info, StringIO.StringIO(data)) + archive.addfile(info, io.BytesIO(data)) if len(sys.argv) < 5: raise RuntimeError('Usage: python archive.py <target> <archive prefix> <timestamp> <source files>') |