(self, g)
Save the program to stream g in (A)scii, (B)ytecode or (P)rotected mode.
Save the program to stream g in (A)scii, (B)ytecode or (P)rotected mode.
Save the program to stream g in ( A ) scii ( B ) ytecode or ( P ) rotected mode .
def save(self, g):
        """Save the program to stream g in (A)scii, (B)ytecode or (P)rotected mode."""
        mode = g.filetype
        if self.protected and mode != b'P':
            raise error.BASICError(error.IFC)
        current = self.bytecode.tell()
        # skip first \x00 in bytecode
        self.bytecode.seek(1)
        if mode == b'B':
            # binary bytecode mode
            g.write(self.bytecode.read())
        elif mode == b'P':
            # protected mode
            converter.protect(self.bytecode, g)
        else:
            # ascii mode
            while True:
                current_line, output, _ = self.lister.detokenise_line(self.bytecode)
                if current_line == -1 or (current_line > self.max_list_line):
                    break
                g.write_line(bytes(output))
        self.bytecode.seek(current)
def save ( self , g ) : mode = g . filetype if self . protected and mode != b'P' : raise error . BASICError ( error . IFC ) current = self . bytecode . tell ( ) # skip first \x00 in bytecode self . bytecode . seek ( 1 ) if mode == b'B' : # binary bytecode mode g . write ( self . bytecode . read ( ) ) elif mode == b'P' : # protected mode converter . protect ( self . bytecode , g ) else : # ascii mode while True : current_line , output , _ = self . lister . detokenise_line ( self . bytecode ) if current_line == - 1 or ( current_line > self . max_list_line ) : break g . write_line ( bytes ( output ) ) self . bytecode . seek ( current )