pygpt-net 2.4.41__py3-none-any.whl → 2.4.43__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- CHANGELOG.md +13 -0
- README.md +142 -70
- pygpt_net/CHANGELOG.txt +13 -0
- pygpt_net/__init__.py +3 -3
- pygpt_net/app.py +3 -1
- pygpt_net/controller/audio/__init__.py +2 -2
- pygpt_net/controller/camera.py +1 -10
- pygpt_net/controller/chat/attachment.py +36 -23
- pygpt_net/controller/chat/audio.py +2 -2
- pygpt_net/controller/config/placeholder.py +15 -1
- pygpt_net/controller/ui/mode.py +16 -21
- pygpt_net/core/attachments/__init__.py +1 -1
- pygpt_net/core/attachments/context.py +10 -8
- pygpt_net/core/audio/__init__.py +4 -1
- pygpt_net/core/audio/whisper.py +37 -0
- pygpt_net/core/bridge/worker.py +2 -2
- pygpt_net/core/db/__init__.py +2 -1
- pygpt_net/core/debug/events.py +22 -10
- pygpt_net/core/debug/tabs.py +6 -3
- pygpt_net/core/history.py +3 -2
- pygpt_net/core/idx/__init__.py +16 -4
- pygpt_net/core/idx/chat.py +15 -5
- pygpt_net/core/idx/indexing.py +24 -8
- pygpt_net/core/installer.py +2 -4
- pygpt_net/core/models.py +62 -17
- pygpt_net/core/modes.py +11 -13
- pygpt_net/core/notepad.py +4 -4
- pygpt_net/core/plugins.py +27 -16
- pygpt_net/core/presets.py +20 -9
- pygpt_net/core/profile.py +11 -3
- pygpt_net/core/render/web/parser.py +3 -1
- pygpt_net/core/settings.py +5 -5
- pygpt_net/core/tabs/tab.py +10 -2
- pygpt_net/core/tokens.py +8 -6
- pygpt_net/core/web/__init__.py +105 -0
- pygpt_net/core/{web.py → web/helpers.py} +93 -67
- pygpt_net/data/config/config.json +3 -3
- pygpt_net/data/config/models.json +3 -3
- pygpt_net/data/config/modes.json +3 -3
- pygpt_net/data/locale/locale.en.ini +1 -0
- pygpt_net/data/locale/plugin.cmd_web.en.ini +2 -0
- pygpt_net/data/locale/plugin.mailer.en.ini +21 -0
- pygpt_net/item/ctx.py +66 -3
- pygpt_net/migrations/Version20241215110000.py +25 -0
- pygpt_net/migrations/__init__.py +3 -1
- pygpt_net/plugin/agent/__init__.py +7 -2
- pygpt_net/plugin/audio_output/__init__.py +6 -1
- pygpt_net/plugin/base/plugin.py +58 -26
- pygpt_net/plugin/base/worker.py +20 -17
- pygpt_net/plugin/cmd_history/config.py +2 -2
- pygpt_net/plugin/cmd_web/__init__.py +3 -4
- pygpt_net/plugin/cmd_web/config.py +71 -3
- pygpt_net/plugin/cmd_web/websearch.py +20 -12
- pygpt_net/plugin/cmd_web/worker.py +67 -4
- pygpt_net/plugin/idx_llama_index/config.py +3 -3
- pygpt_net/plugin/mailer/__init__.py +123 -0
- pygpt_net/plugin/mailer/config.py +149 -0
- pygpt_net/plugin/mailer/runner.py +285 -0
- pygpt_net/plugin/mailer/worker.py +123 -0
- pygpt_net/provider/agents/base.py +5 -2
- pygpt_net/provider/agents/openai.py +4 -2
- pygpt_net/provider/agents/openai_assistant.py +4 -2
- pygpt_net/provider/agents/planner.py +4 -2
- pygpt_net/provider/agents/react.py +4 -2
- pygpt_net/provider/audio_output/openai_tts.py +5 -11
- pygpt_net/provider/core/assistant/base.py +5 -3
- pygpt_net/provider/core/assistant/json_file.py +8 -5
- pygpt_net/provider/core/assistant_file/base.py +4 -3
- pygpt_net/provider/core/assistant_file/db_sqlite/__init__.py +4 -3
- pygpt_net/provider/core/assistant_file/db_sqlite/storage.py +3 -2
- pygpt_net/provider/core/assistant_store/base.py +6 -4
- pygpt_net/provider/core/assistant_store/db_sqlite/__init__.py +5 -4
- pygpt_net/provider/core/assistant_store/db_sqlite/storage.py +5 -3
- pygpt_net/provider/core/attachment/base.py +5 -3
- pygpt_net/provider/core/attachment/json_file.py +4 -3
- pygpt_net/provider/core/calendar/base.py +5 -3
- pygpt_net/provider/core/calendar/db_sqlite/__init__.py +6 -5
- pygpt_net/provider/core/calendar/db_sqlite/storage.py +5 -4
- pygpt_net/provider/core/config/base.py +8 -6
- pygpt_net/provider/core/config/json_file.py +9 -7
- pygpt_net/provider/core/ctx/base.py +27 -25
- pygpt_net/provider/core/ctx/db_sqlite/__init__.py +51 -35
- pygpt_net/provider/core/ctx/db_sqlite/storage.py +92 -38
- pygpt_net/provider/core/ctx/db_sqlite/utils.py +37 -11
- pygpt_net/provider/core/index/base.py +129 -23
- pygpt_net/provider/core/index/db_sqlite/__init__.py +130 -23
- pygpt_net/provider/core/index/db_sqlite/storage.py +130 -23
- pygpt_net/provider/core/index/db_sqlite/utils.py +4 -2
- pygpt_net/provider/core/mode/base.py +5 -3
- pygpt_net/provider/core/mode/json_file.py +7 -6
- pygpt_net/provider/core/model/base.py +6 -4
- pygpt_net/provider/core/model/json_file.py +9 -7
- pygpt_net/provider/core/notepad/base.py +5 -3
- pygpt_net/provider/core/notepad/db_sqlite/__init__.py +5 -4
- pygpt_net/provider/core/notepad/db_sqlite/storage.py +4 -3
- pygpt_net/provider/core/plugin_preset/base.py +4 -2
- pygpt_net/provider/core/plugin_preset/json_file.py +5 -3
- pygpt_net/provider/core/preset/base.py +6 -4
- pygpt_net/provider/core/preset/json_file.py +9 -9
- pygpt_net/provider/core/prompt/base.py +6 -3
- pygpt_net/provider/core/prompt/json_file.py +11 -6
- pygpt_net/provider/gpt/assistants.py +15 -6
- pygpt_net/provider/gpt/audio.py +5 -5
- pygpt_net/provider/gpt/chat.py +7 -5
- pygpt_net/provider/gpt/completion.py +8 -4
- pygpt_net/provider/gpt/image.py +3 -3
- pygpt_net/provider/gpt/store.py +46 -12
- pygpt_net/provider/gpt/vision.py +16 -11
- pygpt_net/provider/llms/anthropic.py +7 -2
- pygpt_net/provider/llms/azure_openai.py +26 -5
- pygpt_net/provider/llms/base.py +47 -9
- pygpt_net/provider/llms/google.py +7 -2
- pygpt_net/provider/llms/hugging_face.py +13 -3
- pygpt_net/provider/llms/hugging_face_api.py +18 -4
- pygpt_net/provider/llms/local.py +7 -2
- pygpt_net/provider/llms/ollama.py +30 -6
- pygpt_net/provider/llms/openai.py +32 -6
- pygpt_net/provider/vector_stores/__init__.py +45 -14
- pygpt_net/provider/vector_stores/base.py +35 -8
- pygpt_net/provider/vector_stores/chroma.py +13 -3
- pygpt_net/provider/vector_stores/ctx_attachment.py +32 -13
- pygpt_net/provider/vector_stores/elasticsearch.py +12 -3
- pygpt_net/provider/vector_stores/pinecode.py +12 -3
- pygpt_net/provider/vector_stores/redis.py +12 -3
- pygpt_net/provider/vector_stores/simple.py +12 -3
- pygpt_net/provider/vector_stores/temp.py +16 -4
- pygpt_net/provider/web/base.py +10 -3
- pygpt_net/provider/web/google_custom_search.py +9 -3
- pygpt_net/provider/web/microsoft_bing.py +9 -3
- pygpt_net/tools/__init__.py +13 -5
- pygpt_net/tools/audio_transcriber/__init__.py +4 -3
- pygpt_net/tools/base.py +15 -8
- pygpt_net/tools/code_interpreter/__init__.py +4 -3
- pygpt_net/tools/html_canvas/__init__.py +4 -3
- pygpt_net/tools/image_viewer/__init__.py +10 -4
- pygpt_net/tools/indexer/__init__.py +8 -7
- pygpt_net/tools/media_player/__init__.py +4 -3
- pygpt_net/tools/text_editor/__init__.py +36 -10
- pygpt_net/ui/layout/chat/output.py +2 -2
- pygpt_net/ui/layout/ctx/ctx_list.py +1 -1
- pygpt_net/ui/menu/audio.py +12 -1
- {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.43.dist-info}/METADATA +143 -71
- {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.43.dist-info}/RECORD +146 -138
- {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.43.dist-info}/LICENSE +0 -0
- {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.43.dist-info}/WHEEL +0 -0
- {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.43.dist-info}/entry_points.txt +0 -0
@@ -6,10 +6,11 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date: 2024.
|
9
|
+
# Updated Date: 2024.12.14 22:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import uuid
|
13
|
+
from typing import Dict
|
13
14
|
|
14
15
|
from packaging.version import Version
|
15
16
|
|
@@ -65,7 +66,7 @@ class DbSqliteProvider(BaseProvider):
|
|
65
66
|
note.id = self.storage.insert(note)
|
66
67
|
return note.id
|
67
68
|
|
68
|
-
def load_all(self) ->
|
69
|
+
def load_all(self) -> Dict[str, CalendarNoteItem]:
|
69
70
|
"""
|
70
71
|
Load notes from DB
|
71
72
|
|
@@ -73,7 +74,7 @@ class DbSqliteProvider(BaseProvider):
|
|
73
74
|
"""
|
74
75
|
return self.storage.get_all()
|
75
76
|
|
76
|
-
def load_by_month(self, year: int, month: int) ->
|
77
|
+
def load_by_month(self, year: int, month: int) -> Dict[str, CalendarNoteItem]:
|
77
78
|
"""
|
78
79
|
Load notes from DB
|
79
80
|
|
@@ -92,7 +93,7 @@ class DbSqliteProvider(BaseProvider):
|
|
92
93
|
"""
|
93
94
|
return self.storage.get_by_date(year, month, day)
|
94
95
|
|
95
|
-
def get_notes_existence_by_day(self, year, month) ->
|
96
|
+
def get_notes_existence_by_day(self, year, month) -> Dict[str, Dict[int, int]]:
|
96
97
|
"""
|
97
98
|
Get notes existence by day
|
98
99
|
|
@@ -114,7 +115,7 @@ class DbSqliteProvider(BaseProvider):
|
|
114
115
|
self.window.core.debug.log(e)
|
115
116
|
print("Error while saving note: {}".format(str(e)))
|
116
117
|
|
117
|
-
def save_all(self, items:
|
118
|
+
def save_all(self, items: Dict[str, CalendarNoteItem]):
|
118
119
|
"""
|
119
120
|
Save all notes to DB
|
120
121
|
|
@@ -6,10 +6,11 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date: 2024.
|
9
|
+
# Updated Date: 2024.12.14 22:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import time
|
13
|
+
from typing import Dict
|
13
14
|
|
14
15
|
from sqlalchemy import text
|
15
16
|
|
@@ -34,7 +35,7 @@ class Storage:
|
|
34
35
|
"""
|
35
36
|
self.window = window
|
36
37
|
|
37
|
-
def get_all(self) ->
|
38
|
+
def get_all(self) -> Dict[str, CalendarNoteItem]:
|
38
39
|
"""
|
39
40
|
Return dict with CalendarNoteItem objects, indexed by YYYY-MM-DD
|
40
41
|
|
@@ -54,7 +55,7 @@ class Storage:
|
|
54
55
|
items[dt] = note
|
55
56
|
return items
|
56
57
|
|
57
|
-
def get_by_month(self, year: int, month: int) ->
|
58
|
+
def get_by_month(self, year: int, month: int) -> Dict[str, CalendarNoteItem]:
|
58
59
|
"""
|
59
60
|
Return dict with CalendarNoteItem objects, indexed by YYYY-MM-DD
|
60
61
|
|
@@ -96,7 +97,7 @@ class Storage:
|
|
96
97
|
self.unpack(notepad, row._asdict())
|
97
98
|
return notepad
|
98
99
|
|
99
|
-
def get_notes_existence_by_day(self, year: int, month: int) ->
|
100
|
+
def get_notes_existence_by_day(self, year: int, month: int) -> Dict[str, Dict[int, int]]:
|
100
101
|
"""
|
101
102
|
Return a dict of days with the count of notes for the given year and month.
|
102
103
|
|
@@ -6,9 +6,11 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date:
|
9
|
+
# Updated Date: 2024.12.14 22:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
|
+
from typing import Dict, Any, Optional
|
13
|
+
|
12
14
|
from packaging.version import Version
|
13
15
|
|
14
16
|
|
@@ -30,19 +32,19 @@ class BaseProvider:
|
|
30
32
|
def patch(self, version: Version) -> bool:
|
31
33
|
pass
|
32
34
|
|
33
|
-
def load(self, all: bool = False) ->
|
35
|
+
def load(self, all: bool = False) -> Optional[Dict[str, Any]]:
|
34
36
|
pass
|
35
37
|
|
36
|
-
def load_base(self) ->
|
38
|
+
def load_base(self) -> Optional[Dict[str, Any]]:
|
37
39
|
pass
|
38
40
|
|
39
|
-
def save(self, items:
|
41
|
+
def save(self, items: Dict[str, Any], filename: str = 'config.json'):
|
40
42
|
pass
|
41
43
|
|
42
|
-
def get_options(self) ->
|
44
|
+
def get_options(self) -> Optional[Dict[str, Any]]:
|
43
45
|
pass
|
44
46
|
|
45
|
-
def get_sections(self) ->
|
47
|
+
def get_sections(self) -> Optional[Dict[str, Any]]:
|
46
48
|
pass
|
47
49
|
|
48
50
|
def get_version(self) -> str:
|
@@ -6,12 +6,14 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date: 2024.
|
9
|
+
# Updated Date: 2024.12.14 22:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import json
|
13
13
|
import os
|
14
14
|
import shutil
|
15
|
+
from typing import Optional, Dict, Any
|
16
|
+
|
15
17
|
from packaging.version import Version
|
16
18
|
|
17
19
|
from pygpt_net.provider.core.config.base import BaseProvider
|
@@ -38,7 +40,7 @@ class JsonFileProvider(BaseProvider):
|
|
38
40
|
src = os.path.join(self.path_app, 'data', 'config', self.config_file)
|
39
41
|
shutil.copyfile(src, dst)
|
40
42
|
|
41
|
-
def get_version(self) -> str
|
43
|
+
def get_version(self) -> Optional[str]:
|
42
44
|
"""
|
43
45
|
Get config file version
|
44
46
|
|
@@ -52,7 +54,7 @@ class JsonFileProvider(BaseProvider):
|
|
52
54
|
if '__meta__' in data and 'version' in data['__meta__']:
|
53
55
|
return data['__meta__']['version']
|
54
56
|
|
55
|
-
def load(self, all: bool = False) ->
|
57
|
+
def load(self, all: bool = False) -> Optional[Dict[str, Any]]:
|
56
58
|
"""
|
57
59
|
Load config from JSON file
|
58
60
|
|
@@ -72,7 +74,7 @@ class JsonFileProvider(BaseProvider):
|
|
72
74
|
print("FATAL ERROR: {}".format(e))
|
73
75
|
return data
|
74
76
|
|
75
|
-
def load_base(self) ->
|
77
|
+
def load_base(self) -> Optional[Dict[str, Any]]:
|
76
78
|
"""
|
77
79
|
Load config from JSON file
|
78
80
|
|
@@ -90,7 +92,7 @@ class JsonFileProvider(BaseProvider):
|
|
90
92
|
print("FATAL ERROR: {}".format(e))
|
91
93
|
return data
|
92
94
|
|
93
|
-
def save(self, data:
|
95
|
+
def save(self, data: Dict[str, Any], filename: str = 'config.json'):
|
94
96
|
"""
|
95
97
|
Save config to JSON file
|
96
98
|
|
@@ -106,7 +108,7 @@ class JsonFileProvider(BaseProvider):
|
|
106
108
|
except Exception as e:
|
107
109
|
print("FATAL ERROR: {}".format(e))
|
108
110
|
|
109
|
-
def get_options(self) ->
|
111
|
+
def get_options(self) -> Optional[Dict[str, Any]]:
|
110
112
|
"""
|
111
113
|
Load config settings options from JSON file
|
112
114
|
|
@@ -124,7 +126,7 @@ class JsonFileProvider(BaseProvider):
|
|
124
126
|
print("FATAL ERROR: {}".format(e))
|
125
127
|
return data
|
126
128
|
|
127
|
-
def get_sections(self) ->
|
129
|
+
def get_sections(self) -> Optional[Dict[str, Any]]:
|
128
130
|
"""
|
129
131
|
Load config sections from JSON file
|
130
132
|
|
@@ -6,9 +6,11 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date: 2024.12.
|
9
|
+
# Updated Date: 2024.12.14 22:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
|
+
from typing import List, Dict, Optional
|
13
|
+
|
12
14
|
from packaging.version import Version
|
13
15
|
|
14
16
|
from pygpt_net.item.ctx import CtxMeta, CtxItem, CtxGroup
|
@@ -29,46 +31,46 @@ class BaseProvider:
|
|
29
31
|
def patch(self, version: Version) -> bool:
|
30
32
|
pass
|
31
33
|
|
32
|
-
def append_item(self, meta: CtxMeta, item: CtxItem):
|
34
|
+
def append_item(self, meta: CtxMeta, item: CtxItem) -> bool:
|
33
35
|
pass
|
34
36
|
|
35
|
-
def update_item(self, item: CtxItem):
|
37
|
+
def update_item(self, item: CtxItem) -> bool:
|
36
38
|
pass
|
37
39
|
|
38
|
-
def create(self, meta: CtxMeta):
|
40
|
+
def create(self, meta: CtxMeta) -> int:
|
39
41
|
pass
|
40
42
|
|
41
|
-
def load(self, id) ->
|
43
|
+
def load(self, id: int) -> List[CtxItem]:
|
42
44
|
return []
|
43
45
|
|
44
|
-
def save(self, id, meta: CtxMeta, items:
|
46
|
+
def save(self, id: int, meta: CtxMeta, items: List[CtxItem]) -> bool:
|
45
47
|
pass
|
46
48
|
|
47
|
-
def remove(self, id):
|
49
|
+
def remove(self, id: int) -> bool:
|
48
50
|
pass
|
49
51
|
|
50
|
-
def remove_item(self, id):
|
52
|
+
def remove_item(self, id: int) -> bool:
|
51
53
|
pass
|
52
54
|
|
53
|
-
def remove_items_from(self, meta_id: int, item_id: int):
|
55
|
+
def remove_items_from(self, meta_id: int, item_id: int) -> bool:
|
54
56
|
pass
|
55
57
|
|
56
|
-
def truncate(self):
|
58
|
+
def truncate(self) -> bool:
|
57
59
|
pass
|
58
60
|
|
59
61
|
def get_meta(
|
60
62
|
self,
|
61
|
-
search_string: str = None,
|
62
|
-
order_by: str = None,
|
63
|
-
order_direction: str = None,
|
64
|
-
limit: int = None,
|
65
|
-
offset: int = None,
|
66
|
-
filters: dict = None,
|
63
|
+
search_string: Optional[str] = None,
|
64
|
+
order_by: Optional[str] = None,
|
65
|
+
order_direction: Optional[str] = None,
|
66
|
+
limit: Optional[int] = None,
|
67
|
+
offset: Optional[int] = None,
|
68
|
+
filters: Optional[dict] = None,
|
67
69
|
search_content: bool = False
|
68
|
-
):
|
70
|
+
) -> Dict[int, CtxMeta]:
|
69
71
|
pass
|
70
72
|
|
71
|
-
def get_meta_indexed(self):
|
73
|
+
def get_meta_indexed(self) -> Dict[int, CtxMeta]:
|
72
74
|
pass
|
73
75
|
|
74
76
|
def get_item_by_id(self, id: int) -> CtxItem:
|
@@ -95,25 +97,25 @@ class BaseProvider:
|
|
95
97
|
def clear_meta_indexed_all(self) -> bool:
|
96
98
|
pass
|
97
99
|
|
98
|
-
def get_groups(self) ->
|
100
|
+
def get_groups(self) -> Dict[int, CtxGroup]:
|
99
101
|
pass
|
100
102
|
|
101
|
-
def insert_group(self, group: CtxGroup):
|
103
|
+
def insert_group(self, group: CtxGroup) -> int:
|
102
104
|
pass
|
103
105
|
|
104
|
-
def update_group(self, group: CtxGroup):
|
106
|
+
def update_group(self, group: CtxGroup) -> bool:
|
105
107
|
pass
|
106
108
|
|
107
|
-
def remove_group(self, id: int, all: bool = False):
|
109
|
+
def remove_group(self, id: int, all: bool = False) -> bool:
|
108
110
|
pass
|
109
111
|
|
110
|
-
def truncate_groups(self):
|
112
|
+
def truncate_groups(self) -> bool:
|
111
113
|
pass
|
112
114
|
|
113
|
-
def update_meta_group_id(self, meta_id: int, group_id: int):
|
115
|
+
def update_meta_group_id(self, meta_id: int, group_id: int) -> bool:
|
114
116
|
pass
|
115
117
|
|
116
|
-
def clear_meta(self, meta_id: int):
|
118
|
+
def clear_meta(self, meta_id: int) -> bool:
|
117
119
|
pass
|
118
120
|
|
119
121
|
|
@@ -6,10 +6,11 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date: 2024.12.
|
9
|
+
# Updated Date: 2024.12.14 22:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import time
|
13
|
+
from typing import List, Dict, Optional
|
13
14
|
from uuid import uuid4
|
14
15
|
from packaging.version import Version
|
15
16
|
|
@@ -29,6 +30,11 @@ class DbSqliteProvider(BaseProvider):
|
|
29
30
|
self.type = "ctx"
|
30
31
|
|
31
32
|
def attach(self, window):
|
33
|
+
"""
|
34
|
+
Attach window
|
35
|
+
|
36
|
+
:param window: Window instance
|
37
|
+
"""
|
32
38
|
self.window = window
|
33
39
|
self.storage.attach(window)
|
34
40
|
|
@@ -68,14 +74,14 @@ class DbSqliteProvider(BaseProvider):
|
|
68
74
|
|
69
75
|
def get_meta(
|
70
76
|
self,
|
71
|
-
search_string: str = None,
|
72
|
-
order_by: str = None,
|
73
|
-
order_direction: str = None,
|
74
|
-
limit: int = None,
|
75
|
-
offset: int = None,
|
76
|
-
filters: dict = None,
|
77
|
+
search_string: Optional[str] = None,
|
78
|
+
order_by: Optional[str] = None,
|
79
|
+
order_direction: Optional[str] = None,
|
80
|
+
limit: Optional[int] = None,
|
81
|
+
offset: Optional[int] = None,
|
82
|
+
filters: Optional[dict] = None,
|
77
83
|
search_content: bool = False,
|
78
|
-
) ->
|
84
|
+
) -> Dict[int, CtxMeta]:
|
79
85
|
"""
|
80
86
|
Return dict of ctx meta, TODO: add order, limit, offset, etc.
|
81
87
|
|
@@ -102,7 +108,7 @@ class DbSqliteProvider(BaseProvider):
|
|
102
108
|
search_content=search_content,
|
103
109
|
)
|
104
110
|
|
105
|
-
def get_meta_indexed(self) ->
|
111
|
+
def get_meta_indexed(self) -> Dict[int, CtxMeta]:
|
106
112
|
"""
|
107
113
|
Return dict of ctx meta indexed by ID
|
108
114
|
|
@@ -118,7 +124,7 @@ class DbSqliteProvider(BaseProvider):
|
|
118
124
|
"""
|
119
125
|
return self.storage.get_last_meta_id()
|
120
126
|
|
121
|
-
def get_item_by_id(self, id: int) -> CtxItem:
|
127
|
+
def get_item_by_id(self, id: int) -> Optional[CtxItem]:
|
122
128
|
"""
|
123
129
|
Get ctx item by ID
|
124
130
|
|
@@ -127,7 +133,7 @@ class DbSqliteProvider(BaseProvider):
|
|
127
133
|
"""
|
128
134
|
return self.storage.get_item_by_id(id)
|
129
135
|
|
130
|
-
def load(self, id: int) ->
|
136
|
+
def load(self, id: int) -> List[CtxItem]:
|
131
137
|
"""
|
132
138
|
Load items for ctx ID
|
133
139
|
|
@@ -137,13 +143,14 @@ class DbSqliteProvider(BaseProvider):
|
|
137
143
|
return self.storage.get_items(id)
|
138
144
|
|
139
145
|
def get_ctx_count_by_day(
|
140
|
-
self,
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
146
|
+
self,
|
147
|
+
year: int,
|
148
|
+
month: Optional[int] = None,
|
149
|
+
day: Optional[int] = None,
|
150
|
+
search_string: Optional[str] = None,
|
151
|
+
filters: Optional[dict] = None,
|
145
152
|
search_content: bool = False,
|
146
|
-
) ->
|
153
|
+
) -> Dict[str, int]:
|
147
154
|
"""
|
148
155
|
Get ctx count by day or by month if only year is provided
|
149
156
|
|
@@ -165,13 +172,14 @@ class DbSqliteProvider(BaseProvider):
|
|
165
172
|
)
|
166
173
|
|
167
174
|
def get_ctx_labels_count_by_day(
|
168
|
-
self,
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
175
|
+
self,
|
176
|
+
year: int,
|
177
|
+
month: Optional[int] = None,
|
178
|
+
day: Optional[int] = None,
|
179
|
+
search_string: Optional[str] = None,
|
180
|
+
filters: Optional[dict] = None,
|
173
181
|
search_content: bool = False,
|
174
|
-
) ->
|
182
|
+
) -> Dict[str, Dict[int, int]]:
|
175
183
|
"""
|
176
184
|
Get ctx labels count by day or by month if only year is provided
|
177
185
|
|
@@ -213,7 +221,7 @@ class DbSqliteProvider(BaseProvider):
|
|
213
221
|
self.storage.update_meta_ts(item.meta_id)
|
214
222
|
return self.storage.update_item(item) is not None
|
215
223
|
|
216
|
-
def save(self, id: int, meta: CtxMeta, items:
|
224
|
+
def save(self, id: int, meta: CtxMeta, items: List[CtxItem]) -> bool:
|
217
225
|
"""
|
218
226
|
Save ctx
|
219
227
|
|
@@ -225,7 +233,7 @@ class DbSqliteProvider(BaseProvider):
|
|
225
233
|
if self.storage.update_meta(meta):
|
226
234
|
return True # update only meta, items are appended separately
|
227
235
|
|
228
|
-
def save_all(self, id: int, meta: CtxMeta, items:
|
236
|
+
def save_all(self, id: int, meta: CtxMeta, items: List[CtxItem]) -> bool:
|
229
237
|
"""
|
230
238
|
Save ctx
|
231
239
|
|
@@ -255,7 +263,7 @@ class DbSqliteProvider(BaseProvider):
|
|
255
263
|
"""
|
256
264
|
return self.storage.delete_item_by_id(id)
|
257
265
|
|
258
|
-
def remove_items_from(self, meta_id: int, item_id: int):
|
266
|
+
def remove_items_from(self, meta_id: int, item_id: int) -> bool:
|
259
267
|
"""
|
260
268
|
Remove ctx items from meta_id
|
261
269
|
|
@@ -328,7 +336,7 @@ class DbSqliteProvider(BaseProvider):
|
|
328
336
|
"""
|
329
337
|
return self.storage.clear_meta_indexed_all()
|
330
338
|
|
331
|
-
def get_groups(self) ->
|
339
|
+
def get_groups(self) -> Dict[int, CtxGroup]:
|
332
340
|
"""
|
333
341
|
Return dict of groups
|
334
342
|
|
@@ -336,7 +344,7 @@ class DbSqliteProvider(BaseProvider):
|
|
336
344
|
"""
|
337
345
|
return self.storage.get_groups()
|
338
346
|
|
339
|
-
def get_meta_by_id(self, id: int) -> CtxMeta
|
347
|
+
def get_meta_by_id(self, id: int) -> Optional[CtxMeta]:
|
340
348
|
"""
|
341
349
|
Get meta by ID
|
342
350
|
|
@@ -353,15 +361,16 @@ class DbSqliteProvider(BaseProvider):
|
|
353
361
|
"""
|
354
362
|
return self.storage.get_meta_by_root_id_and_preset_id(root_id, preset_id)
|
355
363
|
|
356
|
-
def insert_group(self, group: CtxGroup):
|
364
|
+
def insert_group(self, group: CtxGroup) -> int:
|
357
365
|
"""
|
358
366
|
Insert group
|
359
367
|
|
360
368
|
:param group: CtxGroup
|
369
|
+
:return: group ID
|
361
370
|
"""
|
362
371
|
return self.storage.insert_group(group)
|
363
372
|
|
364
|
-
def update_group(self, group: CtxGroup):
|
373
|
+
def update_group(self, group: CtxGroup) -> bool:
|
365
374
|
"""
|
366
375
|
Update group
|
367
376
|
|
@@ -369,32 +378,39 @@ class DbSqliteProvider(BaseProvider):
|
|
369
378
|
"""
|
370
379
|
return self.storage.update_group(group)
|
371
380
|
|
372
|
-
def remove_group(self, id: int, all: bool = False):
|
381
|
+
def remove_group(self, id: int, all: bool = False) -> bool:
|
373
382
|
"""
|
374
383
|
Remove group by ID
|
375
384
|
|
376
385
|
:param id: group ID
|
377
386
|
:param all: remove items
|
387
|
+
:return: True if removed
|
378
388
|
"""
|
379
389
|
return self.storage.delete_group(id, all=all)
|
380
390
|
|
381
|
-
def truncate_groups(self):
|
382
|
-
"""
|
391
|
+
def truncate_groups(self) -> bool:
|
392
|
+
"""
|
393
|
+
Remove groups
|
394
|
+
|
395
|
+
:return: True if removed
|
396
|
+
"""
|
383
397
|
return self.storage.truncate_groups()
|
384
398
|
|
385
|
-
def update_meta_group_id(self, id: int, group_id: int):
|
399
|
+
def update_meta_group_id(self, id: int, group_id: int) -> bool:
|
386
400
|
"""
|
387
401
|
Update meta group ID
|
388
402
|
|
389
403
|
:param id: ctx ID
|
390
404
|
:param group_id: group ID
|
405
|
+
:return: True if updated
|
391
406
|
"""
|
392
407
|
return self.storage.update_meta_group_id(id, group_id)
|
393
408
|
|
394
|
-
def clear_meta(self, id: int):
|
409
|
+
def clear_meta(self, id: int) -> bool:
|
395
410
|
"""
|
396
411
|
Clear meta by ID
|
397
412
|
|
398
413
|
:param id: ctx ID
|
414
|
+
:return: True if cleared
|
399
415
|
"""
|
400
416
|
return self.storage.clear_meta(id)
|