Skip to content

Add ISBN 10 to 13 converter bot#335

Open
davidscotson wants to merge 1 commit intointernetarchive:masterfrom
davidscotson:isbn10to13
Open

Add ISBN 10 to 13 converter bot#335
davidscotson wants to merge 1 commit intointernetarchive:masterfrom
davidscotson:isbn10to13

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
Contributor

@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
Contributor

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
Contributor

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