Skip to content

Commit 95086ea

Browse files
committed
Fixed issue where multiple results not properly matching
1 parent c0d2913 commit 95086ea

1 file changed

Lines changed: 8 additions & 13 deletions

File tree

get_uris.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def gui():
4040
defaults['_DO_FILE_'] = values['_DO_FILE_']
4141
defaults['_DOTEMP_FILE_'] = values['_DOTEMP_FILE_']
4242
write_digobjs(values['_DO_FILE_'], values['_DOTEMP_FILE_'], client,
43-
repositories[values["_REPO_SELECT_"]], window)
43+
repositories[values["_REPO_SELECT_"]], window)
4444
if event == "_SAVE_REPO_":
4545
defaults["repo_default"] = values["_REPO_SELECT_"]
4646
if event == "_OPEN_DOTEMP_":
@@ -98,14 +98,14 @@ def write_digobjs(digobj_file, dotemp_file, client, repo, gui_window):
9898
print(write_obj_error)
9999
close_wbs(digobj_wb, dotemp_wb)
100100
else:
101-
print(f'Written: {digobj_title}, {digobj_date}')
101+
print(f'{digobj_title}, {digobj_date}')
102102
close_wbs(digobj_wb, dotemp_wb)
103+
print(f'\n{"*" * 112}\n{" " * 40}Finished writing {total_digobjs} to {dotemp_sheet}\n{"*" * 112}')
103104
if errors:
104-
error_message = "ERROR: Could not find any records with the following titles:\n"
105+
error_message = "\nERROR: Could not find any records with the following titles:\n"
105106
for error in errors:
106107
error_message += "\n" + error + "\n"
107108
print(error_message)
108-
print(f'\n{"*" * 112}\n{" " * 40}Finished writing {total_digobjs} to {dotemp_sheet}\n{"*" * 112}')
109109
gui_window[f'{"_WRITE_DOS_"}'].update(disabled=False)
110110
return errors
111111

@@ -119,7 +119,7 @@ def get_results(client, repo, digobj_title, digobj_date):
119119
archobj_uri = None
120120
resource_uri = None
121121
search_archobjs = client.get_paged(f"/repositories/{repo}/search",
122-
params={"q": f'title:"{digobj_title}"', # , {digobj_date}
122+
params={"q": f'title:"{digobj_title}, {digobj_date}"',
123123
"type": ['archival_object']})
124124
search_results = []
125125
for results in search_archobjs:
@@ -134,7 +134,7 @@ def get_results(client, repo, digobj_title, digobj_date):
134134
result_child = result["child_container_u_sstr"][0]
135135
result_option = f'{result["title"]}; {box_coll_list[0]}; {result_child}; {box_coll_list[1]}'
136136
search_options.append(result_option)
137-
multresults_layout = [[psg.Text(f'\n\nFound multiple options for\n{digobj_title}, {digobj_date}\n\n' # TODO: add Box and Folder #, and identifier (ms1000) for info
137+
multresults_layout = [[psg.Text(f'\n\nFound multiple options for\n{digobj_title}, {digobj_date}\n\n'
138138
f'Choose one of the following:\n')],
139139
[psg.Listbox(search_options, size=(120, 5),
140140
key="_ARCHOBJ_FILE_")],
@@ -144,18 +144,14 @@ def get_results(client, repo, digobj_title, digobj_date):
144144
while selection is True:
145145
multresults_event, multresults_values = multresults_window.Read()
146146
if multresults_event == "_SELECT_ARCHOBJ_":
147+
result_title = multresults_values["_ARCHOBJ_FILE_"][0].split(";")[0]
147148
for result in search_results:
148-
selection_title = multresults_values["_ARCHOBJ_FILE_"][0].split(";")[0] # TODO: this part is screwing with me - not matching on second option at all, despite being perflectly matched
149-
print(selection_title)
150-
if result["title"].split(";")[0] == selection_title:
149+
if result["title"] == result_title:
151150
archobj_uri = result["uri"]
152151
resource_uri = result["resource"]
153152
selection = False
154153
multresults_window.close()
155154
break
156-
else:
157-
psg.popup_error("ERROR\nSelected result does not match!", font=("Roboto", 14),
158-
keep_on_top=True)
159155
elif len(search_results) == 0:
160156
print(f'\nERROR: No results found for:\n{digobj_title}, {digobj_date}\n')
161157
return archobj_uri, resource_uri
@@ -175,7 +171,6 @@ def write_digobj(resource_uri, archobj_uri, digobj_id, digobj_title, digobj_publ
175171
for column_num, column_value in column_map.items():
176172
dotemp_sheet.cell(row=write_row_index, column=column_num).value = column_value
177173
write_row_index += 1
178-
# print(f'Wrote {digobj_title} to {dotemp_file}\n')
179174
try:
180175
dotemp_wb.save(dotemp_file)
181176
return None

0 commit comments

Comments
 (0)