summaryrefslogtreecommitdiff
path: root/support/ui_utils/read_data.py
blob: ec0f249921673a28d60a5cc76a43cdafa4139300 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
import json
import os
from support.ui_utils.workpath import workdir

class ReadData:
    def __init__(self):
        #json文件和测试文件目录
        self.workdir = workdir
        self.support = "support"
        self.ui_data = "ui_data"
        #profiles模块目录名称
        self.profiles_data = "profiles_data"
        self.profiles_file = "profiles"
        #objects模块目录名称
        self.objects_data = "objects_data"
        self.general_ui_utils = "general_ui_utils"
        self.preset_file ="preset_file"
        self.object = "object"
        self.download_file = "download_file"
        #admin模块目录名称
        self.admin_data = "admin_area"
        self.System_Appearance = "System_Appearance"

    def _from_json(self, file):
        """
        从json中读取数据函数
        :param file:
        :return:
        """
        with open(file, "r", encoding="utf-8") as f:
            data = json.load(f)["item"]
            data = list(data)
            return data

    def _abs_path(self, file_name):
        """
        重组路径-profiles模块路径重组
        :param file_name:
        :return:
        """
        file = os.path.join(self.workdir, self.support, self.ui_data, self.profiles_data, file_name)
        return file
    
    def _abs_obj_path(self,file_name):
        '''
        重组路径-objects模块路径重组
        '''
        file = os.path.join(self.workdir,self.support, self.ui_data, self.objects_data, file_name)
        return file
    
    def _profiles_files_dowload_path(self):
        self.file_path = os.path.join(self.workdir, self.support, self.general_ui_utils, self.profiles_file, self.download_file)
        return self.file_path
    
    def _obj_files_path(self,file_name):
        '''
        重组路径-objects模块路径重组
        '''
        file = os.path.join(self.workdir,self.support, self.general_ui_utils, self.preset_file,self.object,file_name)
        return file
    
    def _obj_files_dowload_path(self):
        self.file_path = os.path.join(self.workdir,self.support, self.general_ui_utils, self.preset_file,self.download_file)
        return self.file_path

    def _admin_files_dowload_path(self):
        self.file_path = os.path.join(self.workdir, self.support, self.general_ui_utils, "admin")
        return self.file_path
    
    def _admin_logs_dowload_path(self):
        self.file_path = os.path.join(self.workdir, self.support, self.general_ui_utils, "admin","admin_logs")
        return self.file_path
    
    def _object_applications_export_path(self):
        self.file_path = os.path.join(self.workdir, self.support, self.general_ui_utils, "objects", "Applications","export_json")
        return self.file_path

    def _abs_admin_path(self,file_name):
        '''
        重组路径-admin模块路径重组
        '''
        file = os.path.join(self.workdir,self.support, self.ui_data, self.admin_data, self.System_Appearance,file_name)
        return file

    def _abs_update_path(self,file_name):
        '''
        重组路径-admin模块路径重组
        '''
        file = os.path.join(self.workdir,self.support, self.ui_data, self.admin_data, "System_Updates",file_name)
        return file

    def _abs_Assessment_path(self,file_name):
        '''
        重组路径-admin模块路径重组
        '''
        file = os.path.join(self.workdir,self.support, self.ui_data, self.admin_data, "System_Assessment",file_name)
        return file

    def _abs_Ip_Library_path(self, file_name):
        '''
        重组路径-admin模块路径重组
        '''
        file = os.path.join(self.workdir, self.support, self.ui_data, self.admin_data, "IP_Libraries", file_name)
        return file

    def _abs_admin_logs_path(self, file_name):
        '''
        重组路径-admin模块路径重组
        '''
        file = os.path.join(self.workdir, self.support, self.ui_data, self.admin_data, "Admin_Logs", file_name)
        return file


    def read_data_profiles(self, file_name):
        """
        profile模块提取json数据方法
        :param file_name:
        :return:
        """
        file = self._abs_path(file_name)
        return self._from_json(file)

    def read_data_object(self,file_name):     # Json文件
        '''
        object模块提取json数据方法
        :param file_name:
        :return:
        '''
        file = self._abs_obj_path(file_name)
        return self._from_json(file)

    def read_data_admin(self,file_name):
        '''
        object模块提取json数据方法
        :param file_name:
        :return:
        '''
        file = self._abs_admin_path(file_name)
        return self._from_json(file)

    def read_data_admin_System_Updates(self, file_name):
        '''
        object模块提取json数据方法
        :param file_name:
        :return:
        '''
        file = self._abs_update_path(file_name)
        return self._from_json(file)

    def read_data_admin_System_Assessment(self, file_name):
        '''
        object模块提取json数据方法
        :param file_name:
        :return:
        '''
        file = self._abs_Assessment_path(file_name)
        return self._from_json(file)

    def read_data_admin_IP_Libraries(self, file_name):
        '''
        object模块提取json数据方法
        :param file_name:
        :return:
        '''
        file = self._abs_Ip_Library_path(file_name)
        return self._from_json(file)
    
    def read_data_admin_admin_logs(self, file_name):
        '''
        object模块提取json数据方法
        :param file_name:
        :return:
        '''
        file = self._abs_admin_logs_path(file_name)
        return self._from_json(file)
    
    def generate_id(self, param):
        """
        测试用例中ids信息提取
        :param param:
        :return:
        """
        ids: str = param["ids"]
        #print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], ids)
        return ids

    def _admin_area_path(self, file_name):
        """
        重组路径
        :param file_name:
        :return:
        """
        file = os.path.join(self.workdir, self.support, self.ui_data, "admin_area", file_name)
        return self._from_json(file)
    
    def _manage_users_path(self, file_name):
        """
        重组路径
        :param file_name:
        :return:
        """
        file = os.path.join(self.workdir, self.support, self.ui_data, "admin_area", "manage_users", file_name)
        return self._from_json(file)
    
    def Read_Header_logo(self,folder_path):
        """
        提取测试图片

        """
        # 获取文件夹下所有文件的完整路径
        file_paths = [os.path.join(folder_path, file) for file in os.listdir(folder_path)]
        return file_paths

    def Read_Appearance_Title(self,title_file):
        """
        提取Appearance下的Title
        """
        with open(title_file, 'r') as file:
            lines = file.readlines()  # 逐行读取文件内容并存储到列表中

        return lines

    def Read_Favicon(self,Favicon_path):
        # 获取文件夹下所有文件的完整路径
        file_paths = [os.path.join(Favicon_path, file) for file in os.listdir(Favicon_path)]
        return file_paths

    def Read_Login_Logo_Data(self,Login_path):
        file_paths = [os.path.join(Login_path, file) for file in os.listdir(Login_path)]
        return file_paths

    def Read_Language_txt(self,language_path):
        with open(language_path, 'r', encoding='utf-8') as file:
            lines = [line.strip() for line in file]
        return lines

if __name__ == '__main__':
    r = ReadData()
    r.read_data_admin(file_name="language.json")