Turn an archive into a single pgn file, via stdout
This commit is contained in:
1 parent
f71a068949
commit
a0d76f32ec
1 file changed
+38
@@ -0,0 +1,38 @@
|
||||
#!/bin/python3
|
||||
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
# #
|
||||
# OpenBench is a chess engine testing framework by Andrew Grant. #
|
||||
# <https://github.com/AndyGrant/OpenBench> <andrew@grantnet.us> #
|
||||
# #
|
||||
# OpenBench is free software: you can redistribute it and/or modify #
|
||||
# it under the terms of the GNU General Public License as published by #
|
||||
# the Free Software Foundation, either version 3 of the License, or #
|
||||
# (at your option) any later version. #
|
||||
# #
|
||||
# OpenBench is distributed in the hope that it will be useful, #
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
||||
# GNU General Public License for more details. #
|
||||
# #
|
||||
# You should have received a copy of the GNU General Public License #
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
|
||||
# #
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
|
||||
import argparse
|
||||
import bz2
|
||||
import tarfile
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('archive', help='Path to the OpenBench pgn archive')
|
||||
args = parser.parse_args()
|
||||
|
||||
data = {}
|
||||
with tarfile.open(args.archive, 'r') as tar:
|
||||
for member in filter(lambda x: x.isfile(), tar.getmembers()):
|
||||
if file := tar.extractfile(member):
|
||||
for line in bz2.decompress(file.read()).decode('utf-8').split('\n'):
|
||||
print (line)
|
||||
Reference in new issue
Block a user