forked from espeak-ng/espeak-ng
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwindows-data.test
76 lines (60 loc) · 2.16 KB
/
windows-data.test
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
#!/usr/bin/env python3
import sys
import os
import xml.etree.ElementTree as etree
passed = True
def check_result(check, message):
global passed
if check:
print('passed')
elif message:
print('failed: ' + message)
passed = False
else:
print('failed')
passed = False
def check_missing(items, target):
missing = []
for item in items:
if not item in target:
missing.append(item)
check_result(len(missing) == 0, ', '.join(missing))
return missing
def all_descendants(proj, name):
for e in proj.iter():
if e.tag == '{http://schemas.microsoft.com/developer/msbuild/2003}' + name:
yield e
def children(e, name):
for c in e:
if not isinstance(c, str):
if c.tag == '{http://schemas.microsoft.com/developer/msbuild/2003}' + name:
yield c
def element_map(proj, name):
print('testing for duplicate \'' + name + '\' names ... ', end='')
items = {}
duplicates = []
for e in all_descendants(proj, name):
id = e.attrib.get("Name")
if id in items.keys():
duplicates.append(id)
else:
items[id] = e
check_result(len(duplicates) == 0 , ', '.join(duplicates))
return items
def list_dictionaries():
for file in os.listdir('dictsource'):
if file.endswith('_rules'):
yield file.split('_')[0]
# 1. Check for missing/duplicate names #################################################################################
proj = etree.parse('src/windows/data.vcxproj').getroot()
targets = element_map(proj, 'Target')
# 2. Check for missing dictionaries ####################################################################################
dictionaries = list(list_dictionaries())
depends_on_dictionaries = targets['Dictionaries'].attrib.get('DependsOnTargets').split(';')
print('testing for missing dictionary targets ... ', end='')
check_missing(depends_on_dictionaries, targets.keys())
print('testing for missing dependencies on dictionaries ... ', end='')
check_missing(set.intersection(set(dictionaries), set(targets.keys())), depends_on_dictionaries)
########################################################################################################################
if not passed:
sys.exit(-1)