mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
books_with_same_title()
This commit is contained in:
parent
ecbea8b0e2
commit
1e4d11d78f
@ -10,6 +10,7 @@ import os, traceback, types
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
from future_builtins import zip
|
from future_builtins import zip
|
||||||
|
|
||||||
|
from calibre import force_unicode
|
||||||
from calibre.db import _get_next_series_num_for_list, _get_series_values
|
from calibre.db import _get_next_series_num_for_list, _get_series_values
|
||||||
from calibre.db.adding import (
|
from calibre.db.adding import (
|
||||||
find_books_in_directory, import_book_directory_multiple,
|
find_books_in_directory, import_book_directory_multiple,
|
||||||
@ -112,6 +113,8 @@ class LibraryDatabase(object):
|
|||||||
# Cleaning is not required anymore
|
# Cleaning is not required anymore
|
||||||
self.clean = self.clean_custom = MT(lambda self:None)
|
self.clean = self.clean_custom = MT(lambda self:None)
|
||||||
self.clean_standard_field = MT(lambda self, field, commit=False:None)
|
self.clean_standard_field = MT(lambda self, field, commit=False:None)
|
||||||
|
# apsw operates in autocommit mode
|
||||||
|
self.commit = MT(lambda self:None)
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
self.backend.close()
|
self.backend.close()
|
||||||
@ -368,8 +371,19 @@ class LibraryDatabase(object):
|
|||||||
return []
|
return []
|
||||||
return self.books_in_series(series_ids[0])
|
return self.books_in_series(series_ids[0])
|
||||||
|
|
||||||
# Private interface {{{
|
def books_with_same_title(self, mi, all_matches=True):
|
||||||
|
title = mi.title
|
||||||
|
ans = set()
|
||||||
|
if title:
|
||||||
|
title = icu_lower(force_unicode(title))
|
||||||
|
for book_id, x in self.new_api.get_id_map('title').iteritems():
|
||||||
|
if icu_lower(x) == title:
|
||||||
|
ans.add(book_id)
|
||||||
|
if not all_matches:
|
||||||
|
break
|
||||||
|
return ans
|
||||||
|
|
||||||
|
# Private interface {{{
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
for row in self.data.iterall():
|
for row in self.data.iterall():
|
||||||
yield row
|
yield row
|
||||||
|
@ -177,6 +177,7 @@ class LegacyTest(BaseTest):
|
|||||||
'authors_with_sort_strings':[(0,), (1,), (2,)],
|
'authors_with_sort_strings':[(0,), (1,), (2,)],
|
||||||
'book_on_device_string':[(1,), (2,), (3,)],
|
'book_on_device_string':[(1,), (2,), (3,)],
|
||||||
'books_in_series_of':[(0,), (1,), (2,)],
|
'books_in_series_of':[(0,), (1,), (2,)],
|
||||||
|
'books_with_same_title':[(Metadata(db.title(0)),), (Metadata(db.title(1)),), (Metadata('1234'),)],
|
||||||
}.iteritems():
|
}.iteritems():
|
||||||
for a in args:
|
for a in args:
|
||||||
fmt = lambda x: x
|
fmt = lambda x: x
|
||||||
@ -266,8 +267,9 @@ class LegacyTest(BaseTest):
|
|||||||
'author_id', # replaced by get_author_id
|
'author_id', # replaced by get_author_id
|
||||||
'books_for_author', # broken
|
'books_for_author', # broken
|
||||||
'books_in_old_database', # unused
|
'books_in_old_database', # unused
|
||||||
'clean_user_categories', # internal API
|
|
||||||
'cleanup_tags', # internal API
|
# Internal API
|
||||||
|
'clean_user_categories', 'cleanup_tags', 'books_list_filter',
|
||||||
}
|
}
|
||||||
SKIP_ARGSPEC = {
|
SKIP_ARGSPEC = {
|
||||||
'__init__', 'get_next_series_num_for', 'has_book', 'author_sort_from_authors',
|
'__init__', 'get_next_series_num_for', 'has_book', 'author_sort_from_authors',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user