Skip to content

Commit

Permalink
🔖 Release 0.3.5
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jmuchovej committed Sep 7, 2021
1 parent 8711109 commit 3ff2de2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
17 changes: 8 additions & 9 deletions paperpile_notion/from_bib.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,14 @@ def create_author(ctx: click.Context, author: str) -> None:

def _get_author_notionID(ctx: click.Context, author: str) -> Dict:
authors = ctx.obj["authors"]
extract = process.extractOne(author, authors.keys(), **_extractOne)
while extract is None:
try:
create_author(ctx, author)
except:
print(author)
print(asdict(Author(author)))
try:
# Essentially a no-op, so it sidesteps error-handling
create_author(ctx, author)
extract = process.extractOne(author, authors.keys(), **_extractOne)

return {"id": authors[extract[0]]["notionID"]}
return {"id": authors[extract[0]]["notionID"]}
except: # Too many possible errors
# Cut our losses to avoid blowing up the Author database.
return None


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

l_entry = models.from_props(ctx.obj["articles-cls"], entry)
kwargs = {"properties": asdict(l_entry)}
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "paperpile-notion"
version = "0.3.3"
version = "0.3.5"
description = "Sync Notion with Paperpile"
authors = ["J Muchovej <[email protected]>"]
license = "MIT"
Expand Down

0 comments on commit 3ff2de2

Please sign in to comment.