-
Notifications
You must be signed in to change notification settings - Fork 0
/
notebook.py
47 lines (43 loc) · 1.22 KB
/
notebook.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
40
41
42
43
44
45
46
47
"""
Notebook
"""
import note
class Notebook:
"""
Notebook main class
"""
notes = []
def new_note(self, memo: str, tags=''):
"""
Create a new note.
"""
tags = tags.split(', ')
new_note = note.Note(memo, tags)
self.notes.append(new_note)
def search(self, s_filter: str)-> list:
"""
Search note by tags
"""
possible_notes = []
for note1 in self.notes:
if s_filter in note1.tags:
note_id = self.notes.index(note1)
possible_notes.append((note_id, note1.memo))
return possible_notes
def modify_memo(self, note_id, memo):
"""
Modify memo to the note with note id
"""
note_id = int(note_id)
if note_id > len(self.notes):
return "There is no such id"
self.notes[note_id].memo = memo
def modify_tags(self, note_id, tags):
"""
Modify tags to the note with note id
"""
note_id = int(note_id)
if note_id > len(self.notes):
return "There is no such id"
tags = tags.split(', ')
self.notes[note_id].tags = tags