Skip to content

Class Environment All

Module about passing folder names

EnvAll

EnvAll(**kwargs)
Source code in fenv\env_all.py
10
11
12
def __init__(self, **kwargs):
    self.kwargs = kwargs
    self.config = configparser.ConfigParser()

create_lib_default_env

create_lib_default_env()

It's a function that creates the env.

Return

str : env name

Source code in fenv\env_all.py
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
def create_lib_default_env(self):
    """It's a function that creates the env.
    Return:
        str : env name
    """
    self.data_list = []

    if platform.system() == "Windows":
        path_lib_all = self.get_path_lib_all()
        for i in os.listdir(path_lib_all):
            self.data_list.append(i)
            self.data_string = ",".join(self.data_list)
            self.config["fenv"] = {"default_lib": self.data_string}
            with open(rf"{self.get_env_name()}\fenv.cfg", "w") as configfile:
                self.config.write(configfile)
    elif platform.system() == "Linux":
        path_lib_all = self.get_path_lib_all()
        for i in os.listdir(path_lib_all):
            self.data_list.append(i)
            self.data_string = ",".join(self.data_list)
            self.config["fenv"] = {
                "default_lib": self.data_string,
            }
            with open(rf"{self.get_env_name()}/fenv.cfg", "w") as configfile:
                self.config.write(configfile)

get_env_name

get_env_name()

It's a function that checks if the environment directory exists.

Return

[] : empyt list

Source code in fenv\env_all.py
14
15
16
17
18
19
20
21
22
23
24
def get_env_name(self):
    """It's a function that checks if the environment directory exists.
    Return:
        [] : empyt list
    """
    self.folder_name = "env*"
    return (
        fnmatch.filter(os.listdir("."), self.folder_name)
        if fnmatch.filter(os.listdir("."), self.folder_name) == []
        else str(fnmatch.filter(os.listdir("."), self.folder_name)[0])
    )

get_lib_default_env

get_lib_default_env()

It reads a config file, gets a string, splits it into a list, and returns the list

Return

data_list : list

Source code in fenv\env_all.py
60
61
62
63
64
65
66
67
68
69
70
71
def get_lib_default_env(self):
    """
    It reads a config file, gets a string, splits it into a list, and returns the list
    Return:
        data_list : list
    """
    self.config.read(rf"{self.get_env_name()}/fenv.cfg")

    self.data_string = self.config.get("fenv", "default_lib")

    self.data_list = self.data_string.split(",")
    return self.data_list

get_path_lib_all

get_path_lib_all()

It's a function that checks if the environment directory exists.

Return

path_lib_all : str

Source code in fenv\env_all.py
73
74
75
76
77
78
79
80
81
82
83
84
def get_path_lib_all(self):
    """
    It's a function that checks if the environment directory exists.
    Return:
        path_lib_all : str
    """
    if platform.system() == "Windows":
        return f"{self.get_env_name()}\Lib\site-packages"
    elif platform.system() == "Linux":
        return "".join(
            glob.glob(f"{self.get_env_name()}/lib/python*/site-packages")
        )

get_root_dir_name

get_root_dir_name()

It's a function that checks if the root directory exists.

Return

str : root directory

Source code in fenv\env_all.py
26
27
28
29
30
31
32
def get_root_dir_name(self):
    """It's a function that checks if the root directory exists.

    Return:
        str : root directory
    """
    return os.path.basename(os.path.abspath("."))