1 #! /usr/bin/env python2.4
3 # from pysqlite2 import dbapi2
9 from libkombilo
import *
12 os
.system('rm t1.db*')
16 def process(filenames
):
17 """Process a list of sgf files, put the game info into "table" of the database
18 given by con, and call the relevant processing functions for the algorithms in algos"""
20 starttime
= time
.time()
22 pop
= ProcessOptions()
24 # pop.rootNodeTags = 'PW,PB,RE,DT'
26 pop
.algos
= ALGO_FINALPOS | ALGO_MOVELIST
27 gl
= GameList('t1.db', 'id', '', pop
, 100)
29 print 'Database error'
33 for filename
in filenames
:
43 print 'Unable to read file %s' % filename
46 path
, fn
= os
.path
.split(filename
)
47 if gl
.process(sgf
, path
, fn
, '', CHECK_FOR_DUPLICATES_STRICT
):
48 if gl
.process_results() & IS_DUPLICATE
:
49 print 'duplicate', counter
50 else: print 'SGF error'
53 gl
.finalize_processing()
54 print 'Processed %d games in %.2f seconds' % (counter
, time
.time()-starttime
)
56 # filelist = glob.glob('./*.sgf')
57 # filelist = glob.glob('/home/ug/go/KGS2005/*.sgf')
58 # filelist = glob.glob('/Users/tin/Sites/eidogo/sgf/downloaded/Honinbo/*.sgf')
59 filelist
= glob
.glob('/Users/tin/Sites/eidogo/sgf/games/*.sgf')
64 gl
= GameList("t1.db", "id", "")
71 p
= Pattern(CENTER_PATTERN
, 19, 3, 5, ".X..OX.OX.OXOXO")
77 for i
in range(gl
.size())[-10:]:
78 print gl
.currentEntryAsString(i
)