
import sys
import struct
import json

def sendraw(buf):
	sys.stdout.write(struct.pack("<q", len(buf)))
	sys.stdout.write(buf)
	sys.stdout.flush()

def send(obj):
    sendraw(json.dumps(obj))

def mainloop():
    text = ''
    while True:
        sizebuf = sys.stdin.read(8)
        if len(sizebuf) == 0:
            return
        (size,) = struct.unpack("<q", sizebuf)
        cmd, arg = json.loads(sys.stdin.read(size))
        print >> sys.stderr, cmd, arg
        if cmd == 'key':
            chars = arg['chars']
            if chars == u'\x7f':
                if len(text):
                    text = text[:-1]
            else:
                text += chars
            send(['settext', text])

mainloop()


import sys
import struct
import json

def sendraw(buf):
    sys.stdout.write(struct.pack("<q", len(buf)))
    sys.stdout.write(buf)
    sys.stdout.flush()

def send(obj):
    sendraw(json.dumps(obj))

def mainloop():
    text = ''
    while True:
        sizebuf = sys.stdin.read(8)
        if len(sizebuf) == 0:
            return
        (size,) = struct.unpack("<q", sizebuf)
        cmd, arg = json.loads(sys.stdin.read(size))
        print >> sys.stderr, cmd, arg
        if cmd == 'key':
            chars = arg['chars']
            if chars == u'\x7f':
                if len(text):
                    text = text[:-1]
            else:
                text += chars
            send(['settext', text])

mainloop()

Replace tab indentation with 4 spaces
Replace tab indentation with 4 spaces
  
  import sys
  import struct
  import json
  
  def sendraw(buf):
- 	sys.stdout.write(struct.pack("<q", len(buf)))
+     sys.stdout.write(struct.pack("<q", len(buf)))
- 	sys.stdout.write(buf)
+     sys.stdout.write(buf)
- 	sys.stdout.flush()
+     sys.stdout.flush()
  
  def send(obj):
      sendraw(json.dumps(obj))
  
  def mainloop():
      text = ''
      while True:
          sizebuf = sys.stdin.read(8)
          if len(sizebuf) == 0:
              return
          (size,) = struct.unpack("<q", sizebuf)
          cmd, arg = json.loads(sys.stdin.read(size))
          print >> sys.stderr, cmd, arg
          if cmd == 'key':
              chars = arg['chars']
              if chars == u'\x7f':
                  if len(text):
                      text = text[:-1]
              else:
                  text += chars
              send(['settext', text])
  
  mainloop()
  
Replace tab indentation with 4 spaces
## Code Before:

import sys
import struct
import json

def sendraw(buf):
	sys.stdout.write(struct.pack("<q", len(buf)))
	sys.stdout.write(buf)
	sys.stdout.flush()

def send(obj):
    sendraw(json.dumps(obj))

def mainloop():
    text = ''
    while True:
        sizebuf = sys.stdin.read(8)
        if len(sizebuf) == 0:
            return
        (size,) = struct.unpack("<q", sizebuf)
        cmd, arg = json.loads(sys.stdin.read(size))
        print >> sys.stderr, cmd, arg
        if cmd == 'key':
            chars = arg['chars']
            if chars == u'\x7f':
                if len(text):
                    text = text[:-1]
            else:
                text += chars
            send(['settext', text])

mainloop()

## Instruction:
Replace tab indentation with 4 spaces
## Code After:

import sys
import struct
import json

def sendraw(buf):
    sys.stdout.write(struct.pack("<q", len(buf)))
    sys.stdout.write(buf)
    sys.stdout.flush()

def send(obj):
    sendraw(json.dumps(obj))

def mainloop():
    text = ''
    while True:
        sizebuf = sys.stdin.read(8)
        if len(sizebuf) == 0:
            return
        (size,) = struct.unpack("<q", sizebuf)
        cmd, arg = json.loads(sys.stdin.read(size))
        print >> sys.stderr, cmd, arg
        if cmd == 'key':
            chars = arg['chars']
            if chars == u'\x7f':
                if len(text):
                    text = text[:-1]
            else:
                text += chars
            send(['settext', text])

mainloop()
