def new_collection(self, newname): collection = Collection(name=newname) if platform() == 'android': collection.directory = '/sdcard/noGo/collections' else: collection.directory = './games' collection.save() self.manager.refresh_collections_index()
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()
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: