def parse_env_file(env_file):
 environment = {}
 with open(env_file, 'r') as f:
  for line in f:
   if (line[0] == '#'):
    continue
   line = line.strip()
   if (not line):
    continue
   parse_line = line.split('=', 1)
   if (len(parse_line) == 2):
    (k, v) = parse_line
    environment[k] = v
   else:
    raise errors.DockerException('Invalid line in environment file {0}:\n{1}'.format(env_file, line))
 return environment

def parse_env_file ( env_file ) : environment = { } with open ( env_file , 'r' ) as f : for line in f : if ( line [ 0 ] == '#' ) : continue line = line . strip ( ) if ( not line ) : continue parse_line = line . split ( '=' , 1 ) if ( len ( parse_line ) == 2 ) : ( k , v ) = parse_line environment [ k ] = v else : raise errors . DockerException ( 'Invalid line in environment file {0}:\n{1}' . format ( env_file , line ) ) return environment
reads a line-separated environment file .