Beispiel #1
0
     [287, 12, '            str_ += str(k)\n'],
     [288, 12, "            str_ += ':'\n"],
     [289, 12, '            str_ += str(v)\n'],
     [290, 12, "            str_ += '\\n'\n"],
     [291, 0, '}\n'],
     [292, 8, "        str_ += '},\\n'\n"],
     [293, 8, "        str_ += 'last_pawn_move'\n"],
     [294, 8, "        str_ += ':'\n"],
     [295, 8, '        str_ += str(self.last_pawn_move)\n'],
     [296, 8, "        str_ += ',\\n'\n"],
     [297, 8, "        str_ += 'num_consecutive_non_pawn_moves'\n"],
     [298, 8, "        str_ += ':'\n"],
     [299, 8, '        str_ += str(self.num_consecutive_non_pawn_moves)\n'],
     [300, 8, "        str_ += ',\\n'\n"],
     [301, 8, "        str_ += 'game_status'\n"],
     [302, 8, "        str_ += ':'\n"],
     [303, 8, '        str_ += str(self.game_status)\n'],
     [304, 8, "        str_ += ',\\n'\n"],
     [305, 8, "        str_ += 'winner'\n"],
     [306, 8, "        str_ += ':'\n"],
     [307, 8, '        str_ += str(self.winner)\n'],
     [308, 8, "        str_ += ',\\n'\n"],
     [309, 8, '        return str_\n'],
     [310, 0, '}\n'],
     [311, 0, '}\n'],
     [312, 0, 'if __name__ == "__main__":\n'],
     [313, 0, '}\n'],
     [314, 4, '    pass  # TODO: implement test\n']
 ]
 print_list(get_cflc(line_data))
            [289, 12, '            str_ += str(v)\n'],
            [290, 12, "            str_ += '\\n'\n"],
            [291, 0, '}\n'],
            [292, 8, "        str_ += '},\\n'\n"],
            [293, 8, "        str_ += 'last_pawn_move'\n"],
            [294, 8, "        str_ += ':'\n"],
            [295, 8, '        str_ += str(self.last_pawn_move)\n'],
            [296, 8, "        str_ += ',\\n'\n"],
            [297, 8, "        str_ += 'num_consecutive_non_pawn_moves'\n"],
            [298, 8, "        str_ += ':'\n"],
            [299, 8, '        str_ += str(self.num_consecutive_non_pawn_moves)\n'],
            [300, 8, "        str_ += ',\\n'\n"],
            [301, 8, "        str_ += 'game_status'\n"],
            [302, 8, "        str_ += ':'\n"],
            [303, 8, '        str_ += str(self.game_status)\n'],
            [304, 8, "        str_ += ',\\n'\n"],
            [305, 8, "        str_ += 'winner'\n"],
            [306, 8, "        str_ += ':'\n"],
            [307, 8, '        str_ += str(self.winner)\n'],
            [308, 8, "        str_ += ',\\n'\n"],
            [309, 8, '        return str_\n'],
            [310, 0, '}\n'],
            [311, 0, '}\n'],
            [312, 0, 'if __name__ == "__main__":\n'],
            [313, 0, '}\n'],
            [314, 4, '    pass  # TODO: implement test\n']
        ]
    print_list(
        update_cb_indents(cflc_indexs_sorted_by_indent, cb_locations,
                          line_data))
Beispiel #3
0
         [288, 12, "            str_ += ':'\n"],
         [289, 12, '            str_ += str(v)\n'],
         [290, 12, "            str_ += '\\n'\n"],
         [291, 8, '        }\n'],
         [292, 8, "        str_ += '},\\n'\n"],
         [293, 8, "        str_ += 'last_pawn_move'\n"],
         [294, 8, "        str_ += ':'\n"],
         [295, 8, '        str_ += str(this.last_pawn_move)\n'],
         [296, 8, "        str_ += ',\\n'\n"],
         [297, 8, "        str_ += 'num_consecutive_non_pawn_moves'\n"],
         [298, 8, "        str_ += ':'\n"],
         [299, 8, '        str_ += str(this.num_consecutive_non_pawn_moves)\n'],
         [300, 8, "        str_ += ',\\n'\n"],
         [301, 8, "        str_ += 'game_status'\n"],
         [302, 8, "        str_ += ':'\n"],
         [303, 8, '        str_ += str(this.game_status)\n'],
         [304, 8, "        str_ += ',\\n'\n"],
         [305, 8, "        str_ += 'winner'\n"],
         [306, 8, "        str_ += ':'\n"],
         [307, 8, '        str_ += str(this.winner)\n'],
         [308, 8, "        str_ += ',\\n'\n"],
         [309, 8, '        return str_\n'],
         [310, 4, '    }\n'],
         [311, 0, '}\n'],
         [312, 0, 'if (__name__ == "__main__") {\n'],
         [313, 0, '}\n'],
         [314, 4, '    pass  # TODO: implement test\n'],
         [315, 1, '\n']
     ]
 print_list(refactor_tuple_decs(line_data))
