-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add proper parsing for missing note attributes
- Loading branch information
Showing
10 changed files
with
116 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import hashlib | ||
from dataclasses import dataclass | ||
from datetime import datetime | ||
from typing import List | ||
|
||
|
||
@dataclass(frozen=True) | ||
class EvernoteResource(object): | ||
data_bin: bytes | ||
size: int | ||
md5: str | ||
mime: str | ||
file_name: str | ||
|
||
|
||
@dataclass | ||
class EvernoteNote(object): | ||
title: str | ||
created: datetime | ||
updated: datetime | ||
content: str # noqa: WPS110 | ||
tags: List[str] | ||
author: str | ||
url: str | ||
is_webclip: bool | ||
resources: List[EvernoteResource] | ||
_note_hash: str = None | ||
|
||
def resource_by_md5(self, md5): | ||
for resource in self.resources: | ||
if resource.md5 == md5: | ||
return resource | ||
return None | ||
|
||
@property | ||
def note_hash(self): | ||
if self._note_hash is None: | ||
hashable = [ | ||
self.title, | ||
self.created.isoformat(), | ||
self.updated.isoformat(), | ||
self.content, | ||
"".join(self.tags), | ||
self.author, | ||
self.url, | ||
] | ||
|
||
s1_hash = hashlib.sha1() | ||
for h in hashable: | ||
s1_hash.update(h.encode("utf-8")) | ||
self._note_hash = s1_hash.hexdigest() # noqa: WPS601 | ||
|
||
return self._note_hash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters