-
Notifications
You must be signed in to change notification settings - Fork 0
/
note.py
39 lines (33 loc) · 1.12 KB
/
note.py
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
from base import Base
from stringb import String
class Values:
def __init__(self):
self.importance = 100
class Note(Base):
def __init__(self, content, container=None):
super().__init__()
assert isinstance(content, (str, String))
self.content = String(content)
self.container = container
self.hash = hash(self.content)
self.ratings = Values()
self.importance = self.ratings.importance
self.terms = []
self.tags = []
def changed(self):
super().changed()
self.importance = self.ratings.importance
self.length = self.content.length
self.words = self.content.tokens
return self
def upgrade(self):
super().upgrade(self.content)
self.importance = self.ratings.importance
if isinstance(self.content, str):
self.content = String(self.content)
self.changed()
return self
def similar(self, **kwargs):
return self.container.similar(self, **kwargs)
def __str__(self):
return f'{self.content.truncate()} [{self.timestamp.color("cyan")}]'