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

14 statements  

« prev     ^ index     » next       coverage.py v6.4.4, created at 2022-09-14 19:38 -0500

1from pathlib import Path 

2 

3class 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}'