def check_authors(device1, device2): shared_authors = [] for author1 in device1.authors: for author2 in device2.authors: if is_same_author(author1, author2): shared_authors.append(author1) return shared_authors
def check_authors(new_device, db_device, authors): shared_authors = [] for author in new_device.authors: for author_id in db_device.authors: db_author_name = get_author_name(author_id, authors) if is_same_author(author, db_author_name): shared_authors.append(db_author_name) return shared_authors
def add_authors(authors, cursor): authors = get_author_vals(authors) authors_in_db = get_authors_in_db(cursor) seen_authors = [] for author in authors: for db_author in authors_in_db: if is_same_author(author[0], db_author[0]): seen_authors.append(author) db_author = (db_author[0], db_author[1] + author[1]) update_author_list(db_author, cursor) # seen authors in the end of the first for-loop should have all the authors in our author list thats in our db for author in authors: if author not in seen_authors: add_author(author, cursor)
def has_seen_author(author): for auth in authors: if is_same_author(author, auth.name): return True, auth return False, None
def __eq__(self, other): return is_same_author(self.name, other.name)