Browse Source

Initial commit

Signed-off-by: Timur Demin <me@tdem.in>
tags/v0.1.0
Timur Demin 3 months ago
commit
788b853bdc
Signed by: Timur Demin <me@tdem.in> GPG Key ID: 9EDF3F9D9286FA20
6 changed files with 110 additions and 0 deletions
  1. 0
    0
      .gitignore
  2. 3
    0
      .vscode/settings.json
  3. 19
    0
      LICENSE
  4. 61
    0
      scarlet_export/__init__.py
  5. 8
    0
      scarlet_export/notable.py
  6. 19
    0
      setup.py

+ 0
- 0
.gitignore View File


+ 3
- 0
.vscode/settings.json View File

@@ -0,0 +1,3 @@
1
+{
2
+    "files.insertFinalNewline": true
3
+}

+ 19
- 0
LICENSE View File

@@ -0,0 +1,19 @@
1
+Copyright (c) 2019 Timur Demin
2
+
3
+Permission is hereby granted, free of charge, to any person obtaining a copy
4
+of this software and associated documentation files (the "Software"), to deal
5
+in the Software without restriction, including without limitation the rights
6
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+copies of the Software, and to permit persons to whom the Software is
8
+furnished to do so, subject to the following conditions:
9
+
10
+The above copyright notice and this permission notice shall be included in all
11
+copies or substantial portions of the Software.
12
+
13
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+SOFTWARE.

+ 61
- 0
scarlet_export/__init__.py View File

@@ -0,0 +1,61 @@
1
+from argparse import ArgumentParser
2
+from pathlib import Path
3
+import json
4
+
5
+from notable import exportNotes as exportToNotable
6
+
7
+if __name__ == '__main__':
8
+    parser = ArgumentParser('Scarlet Notes data export program')
9
+    parser.add_argument(
10
+        '-t', dest='program',
11
+        type='str',
12
+        help='the file format the data will be exported to [notable]',
13
+        optional=True
14
+    )
15
+    parser.add_argument(
16
+        '-o', dest='outputDirName',
17
+        type='str',
18
+        help='output directory (where the data will be saved to)',
19
+        optional=False,
20
+    )
21
+    parser.add_argument(
22
+        'inputFile', dest='inputFileName',
23
+        type='str',
24
+        help='input file (the .txt file from Scarlet Notes)',
25
+        optional=False
26
+    )
27
+    args = parser.parse_args()
28
+    # check if the input file exists
29
+    inputPath = Path(args['inputFileName'])
30
+    if not inputPath.is_file():
31
+        print('File {0} does not exist. Exiting.'.format(
32
+            args['inputFileName']
33
+        ))
34
+        exit(1)
35
+    # create the output dir if it doesn't exist yet
36
+    outputPath = Path(args['outputDirName'])
37
+    if not outputPath.exists() and not outputPath.is_file():
38
+        outputPath.mkdir()
39
+    else:
40
+        print('Cannot create directory {0}. Exiting.'.format(
41
+            args['outputDirName']
42
+        ))
43
+        exit(1)
44
+    # read and parse the file as JSON
45
+    with open(args['inputFileName']) as inputFile:
46
+        try:
47
+            data = json.load(inputFile)
48
+        except json.JSONDecodeError:
49
+            print('Could not parse the input file.')
50
+            exit(1)
51
+    inputFile.close()
52
+    # currently the script only supports a single program to export the
53
+    # data to
54
+    if args['program'] == 'notable':
55
+        exportToNotable(data, args['outputDirName'])
56
+    else:
57
+        print('The program {0} is currently not supported.'.format(
58
+            args['program']
59
+        ))
60
+        print('Exiting.')
61
+        exit(1)

+ 8
- 0
scarlet_export/notable.py View File

@@ -0,0 +1,8 @@
1
+def exportNotes(inputJson, outputDir):
2
+    """
3
+    Exports the notes from Scarlet Notes to Notable.
4
+
5
+    @param inputJson: an object generated with `json.load()`
6
+    @param outputDir: output directory name
7
+    """
8
+    pass

+ 19
- 0
setup.py View File

@@ -0,0 +1,19 @@
1
+from setuptools import setup
2
+
3
+setup(
4
+    name='scarlet_export',
5
+    version='0.1.0',
6
+    description='A Scarlet Notes data export tool',
7
+    author='Timur Demin',
8
+    author_email='me@tdem.in',
9
+    url='https://git.tdem.in/tdemin/scarlet_export',
10
+    packages=['scarlet_export'],
11
+    include_package_data=True,
12
+    license='MIT',
13
+    classifiers=[
14
+        'License :: OSI Approved :: MIT License',
15
+        'Programming Language :: Python',
16
+        'Programming Language :: Python :: 3',
17
+        'Programming Language :: Python :: 3.7',
18
+    ]
19
+)

Loading…
Cancel
Save