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

add classifier keywords remove script #56

Merged
merged 1 commit into from
Sep 16, 2024

Conversation

PascalEgn
Copy link
Contributor

Comment on lines 20 to 22
for keyword in record.get("keywords", []):
if keyword.get("source", "") == "classifier":
record["keywords"].remove(keyword)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you sure mutating a list you're iterating on works correctly? the safer approach is usually to build a new list that only contains the elements you need, like in

new_ids = [
id_dict for id_dict in author_ids if id_dict["schema"] != "INSPIRE BAI"
]
if new_ids:
author["ids"] = new_ids
else:
del author["ids"]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, it would not work correctly like this. I changed it now :)

@PascalEgn PascalEgn force-pushed the add-classifier-keywords-remove-script branch from a78e9d3 to ff119c5 Compare September 16, 2024 11:22
@PascalEgn PascalEgn force-pushed the add-classifier-keywords-remove-script branch from 6223e64 to ba18a6b Compare September 16, 2024 11:23
@PascalEgn PascalEgn merged commit 1d04298 into master Sep 16, 2024
1 check passed
@drjova drjova deleted the add-classifier-keywords-remove-script branch September 23, 2024 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants