Coverage for src/zettel/notes.py: 100%

1 from pathlib import Path

2

3 class Note():

4 def __init__(self, path):

5 try:

6 with open(path, 'r') as f:

7 content = f.read()

8 self.content = content

9 except UnicodeDecodeError as err:

10 self.content = str(err)

11 self.path = Path(path)

12 self.id = self.path.stem

13 self.title = self.content.partition('\n')[0].replace('# ', '')

14

15 def __repr__(self) -> str:

16 return f'[{self.id}] {self.title}'