#!/bin/env python1.5

# -----------------------------------------------------------------------------
# Fake AsciiClient for testing Sparky interface to AutoAssign.
# Just read resonance shifts from a file.
#
import sys

shifts_path = '/usr/local/src/sparky/data/bpti/autoassign/shifts'

# -----------------------------------------------------------------------------
#
def test_shifts(shifts_path):

  f = open(shifts_path, 'r')
  lines = f.readlines()
  f.close()
  return lines

# -----------------------------------------------------------------------------
#
def echo_commands():

  while 1:
    line = sys.stdin.readline()
    if line == '':
      break               # EOF
    sys.stdout.write(line)
    if line == 'Examine (List, Chemical Shifts Publish Format)\n':
      for shift_line in test_shifts(shifts_path):
        sys.stdout.write(shift_line)
      sys.stdout.write('END_MSG\n')
    if line != '\n':
      sys.stdout.write('END_TASK\n')
    sys.stdout.flush()

# -----------------------------------------------------------------------------
#
echo_commands()