Beispiel #4
0
         [(12, '            return self.rooks_moved[(8, 1)]\n')],
         [(8, "        elif color == 'B':\n")],
         [(12, '            return self.rooks_moved[(8, 8)]\n'), (1, '\n')],
         [(4, '    def __str__(self):\n')],
         [(8, '        """called when object is argument to print"""\n'), (1, '\n'), (8, '        str_ = ""\n'),
          (1, '\n'), (8, '        str_ += \'"rooks_moved": {\\n\'\n'),
          (8, '        for k, v in self.rooks_moved.items():\n')],
         [(12, '            str_ += str(k)\n'), (12, "            str_ += ':'\n"),
          (12, '            str_ += str(v)\n'), (12, "            str_ += '\\n'\n")],
         [(8, "        str_ += '},\\n'\n"), (1, '\n'), (8, '        str_ += \'"kings_moved": {\\n\'\n'),
          (8, '        for k, v in self.kings_moved.items():\n')],
         [(12, '            str_ += str(k)\n'), (12, "            str_ += ':'\n"),
          (12, '            str_ += str(v)\n'), (12, "            str_ += '\\n'\n")],
         [(8, "        str_ += '},\\n'\n"), (1, '\n'), (8, '        str_ += \'"pawn_histories": {\\n\'\n'),
          (8, '        for k, v in self.pawn_histories.items():\n')],
         [(12, '            str_ += str(k)\n'), (12, "            str_ += ':'\n"),
          (12, '            str_ += str(v)\n'), (12, "            str_ += '\\n'\n")],
         [(8, "        str_ += '},\\n'\n"), (1, '\n'), (8, "        str_ += 'last_pawn_move'\n"),
          (8, "        str_ += ':'\n"), (8, '        str_ += str(self.last_pawn_move)\n'),
          (8, "        str_ += ',\\n'\n"), (1, '\n'), (8, "        str_ += 'num_consecutive_non_pawn_moves'\n"),
          (8, "        str_ += ':'\n"), (8, '        str_ += str(self.num_consecutive_non_pawn_moves)\n'),
          (8, "        str_ += ',\\n'\n"), (1, '\n'), (8, "        str_ += 'game_status'\n"),
          (8, "        str_ += ':'\n"), (8, '        str_ += str(self.game_status)\n'),
          (8, "        str_ += ',\\n'\n"), (1, '\n'), (8, "        str_ += 'winner'\n"),
          (8, "        str_ += ':'\n"), (8, '        str_ += str(self.winner)\n'), (8, "        str_ += ',\\n'\n"),
          (1, '\n'), (8, '        return str_\n'), (1, '\n'), (1, '\n')],
         [(0, 'if __name__ == "__main__":\n')],
         [(4, '    pass  # TODO: implement test')]
     ]
 print_list(ending_curly_braces(blocks, 4), pprint_=True)
         [310, 4, '    "in", "Hamlet", "on", "the", "West", "End", "and", "won", "a", "second", \n'],
         [311, 4, '    "Olivier","Award", "In", "1993", "TV", "Guide", "named", "Stewart", "the", \n'],
         [312, 4, '    "Best", "Dramatic", "Television", "Actor", "of", "the", "1980s", "He",\n'],
         [313, 4, '    "received", "a", "star", "on", "the", "Hollywood", "Walk", "of", "Fame", "on", \n'],
         [314, 4, '    "16", "December", "1996", "In","2010", "Stewart", "was", "knighted", "by", \n'],
         [315, 4, '    "Queen", "Elizabeth", "II", "for", "services", "to", "drama", ]\n'],
         [316, 4, '    latinWords = translate(words)\n'],
         [317, 4, '    if (len(words) == len(latinWords)) {\n'],
         [318, 8, '        for (i in range(0, len(latinWords))) {\n'],
         [319, 12, '            print("English: {:>15}  Pig Latin: {:>15}".format(words[i], latinWords[i]))\n'],
         [320, 8, '        }\n'],
         [321, 4, '    }\n'],
         [322, 4, '    print("English: {:>15}  Pig Latin: {:>15}".format(\'yes\', igpay(\'yes\')))\n'],
         [323, 4, '    print("English: {:>15}  Pig Latin: {:>15}".format(\'add\', igpay(\'add\')))\n'],
         [324, 4, '    print("English: {:>15}  Pig Latin: {:>15}".format(\'office\', igpay(\'office\')))\n'],
         [325, 4, '    print("English: {:>15}  Pig Latin: {:>15}".format(\'why\', igpay(\'why\')))\n'],
         [326, 4, '    print("English: {:>15}  Pig Latin: {:>15}".format(\'The\', igpay(\'The\')))\n'],
         [327, 4, '    print("English: {:>15}  Pig Latin: {:>15}".format(\'parrot\', igpay(\'parrot\')))\n'],
         [328, 4, '    print("English: {:>15}  Pig Latin: {:>15}".format(\'knights\', igpay(\'knights\')))\n'],
         [329, 4, '    print("English: {:>15}  Pig Latin: {:>15}".format("Can\'t", igpay("Can\'t")))\n'],
         [330, 4, '    print("English: {:>15}  Pig Latin: {:>15}".format("Won\'t", igpay("Won\'t")))\n'],
         [331, 4, '    print("English: {:>15}  Pig Latin: {:>15}".format("Who?", igpay("Who?")))\n'],
         [332, 4, '    print("English: {:>15}  Pig Latin: {:>15}".format("Ni!", igpay("Ni!")))\n'],
         [333, 4, '    print("English: {:>15}  Pig Latin: {:>15}".format("Nu!", igpay("Nu!")))\n'],
         [334, 4, '    print("English: {:>15}  Pig Latin: {:>15}".format("3.14159265", igpay("3.14159265")))\n'],
         [335, 0, '}\n'],
         [336, 4, '    print("English: {:>15}  Pig Latin: {:>15}".format("", igpay("")))\n'],
         [337, 1, '\n']
     ]
 print_list(refactor_for_range(line_data))
         [310, 4, '    "in", "Hamlet", "on", "the", "West", "End", "and", "won", "a", "second", \n'],
         [311, 4, '    "Olivier","Award", "In", "1993", "TV", "Guide", "named", "Stewart", "the", \n'],
         [312, 4, '    "Best", "Dramatic", "Television", "Actor", "of", "the", "1980s", "He",\n'],
         [313, 4, '    "received", "a", "star", "on", "the", "Hollywood", "Walk", "of", "Fame", "on", \n'],
         [314, 4, '    "16", "December", "1996", "In","2010", "Stewart", "was", "knighted", "by", \n'],
         [315, 4, '    "Queen", "Elizabeth", "II", "for", "services", "to", "drama", ]\n'],
         [316, 4, '    latinWords = translate(words)\n'],
         [317, 4, '    if (len(words) == len(latinWords)) {\n'],
         [318, 8, '        for (i in range(0, len(latinWords))) {\n'],
         [319, 12, '            print("English: {:>15}  Pig Latin: {:>15}".format(words[i], latinWords[i]))\n'],
         [320, 8, '        }\n'],
         [321, 4, '    }\n'],
         [322, 4, '    print("English: {:>15}  Pig Latin: {:>15}".format(\'yes\', igpay(\'yes\')))\n'],
         [323, 4, '    print("English: {:>15}  Pig Latin: {:>15}".format(\'add\', igpay(\'add\')))\n'],
         [324, 4, '    print("English: {:>15}  Pig Latin: {:>15}".format(\'office\', igpay(\'office\')))\n'],
         [325, 4, '    print("English: {:>15}  Pig Latin: {:>15}".format(\'why\', igpay(\'why\')))\n'],
         [326, 4, '    print("English: {:>15}  Pig Latin: {:>15}".format(\'The\', igpay(\'The\')))\n'],
         [327, 4, '    print("English: {:>15}  Pig Latin: {:>15}".format(\'parrot\', igpay(\'parrot\')))\n'],
         [328, 4, '    print("English: {:>15}  Pig Latin: {:>15}".format(\'knights\', igpay(\'knights\')))\n'],
         [329, 4, '    print("English: {:>15}  Pig Latin: {:>15}".format("Can\'t", igpay("Can\'t")))\n'],
         [330, 4, '    print("English: {:>15}  Pig Latin: {:>15}".format("Won\'t", igpay("Won\'t")))\n'],
         [331, 4, '    print("English: {:>15}  Pig Latin: {:>15}".format("Who?", igpay("Who?")))\n'],
         [332, 4, '    print("English: {:>15}  Pig Latin: {:>15}".format("Ni!", igpay("Ni!")))\n'],
         [333, 4, '    print("English: {:>15}  Pig Latin: {:>15}".format("Nu!", igpay("Nu!")))\n'],
         [334, 4, '    print("English: {:>15}  Pig Latin: {:>15}".format("3.14159265", igpay("3.14159265")))\n'],
         [335, 0, '}\n'],
         [336, 4, '    print("English: {:>15}  Pig Latin: {:>15}".format("", igpay("")))\n'],
         [337, 1, '\n']
     ]
 print_list(refactor_comments(line_data))
Beispiel #7
0
         195,
         198,
         199,
         204,
         209,
         213,
         217,
         222,
         225,
         229,
         230,
         235,
         238,
         242,
         243,
         247,
         252,
         255,
         256,
         261,
         264,
         265,
         275,
         283,
         291,
         310,
         311,
         313
     ]
 print_list(cb_loc_add_check_col(cb_locations))
     [258, 12, "            str_ += '\\n'\n"],
     [259, 8, "        str_ += '},\\n'\n"],
     [260, 1, '\n'],
     [261, 8, "        str_ += 'last_pawn_move'\n"],
     [262, 8, "        str_ += ':'\n"],
     [263, 8, '        str_ += str(self.last_pawn_move)\n'],
     [264, 8, "        str_ += ',\\n'\n"],
     [265, 1, '\n'],
     [266, 8, "        str_ += 'num_consecutive_non_pawn_moves'\n"],
     [267, 8, "        str_ += ':'\n"],
     [268, 8, '        str_ += str(self.num_consecutive_non_pawn_moves)\n'],
     [269, 8, "        str_ += ',\\n'\n"],
     [270, 1, '\n'],
     [271, 8, "        str_ += 'game_status'\n"],
     [272, 8, "        str_ += ':'\n"],
     [273, 8, '        str_ += str(self.game_status)\n'],
     [274, 8, "        str_ += ',\\n'\n"],
     [275, 1, '\n'],
     [276, 8, "        str_ += 'winner'\n"],
     [277, 8, "        str_ += ':'\n"],
     [278, 8, '        str_ += str(self.winner)\n'],
     [279, 8, "        str_ += ',\\n'\n"],
     [280, 1, '\n'],
     [281, 8, '        return str_\n'],
     [282, 1, '\n'],
     [283, 1, '\n'],
     [284, 0, 'if __name__ == "__main__":\n'],
     [285, 4, '    pass  # TODO: implement test']
 ]
 print_list(get_indent_boundaries(cflc, len(line_data)))
