Пример #1
0
 def refresh_collection(self, collection):
     print 'Asked to refresh collection', collection
     matching_screens = filter(lambda j: j == ('Collection ' + collection), self.screen_names)
     if len(matching_screens) > 0:
         scr = self.get_screen(matching_screens[0])
         collection_model = list(Collection.select().where(Collection.name == collection))[0]
         gc = scr.children[0]
         games = get_games_in(collection_model)
         args_converter = games_args_converter
         list_adapter = ListAdapter(data=games,
                                    args_converter = args_converter,
                                    selection_mode = 'single',
                                    allow_empty_selection=True,
                                    cls=GameChooserButton,
                                    )
         gc.gameslist.adapter = list_adapter
     self.refresh_collections_index()
Пример #2
0
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:
            colmod = [Collection(name=entry)]
            colmod[0].save()
            print 'made new collection', colmod[0].name
        col = colmod[0]
        collections.append(col)

        info = get_gameinfo_from_file(sgf)
        apply_gameinfo_to_sgfmodel(model, info)

        sgfmodels.append(model)
    # with db.transaction():
    #     for model in sgfmodels:
    #         try:
    #             model.save()