def load_table_details(db_str: str, table: str) -> Table: with sqlite3.connect(db_str) as connection: connection.row_factory = sqlite3.Row try: cursor = connection.cursor() cursor.execute( """ SELECT query, interval, config, last_created, force, waiting FROM tables WHERE table_name = ? """, (table, ), ) row = cursor.fetchone() # noinspection PyTypeChecker return Table( name=table, query=row["query"], interval=row["interval"], config=json.loads(row["config"]), last_created=row["last_created"], force=row["force"], waiting=row["waiting"], ) except TypeError: raise TableNotFoundInDBError(table)
def build_table_configs(graph: nx.DiGraph, views_path: str) -> List[Table]: nodes = dict(graph.nodes(data=True)) return [ Table( table, data["contents"], data["interval"], parse_table_config(table, views_path), ) for table, data in nodes.items() ]
def process_callback(self, callback: CallbackQuery) -> None: records = self.collector.get_removal_queue(callback.chat_id) page = callback.data.get("page") table = Table(records, cast(int, page)) self.client.edit_message_text( callback.chat_id, callback.message_id, table.build(), parse_mode="HTML", **table.get_reply_markup(), ) self.client.answer_callback_query(callback.id)
def process(self, message: Message) -> None: records = self.collector.get_removal_queue(message.chat.id) table = Table(records, 1) self.client.reply(message, table.build(), **table.get_reply_markup())
def set_table(self, names): self.player_names = names self.table = Table([Player(n) for n in self.player_names])
def initialize_table(self): self.table = Table(self.players)
from play.play_round import Round from utils.player import Player from utils.table import Table import random player_names = ['anil', 'pogo', 'mangal', 'ramya', 'harsha'] players = [Player(name) for name in player_names] table = Table(players) r = Round(table) print(r.table) r.table.move_player_to_front_by_name('ramya') print(r.table) r.table.move_player_to_front_by_name('harsha') print(r.table) # r.table.move_dealer() # print(r.table) r.table.remove_player("anil") print(r.table) print("Trump is : {}".format(r.trump_card)) # cards_played = {'anil': random.choice(players[0].hand.cards), # 'pogo': random.choice(players[1].hand.cards), # 'mangal': random.choice(players[2].hand.cards), # 'ramya': random.choice(players[3].hand.cards), # 'harsha': random.choice(players[4].hand.cards)} # # r.play_round(cards_played) # print(r.players)
if not test_results: drop_temp_table(table.name, connection) return replace_old_table(table.name, connection) drop_old_table(table.name, connection) connection.close() if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("table", help="table to create", type=str) parser.add_argument("--path", "-p", default="./views/", help="folder containing the views") parser.add_argument("--verbose", "-v", default=False, help="Verbose", action="store_true") args = parser.parse_args() table = Table( name=args.table, query=load_select_query(args.path, args.table), interval=None, config=parse_table_config(args.table, args.path), ) create_table(table, args.path, args.verbose)