From edc11057e99ce2d69421f09fc5b6d94ca05b524c Mon Sep 17 00:00:00 2001 From: neodarz Date: Sun, 29 Sep 2019 19:17:49 +0200 Subject: Add function for removing an article --- README.md | 2 +- db.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1c36593..d34e6bf 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Fonctionalities: [X] Get all articles [ ] Get `n` articles from a range [ ] Add an article - [ ] Delete an article + [X] Delete an article [ ] Edit an article [X] Import from shaarli 0.11 [ ] Search diff --git a/db.py b/db.py index 3fc7c6f..cb280d8 100644 --- a/db.py +++ b/db.py @@ -99,3 +99,12 @@ def bookmarks(path): for name in files: bookmarks.append(bookmark(path / Path(name))) return bookmarks + + +def remove(path): + path = Path(path) + try: + os.remove(path) + logging.info("{} removed".format(path.name)) + except FileNotFoundError: + logging.warning("{} doesn't exist!".format(path.name)) -- cgit v1.2.1