From 35f0b7326f8d64693e99a47ac2bce5dc55e9f17b Mon Sep 17 00:00:00 2001 From: Timur Demin Date: Tue, 16 Jul 2019 20:25:20 +0500 Subject: [PATCH] Update the script for older versions of Scarlet --- scarlet_export/__init__.py | 6 ++++-- scarlet_export/note.py | 9 +++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/scarlet_export/__init__.py b/scarlet_export/__init__.py index f88a8af..a491b44 100644 --- a/scarlet_export/__init__.py +++ b/scarlet_export/__init__.py @@ -62,8 +62,10 @@ def main(): for tag in data['tags']: tags[tag['uuid']] = tag['title'] folders = {} - for folder in data['folders']: - folders[folder['uuid']] = folder['title'] + # folders are only available in Scarlet v6 and later + if 'folders' in data: + for folder in data['folders']: + folders[folder['uuid']] = folder['title'] for note in data['notes']: parsedNote = Note(note, tags, folders) notes.append(parsedNote) diff --git a/scarlet_export/note.py b/scarlet_export/note.py index 7aa9474..47369d7 100644 --- a/scarlet_export/note.py +++ b/scarlet_export/note.py @@ -13,10 +13,11 @@ class Note: """ def __init__(self, note, tags, folders): self.uuid = note['uuid'] - if note['folder'] != '': - self.folder = folders[note['folder']] - else: - self.folder = '' + # folders are only available since Scarlet v6 + if 'folder' in note: + if note['folder'] != '': + self.folder = folders[note['folder']] + else: self.folder = '' self.updateTimestamp = int(note['updateTimestamp']) self.timestamp = int(note['timestamp']) self.tags = []