emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/calibre 6366966c9b 60/76: Add abstraction layer on top


From: ELPA Syncer
Subject: [elpa] externals/calibre 6366966c9b 60/76: Add abstraction layer on top of calibre-db
Date: Thu, 18 May 2023 09:57:46 -0400 (EDT)

branch: externals/calibre
commit 6366966c9b9942c285cd5d76db5f644a95580780
Author: Kjartan Óli Ágústsson <kjartanoli@disroot.org>
Commit: Kjartan Óli Ágústsson <kjartanoli@disroot.org>

    Add abstraction layer on top of calibre-db
    
    * calibre-core.el:
    (calibre-library-buffer):
    (calibre--books):
    (calibre-library--filters):
    (calibre-library-clear-filters):
    (calibre--library):
    (calibre-select-library):
    (calibre-library--refresh):
    (calibre-library--set-header):
    (calibre-library-time-format):
    (calibre-library-columns):
    (calibre-library--header-format):
    (calibre-book--print-info):
    (calibre-book--file):
    (calibre-composite-filter-p):
    (calibre--get-filter-items):
    (calibre-library--filter):
    Move from calibre-db.el.
    (calibre-core--interface):
    (calibre-core--get-authors):
    (calibre-core--get-tags):
    (calibre-core--get-formats):
    (calibre-core--get-series):
    (calibre-core--get-publishers):
    (calibre-cli--get-authors):
    (calibre-cli--get-tags):
    (calibre-cli--get-formats):
    (calibre-cli--get-series):
    (calibre-cli--get-publishers):
    Create.
    * calibre-db.el (calibre-composite-filter-p):
    (calibre--get-filter-items):
    (calibre-library--filter):
    (calibre--books):
    (calibre-library--filters):
    (calibre-library-clear-filters):
    (calibre--library):
    (calibre-select-library):
    (calibre-library-buffer):
    (calibre-library--refresh):
    (calibre-library--set-header):
    (calibre-library-time-format):
    (calibre-library-columns):
    (calibre-library--header-format):
    (calibre-book--print-info):
    (calibre-book--file):
    Move to calibre-core.el.
    * calibre-edit.el, calibre-exec.el, calibre-search.el,
    calibre-virtual-library.el: Use calibre-core instead of calibre-db.
---
 calibre-db.el => calibre-core.el | 331 ++++++++++++++-------------------------
 calibre-db.el                    | 211 -------------------------
 calibre-edit.el                  |   2 +-
 calibre-exec.el                  |   2 +-
 calibre-search.el                |   4 +-
 calibre-virtual-library.el       |   2 +-
 6 files changed, 123 insertions(+), 429 deletions(-)

diff --git a/calibre-db.el b/calibre-core.el
similarity index 61%
copy from calibre-db.el
copy to calibre-core.el
index f5af9f2833..95131de047 100644
--- a/calibre-db.el
+++ b/calibre-core.el
@@ -1,10 +1,7 @@
-;;; calibre-db.el --- Interact with the Calibre database -*- lexical-binding:t 
-*-
+;;; calibre-core.el --- Abstract interface for the Calibre Library  -*- 
lexical-binding: t; -*-
 
 ;; Copyright (C) 2023  Kjartan Oli Agustsson
 
-;; Author: Kjartan Oli Agustsson <kjartanoli@disroot.org>
-;; Maintainer: Kjartan Oli Agustsson <kjartanoli@disroot.org>
-
 ;; This file is part of calibre.el.
 
 ;; calibre.el is free software: you can redistribute it and/or modify
@@ -21,218 +18,34 @@
 ;; along with calibre.el.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
-;; Fetch data from the library database.
+;; This file contains the abstract interface for accessing the calibre
+;; library.  This abstract layer absolves the upper layers of caring
+;; which interface is used.
 
 ;;; Code:
