Changeset View
Changeset View
Standalone View
Standalone View
contrib/apple-sdk-tools/extract_xcode.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2020 The Bitcoin Core developers | # Copyright (c) 2020 The Bitcoin Core developers | ||||
# Distributed under the MIT software license, see the accompanying | # Distributed under the MIT software license, see the accompanying | ||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
"""XCode extractor | """XCode extractor | ||||
""" | """ | ||||
import argparse | import argparse | ||||
import os.path | |||||
import sys | import sys | ||||
import struct | import struct | ||||
import zlib | import zlib | ||||
import xml.etree.ElementTree as ET | import xml.etree.ElementTree as ET | ||||
import lzma | import lzma | ||||
XAR_MAGIC = b'\x78\x61\x72\x21' | XAR_MAGIC = b'\x78\x61\x72\x21' | ||||
PBZX_MAGIC = b'\x70\x62\x7a\x78' | PBZX_MAGIC = b'\x70\x62\x7a\x78' | ||||
Show All 31 Lines | def run(): | ||||
parser = argparse.ArgumentParser( | parser = argparse.ArgumentParser( | ||||
description=__doc__, formatter_class=argparse.RawTextHelpFormatter) | description=__doc__, formatter_class=argparse.RawTextHelpFormatter) | ||||
parser.add_argument("-f", '--file', nargs='?', default="-") | parser.add_argument("-f", '--file', nargs='?', default="-") | ||||
parser.add_argument('outfile', nargs='?', default="-") | parser.add_argument('outfile', nargs='?', default="-") | ||||
args = parser.parse_args() | args = parser.parse_args() | ||||
if os.path.exists(args.outfile): | |||||
print(f"Error: Output file {args.outfile} already exists.", file=sys.stderr) | |||||
sys.exit(1) | |||||
with io_wrapper(args.file, "rb") as infile, io_wrapper(args.outfile, "wb") as outfile: | with io_wrapper(args.file, "rb") as infile, io_wrapper(args.outfile, "wb") as outfile: | ||||
start_offset = 0 | start_offset = 0 | ||||
magic = infile.read(4) | magic = infile.read(4) | ||||
if magic != XAR_MAGIC: | if magic != XAR_MAGIC: | ||||
print("bad xar magic", file=sys.stderr) | print("bad xar magic", file=sys.stderr) | ||||
sys.exit(1) | sys.exit(1) | ||||
▲ Show 20 Lines • Show All 66 Lines • Show Last 20 Lines |