Beispiel #9
0
         (12, "            str_ += '\\n'\n"),
         (8, "        str_ += '},\\n'\n"),
         (1, '\n'),
         (8, "        str_ += 'last_pawn_move'\n"),
         (8, "        str_ += ':'\n"),
         (8, '        str_ += str(self.last_pawn_move)\n'),
         (8, "        str_ += ',\\n'\n"),
         (1, '\n'),
         (8, "        str_ += 'num_consecutive_non_pawn_moves'\n"),
         (8, "        str_ += ':'\n"),
         (8, '        str_ += str(self.num_consecutive_non_pawn_moves)\n'),
         (8, "        str_ += ',\\n'\n"),
         (1, '\n'),
         (8, "        str_ += 'game_status'\n"),
         (8, "        str_ += ':'\n"),
         (8, '        str_ += str(self.game_status)\n'),
         (8, "        str_ += ',\\n'\n"),
         (1, '\n'),
         (8, "        str_ += 'winner'\n"),
         (8, "        str_ += ':'\n"),
         (8, '        str_ += str(self.winner)\n'),
         (8, "        str_ += ',\\n'\n"),
         (1, '\n'),
         (8, '        return str_\n'),
         (1, '\n'),
         (1, '\n'),
         (0, 'if __name__ == "__main__":\n'),
         (4, '    pass  # TODO: implement test')
     ]
 print_list(refactor_classes(line_data))
         [288, 12, "            str_ += ':'\n"],
         [289, 12, '            str_ += str(v)\n'],
         [290, 12, "            str_ += '\\n'\n"],
         [291, 8, '        }\n'],
         [292, 8, "        str_ += '},\\n'\n"],
         [293, 8, "        str_ += 'last_pawn_move'\n"],
         [294, 8, "        str_ += ':'\n"],
         [295, 8, '        str_ += str(this.last_pawn_move)\n'],
         [296, 8, "        str_ += ',\\n'\n"],
         [297, 8, "        str_ += 'num_consecutive_non_pawn_moves'\n"],
         [298, 8, "        str_ += ':'\n"],
         [299, 8, '        str_ += str(this.num_consecutive_non_pawn_moves)\n'],
         [300, 8, "        str_ += ',\\n'\n"],
         [301, 8, "        str_ += 'game_status'\n"],
         [302, 8, "        str_ += ':'\n"],
         [303, 8, '        str_ += str(this.game_status)\n'],
         [304, 8, "        str_ += ',\\n'\n"],
         [305, 8, "        str_ += 'winner'\n"],
         [306, 8, "        str_ += ':'\n"],
         [307, 8, '        str_ += str(this.winner)\n'],
         [308, 8, "        str_ += ',\\n'\n"],
         [309, 8, '        return str_\n'],
         [310, 4, '    }\n'],
         [311, 0, '}\n'],
         [312, 0, 'if (__name__ == "__main__") {\n'],
         [313, 0, '}\n'],
         [314, 4, '    pass  # TODO: implement test\n'],
         [315, 1, '\n']
     ]
 print_list(refactor_dict_methods(line_data))
Beispiel #11
0
            [287, 12, '            str_ += str(k)\n'],
            [288, 12, "            str_ += ':'\n"],
            [289, 12, '            str_ += str(v)\n'],
            [290, 12, "            str_ += '\\n'\n"],
            [291, 0, '}\n'],
            [292, 8, "        str_ += '},\\n'\n"],
            [293, 8, "        str_ += 'last_pawn_move'\n"],
            [294, 8, "        str_ += ':'\n"],
            [295, 8, '        str_ += str(self.last_pawn_move)\n'],
            [296, 8, "        str_ += ',\\n'\n"],
            [297, 8, "        str_ += 'num_consecutive_non_pawn_moves'\n"],
            [298, 8, "        str_ += ':'\n"],
            [299, 8, '        str_ += str(self.num_consecutive_non_pawn_moves)\n'],
            [300, 8, "        str_ += ',\\n'\n"],
            [301, 8, "        str_ += 'game_status'\n"],
            [302, 8, "        str_ += ':'\n"],
            [303, 8, '        str_ += str(self.game_status)\n'],
            [304, 8, "        str_ += ',\\n'\n"],
            [305, 8, "        str_ += 'winner'\n"],
            [306, 8, "        str_ += ':'\n"],
            [307, 8, '        str_ += str(self.winner)\n'],
            [308, 8, "        str_ += ',\\n'\n"],
            [309, 8, '        return str_\n'],
            [310, 0, '}\n'],
            [311, 0, '}\n'],
            [312, 0, 'if __name__ == "__main__":\n'],
            [313, 0, '}\n'],
            [314, 4, '    pass  # TODO: implement test\n']
        ]
    print_list(get_indexs_cflc(line_data))
Beispiel #12
0
         [288, 12, "            str_ += ':'\n"],
         [289, 12, '            str_ += str(v)\n'],
         [290, 12, "            str_ += '\\n'\n"],
         [291, 8, '        }\n'],
         [292, 8, "        str_ += '},\\n'\n"],
         [293, 8, "        str_ += 'last_pawn_move'\n"],
         [294, 8, "        str_ += ':'\n"],
         [295, 8, '        str_ += str(this.last_pawn_move)\n'],
         [296, 8, "        str_ += ',\\n'\n"],
         [297, 8, "        str_ += 'num_consecutive_non_pawn_moves'\n"],
         [298, 8, "        str_ += ':'\n"],
         [299, 8, '        str_ += str(this.num_consecutive_non_pawn_moves)\n'],
         [300, 8, "        str_ += ',\\n'\n"],
         [301, 8, "        str_ += 'game_status'\n"],
         [302, 8, "        str_ += ':'\n"],
         [303, 8, '        str_ += str(this.game_status)\n'],
         [304, 8, "        str_ += ',\\n'\n"],
         [305, 8, "        str_ += 'winner'\n"],
         [306, 8, "        str_ += ':'\n"],
         [307, 8, '        str_ += str(this.winner)\n'],
         [308, 8, "        str_ += ',\\n'\n"],
         [309, 8, '        return str_\n'],
         [310, 4, '    }\n'],
         [311, 0, '}\n'],
         [312, 0, 'if (__name__ == "__main__") {\n'],
         [313, 0, '}\n'],
         [314, 4, '    pass  # TODO: implement test\n'],
         [315, 1, '\n']
     ]
 print_list(refactor_for_in(line_data))
