diff --git a/.gitignore b/.gitignore index c90f1b7..2af5ed2 100644 --- a/.gitignore +++ b/.gitignore @@ -170,4 +170,7 @@ data/ # openai-whisper share -share/ \ No newline at end of file +share/ + +# local config +.config.yaml \ No newline at end of file diff --git a/example.config.yaml b/example.config.yaml new file mode 100644 index 0000000..99ae7cf --- /dev/null +++ b/example.config.yaml @@ -0,0 +1,3 @@ +username: "username" +password: "password" +url: "url.org" \ No newline at end of file diff --git a/notescriber/__init__.py b/notescriber/__init__.py index 299b192..4f377d9 100644 --- a/notescriber/__init__.py +++ b/notescriber/__init__.py @@ -1,12 +1,15 @@ #!/usr/bin/env python3 +from notescriber import config from notescriber import dispatcher from notescriber import notetaker from notescriber import picker from notescriber import transcriber +config = config.Config() +config.load_config(".config.yaml") dispatcher = dispatcher.Dispatcher() -notetaker = notetaker.Notetaker() -picker = picker.Picker("/home/octopusx/Code/test",dispatcher) +notetaker = notetaker.Notetaker(config.username,config.password, config.url) +picker = picker.Picker(config.path, dispatcher) transcriber = transcriber.Transcriber() dispatcher.add_note_generator(notetaker) diff --git a/notescriber/config.py b/notescriber/config.py index e69de29..6f2247a 100644 --- a/notescriber/config.py +++ b/notescriber/config.py @@ -0,0 +1,27 @@ +import argparse +import yaml + +class Config: + + username = None + password = None + url = None + path = None + + def __init__(self): + pass + + def parse_args(self): + parser = argparse.ArgumentParser(description='Process some integers.') + parser.add_argument('--path', type=str, help='Path to config yaml file') + args = parser.parse_args() + return args.arg + + def load_config(self, path=None): + if path is None: + path = '.config.yaml' + confFile = yaml.safe_load(open(path)) + self.username = confFile['username'] + self.password = confFile['password'] + self.url = confFile['url'] + self.path = confFile['path'] \ No newline at end of file diff --git a/notescriber/notetaker.py b/notescriber/notetaker.py index f01fec2..f0274de 100644 --- a/notescriber/notetaker.py +++ b/notescriber/notetaker.py @@ -4,12 +4,14 @@ class Notetaker: username = None password = None + url = None - def __init__(self, username, password): + def __init__(self, username, password, url): self.username = username self.password = password + self.url = url def generate_note(self, filename, note): - api = NotesApi(self.username, self.password, 'cloud.octopusx.de') + api = NotesApi(self.username, self.password, self.url) ncnote = Note(title=filename, content=note, category="Voicenotes") api.create_note(ncnote) diff --git a/requirements.txt b/requirements.txt index 3a448ce..e3b06ad 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ openai-whisper==20231117 pyinotify==0.9.6 -nextcloud_notes_api==1.0.0 \ No newline at end of file +nextcloud_notes_api==1.0.0 +PyYaml==6.0.1 \ No newline at end of file diff --git a/tests/config_test.py b/tests/config_test.py new file mode 100644 index 0000000..3aa0611 --- /dev/null +++ b/tests/config_test.py @@ -0,0 +1,16 @@ +import unittest +from notescriber.config import Config + +class TranscriptorTest(unittest.TestCase): + def setUp(self): + pass + + def tearDown(self): + pass + + def test_run(self): + cfg = Config() + cfg.load_config(path="example.config.yaml") + self.assertEqual("username", cfg.username) + self.assertEqual("password", cfg.password) + self.assertEqual("url.org", cfg.url) diff --git a/tests/notetaker_test.py b/tests/notetaker_test.py index c1f8249..035bd76 100644 --- a/tests/notetaker_test.py +++ b/tests/notetaker_test.py @@ -9,6 +9,6 @@ class TranscriptorTest(unittest.TestCase): pass def test_run(self): - ntk = Notetaker() - ntk.generate_note("Test Note Title","This is my note") + ntk = Notetaker("title","content", "url") + # ntk.generate_note("Test Note Title","This is my note") self.assertEqual(True, True)