pgn_read/core/game.py
def append_pawn_move(self, match):
        """Delegate lower case match to superclass."""

        # self._state is None and self._bishop_or_bpawn will have been set
        # by self.append_other_or_disambiguation_pgn().
        assert self._state is None
        if self._bishop_or_bpawn:
            bishop = text_format.match(
                self._bishop_or_bpawn.group().upper()+match.group().lower())
            if bishop:
                super(GameTextPGN, self).append_piece_move(bishop)
                self._bishop_or_bpawn = None
                return
            self.append_token_and_set_error()
            return

        mgl = match.group().lower()

        # So the test on self._piece_placement_data gives a helpful answer.
        # Cannot wait till it's done in 'super().append_pawn_move(pgn_match)'.
        if self._movetext_offset is None:
            if not self.set_initial_position():
                self.append_token_and_set_error(match)
                self._bishop_or_bpawn = None
                return
            self._ravstack.append([0])
            self._movetext_offset = len(self._text)

        if PGN_CAPTURE_MOVE in mgl:
            if mgl.startswith(FEN_BLACK_BISHOP):
                self._append_bishop_or_bpawn_capture(match)
                return
            pgn_match = text_format.match(mgl[0]+mgl[-3:])
        elif LAN_MOVE_SEPARATOR in mgl:
            if mgl.startswith(FEN_BLACK_BISHOP):
                self._append_bishop_or_bpawn_move(match)
                return
            for sr, dr, es in ('243', '756'):
                if mgl[1] == sr and mgl[4] == dr:
                    if mgl[0] != mgl[3]:
                        self.append_token_and_set_error(match)
                        self._bishop_or_bpawn = None
                        return
                    if mgl[0] + es in self._piece_placement_data:
                        self.append_token_and_set_error(match)
                        self._bishop_or_bpawn = None
                        return
            pgn_match = text_format.match(mgl[-2:])
        elif mgl not in self._piece_placement_data:
            pgn_match = text_format.match(mgl)
        elif self._full_disambiguation_detected:
            del self._full_disambiguation_detected
            self._bishop_or_bpawn = None
            return
        else:
            self._long_algebraic_notation_pawn_move(text_format.match(mgl))
            if self._state is not None:
                piece = self._piece_placement_data[mgl]
                if self._active_color == piece.color:
                    if self._active_color == FEN_WHITE_ACTIVE:
                        if piece.name == FEN_WHITE_PAWN:
                            self._full_disambiguation_detected = True
                    elif self._active_color == FEN_BLACK_ACTIVE:
                        if piece.name == FEN_BLACK_PAWN:
                            self._full_disambiguation_detected = True
                self._bishop_or_bpawn = possible_bishop_or_bpawn.match(
                    match.group())
                if self._full_disambiguation_detected and self._bishop_or_bpawn:
                    del self._full_disambiguation_detected
            else:
                self._bishop_or_bpawn = None
            return
        if pgn_match is None:
            self.append_token_and_set_error(match)
            self._bishop_or_bpawn = None
            return
        super(GameTextPGN, self).append_pawn_move(pgn_match)
        if self._state is None:
            self._bishop_or_bpawn = None
            return

        # self._state is not None so self.append_token_after_error() will
        # process next token.
        assert self._state is not None
        self._bishop_or_bpawn = possible_bishop_or_bpawn.match(match.group())
Delegate lower case match to superclass.
Delegate lower case match to superclass.
Delegate lower case match to superclass .
def append_pawn_move(self, match):
        assert self._state is None
        if self._bishop_or_bpawn:
            bishop = text_format.match(
                self._bishop_or_bpawn.group().upper()+match.group().lower())
            if bishop:
                super(GameTextPGN, self).append_piece_move(bishop)
                self._bishop_or_bpawn = None
                return
            self.append_token_and_set_error()
            return
        mgl = match.group().lower()
        if self._movetext_offset is None:
            if not self.set_initial_position():
                self.append_token_and_set_error(match)
                self._bishop_or_bpawn = None
                return
            self._ravstack.append([0])
            self._movetext_offset = len(self._text)
        if PGN_CAPTURE_MOVE in mgl:
            if mgl.startswith(FEN_BLACK_BISHOP):
                self._append_bishop_or_bpawn_capture(match)
                return
            pgn_match = text_format.match(mgl[0]+mgl[-3:])
        elif LAN_MOVE_SEPARATOR in mgl:
            if mgl.startswith(FEN_BLACK_BISHOP):
                self._append_bishop_or_bpawn_move(match)
                return
            for sr, dr, es in ('243', '756'):
                if mgl[1] == sr and mgl[4] == dr:
                    if mgl[0] != mgl[3]:
                        self.append_token_and_set_error(match)
                        self._bishop_or_bpawn = None
                        return
                    if mgl[0] + es in self._piece_placement_data:
                        self.append_token_and_set_error(match)
                        self._bishop_or_bpawn = None
                        return
            pgn_match = text_format.match(mgl[-2:])
        elif mgl not in self._piece_placement_data:
            pgn_match = text_format.match(mgl)
        elif self._full_disambiguation_detected:
            del self._full_disambiguation_detected
            self._bishop_or_bpawn = None
            return
        else:
            self._long_algebraic_notation_pawn_move(text_format.match(mgl))
            if self._state is not None:
                piece = self._piece_placement_data[mgl]
                if self._active_color == piece.color:
                    if self._active_color == FEN_WHITE_ACTIVE:
                        if piece.name == FEN_WHITE_PAWN:
                            self._full_disambiguation_detected = True
                    elif self._active_color == FEN_BLACK_ACTIVE:
                        if piece.name == FEN_BLACK_PAWN:
                            self._full_disambiguation_detected = True
                self._bishop_or_bpawn = possible_bishop_or_bpawn.match(
                    match.group())
                if self._full_disambiguation_detected and self._bishop_or_bpawn:
                    del self._full_disambiguation_detected
            else:
                self._bishop_or_bpawn = None
            return
        if pgn_match is None:
            self.append_token_and_set_error(match)
            self._bishop_or_bpawn = None
            return
        super(GameTextPGN, self).append_pawn_move(pgn_match)
        if self._state is None:
            self._bishop_or_bpawn = None
            return
        assert self._state is not None
        self._bishop_or_bpawn = possible_bishop_or_bpawn.match(match.group())
