コード例 #1
0
ファイル: index_games.py プロジェクト: pombredanne/noGo
import os
import glob

from abstractboard import get_gameinfo_from_file, apply_gameinfo_to_sgfmodel
from sgfmodels import Collection, Sgf, CollectionSgf, db

default_cols = ['Pro10','IMeijin','Kisei','ITengen','Gosei','Honinbo','Shusaku','Meijin','CJSuperGo','Tengen','Judan','Oza','NihonKiin','Ing']

#collectionslist = CollectionsList()

if not Sgf.table_exists():
    Sgf.create_table()
if not Collection.table_exists():
    Collection.create_table()
if not CollectionSgf.table_exists():
    CollectionSgf.create_table()

for entry in default_cols:
    sgfs = glob.glob('./games/' + entry + '/*.sgf')
    sgfmodels = []
    collections = []
    colsgfmodels = []
    for sgf in sgfs:
        with open(sgf) as fileh:
            sgfstr = fileh.read()
        model = Sgf()
        model.filename = sgf
        model.sgf = sgfstr

        colmod = list(Collection.select().where(Collection.name == entry))
        if len(colmod) == 0: