(self, ins, bytepos=None)
return output[:255], textpos
Detokenise tokens until end of line.
Detokenise tokens until end of line.
Detokenise tokens until end of line .
def detokenise_compound_statement(self, ins, bytepos=None):
        """Detokenise tokens until end of line."""
        litstring, comment = False, False
        textpos = 0
        output = bytearray()
        while True:
            s = ins.read(1)
            if not textpos and bytepos is not None and ins.tell() >= bytepos:
                textpos = len(output)
            if s in tk.END_LINE:
                # \x00 ends lines and comments when listed,
                # if not inside a number constant
                # stream ended or end of line
                break
            elif s == b'"':
                # start of literal string, passed verbatim
                # until a closing quote or EOL comes by
                # however number codes are *printed* as the corresponding numbers,
                # even inside comments & literals
                output += s
                litstring = not litstring
            elif s in tk.NUMBER or s in tk.LINE_NUMBER:
                self._detokenise_number(ins, s, output)
            elif comment or litstring or (b'\x20' <= s <= b'\x7E'):
                # honest ASCII
                output += s
            elif s == b'\x0A':
                # LF becomes LF CR
                output += b'\x0A\x0D'
            elif s <= b'\x09':
                # controls that do not double as tokens
                output += s
            else:
                ins.seek(-1, 1)
                comment = self._detokenise_keyword(ins, output)
        return output[:255], textpos
def detokenise_compound_statement ( self , ins , bytepos = None ) : litstring , comment = False , False textpos = 0 output = bytearray ( ) while True : s = ins . read ( 1 ) if not textpos and bytepos is not None and ins . tell ( ) >= bytepos : textpos = len ( output ) if s in tk . END_LINE : # \x00 ends lines and comments when listed, # if not inside a number constant # stream ended or end of line break elif s == b'"' : # start of literal string, passed verbatim # until a closing quote or EOL comes by # however number codes are *printed* as the corresponding numbers, # even inside comments & literals output += s litstring = not litstring elif s in tk . NUMBER or s in tk . LINE_NUMBER : self . _detokenise_number ( ins , s , output ) elif comment or litstring or ( b'\x20' <= s <= b'\x7E' ) : # honest ASCII output += s elif s == b'\x0A' : # LF becomes LF CR output += b'\x0A\x0D' elif s <= b'\x09' : # controls that do not double as tokens output += s else : ins . seek ( - 1 , 1 ) comment = self . _detokenise_keyword ( ins , output ) return output [ : 255 ] , textpos