(self, g)
Load program from ascii, bytecode or protected stream.
Load program from ascii, bytecode or protected stream.
Load program from ascii bytecode or protected stream .
def load(self, g):
        """Load program from ascii, bytecode or protected stream."""
        self.erase()
        if g.filetype == b'B':
            # bytecode file
            self.bytecode.seek(1)
            self.bytecode.write(g.read())
        elif g.filetype == b'P':
            # protected file
            self.bytecode.seek(1)
            self.protected = self.allow_protect
            converter.unprotect(g, self.bytecode)
        elif g.filetype == b'A':
            # assume ASCII file
            # erase() only writes the terminator
            # so we need to get rid of the old code which is still in memory
            # or it'll end up after the new code in memory
            self.bytecode.truncate()
            # anything but numbers or whitespace: Direct Statement in File
            self.merge(g)
        else:
            logging.debug('Incorrect file type `%s` on LOAD', g.filetype)
        # rebuild line number dict and offsets
        if g.filetype != b'A':
            self.rebuild_line_dict()
        self.code_size = self.bytecode.tell()
def load ( self , g ) : self . erase ( ) if g . filetype == b'B' : # bytecode file self . bytecode . seek ( 1 ) self . bytecode . write ( g . read ( ) ) elif g . filetype == b'P' : # protected file self . bytecode . seek ( 1 ) self . protected = self . allow_protect converter . unprotect ( g , self . bytecode ) elif g . filetype == b'A' : # assume ASCII file # erase() only writes the terminator # so we need to get rid of the old code which is still in memory # or it'll end up after the new code in memory self . bytecode . truncate ( ) # anything but numbers or whitespace: Direct Statement in File self . merge ( g ) else : logging . debug ( 'Incorrect file type `%s` on LOAD' , g . filetype ) # rebuild line number dict and offsets if g . filetype != b'A' : self . rebuild_line_dict ( ) self . code_size = self . bytecode . tell ( )