From 4eb685d94e89a2aef61047225c1834a89de01de2 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Wed, 28 Oct 2020 13:13:57 +0200 Subject: Simplify rcc - drop qrc parsing and zstd compression --- rcc_format/zstd.py | 43 ------------------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 rcc_format/zstd.py (limited to 'rcc_format/zstd.py') diff --git a/rcc_format/zstd.py b/rcc_format/zstd.py deleted file mode 100644 index 34eeb64..0000000 --- a/rcc_format/zstd.py +++ /dev/null @@ -1,43 +0,0 @@ -import subprocess -from rcc_format.util import * - -def zstd(filelist, args): - if args.train is not None: - train(filelist, args.train, args.binary, args.dsize) - return - - write_header(args.output, args.namespace) - - for f in filelist: - with open(f.path, 'rb') as contents: - write_item(args.output, f.variable, compress(contents, args.binary, args.level, dictionary=args.dict)) - - write_entries(args.output, filelist) - if args.dict is not None: - write_item(args.output, 'dict', args.dict.read()) - print("constexpr auto dictionary = std::span(dict, dict_len);", file=args.output) - else: - print("constexpr std::span dictionary {};", file=args.output) - - print("constexpr auto compression = embed::Zstd;", file=args.output) - - write_footer(args.output, args.namespace) - -def train(filelist, output, zstd_bin, maxdict): - cmd = [ zstd_bin, '--train', '--maxdict=' + str(maxdict), '-o', output.name ] - - for f in filelist: - cmd.append(f.path) - - subprocess.run(cmd) - -def compress(file, zstd_bin, level, dictionary=None): - cmd = [ zstd_bin, '--compress', '--stdout', '-' + str(level) ] - - if dictionary is not None: - cmd.append('-D') - cmd.append(dictionary.name) - - cmd.append(file.name) - return subprocess.run(cmd, capture_output=True).stdout - -- cgit v1.2.1