Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
Signed-off-by: Timur Demin <me@tdem.in>
  • Loading branch information
tdemin committed Apr 8, 2019
0 parents commit 788b853
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 0 deletions.
Empty file added .gitignore
Empty file.
3 changes: 3 additions & 0 deletions .vscode/settings.json
@@ -0,0 +1,3 @@
{
"files.insertFinalNewline": true
}
19 changes: 19 additions & 0 deletions 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.
61 changes: 61 additions & 0 deletions 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)
8 changes: 8 additions & 0 deletions 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
19 changes: 19 additions & 0 deletions 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',
]
)

0 comments on commit 788b853

Please sign in to comment.