Beispiel #13
0
          (12, '            str_ += str(v)\n'),
          (12, "            str_ += '\\n'\n")],
         [(8, "        str_ += '},\\n'\n")],
         [(1, '\n')],
         [(8, '        str_ += \'"pawn_histories": {\\n\'\n'),
          (8, '        for k, v in self.pawn_histories.items():\n')],
         [(12, '            str_ += str(k)\n'), (12, "            str_ += ':'\n"),
          (12, '            str_ += str(v)\n'),
          (12, "            str_ += '\\n'\n")],
         [(8, "        str_ += '},\\n'\n")],
         [(1, '\n')],
         [(8, "        str_ += 'last_pawn_move'\n"), (8, "        str_ += ':'\n"),
          (8, '        str_ += str(self.last_pawn_move)\n'), (8, "        str_ += ',\\n'\n")],
         [(1, '\n')],
         [(8, "        str_ += 'num_consecutive_non_pawn_moves'\n"), (8, "        str_ += ':'\n"),
          (8, '        str_ += str(self.num_consecutive_non_pawn_moves)\n'), (8, "        str_ += ',\\n'\n")],
         [(1, '\n')],
         [(8, "        str_ += 'game_status'\n"), (8, "        str_ += ':'\n"),
          (8, '        str_ += str(self.game_status)\n'), (8, "        str_ += ',\\n'\n")],
         [(1, '\n')],
         [(8, "        str_ += 'winner'\n"), (8, "        str_ += ':'\n"), (8, '        str_ += str(self.winner)\n'),
          (8, "        str_ += ',\\n'\n")],
         [(1, '\n')],
         [(8, '        return str_\n')],
         [(1, '\n'), (1, '\n')],
         [(0, 'if __name__ == "__main__":\n')],
         [(4, '    pass  # TODO: implement test')]
     ]
 blocks = refactor_identifiers_by_scope(blocks)
 print_list(blocks)
Beispiel #14
0
        [187, 4, '    def update_kings_moved(self, sqr):\n'],
        [191, 4, '    def update_pawn_history(self, id_, new_loc, promo):\n'],
        [193, 8, '        if promo:\n'],
        [196, 8, '        else:\n'],
        [200, 4, '    def get_records(self, for_web=False):\n'],
        [202, 8, '        if for_web:\n'],
        [210, 4, '    def reset_non_pawn_moves(self):\n'],
        [214, 4, '    def delete_pawn(self, id):\n'],
        [218, 4, '    def has_king_moved(self, color):\n'],
        [220, 8, "        if color == 'W':\n"],
        [223, 8, "        elif color == 'B':\n"],
        [226, 8, '        else:\n'],
        [231, 4, '    def get_start_king(self, color):\n'],
        [233, 8, "        if color == 'W':\n"],
        [236, 8, "        elif color == 'B':\n"],
        [239, 8, '        else:\n'],
        [244, 4, '    def update_rook_dict(self, rooks_moved):\n'],
        [248, 4, '    def queen_side_rook_moved(self, color):\n'],
        [250, 8, "        if color == 'W':\n"],
        [253, 8, "        elif color == 'B':\n"],
        [257, 4, '    def king_side_rook_moved(self, color):\n'],
        [259, 8, "        if color == 'W':\n"],
        [262, 8, "        elif color == 'B':\n"],
        [266, 4, '    def __str__(self):\n'],
        [270, 8, '        for k, v in self.rooks_moved.items():\n'],
        [278, 8, '        for k, v in self.kings_moved.items():\n'],
        [286, 8, '        for k, v in self.pawn_histories.items():\n'],
        [312, 0, 'if __name__ == "__main__":\n']
    ]
    print_list(sort_cflc(cflc))
Beispiel #15
0
     [68, 8, '        for rf in self.rooks_moved.keys():\n'],
     [56, 8, '        for hist in self.pawn_histories.values():\n'],
     [39, 8, '        for hist in self.pawn_histories.values():\n'],
     [32, 8, '        else:\n'],
     [28, 8, '        if j_records is None:\n'],
     [17, 8, '        else:\n'],
     [10, 8, '        if j_records is None:\n'],
     [266, 4, '    def __str__(self):\n'],
     [257, 4, '    def king_side_rook_moved(self, color):\n'],
     [248, 4, '    def queen_side_rook_moved(self, color):\n'],
     [244, 4, '    def update_rook_dict(self, rooks_moved):\n'],
     [231, 4, '    def get_start_king(self, color):\n'],
     [218, 4, '    def has_king_moved(self, color):\n'],
     [214, 4, '    def delete_pawn(self, id):\n'],
     [210, 4, '    def reset_non_pawn_moves(self):\n'],
     [200, 4, '    def get_records(self, for_web=False):\n'],
     [191, 4, '    def update_pawn_history(self, id_, new_loc, promo):\n'],
     [187, 4, '    def update_kings_moved(self, sqr):\n'],
     [183, 4, '    def update_rooks_moved(self, sqr):\n'],
     [153, 4, '    def update_state(self, board, ranges, enemy_color, npck):\n'],
     [134, 4, '    def update_hist(self, id_, start, dest, promo_flag):\n'],
     [98, 4, '    def _tuple_to_rankfile(self, for_web=False):\n'],
     [62, 4, '    def _rankfile_to_tuple(self, from_web=False):\n'],
     [53, 4, '    def _init_pawn_locs(self):\n'],
     [36, 4, '    def _init_pawn_ids(self, board, file=""):\n'],
     [9, 4, '    def __init__(self, file, board, j_records=None):\n'],
     [312, 0, 'if __name__ == "__main__":\n'],
     [7, 0, 'class JsonRecords(object):\n']
 ]
 print_list(get_index_col(cflc))
Beispiel #16
0
[262, 8, "        str_ += ':'\n"] ,
[263, 8, '        str_ += str(self.last_pawn_move)\n'] ,
[264, 8, "        str_ += ',\\n'\n"] ,
[265, 1, '\n'] ,
[266, 8, "        str_ += 'num_consecutive_non_pawn_moves'\n"] ,
[267, 8, "        str_ += ':'\n"] ,
[268, 8, '        str_ += str(self.num_consecutive_non_pawn_moves)\n'] ,
[269, 8, "        str_ += ',\\n'\n"] ,
[270, 1, '\n'] ,
[271, 8, "        str_ += 'game_status'\n"] ,
[272, 8, "        str_ += ':'\n"] ,
[273, 8, '        str_ += str(self.game_status)\n'] ,
[274, 8, "        str_ += ',\\n'\n"] ,
[275, 1, '\n'] ,
[276, 8, "        str_ += 'winner'\n"] ,
[277, 8, "        str_ += ':'\n"] ,
[278, 8, '        str_ += str(self.winner)\n'] ,
[279, 8, "        str_ += ',\\n'\n"] ,
[280, 1, '\n'] ,
[281, 8, '        return str_\n'] ,
[282, 1, '\n'] ,
[283, 1, '\n'] ,
[284, 0, 'if __name__ == "__main__":\n'] ,
[285, 4, '    pass  # TODO: implement test']
]
    line_data_dict = {}
    for line in line_data:
        line_data_dict[line[0]] = line
    print_list(add_ending_brace(line_data, line_data_dict, indent_shifts))

         [287, 12, '            str_ += str(k)\n'],
         [288, 12, "            str_ += ':'\n"],
         [289, 12, '            str_ += str(v)\n'],
         [290, 12, "            str_ += '\\n'\n"],
         [291, 8, '        }\n'],
         [292, 8, "        str_ += '},\\n'\n"],
         [293, 8, "        str_ += 'last_pawn_move'\n"],
         [294, 8, "        str_ += ':'\n"],
         [295, 8, '        str_ += str(self.last_pawn_move)\n'],
         [296, 8, "        str_ += ',\\n'\n"],
         [297, 8, "        str_ += 'num_consecutive_non_pawn_moves'\n"],
         [298, 8, "        str_ += ':'\n"],
         [299, 8, '        str_ += str(self.num_consecutive_non_pawn_moves)\n'],
         [300, 8, "        str_ += ',\\n'\n"],
         [301, 8, "        str_ += 'game_status'\n"],
         [302, 8, "        str_ += ':'\n"],
         [303, 8, '        str_ += str(self.game_status)\n'],
         [304, 8, "        str_ += ',\\n'\n"],
         [305, 8, "        str_ += 'winner'\n"],
         [306, 8, "        str_ += ':'\n"],
         [307, 8, '        str_ += str(self.winner)\n'],
         [308, 8, "        str_ += ',\\n'\n"],
         [309, 8, '        return str_\n'],
         [310, 4, '    }\n'],
         [311, 0, '}\n'],
         [312, 0, 'if __name__ == "__main__":\n'],
         [313, 0, '}\n'],
         [314, 4, '    pass  # TODO: implement test\n']
     ]
 print_list(refactor_conditionals(line_data))
