#!/usr/bin/python3
# read iiab.env from python

def get_iiab_env(name):
   """ read iiab.env file for a value, return "" if does not exist"""
   try:
      fd = open("{{ iiab_env_file }}","r")
      for line in fd:
         line = line.lstrip()
         line = line.rstrip('\n')
         if len(line) == 0:
            continue
         if line[0] == "#":
            continue
         if line.find("=") == -1:
            continue
         chunks = line.split('=')
         if chunks[0] == name:
            return chunks[1]
      return("")
   except:
      return("")
   finally:
      fd.close()

if __name__ == "__main__":
   print(get_iiab_env("WWWROOT"))
