-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathread_write_project_structure.py
More file actions
59 lines (45 loc) · 2.16 KB
/
read_write_project_structure.py
File metadata and controls
59 lines (45 loc) · 2.16 KB
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
import read_write_dbf
def get_field_value(dbf_list, project_name, field):
dbf_project_field_value = ''
for record in dbf_list:
if record['name'][1] == project_name:
dbf_project_field_value = record[field][1]
break
return dbf_project_field_value
def write_field_value(dbf_list, project_name, field, value):
for record in dbf_list:
if record['name'][1] == project_name:
record[field][1] = value
break
return dbf_list
def find_name_for_path(dbf_list, file_path):
project_name = ''
for record in dbf_list:
project = record['name'][1]
project_path = record['path'][1].rstrip('\\')
# print(project, project_path)
if file_path.lower() == project_path.lower():
project_name = project
break
return project_name
def read_through_include_files(master_list):
project_black_list = ['System', 'Include', 'CSV_Include', 'Library_Controls', 'Library_Equipment',
'SxW_Style_Include', 'Tab_Style_Include', 'SA_Include', 'SA_Library', 'SA_Controls']
for count in range(20): # limit to 20 levels deep
found = 0
for master_index in range(len(master_list)):
project = master_list[master_index]['name'][1]
if project not in project_black_list:
if master_list[master_index]['include_read_in_status'][1] == 1:
found = 1
master_list[master_index]['include_read_in_status'][1] = 2
include_file_path = master_list[master_index]['path'][1].rstrip('\\') + '\\' + 'include.dbf'
include_list, _ = read_write_dbf.read_in_dbf(include_file_path)
for include_index in range(len(include_list)):
project = include_list[include_index]['name'][1]
if project not in project_black_list:
if get_field_value(master_list, project, 'include_read_in_status') == 0:
write_field_value(master_list, project, 'include_read_in_status', 1)
if not found:
break
return master_list