Beispiel #18
0
      "            str_ += '\\n'\n",
      "        str_ += '},\\n'\n",
      '        str_ += \'"pawn_histories": {\\n\'\n',
      '        for k, v in self.pawn_histories.items():\n',
      '            str_ += str(k)\n',
      "            str_ += ':'\n",
      '            str_ += str(v)\n',
      "            str_ += '\\n'\n",
      "        str_ += '},\\n'\n",
      "        str_ += 'last_pawn_move'\n",
      "        str_ += ':'\n",
      '        str_ += str(self.last_pawn_move)\n',
      "        str_ += ',\\n'\n",
      "        str_ += 'num_consecutive_non_pawn_moves'\n",
      "        str_ += ':'\n",
      '        str_ += str(self.num_consecutive_non_pawn_moves)\n',
      "        str_ += ',\\n'\n",
      "        str_ += 'game_status'\n",
      "        str_ += ':'\n",
      '        str_ += str(self.game_status)\n',
      "        str_ += ',\\n'\n",
      "        str_ += 'winner'\n",
      "        str_ += ':'\n",
      '        str_ += str(self.winner)\n',
      "        str_ += ',\\n'\n",
      '        return str_\n',
      'if __name__ == "__main__":\n',
      '    pass  # TODO: implement test\n']
 line_data, line_data_dict = get_line_data(lines)
 print_list(line_data)
Beispiel #19
0
            [217, 12, "            str_ += '\\n'\n"],
            [218, 8, "        str_ += '},\\n'\n"],
            [219, 8, '        str_ += \'"pawn_histories": {\\n\'\n'],
            [220, 8, '        for k, v in self.pawn_histories.items():\n'],
            [221, 12, '            str_ += str(k)\n'],
            [222, 12, "            str_ += ':'\n"],
            [223, 12, '            str_ += str(v)\n'],
            [224, 12, "            str_ += '\\n'\n"],
            [225, 8, "        str_ += '},\\n'\n"],
            [226, 8, "        str_ += 'last_pawn_move'\n"],
            [227, 8, "        str_ += ':'\n"],
            [228, 8, '        str_ += str(self.last_pawn_move)\n'],
            [229, 8, "        str_ += ',\\n'\n"],
            [230, 8, "        str_ += 'num_consecutive_non_pawn_moves'\n"],
            [231, 8, "        str_ += ':'\n"],
            [232, 8, '        str_ += str(self.num_consecutive_non_pawn_moves)\n'],
            [233, 8, "        str_ += ',\\n'\n"],
            [234, 8, "        str_ += 'game_status'\n"],
            [235, 8, "        str_ += ':'\n"],
            [236, 8, '        str_ += str(self.game_status)\n'],
            [237, 8, "        str_ += ',\\n'\n"],
            [238, 8, "        str_ += 'winner'\n"],
            [239, 8, "        str_ += ':'\n"],
            [240, 8, '        str_ += str(self.winner)\n'],
            [241, 8, "        str_ += ',\\n'\n"],
            [242, 8, '        return str_\n'],
            [243, 0, 'if __name__ == "__main__":\n'],
            [244, 4, '    pass  # TODO: implement test\n']
        ]
    print_list(refactor_imports(line_data))
Beispiel #20
0
        164,
        168,
        170,
        172,
        175,
        177,
        184,
        188,
        192,
        194,
        196,
        198,
        202,
        204,
        206,
        208,
        212,
        216,
        219,
        221,
        224,
        227,
        229,
        232,
        238,
        246,
        254,
        284
    ]
    print_list(get_cflc(indexs, line_data))
Beispiel #21
0
         153,
         155,
         163,
         159,
         166,
         169,
         178,
         173,
         175,
         178,
         187,
         182,
         184,
         187,
         190,
         196,
         194,
         196,
         202,
         200,
         202,
         243,
         211,
         218,
         225,
         244]
    line_data_dict = {}
    for i in range(len(line_data)):
        line_data_dict[line_data[i][0]] = line_data[i]
    print_list(add_closing_brace(cb_locations, line_data, line_data_dict))
Beispiel #22
0
            [157, 170],
            [172, 177],
            [194, 196],
            [198, 204],
            [206, 208],
            [219, 221],
            [227, 229],
            [238, 246],
            [254, 46],
            [76, 79],
            [104, 107],
            [124, 126],
            [146, 148],
            [82, 110]
        ]
    print_list(get_blocks(line_data, block_edge_pairs))

