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 ISBN 10 to 13 converter bot #335

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

davidscotson
Copy link
Contributor

Closes #334

Description:

In this Pull Request we have made the following changes:

  • Add a new bot, based heavily on ISBNBot, which will add ISBN 13 to Editions that have an ISBN 10 entry but no ISBN 13.

# we only update editions with no existing isbn 13s (for now at least)
continue

isbns_13 = []
Copy link
Collaborator

@cclauss cclauss Jun 29, 2023

Choose a reason for hiding this comment

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

It is too easy to overlook the plural form when it is in the middle of the variable name.

Suggested change
isbns_13 = []
isbn_13s = []

Can't this be a set() instead of a list() so the deduping is automatic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I avoided that becausi it might randomise the order of the existing entries, but in this specific bot we're only running it on things without existing isbn_13s anyway, so that's probably a worthwhile change.

Comment on lines +55 to +57
isbns_13 = dedupe(
isbns_13
) # remove duplicates, shouldn't normally be necessary
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do not wrap the line just for a comment.

Suggested change
isbns_13 = dedupe(
isbns_13
) # remove duplicates, shouldn't normally be necessary
# remove duplicates, shouldn't normally be necessary
isbns_13 = dedupe(isbns_13)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we switch to a set, the comment (and code) becomes unnecessary, so that might be the way to go.

self.save(lambda: edition.save(comment=comment))


def dedupe(input_list: list) -> list:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
def dedupe(input_list: list) -> list:
def dedupe(input_list: list) -> list:
return sorted(set(input_list))

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.

Bot to add ISBN 13 to items with only ISBN 10
2 participants