def __init__(self, sgf_str='', skin='unicode1.json'): # Parent constructor super(GoGame, self).__init__() # Declare a new dictionary self.header_dict = {} # If an sgf string is given... if len(sgf_str) > 0: # Split it up into units self.units = sgf_str.split(';') # Get the header string self.units = self.units[1:] self.header_str = self.units[0] # Get the list of moves and self.moves = self.units[1:] # Strip off any whitespace self.moves = [move.strip() for move in self.moves] # Convert the header information to a dictionary self.head_list = self.header_str.split(']')[:-1] for unit in self.head_list: l = unit.split('[') l = [i.strip() for i in l] self.header_dict.update({l[0]:l[1]}) self.size = eval(self.header_dict['SZ']) #there is a better way i think # Convert the sgf representations to Turn objects for i, v in enumerate(self.moves): if self.moves[i][0] == 'B': colour = 'black' elif self.moves[i][0] == 'W': colour = 'white' address = (self.moves[i][2].upper(), self.size - (ord(self.moves[i][3]) - 97)) self.moves[i] = Turn(colour, address, self.moves[i][5:]) else: # If this is a new game, there will be no header. So let's make one. black_player = Cli.input("Black player's name: ") white_player = Cli.input("White player's name: ") self.header_dict.update({'SZ': 19, 'PW': white_player, 'PB': black_player, 'KM': 6.5, 'GM':1})
def main(): """ Get input from either command line args or from stdin, and echo it back to stdout. """ text = "" Cli() if len(sys.argv[1:]) > 0: for arg in sys.argv[1:]: text = text + arg + ' ' print((text.rstrip())) # pylint: disable=C0325 else: try: while True: print((Cli.input())) # pylint: disable=C0325 except EOFError: pass
def main(): """ Get stdin, echo translation to stdout. """ Cli.clear() while True: words = [word.strip(".").strip().lower() for word in Cli.input().split()] if words == [":get-list"]: list_ = [w.encode("ascii") for w in list(TRANSLATE_KEY.keys())] print("\n{}".format(sorted(list_, key=str.lower))) # pylint: disable=C0325 continue output = "" for word in words: output += TRANSLATE_KEY[word] + " " print("{}.\n".format(output.encode("utf-8").capitalize().strip())) # pylint: disable=C0325