blocks =\
[
    [[11, 4, '    """contains info for new or saved game relevant to perfoming a castle or en_passant"""\n'], [12, 1, '\n'], [13, 4, '    def __init__(self, file, board, j_records=None):\n'], [14, 1, '\n'], [15, 8, '        if j_records is None:\n'], [16, 12, '            f = open(file, "r")\n'], [17, 12, '            json_data = f.read()\n'], [18, 12, '            records = json.loads(json_data)\n'], [19, 12, '            json.dumps(records, indent=4, sort_keys=False)\n'], [20, 12, '            f.close()\n'], [21, 8, '        else:\n'], [22, 12, '            records = j_records\n'], [23, 1, '\n'], [24, 8, "        self.rooks_moved = records['rooks_moved']\n"], [25, 8, "        self.kings_moved = records['kings_moved']\n"], [26, 8, "        self.pawn_histories = records['pawn_histories']\n"], [27, 8, "        self.last_pawn_move = records['last_pawn_move']\n"], [28, 8, "        self.num_consecutive_non_pawn_moves = records['num_consecutive_non_pawn_moves']\n"], [29, 8, "        self.game_status = records['game_status']\n"], [30, 8, "        self.condition = records['condition']\n"], [31, 8, "        self.winner = records['winner']\n"], [32, 1, '\n'], [33, 8, '        if j_records is None:\n'], [34, 12, '            self._init_pawn_ids(board, file=file)\n'], [35, 12, '            self._rankfile_to_tuple()\n'], [36, 8, '        else:\n'], [37, 12, '            self._rankfile_to_tuple(from_web=True)\n'], [38, 1, '\n'], [39, 4, '    def _init_pawn_ids(self, board, file=""):\n'], [40, 8, '        """exchange the sqr that pawn started the game with, with the id for that pawn"""\n'], [41, 8, '        pawn_histories = {}\n'], [42, 8, '        for hist in self.pawn_histories.values():\n'], [43, 12, '            sqr1 = hist[-1]\n'], [44, 12, '            id_ = board[sqr1]\n'], [45, 12, '            pawn_histories[id_] = hist\n'], [46, 12, "            if get_piece_type(id_) != 'Pawn':\n"], [47, 16, '                print("ERROR: Pawn history not correct")\n'], [48, 16, '                print(file)\n'], [49, 16, '                print(sqr1)\n'], [50, 16, '                print(id_)\n'], [51, 16, '                raise JsonRecordError\n'], [52, 8, '        self.pawn_histories = pawn_histories\n'], [53, 1, '\n'], [54, 4, '    def _init_pawn_locs(self):\n'], [55, 8, '        """swap the key of each pawn_history entry with the coordinate of its current location"""\n'], [56, 8, '        pawn_histories = {}\n'], [57, 8, '        for hist in self.pawn_histories.values():\n'], [58, 12, '            sqr = hist[-1]\n'], [59, 12, '            pawn_histories[sqr] = hist\n'], [60, 8, '        self.pawn_histories = pawn_histories\n'], [61, 1, '\n'], [62, 4, '    def _rankfile_to_tuple(self, from_web=False):\n'], [63, 8, '        """convert the keys and ids for each type of record from a rankfile to a tuple"""\n'], [64, 8, '        rooks_moved = {}\n'], [65, 8, '        kings_moved = {}\n'], [66, 8, '        pawn_histories = {}\n'], [67, 8, '        last_pawn_move = None\n'], [68, 1, '\n'], [69, 8, '        for rf in self.rooks_moved.keys():\n'], [70, 12, '            xy = to_xy(rf)\n'], [71, 12, '            rooks_moved[xy] = self.rooks_moved[rf]\n'], [72, 8, '        for rf in self.kings_moved.keys():\n'], [73, 12, '            xy = to_xy(rf)\n'], [74, 12, '            kings_moved[xy] = self.kings_moved[rf]\n'], [75, 8, '        if from_web:\n'], [76, 12, '            for id_ in self.pawn_histories.keys():\n'], [77, 16, '                self.pawn_histories[id_] = list(map(lambda li: to_xy(li), self.pawn_histories[id_]))\n'], [78, 8, '        else:\n'], [79, 12, '            for rf1 in self.pawn_histories.keys():\n'], [80, 16, '                xy1 = to_xy(rf1)\n'], [81, 16, '                pawn_histories[xy1] = []\n'], [82, 16, '                for rf2 in self.pawn_histories[rf1]:\n'], [83, 20, '                    xy2 = to_xy(rf2)\n'], [84, 20, '                    pawn_histories[xy1].append(xy2)\n'], [85, 8, '        self.rooks_moved = rooks_moved\n'], [86, 8, '        self.kings_moved = kings_moved\n'], [87, 8, '        self.pawn_histories = pawn_histories\n'], [88, 8, "        if self.last_pawn_move != 'None':\n"], [89, 12, '            self.last_pawn_move = to_xy(self.last_pawn_move)\n'], [90, 1, '\n'], [91, 4, '    def _tuple_to_rankfile(self, for_web=False):\n'], [92, 8, '        """convert the keys and ids for each type of record from a tuple to a rankfile"""\n'], [93, 8, '        rooks_moved = {}\n'], [94, 8, '        kings_moved = {}\n'], [95, 8, '        pawn_histories = {}\n'], [96, 8, '        self._init_pawn_locs()\n'], [97, 8, '        for xy in self.rooks_moved.keys():\n'], [98, 12, '            rf = to_rankfile(xy)\n'], [99, 12, '            rooks_moved[rf] = self.rooks_moved[xy]\n'], [100, 8, '        for xy in self.kings_moved.keys():\n'], [101, 12, '            rf = to_rankfile(xy)\n'], [102, 12, '            kings_moved[rf] = self.kings_moved[xy]\n'], [103, 8, '        if for_web:\n'], [104, 12, '            for id_ in self.pawn_histories.keys():\n'], [105, 16, '                self.pawn_histories[id_] = list(map(lambda li: to_rankfile(li), self.pawn_histories[id_]))\n'], [106, 8, '        else:\n'], [107, 12, '            for xy1 in self.pawn_histories.keys():\n'], [108, 16, '                rf1 = to_rankfile(xy1)\n'], [109, 16, '                pawn_histories[rf1] = []\n'], [110, 16, '                for xy2 in self.pawn_histories[xy1]:\n'], [111, 20, '                    rf2 = to_rankfile(xy2)\n'], [112, 20, '                    pawn_histories[rf1].append(rf2)\n'], [113, 8, '        self.rooks_moved = rooks_moved\n'], [114, 8, '        self.kings_moved = kings_moved\n'], [115, 8, '        self.pawn_histories = pawn_histories\n'], [116, 8, "        if self.last_pawn_move != 'None':\n"], [117, 12, '            self.last_pawn_move = to_rankfile(self.last_pawn_move)\n'], [118, 1, '\n'], [119, 4, '    def update_hist(self, id_, start, dest, promo_flag):\n'], [120, 8, '        """update json records depending on the piece type of id_ at location start"""\n'], [121, 8, '        p_type = get_piece_type(id_)\n'], [122, 8, '        if p_type != "Pawn":\n'], [123, 12, '            self.num_consecutive_non_pawn_moves += 1\n'], [124, 12, "            if p_type == 'Rook' and start in self.rooks_moved.keys():\n"], [125, 16, '                self.update_rooks_moved(start)\n'], [126, 12, "            elif p_type == 'King' and start in self.kings_moved.keys():\n"], [127, 16, '                self.update_kings_moved(start)\n'], [128, 8, '        else:\n'], [129, 12, '            self.reset_non_pawn_moves()\n'], [130, 12, '            self.last_pawn_move = dest\n'], [131, 12, '            self.update_pawn_history(id_, dest, promo_flag)\n'], [132, 8, '        return\n'], [133, 1, '\n'], [134, 4, '    def update_state(self, board, ranges, enemy_color, npck):\n'], [135, 8, '        """\n'], [136, 9, '         update the status of the game: OVER or IN_PROGRESS\n'], [137, 9, "         update the winner of the game: 'w', 'b', or '-' (neither)\n"], [138, 9, "         udpate the condition of the enemy king: 'check', 'checkmate', 'stalemate', or 'safe'\n"], [139, 9, '         :param board: dict, game board\n'], [140, 9, '         :param npck: int, number of pieces checking the king\n'], [141, 9, '         :param ranges: dict, ranges of pieces of color\n'], [142, 9, '         :param enemy_color: str, color of king\n'], [143, 8, '        """\n'], [144, 1, '\n'], [145, 8, '        if not any(ranges.values()):\n'], [146, 12, '            if npck > 0:\n'], [147, 16, "                self.condition, self.game_status, self.winner = 'checkmate', OVER, enemy_color\n"], [148, 12, '            else:\n'], [149, 16, "                self.condition, self.game_status, self.winner = 'stalemate', OVER, '-'\n"], [150, 12, '            return\n'], [151, 1, '\n'], [152, 8, '        piece_types = get_piece_types(board)\n'], [153, 8, "        if piece_types in [['King', 'King'], ['Bishop', 'King', 'King'], ['King', 'King', 'Knight']]:\n"], [154, 12, "            self.condition, self.game_status, self.winner = 'stalemate', OVER, '-'\n"], [155, 8, '        elif npck > 0:\n'], [156, 12, "            self.condition, self.game_status, self.winner = 'check', IN_PROGRESS, '-'\n"], [157, 8, '        else:\n'], [158, 12, "            self.condition, self.game_status, self.winner = '', IN_PROGRESS, '-'\n"], [159, 1, '\n'], [160, 4, '    def update_rooks_moved(self, sqr):\n'], [161, 8, '        """update rooks_moved because rook that start game at sqr has moved"""\n'], [162, 8, '        self.rooks_moved[sqr] = True\n'], [163, 1, '\n'], [164, 4, '    def update_kings_moved(self, sqr):\n'], [165, 8, '        """update kings_moved because king that started game at sqr has moved"""\n'], [166, 8, '        self.kings_moved[sqr] = True\n'], [167, 1, '\n'], [168, 4, '    def update_pawn_history(self, id_, new_loc, promo):\n'], [169, 8, '        """update location of pawn by appending its new location to its history"""\n'], [170, 8, '        if promo:\n'], [171, 12, '            del self.pawn_histories[id_]\n'], [172, 8, '        else:\n'], [173, 12, '            self.pawn_histories[id_].append(new_loc)\n'], [174, 1, '\n'], [175, 4, '    def get_records(self, for_web=False):\n'], [176, 8, '        """return the json records as one python dict"""\n'], [177, 8, '        if for_web:\n'], [178, 12, '            self._tuple_to_rankfile(for_web=True)\n'], [179, 8, "        return {'rooks_moved': self.rooks_moved, 'kings_moved': self.kings_moved,\n"], [180, 16, "                'pawn_histories': self.pawn_histories, 'last_pawn_move': self.last_pawn_move,\n"], [181, 16, "                'num_consecutive_non_pawn_moves': self.num_consecutive_non_pawn_moves,\n"], [182, 16, "                'game_status': self.game_status, 'condition': self.condition, 'winner': self.winner}\n"], [183, 1, '\n'], [184, 4, '    def reset_non_pawn_moves(self):\n'], [185, 8, '        """ a pawn has just moved, so reset number of consecutive non pawn moves to 0"""\n'], [186, 8, '        self.num_consecutive_non_pawn_moves = 0\n'], [187, 1, '\n'], [188, 4, '    def delete_pawn(self, id):\n'], [189, 8, '        """delete pawn with id from pawn histories"""\n'], [190, 8, '        del self.pawn_histories[id]\n'], [191, 1, '\n'], [192, 4, '    def has_king_moved(self, color):\n'], [193, 8, '        """return true/false of if the King of color has moved from its starting position"""\n'], [194, 8, "        if color == 'W':\n"], [195, 12, '            return self.kings_moved[(5, 1)]\n'], [196, 8, "        elif color == 'B':\n"], [197, 12, '            return self.kings_moved[(5, 8)]\n'], [198, 8, '        else:\n'], [199, 12, "            print('error: not a valid color\\n')\n"], [200, 12, '            return -1\n'], [201, 1, '\n'], [202, 4, '    def get_start_king(self, color):\n'], [203, 8, '        """get starting position of king based off of color"""\n'], [204, 8, "        if color == 'W':\n"], [205, 12, '            return (5, 1)\n'], [206, 8, "        elif color == 'B':\n"], [207, 12, '            return (5, 8)\n'], [208, 8, '        else:\n'], [209, 12, "            print('error:invalid color')\n"], [210, 12, '            return -1\n'], [211, 1, '\n'], [212, 4, '    def update_rook_dict(self, rooks_moved):\n'], [213, 8, '        """update rooks_moved dict to a new one"""\n'], [214, 8, '        self.rooks_moved = rooks_moved\n'], [215, 1, '\n'], [216, 4, '    def queen_side_rook_moved(self, color):\n'], [217, 8, '        """return true if the queen side rook of the given color has moved, otherwise false"""\n'], [218, 1, '\n'], [219, 8, "        if color == 'W':\n"], [220, 12, '            return self.rooks_moved[(1, 1)]\n'], [221, 8, "        elif color == 'B':\n"], [222, 12, '            return self.rooks_moved[(1, 8)]\n'], [223, 1, '\n'], [224, 4, '    def king_side_rook_moved(self, color):\n'], [225, 8, '        """return true if the king side rook of the given color has moved, otherwise false"""\n'], [226, 1, '\n'], [227, 8, "        if color == 'W':\n"], [228, 12, '            return self.rooks_moved[(8, 1)]\n'], [229, 8, "        elif color == 'B':\n"], [230, 12, '            return self.rooks_moved[(8, 8)]\n'], [231, 1, '\n'], [232, 4, '    def __str__(self):\n'], [233, 8, '        """called when object is argument to print"""\n'], [234, 1, '\n'], [235, 8, '        str_ = ""\n'], [236, 1, '\n'], [237, 8, '        str_ += \'"rooks_moved": {\\n\'\n'], [238, 8, '        for k, v in self.rooks_moved.items():\n'], [239, 12, '            str_ += str(k)\n'], [240, 12, "            str_ += ':'\n"], [241, 12, '            str_ += str(v)\n'], [242, 12, "            str_ += '\\n'\n"], [243, 8, "        str_ += '},\\n'\n"], [244, 1, '\n'], [245, 8, '        str_ += \'"kings_moved": {\\n\'\n'], [246, 8, '        for k, v in self.kings_moved.items():\n'], [247, 12, '            str_ += str(k)\n'], [248, 12, "            str_ += ':'\n"], [249, 12, '            str_ += str(v)\n'], [250, 12, "            str_ += '\\n'\n"], [251, 8, "        str_ += '},\\n'\n"], [252, 1, '\n'], [253, 8, '        str_ += \'"pawn_histories": {\\n\'\n'], [254, 8, '        for k, v in self.pawn_histories.items():\n'], [255, 12, '            str_ += str(k)\n'], [256, 12, "            str_ += ':'\n"], [257, 12, '            str_ += str(v)\n'], [258, 12, "            str_ += '\\n'\n"], [259, 8, "        str_ += '},\\n'\n"], [260, 1, '\n'], [261, 8, "        str_ += 'last_pawn_move'\n"], [262, 8, "        str_ += ':'\n"], [263, 8, '        str_ += str(self.last_pawn_move)\n'], [264, 8, "        str_ += ',\\n'\n"], [265, 1, '\n'], [266, 8, "        str_ += 'num_consecutive_non_pawn_moves'\n"], [267, 8, "        str_ += ':'\n"], [268, 8, '        str_ += str(self.num_consecutive_non_pawn_moves)\n'], [269, 8, "        str_ += ',\\n'\n"], [270, 1, '\n'], [271, 8, "        str_ += 'game_status'\n"], [272, 8, "        str_ += ':'\n"], [273, 8, '        str_ += str(self.game_status)\n'], [274, 8, "        str_ += ',\\n'\n"], [275, 1, '\n'], [276, 8, "        str_ += 'winner'\n"], [277, 8, "        str_ += ':'\n"], [278, 8, '        str_ += str(self.winner)\n'], [279, 8, "        str_ += ',\\n'\n"], [280, 1, '\n'], [281, 8, '        return str_\n'], [282, 1, '\n'], [283, 1, '\n']] ,
    [[14, 1, '\n'], [15, 8, '        if j_records is None:\n'], [16, 12, '            f = open(file, "r")\n'], [17, 12, '            json_data = f.read()\n'], [18, 12, '            records = json.loads(json_data)\n'], [19, 12, '            json.dumps(records, indent=4, sort_keys=False)\n'], [20, 12, '            f.close()\n'], [21, 8, '        else:\n'], [22, 12, '            records = j_records\n'], [23, 1, '\n'], [24, 8, "        self.rooks_moved = records['rooks_moved']\n"], [25, 8, "        self.kings_moved = records['kings_moved']\n"], [26, 8, "        self.pawn_histories = records['pawn_histories']\n"], [27, 8, "        self.last_pawn_move = records['last_pawn_move']\n"], [28, 8, "        self.num_consecutive_non_pawn_moves = records['num_consecutive_non_pawn_moves']\n"], [29, 8, "        self.game_status = records['game_status']\n"], [30, 8, "        self.condition = records['condition']\n"], [31, 8, "        self.winner = records['winner']\n"], [32, 1, '\n'], [33, 8, '        if j_records is None:\n'], [34, 12, '            self._init_pawn_ids(board, file=file)\n'], [35, 12, '            self._rankfile_to_tuple()\n'], [36, 8, '        else:\n'], [37, 12, '            self._rankfile_to_tuple(from_web=True)\n'], [38, 1, '\n']] ,
    [[55, 8, '        """swap the key of each pawn_history entry with the coordinate of its current location"""\n'], [56, 8, '        pawn_histories = {}\n'], [57, 8, '        for hist in self.pawn_histories.values():\n'], [58, 12, '            sqr = hist[-1]\n'], [59, 12, '            pawn_histories[sqr] = hist\n'], [60, 8, '        self.pawn_histories = pawn_histories\n'], [61, 1, '\n']] ,
    [[92, 8, '        """convert the keys and ids for each type of record from a tuple to a rankfile"""\n'], [93, 8, '        rooks_moved = {}\n'], [94, 8, '        kings_moved = {}\n'], [95, 8, '        pawn_histories = {}\n'], [96, 8, '        self._init_pawn_locs()\n'], [97, 8, '        for xy in self.rooks_moved.keys():\n'], [98, 12, '            rf = to_rankfile(xy)\n'], [99, 12, '            rooks_moved[rf] = self.rooks_moved[xy]\n'], [100, 8, '        for xy in self.kings_moved.keys():\n'], [101, 12, '            rf = to_rankfile(xy)\n'], [102, 12, '            kings_moved[rf] = self.kings_moved[xy]\n'], [103, 8, '        if for_web:\n'], [104, 12, '            for id_ in self.pawn_histories.keys():\n'], [105, 16, '                self.pawn_histories[id_] = list(map(lambda li: to_rankfile(li), self.pawn_histories[id_]))\n'], [106, 8, '        else:\n'], [107, 12, '            for xy1 in self.pawn_histories.keys():\n'], [108, 16, '                rf1 = to_rankfile(xy1)\n'], [109, 16, '                pawn_histories[rf1] = []\n'], [110, 16, '                for xy2 in self.pawn_histories[xy1]:\n'], [111, 20, '                    rf2 = to_rankfile(xy2)\n'], [112, 20, '                    pawn_histories[rf1].append(rf2)\n'], [113, 8, '        self.rooks_moved = rooks_moved\n'], [114, 8, '        self.kings_moved = kings_moved\n'], [115, 8, '        self.pawn_histories = pawn_histories\n'], [116, 8, "        if self.last_pawn_move != 'None':\n"], [117, 12, '            self.last_pawn_move = to_rankfile(self.last_pawn_move)\n'], [118, 1, '\n']] ,
    [[135, 8, '        """\n'], [136, 9, '         update the status of the game: OVER or IN_PROGRESS\n'], [137, 9, "         update the winner of the game: 'w', 'b', or '-' (neither)\n"], [138, 9, "         udpate the condition of the enemy king: 'check', 'checkmate', 'stalemate', or 'safe'\n"], [139, 9, '         :param board: dict, game board\n'], [140, 9, '         :param npck: int, number of pieces checking the king\n'], [141, 9, '         :param ranges: dict, ranges of pieces of color\n'], [142, 9, '         :param enemy_color: str, color of king\n'], [143, 8, '        """\n'], [144, 1, '\n'], [145, 8, '        if not any(ranges.values()):\n'], [146, 12, '            if npck > 0:\n'], [147, 16, "                self.condition, self.game_status, self.winner = 'checkmate', OVER, enemy_color\n"], [148, 12, '            else:\n'], [149, 16, "                self.condition, self.game_status, self.winner = 'stalemate', OVER, '-'\n"], [150, 12, '            return\n'], [151, 1, '\n'], [152, 8, '        piece_types = get_piece_types(board)\n'], [153, 8, "        if piece_types in [['King', 'King'], ['Bishop', 'King', 'King'], ['King', 'King', 'Knight']]:\n"], [154, 12, "            self.condition, self.game_status, self.winner = 'stalemate', OVER, '-'\n"], [155, 8, '        elif npck > 0:\n'], [156, 12, "            self.condition, self.game_status, self.winner = 'check', IN_PROGRESS, '-'\n"], [157, 8, '        else:\n'], [158, 12, "            self.condition, self.game_status, self.winner = '', IN_PROGRESS, '-'\n"], [159, 1, '\n']] ,
    [[165, 8, '        """update kings_moved because king that started game at sqr has moved"""\n'], [166, 8, '        self.kings_moved[sqr] = True\n'], [167, 1, '\n']] ,
    [[176, 8, '        """return the json records as one python dict"""\n'], [177, 8, '        if for_web:\n'], [178, 12, '            self._tuple_to_rankfile(for_web=True)\n'], [179, 8, "        return {'rooks_moved': self.rooks_moved, 'kings_moved': self.kings_moved,\n"], [180, 16, "                'pawn_histories': self.pawn_histories, 'last_pawn_move': self.last_pawn_move,\n"], [181, 16, "                'num_consecutive_non_pawn_moves': self.num_consecutive_non_pawn_moves,\n"], [182, 16, "                'game_status': self.game_status, 'condition': self.condition, 'winner': self.winner}\n"], [183, 1, '\n']] ,
    [[189, 8, '        """delete pawn with id from pawn histories"""\n'], [190, 8, '        del self.pawn_histories[id]\n'], [191, 1, '\n']] ,
    [[203, 8, '        """get starting position of king based off of color"""\n'], [204, 8, "        if color == 'W':\n"], [205, 12, '            return (5, 1)\n'], [206, 8, "        elif color == 'B':\n"], [207, 12, '            return (5, 8)\n'], [208, 8, '        else:\n'], [209, 12, "            print('error:invalid color')\n"], [210, 12, '            return -1\n'], [211, 1, '\n']] ,
    [[217, 8, '        """return true if the queen side rook of the given color has moved, otherwise false"""\n'], [218, 1, '\n'], [219, 8, "        if color == 'W':\n"], [220, 12, '            return self.rooks_moved[(1, 1)]\n'], [221, 8, "        elif color == 'B':\n"], [222, 12, '            return self.rooks_moved[(1, 8)]\n'], [223, 1, '\n']] ,
    [] ,
    [[22, 12, '            records = j_records\n'], [23, 1, '\n'], [24, 8, "        self.rooks_moved = records['rooks_moved']\n"], [25, 8, "        self.kings_moved = records['kings_moved']\n"], [26, 8, "        self.pawn_histories = records['pawn_histories']\n"], [27, 8, "        self.last_pawn_move = records['last_pawn_move']\n"], [28, 8, "        self.num_consecutive_non_pawn_moves = records['num_consecutive_non_pawn_moves']\n"], [29, 8, "        self.game_status = records['game_status']\n"], [30, 8, "        self.condition = records['condition']\n"], [31, 8, "        self.winner = records['winner']\n"], [32, 1, '\n']] ,
         [288, 12, "            str_ += ':'\n"],
         [289, 12, '            str_ += str(v)\n'],
         [290, 12, "            str_ += '\\n'\n"],
         [291, 8, '        }\n'],
         [292, 8, "        str_ += '},\\n'\n"],
         [293, 8, "        str_ += 'last_pawn_move'\n"],
         [294, 8, "        str_ += ':'\n"],
         [295, 8, '        str_ += str(this.last_pawn_move)\n'],
         [296, 8, "        str_ += ',\\n'\n"],
         [297, 8, "        str_ += 'num_consecutive_non_pawn_moves'\n"],
         [298, 8, "        str_ += ':'\n"],
         [299, 8, '        str_ += str(this.num_consecutive_non_pawn_moves)\n'],
         [300, 8, "        str_ += ',\\n'\n"],
         [301, 8, "        str_ += 'game_status'\n"],
         [302, 8, "        str_ += ':'\n"],
         [303, 8, '        str_ += str(this.game_status)\n'],
         [304, 8, "        str_ += ',\\n'\n"],
         [305, 8, "        str_ += 'winner'\n"],
         [306, 8, "        str_ += ':'\n"],
         [307, 8, '        str_ += str(this.winner)\n'],
         [308, 8, "        str_ += ',\\n'\n"],
         [309, 8, '        return str_\n'],
         [310, 4, '    }\n'],
         [311, 0, '}\n'],
         [312, 0, 'if (__name__ == "__main__") {\n'],
         [313, 0, '}\n'],
         [314, 4, '    pass  # TODO: implement test\n'],
         [315, 1, '\n']
     ]
 print_list(refactor_in_operator(line_data))