summarylogtreecommitdiffstats
path: root/b8ce11c08dc32051545e73e858f0cd044ac12ef2.patch
blob: cedf1ed357342dfcf7851fa82dc4e32469580dbf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
From b8ce11c08dc32051545e73e858f0cd044ac12ef2 Mon Sep 17 00:00:00 2001
From: Alexandru Fikl <alexfikl@gmail.com>
Date: Sun, 3 May 2020 10:51:49 -0500
Subject: [PATCH] add compatibility with isbnlib >= 3.10

---
 papis/isbn.py | 21 ++++++++++++---------
 setup.py      |  2 +-
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/papis/isbn.py b/papis/isbn.py
index fe137cd3..0bbfbd52 100644
--- a/papis/isbn.py
+++ b/papis/isbn.py
@@ -1,6 +1,7 @@
 import papis.document
 import logging
 import isbnlib
+import isbnlib.registry
 import click
 # See https://github.com/xlcnd/isbnlib for details
 from typing import Optional, Dict, Any, List
@@ -11,18 +12,20 @@
 def get_data(
         query: str = "",
         service: Optional[str] = None) -> List[Dict[str, Any]]:
-    global logger
-    results = []  # type: List[Dict[str, Any]]
+    isbnlib_version = tuple(int(n) for n in isbnlib.__version__.split('.'))
+    if service is None and isbnlib_version >= (3, 10, 0):
+        service = "default"
+
     logger.debug('Trying to retrieve isbn')
     isbn = isbnlib.isbn_from_words(query)
     data = isbnlib.meta(isbn, service=service)
-    if data is None:
-        return results
-    else:
-        logger.debug('Trying to retrieve isbn')
-        assert(isinstance(data, dict))
+
+    results = []  # type: List[Dict[str, Any]]
+    if data is not None:
+        assert isinstance(data, dict)
         results.append(data_to_papis(data))
-        return results
+
+    return results
 
 
 def data_to_papis(data: Dict[str, Any]) -> Dict[str, Any]:
@@ -45,7 +48,7 @@ def data_to_papis(data: Dict[str, Any]) -> Dict[str, Any]:
     '--service',
     '-s',
     default='goob',
-    type=click.Choice(['wcat', 'goob', 'openl'])
+    type=click.Choice(list(isbnlib.registry.services.keys()))
 )
 def explorer(ctx: click.core.Context, query: str, service: str) -> None:
     """
diff --git a/setup.py b/setup.py
index 65fc183c..dd136e71 100644
--- a/setup.py
+++ b/setup.py
@@ -65,7 +65,7 @@
         "bibtexparser>=0.6.2",
         "click>=7.0.0",
         "habanero>=0.6.0",
-        "isbnlib>=3.9.1,<3.10",
+        "isbnlib>=3.9.1",
         "prompt_toolkit>=2.0.5",
         "tqdm>=4.1",
         "pygments>=2.2.0",