Skip to content

Commit 3ff2de2

Browse files
committed
🔖 Release 0.3.5
Resolves a case for an infinite loop (it blew up my own Authors database). Essentially, try the no-op `from_bib.create_author` instead of error-handling to `create_author` in the event `fuzzywuzzy` can't extract suitable author.
1 parent 8711109 commit 3ff2de2

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

paperpile_notion/from_bib.py

+8-9
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,14 @@ def create_author(ctx: click.Context, author: str) -> None:
5050

5151
def _get_author_notionID(ctx: click.Context, author: str) -> Dict:
5252
authors = ctx.obj["authors"]
53-
extract = process.extractOne(author, authors.keys(), **_extractOne)
54-
while extract is None:
55-
try:
56-
create_author(ctx, author)
57-
except:
58-
print(author)
59-
print(asdict(Author(author)))
53+
try:
54+
# Essentially a no-op, so it sidesteps error-handling
55+
create_author(ctx, author)
6056
extract = process.extractOne(author, authors.keys(), **_extractOne)
61-
62-
return {"id": authors[extract[0]]["notionID"]}
57+
return {"id": authors[extract[0]]["notionID"]}
58+
except: # Too many possible errors
59+
# Cut our losses to avoid blowing up the Author database.
60+
return None
6361

6462

6563
def create_article(ctx: click.Context, entry: Dict) -> None:
@@ -72,6 +70,7 @@ def create_article(ctx: click.Context, entry: Dict) -> None:
7270
if authors:
7371
_lookup = partial(_get_author_notionID, ctx=ctx)
7472
entry["Authors"] = [_lookup(author=author) for author in entry["Authors"]]
73+
entry["Authors"] = list(filter(lambda x: type(x) == dict, entry["Authors"]))
7574

7675
l_entry = models.from_props(ctx.obj["articles-cls"], entry)
7776
kwargs = {"properties": asdict(l_entry)}

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "paperpile-notion"
3-
version = "0.3.3"
3+
version = "0.3.5"
44
description = "Sync Notion with Paperpile"
55
authors = ["J Muchovej <5000729+jmuchovej@users.noreply.github.com>"]
66
license = "MIT"

0 commit comments

Comments
 (0)