Skip to content

Commit 72a011f

Browse files
committed
move check uniqueness of json folder-name, display-name and repository to own function
1 parent a0e70d8 commit 72a011f

File tree

1 file changed

+31
-24
lines changed

1 file changed

+31
-24
lines changed

validator.py

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,33 @@ def gen_pl_table(filename):
100100
return tab_text
101101

102102

103+
def unique_json_keys_check(plugin, displaynames, foldernames, repositories):
104+
105+
found = False
106+
for name in displaynames :
107+
if plugin["display-name"] == name :
108+
post_error(f'{plugin["display-name"]}: non unique display-name entry')
109+
found = True
110+
if found == False:
111+
displaynames.append(plugin["display-name"])
112+
113+
found = False
114+
for folder in foldernames :
115+
if plugin["folder-name"] == folder :
116+
post_error(f'{plugin["folder-name"]}: non unique folder-name entry')
117+
found = True
118+
if found == False:
119+
foldernames.append(plugin["folder-name"])
120+
121+
found = False
122+
for repo in repositories :
123+
if plugin["repository"] == repo :
124+
post_error(f'{plugin["repository"]}: non unique repository entry')
125+
found = True
126+
if found == False:
127+
repositories.append(plugin["repository"])
128+
129+
103130
def parse(filename):
104131
try:
105132
schema = json.loads(open("pl.schema").read())
@@ -203,30 +230,10 @@ def parse(filename):
203230
f'detected is {dll_version}, but the expected version is {version}.')
204231
continue
205232

206-
# Check the uniqueness of the JSON folder name, the display name, and the repository
207-
found = False
208-
for name in displaynames:
209-
if plugin["display-name"] == name:
210-
post_error(f'{plugin["display-name"]}: non unique display-name entry.')
211-
found = True
212-
if not found:
213-
displaynames.append(plugin["display-name"])
214-
215-
found = False
216-
for folder in foldernames:
217-
if plugin["folder-name"] == folder:
218-
post_error(f'{plugin["folder-name"]}: non unique folder-name entry.')
219-
found = True
220-
if found == False:
221-
foldernames.append(plugin["folder-name"])
222-
223-
found = False
224-
for repo in repositories:
225-
if plugin["repository"] == repo:
226-
post_error(f'{plugin["repository"]}: non unique repository entry.')
227-
found = True
228-
if found == False:
229-
repositories.append(plugin["repository"])
233+
234+
#check uniqueness of json folder-name, display-name and repository
235+
unique_json_keys_check(plugin, displaynames, foldernames, repositories)
236+
230237

231238

232239
ARCHITECTURE_FILENAMES_MAPPING = {

0 commit comments

Comments
 (0)