This repository has been archived by the owner on Jan 20, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Timur Demin <me@tdem.in>
- Loading branch information
0 parents
commit 788b853
Showing
6 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"files.insertFinalNewline": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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', | ||
] | ||
) |