def rewrite(self, block_address, new_bytes):
        """
        Rewrites block with new bytes, keeping the old ones if None is passed. Tag and auth must be set - does auth.
        Returns error state.
        """
        if not self.is_tag_set_auth():
            return True

        error = self.do_auth(block_address)
        if not error:
            (error, data) = self.rfid.read(block_address)
            if not error:
                for i in range(len(new_bytes)):
                    if new_bytes[i] != None:
                        if self.debug:
                            print("Changing pos " + str(i) + " with current value " + str(data[i]) + " to " + str(new_bytes[i]))

                        data[i] = new_bytes[i]

                error = self.rfid.write(block_address, data)
                if self.debug:
                    print("Writing " + str(data) + " to " + self.sector_string(block_address))

        return error
def rewrite ( self , block_address , new_bytes ) : if not self . is_tag_set_auth ( ) : return True error = self . do_auth ( block_address ) if not error : ( error , data ) = self . rfid . read ( block_address ) if not error : for i in range ( len ( new_bytes ) ) : if new_bytes [ i ] != None : if self . debug : print ( "Changing pos " + str ( i ) + " with current value " + str ( data [ i ] ) + " to " + str ( new_bytes [ i ] ) ) data [ i ] = new_bytes [ i ] error = self . rfid . write ( block_address , data ) if self . debug : print ( "Writing " + str ( data ) + " to " + self . sector_string ( block_address ) ) return error
Rewrites block with new bytes, keeping the old ones if None is passed. Tag and auth must be set - does auth.
        Returns error state.