-
Notifications
You must be signed in to change notification settings - Fork 22
/
scan_sizes.py
47 lines (39 loc) · 1.38 KB
/
scan_sizes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/python
#
# Copyright Hugh Perkins 2015 hughperkins at gmail
#
# This Source Code Form is subject to the terms of the Mozilla Public License,
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
# obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, division, print_function
import sys,os,time, os.path
import zipfile
mydir = os.path.dirname(os.path.abspath(__file__))
print( mydir )
sys.path.append(mydir + '/gomill' )
import gomill
import gomill.sgf
#import gomill.handicap_layout
import kgs_dataset_preprocessor
def scanZip( zipfilepath ):
thiszip = zipfile.ZipFile( zipfilepath )
for name in thiszip.namelist():
#print( name )
if name.endswith('.sgf'):
sgfContents = thiszip.read( name )
#sgf = gomill.sgf.Sgf_game.from_string( sgfContents )
#print( sgfContents )
try:
size = sgfContents.split("\nSZ[")[1].split("]")[0]
if size != "19":
print( size )
except:
print( "[not known]" )
#sys.exit(-1)
def go( sTargetDirectory ):
for sZipfilename in os.listdir( sTargetDirectory ):
if sZipfilename.endswith('.zip'):
scanZip( sTargetDirectory + '/' + sZipfilename )
if __name__ == '__main__':
sTargetDirectory = 'data'
go( sTargetDirectory )