# AUTOGENERATED! DO NOT EDIT! File to edit: 10_gym_environment.ipynb (unless otherwise specified).

__all__ = ['read_path', 'show_env']

# Cell
import os
import re

def read_path(path, output_name):
    """

    This function will read path of gym information, and output a txt file that get all gym environment.

    Args:
        path : The gym init file path
        output_name : The name of output file
    Return:
        file_path : The stored all gym environment file path

    """
    file_path = os.path.join("./Data/" + output_name)

    os.system("cat " + path + " | grep \"id=\" >> " + file_path)

    return file_path

def show_env(path):
    """

    This function will read gym environment file and show all gym.

    Args :
        path : The gym environment file path
    Return :
        link : list all gym environment.
    """

    env = []
    f = open(path, 'r')
    for line in f.readlines():
      if(line.find('#')):
        flag = [_.start() for _ in re.finditer("\'",line)]
        env.append(line[flag[0]+1:flag[1]])
    f.close()

    return env