def append_pawn_move ( self , match ) : assert self . _state is None if self . _bishop_or_bpawn : bishop = text_format . match ( self . _bishop_or_bpawn . group ( ) . upper ( ) + match . group ( ) . lower ( ) ) if bishop : super ( GameTextPGN , self ) . append_piece_move ( bishop ) self . _bishop_or_bpawn = None return self . append_token_and_set_error ( ) return mgl = match . group ( ) . lower ( ) if self . _movetext_offset is None : if not self . set_initial_position ( ) : self . append_token_and_set_error ( match ) self . _bishop_or_bpawn = None return self . _ravstack . append ( [ 0 ] ) self . _movetext_offset = len ( self . _text ) if PGN_CAPTURE_MOVE in mgl : if mgl . startswith ( FEN_BLACK_BISHOP ) : self . _append_bishop_or_bpawn_capture ( match ) return pgn_match = text_format . match ( mgl [ 0 ] + mgl [ - 3 : ] ) elif LAN_MOVE_SEPARATOR in mgl : if mgl . startswith ( FEN_BLACK_BISHOP ) : self . _append_bishop_or_bpawn_move ( match ) return for sr , dr , es in ( '243' , '756' ) : if mgl [ 1 ] == sr and mgl [ 4 ] == dr : if mgl [ 0 ] != mgl [ 3 ] : self . append_token_and_set_error ( match ) self . _bishop_or_bpawn = None return if mgl [ 0 ] + es in self . _piece_placement_data : self . append_token_and_set_error ( match ) self . _bishop_or_bpawn = None return pgn_match = text_format . match ( mgl [ - 2 : ] ) elif mgl not in self . _piece_placement_data : pgn_match = text_format . match ( mgl ) elif self . _full_disambiguation_detected : del self . _full_disambiguation_detected self . _bishop_or_bpawn = None return else : self . _long_algebraic_notation_pawn_move ( text_format . match ( mgl ) ) if self . _state is not None : piece = self . _piece_placement_data [ mgl ] if self . _active_color == piece . color : if self . _active_color == FEN_WHITE_ACTIVE : if piece . name == FEN_WHITE_PAWN : self . _full_disambiguation_detected = True elif self . _active_color == FEN_BLACK_ACTIVE : if piece . name == FEN_BLACK_PAWN : self . _full_disambiguation_detected = True self . _bishop_or_bpawn = possible_bishop_or_bpawn . match ( match . group ( ) ) if self . _full_disambiguation_detected and self . _bishop_or_bpawn : del self . _full_disambiguation_detected else : self . _bishop_or_bpawn = None return if pgn_match is None : self . append_token_and_set_error ( match ) self . _bishop_or_bpawn = None return super ( GameTextPGN , self ) . append_pawn_move ( pgn_match ) if self . _state is None : self . _bishop_or_bpawn = None return assert self . _state is not None self . _bishop_or_bpawn = possible_bishop_or_bpawn . match ( match . group ( ) )
Delegate lower case match to superclass.
Delegate lower case match to superclass .
"""Delegate lower case match to superclass.""" # self._state is None and self._bishop_or_bpawn will have been set # by self.append_other_or_disambiguation_pgn(). # So the test on self._piece_placement_data gives a helpful answer. # Cannot wait till it's done in 'super().append_pawn_move(pgn_match)'. # self._state is not None so self.append_token_after_error() will # process next token.
self
match