Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comparison and error hadling fixes #103

Merged
merged 3 commits into from
May 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions dlx_dl/scripts/sync/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ def run(**kwargs):
pass
elif last is None:
raise Exception('No log data found for this source')
elif (datetime.now() - (last.get('time') or datetime.min)) > timedelta(hours=3): # skip check if more than 3 hours
print("wait time limit exceeded for last import confirmation. proceeding")
#elif (datetime.now() - (last.get('time') or datetime.min)) > timedelta(hours=3): # skip check if more than 3 hours
# print("wait time limit exceeded for last import confirmation. proceeding")
elif last:
pre = '035__a:(DHL)' if args.type == 'bib' else '035__a:(DHLAUTH)'
url = f'{API_SEARCH_URL}?search_id=&p={pre}{last["record_id"]}&format=xml'
Expand Down Expand Up @@ -252,7 +252,7 @@ def run(**kwargs):
#print(f'{SEEN} / {TOTAL} ', end='', flush=True)

# limits
if args.limit != 0 and updated_count == args.limit:
if args.limit != 0 and updated_count >= args.limit:
print('\nReached max exports')
enqueue = True if args.queue else False
break
Expand Down Expand Up @@ -496,10 +496,13 @@ def compare_and_update(args, *, dlx_record, dl_record):
continue

if normalize(field.to_mrk()) not in [normalize(x) for x in dlx_fields_serialized]:
if field.tag in [x.tag for x in dlx_fields]:
# compare tag + indicators
if field.tag + ''.join(field.indicators) in [x.tag + ''.join(x.indicators) for x in dlx_fields]:
# this should already be taken care of in dlx->dl
print(f'{dlx_record.id}: SUPERCEDED: {field.to_mrk()}')
take_tags.add(field.tag)
else:
# delete fields where the tag + indicators combo does not exist in dl record
print(f'{dlx_record.id}: TO DELETE: {field.to_mrk()}')

# use the field in the export to delete the field in DL by setting values to empty string
Expand Down
Loading