-(require 'calibre)
-(require 'calibre-book)
-(require 'calibre-util)
-
-(defun calibre-db--make-book (entry)
-  "Create a `calibre-book' from ENTRY.
-ENTRY is a list of the form:
-\(ID TITLE SERIES SERIES-INDEX TIMESTAMP PUBDATE LAST-MODIFIED)."
-  (seq-let [id title series series-index timestamp pubdate last-modified path] 
entry
-    (calibre-book :id id
-                  :title title
-                  :authors (calibre-db--get-book-authors id)
-                  :publisher (calibre-db--get-book-publisher id)
-                  :series series
-                  :series-index series-index
-                  :timestamp (calibre-parse-timestamp timestamp)
-                  :pubdate (calibre-parse-timestamp pubdate)
-                  :last-modified (calibre-parse-timestamp last-modified)
-                  :tags (calibre-db--get-book-tags id)
-                  :formats (calibre-db--get-book-formats id)
-                  :path path
-                  :file-name (calibre-db--get-book-file-name id))))
-
-(defun calibre-db--get-book-authors (id)
-  "Return a list of authors for the book identified by ID."
-  (flatten-list (sqlite-select (calibre--db)
-                               "SELECT authors.name
-FROM authors
-INNER JOIN books_authors_link al ON authors.id = al.author
-WHERE al.book = ?" `[,id])))
-
-(defun calibre-db--get-book-publisher (id)
-  "Return the publisher of the book identified by ID."
-  (car (flatten-list (sqlite-select (calibre--db)
-                               "SELECT publishers.name
-FROM publishers
-INNER JOIN books_publishers_link pl ON publishers.id = pl.publisher
-WHERE pl.book = ?" `[,id]))))
-
-(defun calibre-db--get-book-file-name (id)
-  "Return the file name, sans extension, of the book identified by ID."
-  (car (car (sqlite-select (calibre--db)
-                           "SELECT name
-FROM data
-WHERE book = ?" `[,id]))))
-
-(defun calibre-db--get-book-tags (id)
-  "Return a list of tags for the book identified by ID."
-  (flatten-list (sqlite-select (calibre--db)
-                               "SELECT tags.name
-FROM books
-INNER JOIN books_tags_link tl ON books.id = tl.book
-INNER JOIN tags ON tl.tag = tags.id
-WHERE books.id = ?"
-                               `[,id])))
-
-(defun calibre-db--get-book-formats (id)
-  "Return a list of formats for the book identified by ID."
-  (mapcar (lambda (f)
-            (intern (downcase f)))
-          (flatten-list (sqlite-select (calibre--db)
-                               "SELECT format FROM data WHERE book = ?"
-                               `[,id]))))
-
-(defun calibre-db--get-authors ()
-  "Return a list of the authors in the active library."
-  (sqlite-select (calibre--db)
-                               "SELECT name FROM authors;"))
-
-(defun calibre-db--get-series ()
-  "Return a list of the series in the active library."
-  (flatten-list (sqlite-select (calibre--db)
-                               "SELECT name FROM series;")))
-
-(defun calibre-db--get-tags ()
-  "Return a list of the tags in the active library."
-  (flatten-list (sqlite-select (calibre--db)
-                               "SELECT name FROM tags;")))
-
-(defun calibre-db--get-publishers ()
-  "Return a list of the publishers in the active library."
-  (flatten-list (sqlite-select (calibre--db)
-                               "SELECT name FROM publishers;")))
+(require 'calibre-db)
+(require 'calibre-cli)
 
-(defun calibre-db--get-formats ()
-  "Return a list of the file formats stored in the active library."
-  (flatten-list (sqlite-select (calibre--db)
-                               "SELECT DISTINCT format FROM data;")))
-
-(defvar calibre--db nil)
-(defun calibre--db ()
-  "Return the metadata database."
-  (unless calibre--db
-    (let ((file-name (file-name-concat (calibre--library) "metadata.db")))
-      (if (not (file-exists-p file-name))
-          (progn
-            (message "Metedata database %s does not exist.  Add some books to 
the library to create it." file-name)
-            (setf calibre--db nil))
-        (setf calibre--db
-              (sqlite-open
-               file-name)))))
-  calibre--db)
-
-(defun calibre-db--get-books ()
-  "Return all books in the Calibre library `calibre-library-dir'."
-  (if (not (calibre--db))
-      nil
-    (mapcar #'calibre-db--make-book
-            (sqlite-select (calibre--db)
-                           "SELECT books.id, title, series.name, series_index, 
timestamp, pubdate, last_modified, path
-FROM books
-LEFT JOIN books_series_link sl ON books.id = sl.book
-LEFT JOIN series ON sl.series = series.id;"))))
-
-(defun calibre-db--get-author-books (author)
-  "Return the id's of books written by AUTHOR."
-  (flatten-list (sqlite-select (calibre--db)
-                               "SELECT book
-FROM books_authors_link al
-LEFT JOIN authors a ON al.author = a.id
-WHERE a.name = ?" `[,author])))
-
-(defun calibre-db--get-tag-books (tag)
-  "Return the id's of books tagged with TAG."
-  (flatten-list (sqlite-select (calibre--db)
-                               "SELECT book
-FROM books_tags_link tl
-LEFT JOIN tags t ON tl.tag = t.id
-WHERE t.name = ?" `[,tag])))
-
-(defun calibre-db--get-publisher-books (publisher)
-  "Return the id's of books published by PUBLISHER."
-  (flatten-list (sqlite-select (calibre--db)
-                               "SELECT book
-FROM books_publishers_link pl
-LEFT JOIN publishers p ON pl.publisher = p.id
-WHERE p.name = ?" `[,publisher])))
-
-(defun calibre-db--get-series-books (series)
-  "Return the id's of books that are part of SERIES."
-  (flatten-list (sqlite-select (calibre--db)
-                               "SELECT book
-FROM books_series_link sl
-LEFT JOIN series s ON sl.series = s.id
-WHERE s.name = ?" `[,series])))
-
-(defun calibre-db--get-format-books (format)
-  "Return the id's of books available in FORMAT."
-  (flatten-list (sqlite-select (calibre--db)
-                               "SELECT book
-FROM data
-WHERE format = ?" `[,format])))
-
-(defun calibre-composite-filter-p (object)
-  "Return t if OBJECT is a composite filter."
-  (and (vectorp object) (length= object 2) (listp (elt object 1))))
+(defconst calibre-library-buffer "*Library*")
 
-(defun calibre--get-filter-items (filter)
-  "Return the id's of books matching FILTER."
-  (if (calibre-composite-filter-p filter)
-      (seq-let (op filters) filter
-        (cl-reduce (if (eq op '+)
-                       #'cl-union
-                     #'cl-intersection)
-                    (mapcar (lambda (f)
-                             (calibre--get-filter-items (vconcat `[,op] f)))
-                           filters)))
-    (seq-let (_ field value) filter
-      (cl-case field
-        (author (calibre-db--get-author-books value))
-        (tag (calibre-db--get-tag-books value))
-        (publisher (calibre-db--get-publisher-books value))
-        (series (calibre-db--get-series-books value))
-        (format (calibre-db--get-format-books value))))))
-
-(defun calibre-library--filter (filters books)
-  "Return those books in BOOKS that match FILTERS.
-FILTERS should be a list of vectors, for the exact contents see
-`calibre-virtual-libraries'."
-  (let* ((include (cl-remove-if-not (lambda (f) (eq (elt f 0) '+)) filters))
-         (exclude (cl-remove-if-not (lambda (f) (eq (elt f 0) '-)) filters))
-         (include-ids (when include
-                        (cl-reduce #'cl-intersection
-                                   (mapcar #'calibre--get-filter-items 
include))))
-         (exclude-ids (when exclude
-                        (cl-reduce #'cl-union
-                                   (mapcar #'calibre--get-filter-items 
exclude)))))
-    (cl-remove-if (lambda (b)
-                    (seq-find (lambda (id)
-                                (= id (calibre-book-id b)))
-                              exclude-ids))
-                  (if include-ids
-                      (cl-remove-if-not (lambda (b)
-                                      (seq-find (lambda (id)
-                                                  (= id (calibre-book-id b)))
-                                                include-ids))
-                                        books)
-                    books))))
+(defmacro calibre-core--interface (function &rest args)
+  "Determine which interface to call FUNCTION from.
+ARGS are arguments to pass to FUNCTION.  The functions
+calibre-db--FUNCTION and calibre-cli--FUNCTION must exist."
+  (let ((interface (if (and (fboundp 'sqlite-available-p) (sqlite-available-p))
+                       'calibre-db
+                     'calibre-cli)))
+    `(,(intern (format "%s--%s" interface function)) ,@args)))
 
 (defvar calibre--books nil)
 (defun calibre--books (&optional force)
   "Return the in memory list of books.
 If FORCE is non-nil the list is refreshed from the database."
   (when (or force (not calibre--books))
-    (setf calibre--books (calibre-db--get-books)))
+    (setf calibre--books (calibre-core--interface get-books)))
   calibre--books)
 
 (defvar calibre-library--filters nil)
-
 (defun calibre-library-clear-filters ()
   "Clear all active filters."
   (interactive)
@@ -241,6 +54,12 @@ If FORCE is non-nil the list is refreshed from the 
database."
 
 (defvar calibre--library nil
   "The active library.")
+(defun calibre--library ()
+  "Return the active library.
+If no library is active, prompt the user to select one."
+  (unless calibre--library
+    (calibre-select-library))
+  (alist-get calibre--library calibre-libraries nil nil #'string=))
 
 (defun calibre-select-library (&optional library)
   "Prompt the user to select a library from `calibre-libraries'.
@@ -258,14 +77,6 @@ If LIBRARY is non-nil, select that instead."
         calibre--books nil)
   (calibre-library--refresh t))
 
-(defun calibre--library ()
-  "Return the active library.
-If no library is active, prompt the user to select one."
-  (unless calibre--library
-    (calibre-select-library))
-  (alist-get calibre--library calibre-libraries nil nil #'string=))
-
-(defconst calibre-library-buffer "*Library*")
 (defun calibre-library--refresh (&optional force)
   "Refresh the contents of the library buffer.
 If FORCE is non-nil fetch book data from the database."
@@ -388,5 +199,99 @@ BOOK is a `calibre-book'."
                       path
                       (format "%s.%s" file-name format))))
 
-(provide 'calibre-db)
-;;; calibre-db.el ends here
+(defun calibre-composite-filter-p (object)
+  "Return t if OBJECT is a composite filter."
+  (and (vectorp object) (length= object 2) (listp (elt object 1))))
+
+(defun calibre--get-filter-items (filter)
+  "Return the id's of books matching FILTER."
+  (if (calibre-composite-filter-p filter)
+      (seq-let (op filters) filter
+        (cl-reduce (if (eq op '+)
+                       #'cl-union
+                     #'cl-intersection)
+                    (mapcar (lambda (f)
+                             (calibre--get-filter-items (vconcat `[,op] f)))
+                           filters)))
+    (seq-let (_ field value) filter
+      (cl-case field
+        (author (calibre-core--interface get-author-books value))
+        (tag (calibre-core--interface get-tag-books value))
+        (publisher (calibre-core--interface get-publisher-books value))
+        (series (calibre-core--interface get-series-books value))
+        (format (calibre-core--interface get-format-books value))))))
+
+(defun calibre-library--filter (filters books)
+  "Return those books in BOOKS that match FILTERS.
+FILTERS should be a list of vectors, for the exact contents see
+`calibre-virtual-libraries'."
+  (let* ((include (cl-remove-if-not (lambda (f) (eq (elt f 0) '+)) filters))
+         (exclude (cl-remove-if-not (lambda (f) (eq (elt f 0) '-)) filters))
+         (include-ids (when include
+                        (cl-reduce #'cl-intersection
+                                   (mapcar #'calibre--get-filter-items 
include))))
+         (exclude-ids (when exclude
+                        (cl-reduce #'cl-union
+                                   (mapcar #'calibre--get-filter-items 
exclude)))))
+    (cl-remove-if (lambda (b)
+                    (seq-find (lambda (id)
+                                (= id (calibre-book-id b)))
+                              exclude-ids))
+                  (if include-ids
+                      (cl-remove-if-not (lambda (b)
+                                      (seq-find (lambda (id)
+                                                  (= id (calibre-book-id b)))
+                                                include-ids))
+                                        books)
+                    books))))
+
+(defun calibre-core--get-authors ()
+  "Return a list of the authors in the active library."
+  (calibre-core--interface get-authors))
+
+(defun calibre-core--get-tags ()
+  "Return a list of the tags in the active library."
+  (calibre-core--interface get-tags))
+
+(defun calibre-core--get-formats ()
+  "Return a list of the file formats stored in the active library."
+  (calibre-core--interface get-formats))
+
+(defun calibre-core--get-series ()
+  "Return a list of the series in the active library."
+  (calibre-core--interface get-series))
+
+(defun calibre-core--get-publishers ()
+  "Return a list of the publishers in the active library."
+  (calibre-core--interface get-publishers))
+
+
+;; These functions should be in calibre-cli.el, but they require
+;; calibre--books because the calibredb interface does not expose the
+;; ability get this information.
+(defun calibre-cli--get-authors ()
+  "Return a list of the authors in the active library."
+  (cl-reduce #'cl-union (mapcar #'calibre-book-authors (calibre--books))))
+
+(defun calibre-cli--get-tags ()
+  "Return a list of the tags in the active library."
+  (cl-reduce #'cl-union (mapcar #'calibre-book-tags (calibre--books))))
+
+(defun calibre-cli--get-formats ()
+  "Return a list of the file formats stored in the active library."
+  (cl-reduce #'cl-union (mapcar #'calibre-book-formats (calibre--books))))
+
+(defun calibre-cli--get-series ()
+  "Return a list of the series in the active library."
+  (remq nil (cl-remove-duplicates
+            (mapcar #'calibre-book-series (calibre--books))
+            :test #'string=)))
+
+(defun calibre-cli--get-publishers ()
+  "Return a list of the publishers in the active library."
+  (remq nil (cl-remove-duplicates
+            (mapcar #'calibre-book-publisher (calibre--books))
+            :test #'string=)))
+
+(provide 'calibre-core)
+;;; calibre-core.el ends here
diff --git a/calibre-db.el b/calibre-db.el
index f5af9f2833..345b9fd36b 100644
--- a/calibre-db.el
+++ b/calibre-db.el
@@ -177,216 +177,5 @@ WHERE s.name = ?" `[,series])))
 FROM data
 WHERE format = ?" `[,format])))
 
-(defun calibre-composite-filter-p (object)
-  "Return t if OBJECT is a composite filter."
-  (and (vectorp object) (length= object 2) (listp (elt object 1))))
-
-(defun calibre--get-filter-items (filter)
-  "Return the id's of books matching FILTER."
-  (if (calibre-composite-filter-p filter)
-      (seq-let (op filters) filter
-        (cl-reduce (if (eq op '+)
-                       #'cl-union
-                     #'cl-intersection)
-                    (mapcar (lambda (f)
-                             (calibre--get-filter-items (vconcat `[,op] f)))
-                           filters)))
-    (seq-let (_ field value) filter
-      (cl-case field
-        (author (calibre-db--get-author-books value))
-        (tag (calibre-db--get-tag-books value))
-        (publisher (calibre-db--get-publisher-books value))
-        (series (calibre-db--get-series-books value))
-        (format (calibre-db--get-format-books value))))))
-
-(defun calibre-library--filter (filters books)
-  "Return those books in BOOKS that match FILTERS.
-FILTERS should be a list of vectors, for the exact contents see
-`calibre-virtual-libraries'."
-  (let* ((include (cl-remove-if-not (lambda (f) (eq (elt f 0) '+)) filters))
-         (exclude (cl-remove-if-not (lambda (f) (eq (elt f 0) '-)) filters))
-         (include-ids (when include
-                        (cl-reduce #'cl-intersection
-                                   (mapcar #'calibre--get-filter-items 
include))))
-         (exclude-ids (when exclude
-                        (cl-reduce #'cl-union
-                                   (mapcar #'calibre--get-filter-items 
exclude)))))
-    (cl-remove-if (lambda (b)
-                    (seq-find (lambda (id)
-                                (= id (calibre-book-id b)))
-                              exclude-ids))
-                  (if include-ids
-                      (cl-remove-if-not (lambda (b)
-                                      (seq-find (lambda (id)
-                                                  (= id (calibre-book-id b)))
-                                                include-ids))
-                                        books)
-                    books))))
-
-(defvar calibre--books nil)
-(defun calibre--books (&optional force)
-  "Return the in memory list of books.
-If FORCE is non-nil the list is refreshed from the database."
-  (when (or force (not calibre--books))
-    (setf calibre--books (calibre-db--get-books)))
-  calibre--books)
-
-(defvar calibre-library--filters nil)
-
-(defun calibre-library-clear-filters ()
-  "Clear all active filters."
-  (interactive)
-  (setf calibre-library--filters nil)
-  (calibre-library--refresh))
-
-(defvar calibre--library nil
-  "The active library.")
-
-(defun calibre-select-library (&optional library)
-  "Prompt the user to select a library from `calibre-libraries'.
-If LIBRARY is non-nil, select that instead."
-  (interactive)
-  (unless calibre-libraries
-    (error "No Libraries defined"))
-  (setf calibre--library (if library
-                             library
-                           (let ((names (calibre--library-names)))
-                             (if (not (length> names 1))
-                               (car names)
-                             (completing-read "Library: " names nil t))))
-        calibre--db nil
-        calibre--books nil)
-  (calibre-library--refresh t))
-
-(defun calibre--library ()
-  "Return the active library.
-If no library is active, prompt the user to select one."
-  (unless calibre--library
-    (calibre-select-library))
-  (alist-get calibre--library calibre-libraries nil nil #'string=))
-
-(defconst calibre-library-buffer "*Library*")
-(defun calibre-library--refresh (&optional force)
-  "Refresh the contents of the library buffer.
-If FORCE is non-nil fetch book data from the database."
-  (let ((buffer (get-buffer calibre-library-buffer)))
-    (when buffer
-      (with-current-buffer buffer
-        (let ((book (tabulated-list-get-id)))
-          (calibre-with-preserved-marks (not force)
-            (setf tabulated-list-entries
-                  (mapcar #'calibre-book--print-info
-                          (calibre-library--filter calibre-library--filters
-                                                   (calibre--books force))))
-            (tabulated-list-print)
-            (if book
-                (calibre-library--find-book book)
-              (goto-char (point-max)))))))))
-
-(defun calibre-library--set-header ()
-  "Set the header of the Library buffer."
-  (let ((buffer (get-buffer calibre-library-buffer)))
-    (when buffer
-      (with-current-buffer buffer
-        (setf tabulated-list-format (calibre-library--header-format))
-        (tabulated-list-init-header)))))
-
-(defcustom calibre-library-time-format "%x"
-  "String specifying format for displaying time related metadata.
-See `format-time-string' for an explanation of how to write this
-string."
-  :type 'string
-  :set (lambda (symbol value)
-         (set-default symbol value)
-         (calibre-library--refresh))
-  :group 'calibre
-  :package-version '("calibre" . "1.1.0"))
-
-(defcustom calibre-library-columns '((id . 4)
-                                     (title . 35)
-                                     (authors . 20)
-                                     (publisher . 10)
-                                     (series . 15)
-                                     (series-index . 3)
-                                     (tags . 10)
-                                     (formats . 10))
-  "The metadata fields to display in the library buffer.
-Each entry is a key identifying a metadata field and the width that
-column should have."
-  :type '(repeat (cons
-                  :tag "Column"
-                  (choice
-                   :tag "Attribute"
-                   (const :tag "ID" id)
-                   (const :tag "Title" title)
-                   (const :tag "Author(s)" authors)
-                   (const :tag "Publisher(s)" publisher)
-                   (const :tag "Series" series)
-                   (const :tag "Series Index" series-index)
-                   (const :tag "Tags" tags)
-                   (const :tag "Formats" formats)
-                   (const :tag "Publication date" pubdate))
-                  (integer :tag "Width")))
-  :set (lambda (symbol value)
-         (set-default symbol value)
-         (calibre-library--set-header)
-         (calibre-library--refresh))
-  :package-version '("calibre" . "1.1.0")
-  :group 'calibre)
-
-(defun calibre-library--header-format ()
-  "Create the header for the Library buffer.
-Return a vector suitable as the value of `tabulated-list-format'
-with values determined by `calibre-library-columns'."
-  (vconcat
-   (mapcar (lambda (x)
-             (let ((column (car x))
-                   (width (cdr x)))
-               (cl-case column
-                 (id `("ID" ,width (lambda (a b)
-                                     (< (calibre-book-id (car a))
-                                        (calibre-book-id (car b))))
-                       :right-align t))
-                 (title `("Title" ,width t))
-                 (authors `("Author(s)" ,width t))
-                 (publisher `("Publisher" ,width t))
-                 (series `("Series" ,width (lambda (a b)
-                                             (calibre-book-sort-by-series (car 
a) (car b)))))
-                 (series-index `("#" ,width (lambda (a b)
-                                              (calibre-book-sort-by-series 
(car a) (car b)))
-                                 :right-align t))
-                 (tags `("Tags" ,width))
-                 (formats `("Formats" ,width))
-                 (pubdate `("Publication Date" ,width (lambda (a b)
-                                                        (time-less-p 
(calibre-book-pubdate (car a))
-                                                                     
(calibre-book-pubdate (car b)))))))))
-           calibre-library-columns)))
-
-(defun calibre-book--print-info (book)
-  "Return list suitable as a value of `tabulated-list-entries'.
-BOOK is a `calibre-book'."
-  (list book
-        (with-slots (id title authors publisher series series-index tags 
formats pubdate) book
-          (vconcat (mapcar (lambda (x)
-                             (let ((column (car x)))
-                               (cl-case column
-                                 (id (int-to-string id))
-                                 (title title)
-                                 (authors (string-join authors ", "))
-                                 (publisher (if (not publisher) "" publisher))
-                                 (series (if (not series) "" series))
-                                 (series-index (if series (format "%.1f" 
series-index) ""))
-                                 (tags (string-join tags ", "))
-                                 (formats (string-join (mapcar (lambda (f) 
(upcase (symbol-name f))) formats) ", "))
-                                 (pubdate (format-time-string 
calibre-library-time-format pubdate)))))
-                           calibre-library-columns)))))
-
-(defun calibre-book--file (book format)
-  "Return the path to BOOK in FORMAT."
-  (with-slots (path file-name) book
-    (file-name-concat (calibre--library)
-                      path
-                      (format "%s.%s" file-name format))))
-
 (provide 'calibre-db)
 ;;; calibre-db.el ends here
diff --git a/calibre-edit.el b/calibre-edit.el
index 8145726344..fc7e1802ef 100644
--- a/calibre-edit.el
+++ b/calibre-edit.el
@@ -19,7 +19,7 @@
 
 ;;; Code:
 (require 'eieio-custom)
-(require 'calibre-db)
+(require 'calibre-core)
 (require 'calibre-util)
 (require 'calibre-exec)
 
diff --git a/calibre-exec.el b/calibre-exec.el
index aa34a84123..39fd847c12 100644
--- a/calibre-exec.el
+++ b/calibre-exec.el
@@ -24,7 +24,7 @@
 ;;; Code:
 (eval-when-compile (require 'cl-macs))
 
-(require 'calibre-db)
+(require 'calibre-core)
 
 (defvar calibre-exec--commands nil)
 (defvar calibre-exec--executing nil)
diff --git a/calibre-search.el b/calibre-search.el
index f67e93db9f..16c374abb2 100644
--- a/calibre-search.el
+++ b/calibre-search.el
@@ -22,7 +22,7 @@
 
 ;;; Code:
 (require 'transient)
-(require 'calibre-db)
+(require 'calibre-core)
 
 (defmacro calibre-search--choice-function (field &optional an plural)
   "Create a function to prompt the user to select a value for FIELD.
@@ -41,7 +41,7 @@ will not be appended to the calibre-db--get-FIELD function's 
name."
      ,(format "Prompt the user to select %s %s" (if an "an" "a") field)
      (interactive)
      (completing-read ,(format "%s: " (capitalize field))
-                      (,(intern (format "calibre-db--get-%s%s"
+                      (,(intern (format "calibre-core--get-%s%s"
                                         field
                                         (if plural "" "s")))))))
 
diff --git a/calibre-virtual-library.el b/calibre-virtual-library.el
index ad60178eb9..fc9da4ee5e 100644
--- a/calibre-virtual-library.el
+++ b/calibre-virtual-library.el
@@ -22,7 +22,7 @@
 ;; virtual library is a named set of predefined search filters.
 
 ;;; Code:
-(require 'calibre-db)
+(require 'calibre-core)
 
 (defcustom calibre-virtual-libraries nil
   "A list of predefined filters, i.e. Virtual Libraries.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]