diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..d5d0018 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "files.insertFinalNewline": true +} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..9e25afa --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2019 Timur Demin + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/scarlet_export/__init__.py b/scarlet_export/__init__.py new file mode 100644 index 0000000..246ef87 --- /dev/null +++ b/scarlet_export/__init__.py @@ -0,0 +1,61 @@ +from argparse import ArgumentParser +from pathlib import Path +import json + +from notable import exportNotes as exportToNotable + +if __name__ == '__main__': + parser = ArgumentParser('Scarlet Notes data export program') + parser.add_argument( + '-t', dest='program', + type='str', + help='the file format the data will be exported to [notable]', + optional=True + ) + parser.add_argument( + '-o', dest='outputDirName', + type='str', + help='output directory (where the data will be saved to)', + optional=False, + ) + parser.add_argument( + 'inputFile', dest='inputFileName', + type='str', + help='input file (the .txt file from Scarlet Notes)', + optional=False + ) + args = parser.parse_args() + # check if the input file exists + inputPath = Path(args['inputFileName']) + if not inputPath.is_file(): + print('File {0} does not exist. Exiting.'.format( + args['inputFileName'] + )) + exit(1) + # create the output dir if it doesn't exist yet + outputPath = Path(args['outputDirName']) + if not outputPath.exists() and not outputPath.is_file(): + outputPath.mkdir() + else: + print('Cannot create directory {0}. Exiting.'.format( + args['outputDirName'] + )) + exit(1) + # read and parse the file as JSON + with open(args['inputFileName']) as inputFile: + try: + data = json.load(inputFile) + except json.JSONDecodeError: + print('Could not parse the input file.') + exit(1) + inputFile.close() + # currently the script only supports a single program to export the + # data to + if args['program'] == 'notable': + exportToNotable(data, args['outputDirName']) + else: + print('The program {0} is currently not supported.'.format( + args['program'] + )) + print('Exiting.') + exit(1) diff --git a/scarlet_export/notable.py b/scarlet_export/notable.py new file mode 100644 index 0000000..10f20b4 --- /dev/null +++ b/scarlet_export/notable.py @@ -0,0 +1,8 @@ +def exportNotes(inputJson, outputDir): + """ + Exports the notes from Scarlet Notes to Notable. + + @param inputJson: an object generated with `json.load()` + @param outputDir: output directory name + """ + pass diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..0cf4fe7 --- /dev/null +++ b/setup.py @@ -0,0 +1,19 @@ +from setuptools import setup + +setup( + name='scarlet_export', + version='0.1.0', + description='A Scarlet Notes data export tool', + author='Timur Demin', + author_email='me@tdem.in', + url='https://git.tdem.in/tdemin/scarlet_export', + packages=['scarlet_export'], + include_package_data=True, + license='MIT', + classifiers=[ + 'License :: OSI Approved :: MIT License', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.7', + ] +)