From 82cded334a6218e0cc9d2bb0ee0ba239e8d34184 Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Sun, 2 Oct 2022 14:41:10 -0400 Subject: [PATCH] Added readme --- Main.py | 16 ++++++++------- README.md | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 7 deletions(-) create mode 100644 README.md diff --git a/Main.py b/Main.py index cc74c2a..6cab320 100644 --- a/Main.py +++ b/Main.py @@ -177,18 +177,14 @@ def export_to_onenote(simplenotes, onenote_mgr, chosen_notebook=None, chosen_sec print("Section not found for '%s'" % (chosen_section)) return + config = onenote_mgr.config + onenote_section = retrieve_section(onenote_sections, chosen_section) - url="https://graph.microsoft.com/v1.0/me/onenote/sections/" + onenote_section["id"] + "/pages" + url = f"{config.base_url}me/onenote/sections/" + onenote_section["id"] + "/pages" onenote_notes = onenote_mgr.get_notes(url) count = 0 - config = onenote_mgr.config - interval = config.interval - limit = config.limit - total_notes_added = 0 - bundle_notes_added = 0 - for note in onenote_notes["value"]: count += 1 @@ -196,6 +192,11 @@ def export_to_onenote(simplenotes, onenote_mgr, chosen_notebook=None, chosen_sec print("Note not foudn for '%s'" % (chosen_section)) return + interval = config.interval + limit = config.limit + total_notes_added = 0 + bundle_notes_added = 0 + for note in simplenotes: if note_exists_in_onenote(note, onenote_notes): continue @@ -218,6 +219,7 @@ def export_to_onenote(simplenotes, onenote_mgr, chosen_notebook=None, chosen_sec config = load_config() onenote_mgr.config = config + onenote_notes = onenote_mgr.get_notes(url) bundle_notes_added = 0 else: diff --git a/README.md b/README.md new file mode 100644 index 0000000..139d907 --- /dev/null +++ b/README.md @@ -0,0 +1,60 @@ +# s2o + +s2o is a software utility tool to export notes from Simplenote to OneNote. This software exports notes from Simplenote and creates notes in a specific notebook and section. Once the note has been created, the note is deleted from Simplenote. + + +## Configuration + +```JSON +{ + "token": "some_token", + "secret": "some secret", + "app_id": "sdf348thg348fh3f", + "mode": "token", + "scopes": ["Create", "Read"], + "authority_url": "https://some-link.com", + "base_url": "https://some-other-link.com", + "limit": 100, + "interval": 300, + "vendors": { + "simplenote": { + "username": "me", + "password": "who", + "source_notebook": "", + "source_section": "" + }, + "onenote": { + "username": "", + "password": "", + "target_notebook": "New notebook", + "target_section": "New Section" + } + } +} +``` + +* `token` - Access token used for making OneNote requests. This token will be used if the `mode` is token +* `secret` - The secret phrase when creating the App from Microsoft dev platform +* `app_id` - The application ID when creating the App from Microsoft dev platform +* `mode` - Mode that determines how a token will be retrieved. Supported modes are *token input* and *token*. *token input* will require you to provide the token via the shell. *token* will use the value specified in the `token` field +* `scopes` - Requested scope actions +* `authority_url` - URL for authorization +* `base_url` - Base URL for Microsoft Graph API +* `limit` - The limit in which notes can be exported before sleeping. This is used to prevent too many requests in a short period of time which results in a denial of service +* `interval` - Time in seconds to sleep after a certain amount of notes have been exported. The amount is specified by the `limit` field +* `vendors` - Suported vendors + * `simplenote:username` - Username of the Simplenote account + * `simplenote:password` - Password of the Simplenote account + * `simplenote:source_notebook` - Not used + * `simplenote:source_section` - Not used + * `onenote:username` - Not used + * `onenote:password` - Not used + * `onenote:target_notebook` - Target notebook to save notes from Simplenote + * `onenote:target_section` -- Target section to save notes from Simplenote + + +## Usages + +```BASH +python main.py [path to config.json] +``` \ No newline at end of file