From e960c2d7175572dc12e49c7c116cf7ea78c2b126 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Thu, 5 Oct 2017 01:05:47 -0600 Subject: [PATCH] Implement note creation --- itemmanager.py | 14 ++++++++++++++ sn-fs.py | 11 ++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/itemmanager.py b/itemmanager.py index 2506dab..b8f3708 100644 --- a/itemmanager.py +++ b/itemmanager.py @@ -1,4 +1,5 @@ from api import StandardNotesAPI +from uuid import uuid1 class ItemManager: items = {} @@ -65,6 +66,19 @@ class ItemManager: item['dirty'] = True self.syncItems() + def createNote(self, name, time): + uuid = str(uuid1()) + content = dict(title=name, text='', references=[]) + self.items[uuid] = dict(content_type='Note', + dirty=True, + auth_hash=None, + uuid=uuid, + created_at=time, + updated_at=time, + enc_item_key='', + content=content) + return 0 + def __init__(self, username, password): self.standard_notes = StandardNotesAPI(username, password) self.syncItems() diff --git a/sn-fs.py b/sn-fs.py index 8c76085..691da2c 100644 --- a/sn-fs.py +++ b/sn-fs.py @@ -79,13 +79,18 @@ class StandardNotesFS(LoggingMixIn, Operations): return len(data) - def chmod(self, path, mode): + def create(self, path, mode): + path_parts = path.split('/') + note_name = path_parts[1] + now = datetime.utcnow().isoformat()[:-3] + 'Z' # hack + + self.item_manager.createNote(note_name, now) return 0 - def chown(self, path, uid, gid): + def chmod(self, path, mode): return 0 - def create(self, path, mode): + def chown(self, path, uid, gid): return 0 def destroy(self, path):