def stream_in(p, data):
  """
  Streams to dat from the given command into python

  Parameters
  ----------
  cmd: str
    the command to execute
  parse: boolean
    TODO: if true, will try to parse the output from python generator or list

  """
  if isinstance(data, str):
    data = data.encode()
  stdout, stderr = p.communicate(input=data)
  if p.returncode == 1:
    raise DatException('Node.js error: ' + stderr)
  elif p.returncode == 127:
    raise DatException("It looks like `dat` commandline is missing from PATH.\n",
                   "Are you sure you installed it?\n"
                   "Check http://dat-data.com for instructions")
  else:
    try:
      res = json.loads(stdout.decode())
      if type(res) == dict and res.get('error'):
        return on_error(res)
    except __HOLE__:
      res = {'stdout': stdout, 'stderr': stderr}

    return res
dataset/ETHPy150Open karissa/datpy/datpy.py/stream_in