2
2
3
3
class [module_name](object):
4
4
def __init__(self):
5
- # Define the module folders
6
- from Utility.Define_Folders import Define_Folders as Define_Folders
5
+ # Import the classes
6
+ self.Import_Classes()
7
7
8
- Define_Folders(self)
8
+ # Define the folders of the module
9
+ self.folders = self.Define_Folders(object = self).folders
9
10
10
11
# Module related methods
11
12
self.Define_Basic_Variables()
12
13
self.Define_Texts()
13
14
14
- def Define_Basic_Variables(self):
15
- from copy import deepcopy
15
+ def Import_Classes(self):
16
+ # Define the list of modules to be imported
17
+ modules = [
18
+ "Define_Folders",
19
+ "JSON"
20
+ ]
16
21
17
- # Import the JSON module
18
- from Utility.JSON import JSON as JSON
22
+ # Iterate through the list of modules
23
+ for module_title in modules:
24
+ # Import the module
25
+ module = importlib.import_module("." + module_title, "Utility")
19
26
20
- self.JSON = JSON()
27
+ # Get the sub-class
28
+ sub_class = getattr(module, module_title)
29
+
30
+ # If the module title is not "Define_Folders"
31
+ if module_title != "Define_Folders":
32
+ # Run the sub-class to define its variable
33
+ sub_class = sub_class()
34
+
35
+ # Add the sub-class to the current module
36
+ setattr(self, module_title, sub_class)
21
37
22
38
# Define the "Language" class as the same class inside the "JSON" class
23
39
self.Language = self.JSON.Language
24
40
41
+ def Define_Basic_Variables(self):
25
42
# Get the modules list
26
- self.modules = self.JSON.To_Python(self.folders["apps "]["modules "]["modules "])
43
+ self.modules = self.JSON.To_Python(self.folders["Apps "]["Modules "]["Modules "])
27
44
28
45
# Create a list of the modules that will not be imported
29
46
remove_list = [
30
47
"Define_Folders",
48
+ "Modules",
31
49
"Language",
32
50
"JSON"
33
51
]
@@ -45,21 +63,6 @@ class [module_name](object):
45
63
# Add the sub-class to the current module
46
64
setattr(self, module_title, sub_class())
47
65
48
- # Make a backup of the module folders
49
- self.module_folders = {}
50
-
51
- for item in ["modules", "module_files"]:
52
- self.module_folders[item] = deepcopy(self.folders["apps"][item][self.module["key"]])
53
-
54
- # Define the local folders dictionary as the Folder folders dictionary
55
- self.folders = self.Folder.folders
56
-
57
- self.links = self.Folder.links
58
-
59
- # Restore the backup of the module folders
60
- for item in ["modules", "module_files"]:
61
- self.folders["apps"][item][self.module["key"]] = self.module_folders[item]
62
-
63
66
# Get the switches dictionary from the "Global Switches" module
64
67
self.switches = self.Global_Switches.switches["Global"]
65
68
@@ -70,6 +73,11 @@ class [module_name](object):
70
73
self.user_language = self.Language.user_language
71
74
self.full_user_language = self.Language.full_user_language
72
75
76
+ # Define the local "folders" dictionary as the dictionary inside the "Folder" class
77
+ self.folders = self.Folder.folders
78
+
79
+ # Import the "links" variable from the "Folder"
80
+
73
81
# Get the Sanitize method of the File class
74
82
self.Sanitize = self.File.Sanitize
75
83
0 commit comments