setta 0.0.1.dev0__py3-none-any.whl → 0.0.2__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- setta/__init__.py +1 -1
- setta/cli/__init__.py +1 -0
- setta/cli/connect.py +43 -0
- setta/cli/logger.py +225 -0
- setta/code_gen/__init__.py +0 -0
- setta/code_gen/create_runnable_scripts.py +466 -0
- setta/code_gen/export_selected.py +776 -0
- setta/code_gen/find_placeholders.py +13 -0
- setta/code_gen/python/__init__.py +0 -0
- setta/code_gen/python/ast_utils.py +183 -0
- setta/code_gen/python/check_scope.py +187 -0
- setta/code_gen/python/generate_code.py +280 -0
- setta/code_gen/python/make_parseable.py +97 -0
- setta/code_gen/python/position_line_col.py +33 -0
- setta/code_gen/python/validate_imports.py +87 -0
- setta/code_gen/utils.py +120 -0
- setta/code_gen/yaml/__init__.py +0 -0
- setta/code_gen/yaml/generate_yaml.py +23 -0
- setta/code_gen/yaml/section_dict.py +93 -0
- setta/database/__init__.py +0 -0
- setta/database/backup.py +80 -0
- setta/database/db/__init__.py +0 -0
- setta/database/db/artifacts/__init__.py +0 -0
- setta/database/db/artifacts/load.py +93 -0
- setta/database/db/artifacts/save.py +85 -0
- setta/database/db/artifacts/save_or_create.py +68 -0
- setta/database/db/artifacts/utils.py +13 -0
- setta/database/db/codeInfo/__init__.py +0 -0
- setta/database/db/codeInfo/copy.py +26 -0
- setta/database/db/codeInfo/load.py +65 -0
- setta/database/db/codeInfo/save.py +75 -0
- setta/database/db/codeInfo/utils.py +33 -0
- setta/database/db/evRefs/__init__.py +0 -0
- setta/database/db/evRefs/load.py +45 -0
- setta/database/db/evRefs/save.py +95 -0
- setta/database/db/projects/__init__.py +0 -0
- setta/database/db/projects/copy.py +36 -0
- setta/database/db/projects/delete.py +7 -0
- setta/database/db/projects/load.py +184 -0
- setta/database/db/projects/save.py +267 -0
- setta/database/db/projects/saveAs.py +40 -0
- setta/database/db/projects/utils.py +135 -0
- setta/database/db/sectionVariants/__init__.py +0 -0
- setta/database/db/sectionVariants/copy.py +28 -0
- setta/database/db/sectionVariants/load.py +139 -0
- setta/database/db/sectionVariants/save.py +140 -0
- setta/database/db/sectionVariants/utils.py +44 -0
- setta/database/db/sections/__init__.py +0 -0
- setta/database/db/sections/copy.py +70 -0
- setta/database/db/sections/jsonSource.py +119 -0
- setta/database/db/sections/load.py +350 -0
- setta/database/db/sections/save.py +204 -0
- setta/database/db/sections/utils.py +13 -0
- setta/database/db/uiTypes/__init__.py +0 -0
- setta/database/db/uiTypes/copy.py +33 -0
- setta/database/db/uiTypes/load.py +51 -0
- setta/database/db/uiTypes/save.py +99 -0
- setta/database/db/uiTypes/utils.py +27 -0
- setta/database/db_init.py +36 -0
- setta/database/db_objs.py +102 -0
- setta/database/db_path.py +8 -0
- setta/database/export_db/__init__.py +0 -0
- setta/database/export_db/export_db.py +43 -0
- setta/database/export_db/export_raw.py +53 -0
- setta/database/export_db/export_readable.py +242 -0
- setta/database/export_db/utils.py +16 -0
- setta/database/import_db.py +28 -0
- setta/database/seed.py +41 -0
- setta/database/settings_file.py +118 -0
- setta/database/utils.py +32 -0
- setta/lsp/__init__.py +0 -0
- setta/lsp/file_watcher.py +113 -0
- setta/lsp/reader.py +184 -0
- setta/lsp/reader_fns/__init__.py +0 -0
- setta/lsp/reader_fns/completion.py +84 -0
- setta/lsp/reader_fns/definition.py +2 -0
- setta/lsp/reader_fns/diagnostics.py +99 -0
- setta/lsp/reader_fns/documentHighlight.py +25 -0
- setta/lsp/reader_fns/references.py +34 -0
- setta/lsp/reader_fns/signatureHelp.py +99 -0
- setta/lsp/server.py +150 -0
- setta/lsp/utils.py +60 -0
- setta/lsp/writer.py +306 -0
- setta/routers/__init__.py +11 -0
- setta/routers/artifact.py +105 -0
- setta/routers/code_info.py +32 -0
- setta/routers/dependencies.py +49 -0
- setta/routers/in_memory_fn_stdout_websocket.py +21 -0
- setta/routers/interactive.py +119 -0
- setta/routers/lsp.py +14 -0
- setta/routers/projects.py +188 -0
- setta/routers/reference_renaming.py +111 -0
- setta/routers/sections.py +174 -0
- setta/routers/settings.py +40 -0
- setta/routers/terminals.py +83 -0
- setta/routers/websocket.py +36 -0
- setta/server.py +141 -0
- setta/start.py +112 -0
- setta/static/constants/BaseUITypes.json +153 -0
- setta/static/constants/Settings.json +113 -0
- setta/static/constants/constants.json +117 -0
- setta/static/constants/db_init.sql +249 -0
- setta/static/constants/defaultValues.json +125 -0
- setta/static/constants/settingsProject.json +276 -0
- setta/static/frontend/android-chrome-192x192.png +0 -0
- setta/static/frontend/android-chrome-512x512.png +0 -0
- setta/static/frontend/apple-touch-icon.png +0 -0
- setta/static/frontend/assets/KaTeX_AMS-Regular-0cdd387c.woff2 +0 -0
- setta/static/frontend/assets/KaTeX_AMS-Regular-30da91e8.woff +0 -0
- setta/static/frontend/assets/KaTeX_AMS-Regular-68534840.ttf +0 -0
- setta/static/frontend/assets/KaTeX_Caligraphic-Bold-07d8e303.ttf +0 -0
- setta/static/frontend/assets/KaTeX_Caligraphic-Bold-1ae6bd74.woff +0 -0
- setta/static/frontend/assets/KaTeX_Caligraphic-Bold-de7701e4.woff2 +0 -0
- setta/static/frontend/assets/KaTeX_Caligraphic-Regular-3398dd02.woff +0 -0
- setta/static/frontend/assets/KaTeX_Caligraphic-Regular-5d53e70a.woff2 +0 -0
- setta/static/frontend/assets/KaTeX_Caligraphic-Regular-ed0b7437.ttf +0 -0
- setta/static/frontend/assets/KaTeX_Fraktur-Bold-74444efd.woff2 +0 -0
- setta/static/frontend/assets/KaTeX_Fraktur-Bold-9163df9c.ttf +0 -0
- setta/static/frontend/assets/KaTeX_Fraktur-Bold-9be7ceb8.woff +0 -0
- setta/static/frontend/assets/KaTeX_Fraktur-Regular-1e6f9579.ttf +0 -0
- setta/static/frontend/assets/KaTeX_Fraktur-Regular-51814d27.woff2 +0 -0
- setta/static/frontend/assets/KaTeX_Fraktur-Regular-5e28753b.woff +0 -0
- setta/static/frontend/assets/KaTeX_Main-Bold-0f60d1b8.woff2 +0 -0
- setta/static/frontend/assets/KaTeX_Main-Bold-138ac28d.ttf +0 -0
- setta/static/frontend/assets/KaTeX_Main-Bold-c76c5d69.woff +0 -0
- setta/static/frontend/assets/KaTeX_Main-BoldItalic-70ee1f64.ttf +0 -0
- setta/static/frontend/assets/KaTeX_Main-BoldItalic-99cd42a3.woff2 +0 -0
- setta/static/frontend/assets/KaTeX_Main-BoldItalic-a6f7ec0d.woff +0 -0
- setta/static/frontend/assets/KaTeX_Main-Italic-0d85ae7c.ttf +0 -0
- setta/static/frontend/assets/KaTeX_Main-Italic-97479ca6.woff2 +0 -0
- setta/static/frontend/assets/KaTeX_Main-Italic-f1d6ef86.woff +0 -0
- setta/static/frontend/assets/KaTeX_Main-Regular-c2342cd8.woff2 +0 -0
- setta/static/frontend/assets/KaTeX_Main-Regular-c6368d87.woff +0 -0
- setta/static/frontend/assets/KaTeX_Main-Regular-d0332f52.ttf +0 -0
- setta/static/frontend/assets/KaTeX_Math-BoldItalic-850c0af5.woff +0 -0
- setta/static/frontend/assets/KaTeX_Math-BoldItalic-dc47344d.woff2 +0 -0
- setta/static/frontend/assets/KaTeX_Math-BoldItalic-f9377ab0.ttf +0 -0
- setta/static/frontend/assets/KaTeX_Math-Italic-08ce98e5.ttf +0 -0
- setta/static/frontend/assets/KaTeX_Math-Italic-7af58c5e.woff2 +0 -0
- setta/static/frontend/assets/KaTeX_Math-Italic-8a8d2445.woff +0 -0
- setta/static/frontend/assets/KaTeX_SansSerif-Bold-1ece03f7.ttf +0 -0
- setta/static/frontend/assets/KaTeX_SansSerif-Bold-e99ae511.woff2 +0 -0
- setta/static/frontend/assets/KaTeX_SansSerif-Bold-ece03cfd.woff +0 -0
- setta/static/frontend/assets/KaTeX_SansSerif-Italic-00b26ac8.woff2 +0 -0
- setta/static/frontend/assets/KaTeX_SansSerif-Italic-3931dd81.ttf +0 -0
- setta/static/frontend/assets/KaTeX_SansSerif-Italic-91ee6750.woff +0 -0
- setta/static/frontend/assets/KaTeX_SansSerif-Regular-11e4dc8a.woff +0 -0
- setta/static/frontend/assets/KaTeX_SansSerif-Regular-68e8c73e.woff2 +0 -0
- setta/static/frontend/assets/KaTeX_SansSerif-Regular-f36ea897.ttf +0 -0
- setta/static/frontend/assets/KaTeX_Script-Regular-036d4e95.woff2 +0 -0
- setta/static/frontend/assets/KaTeX_Script-Regular-1c67f068.ttf +0 -0
- setta/static/frontend/assets/KaTeX_Script-Regular-d96cdf2b.woff +0 -0
- setta/static/frontend/assets/KaTeX_Size1-Regular-6b47c401.woff2 +0 -0
- setta/static/frontend/assets/KaTeX_Size1-Regular-95b6d2f1.ttf +0 -0
- setta/static/frontend/assets/KaTeX_Size1-Regular-c943cc98.woff +0 -0
- setta/static/frontend/assets/KaTeX_Size2-Regular-2014c523.woff +0 -0
- setta/static/frontend/assets/KaTeX_Size2-Regular-a6b2099f.ttf +0 -0
- setta/static/frontend/assets/KaTeX_Size2-Regular-d04c5421.woff2 +0 -0
- setta/static/frontend/assets/KaTeX_Size3-Regular-500e04d5.ttf +0 -0
- setta/static/frontend/assets/KaTeX_Size3-Regular-6ab6b62e.woff +0 -0
- setta/static/frontend/assets/KaTeX_Size4-Regular-99f9c675.woff +0 -0
- setta/static/frontend/assets/KaTeX_Size4-Regular-a4af7d41.woff2 +0 -0
- setta/static/frontend/assets/KaTeX_Size4-Regular-c647367d.ttf +0 -0
- setta/static/frontend/assets/KaTeX_Typewriter-Regular-71d517d6.woff2 +0 -0
- setta/static/frontend/assets/KaTeX_Typewriter-Regular-e14fed02.woff +0 -0
- setta/static/frontend/assets/KaTeX_Typewriter-Regular-f01f3e87.ttf +0 -0
- setta/static/frontend/assets/cormorant-garamond-all-700-italic-c9b58582.woff +0 -0
- setta/static/frontend/assets/cormorant-garamond-cyrillic-700-italic-9101ad5f.woff2 +0 -0
- setta/static/frontend/assets/cormorant-garamond-cyrillic-ext-700-italic-950de0d6.woff2 +0 -0
- setta/static/frontend/assets/cormorant-garamond-latin-700-italic-0bc53e12.woff2 +0 -0
- setta/static/frontend/assets/cormorant-garamond-latin-ext-700-italic-525738e0.woff2 +0 -0
- setta/static/frontend/assets/cormorant-garamond-vietnamese-700-italic-99563037.woff2 +0 -0
- setta/static/frontend/assets/erase-5e0448ea.svg +15 -0
- setta/static/frontend/assets/index-1d4b4ecf.css +32 -0
- setta/static/frontend/assets/index-ee99dc72.js +678 -0
- setta/static/frontend/assets/inter-all-400-normal-054f12d0.woff +0 -0
- setta/static/frontend/assets/inter-all-600-normal-c03769e5.woff +0 -0
- setta/static/frontend/assets/inter-all-800-normal-15dc6e4b.woff +0 -0
- setta/static/frontend/assets/inter-cyrillic-400-normal-a4eee61a.woff2 +0 -0
- setta/static/frontend/assets/inter-cyrillic-600-normal-8b14f703.woff2 +0 -0
- setta/static/frontend/assets/inter-cyrillic-800-normal-e706eaaa.woff2 +0 -0
- setta/static/frontend/assets/inter-cyrillic-ext-400-normal-70047a3b.woff2 +0 -0
- setta/static/frontend/assets/inter-cyrillic-ext-600-normal-d4ab9bc4.woff2 +0 -0
- setta/static/frontend/assets/inter-cyrillic-ext-800-normal-eae7515a.woff2 +0 -0
- setta/static/frontend/assets/inter-greek-400-normal-381ea30d.woff2 +0 -0
- setta/static/frontend/assets/inter-greek-600-normal-601f93a2.woff2 +0 -0
- setta/static/frontend/assets/inter-greek-800-normal-7af4fb64.woff2 +0 -0
- setta/static/frontend/assets/inter-greek-ext-400-normal-27027b17.woff2 +0 -0
- setta/static/frontend/assets/inter-greek-ext-600-normal-f2ddf9de.woff2 +0 -0
- setta/static/frontend/assets/inter-greek-ext-800-normal-4cb6189e.woff2 +0 -0
- setta/static/frontend/assets/inter-latin-400-normal-d56fec21.woff2 +0 -0
- setta/static/frontend/assets/inter-latin-600-normal-ff769fa6.woff2 +0 -0
- setta/static/frontend/assets/inter-latin-800-normal-5eea1309.woff2 +0 -0
- setta/static/frontend/assets/inter-latin-ext-400-normal-bb698d85.woff2 +0 -0
- setta/static/frontend/assets/inter-latin-ext-600-normal-ca4808f9.woff2 +0 -0
- setta/static/frontend/assets/inter-latin-ext-800-normal-ebdacc0f.woff2 +0 -0
- setta/static/frontend/assets/logo/logo.svg +8 -0
- setta/static/frontend/assets/pen-455d7d8a.svg +19 -0
- setta/static/frontend/assets/source-code-pro-all-500-normal-6bdaa03b.woff +0 -0
- setta/static/frontend/assets/source-code-pro-cyrillic-500-normal-288a0d68.woff2 +0 -0
- setta/static/frontend/assets/source-code-pro-cyrillic-ext-500-normal-b110a13b.woff2 +0 -0
- setta/static/frontend/assets/source-code-pro-greek-500-normal-04328acb.woff2 +0 -0
- setta/static/frontend/assets/source-code-pro-latin-500-normal-06edef1e.woff2 +0 -0
- setta/static/frontend/assets/source-code-pro-latin-ext-500-normal-6dc60d5e.woff2 +0 -0
- setta/static/frontend/assets/web-vitals-44a8e082.js +1 -0
- setta/static/frontend/assets/work-sans-all-400-normal-38034a3c.woff +0 -0
- setta/static/frontend/assets/work-sans-all-500-normal-550d64e5.woff +0 -0
- setta/static/frontend/assets/work-sans-all-600-normal-ccf14060.woff +0 -0
- setta/static/frontend/assets/work-sans-all-700-normal-494c2971.woff +0 -0
- setta/static/frontend/assets/work-sans-latin-400-normal-36735bc1.woff2 +0 -0
- setta/static/frontend/assets/work-sans-latin-500-normal-3790bfda.woff2 +0 -0
- setta/static/frontend/assets/work-sans-latin-600-normal-5fba494e.woff2 +0 -0
- setta/static/frontend/assets/work-sans-latin-700-normal-a5033d0a.woff2 +0 -0
- setta/static/frontend/assets/work-sans-latin-ext-400-normal-c20f571a.woff2 +0 -0
- setta/static/frontend/assets/work-sans-latin-ext-500-normal-0f5ac96c.woff2 +0 -0
- setta/static/frontend/assets/work-sans-latin-ext-600-normal-97a237d1.woff2 +0 -0
- setta/static/frontend/assets/work-sans-latin-ext-700-normal-103e112c.woff2 +0 -0
- setta/static/frontend/browserconfig.xml +9 -0
- setta/static/frontend/favicon-16x16.png +0 -0
- setta/static/frontend/favicon-32x32.png +0 -0
- setta/static/frontend/favicon.ico +0 -0
- setta/static/frontend/index.html +30 -0
- setta/static/frontend/manifest.json +25 -0
- setta/static/frontend/mstile-144x144.png +0 -0
- setta/static/frontend/mstile-150x150.png +0 -0
- setta/static/frontend/mstile-310x150.png +0 -0
- setta/static/frontend/mstile-310x310.png +0 -0
- setta/static/frontend/mstile-70x70.png +0 -0
- setta/static/frontend/robots.txt +3 -0
- setta/static/frontend/safari-pinned-tab.svg +18 -0
- setta/static/frontend/site.webmanifest +19 -0
- setta/static/seed/.DS_Store +0 -0
- setta/static/seed/examples/.DS_Store +0 -0
- setta/tasks/__init__.py +0 -0
- setta/tasks/fns/__init__.py +9 -0
- setta/tasks/fns/codeAreaAutocomplete.py +209 -0
- setta/tasks/fns/codeAreaFindTemplateVars.py +128 -0
- setta/tasks/fns/codeAreaInitializeCode.py +98 -0
- setta/tasks/fns/findEVRefs.py +236 -0
- setta/tasks/fns/parametersRequest.py +71 -0
- setta/tasks/fns/textFieldAutocomplete.py +210 -0
- setta/tasks/fns/textFieldInitializeCode.py +99 -0
- setta/tasks/fns/typeCheck.py +40 -0
- setta/tasks/fns/utils.py +134 -0
- setta/tasks/task_runner.py +29 -0
- setta/tasks/tasks.py +152 -0
- setta/tasks/utils.py +178 -0
- setta/terminals/__init__.py +0 -0
- setta/terminals/terminals.py +242 -0
- setta/terminals/utils.py +37 -0
- setta/utils/__init__.py +0 -0
- setta/utils/constants.py +148 -0
- setta/utils/generate_memorable_string.py +431 -0
- setta/utils/generate_new_filename.py +80 -0
- setta/utils/section_contents.py +133 -0
- setta/utils/utils.py +271 -0
- setta/utils/websocket_manager.py +91 -0
- setta-0.0.2.dist-info/LICENSE +201 -0
- setta-0.0.2.dist-info/METADATA +24 -0
- setta-0.0.2.dist-info/RECORD +263 -0
- {setta-0.0.1.dev0.dist-info → setta-0.0.2.dist-info}/WHEEL +1 -1
- setta-0.0.2.dist-info/entry_points.txt +2 -0
- setta-0.0.1.dev0.dist-info/METADATA +0 -18
- setta-0.0.1.dev0.dist-info/RECORD +0 -5
- {setta-0.0.1.dev0.dist-info → setta-0.0.2.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,85 @@
|
|
1
|
+
import json
|
2
|
+
|
3
|
+
from setta.utils.constants import DEFAULT_VALUES
|
4
|
+
from setta.utils.utils import filter_dict
|
5
|
+
|
6
|
+
|
7
|
+
def save_artifacts(db, artifacts):
|
8
|
+
query = """
|
9
|
+
INSERT INTO Artifact (id, name, path, value, type)
|
10
|
+
VALUES (:id, :name, :path, :value, :type)
|
11
|
+
ON CONFLICT (id)
|
12
|
+
DO UPDATE SET
|
13
|
+
name = :name,
|
14
|
+
path = :path,
|
15
|
+
value = :value,
|
16
|
+
type = :type
|
17
|
+
"""
|
18
|
+
|
19
|
+
query_params = []
|
20
|
+
|
21
|
+
for id, data in artifacts.items():
|
22
|
+
if data["path"]:
|
23
|
+
# set value to null if path is specified
|
24
|
+
data["value"] = DEFAULT_VALUES["artifact"]["value"]
|
25
|
+
query_params.append(
|
26
|
+
{
|
27
|
+
"id": id,
|
28
|
+
"name": data["name"],
|
29
|
+
"path": data["path"],
|
30
|
+
"value": json.dumps(data["value"]),
|
31
|
+
"type": data["type"],
|
32
|
+
}
|
33
|
+
)
|
34
|
+
|
35
|
+
db.executemany(query, query_params)
|
36
|
+
|
37
|
+
|
38
|
+
def save_artifact_groups(db, artifact_groups):
|
39
|
+
query = """
|
40
|
+
INSERT INTO ArtifactGroupId (id, name, data)
|
41
|
+
VALUES (:id, :name, :data)
|
42
|
+
ON CONFLICT (id)
|
43
|
+
DO UPDATE SET
|
44
|
+
name = :name,
|
45
|
+
data = :data
|
46
|
+
"""
|
47
|
+
query_params = []
|
48
|
+
for k, group in artifact_groups.items():
|
49
|
+
data_keys = group.keys() - {"name", "artifactTransforms"}
|
50
|
+
query_params.append(
|
51
|
+
{
|
52
|
+
"id": k,
|
53
|
+
"name": group["name"],
|
54
|
+
"data": json.dumps(filter_dict(group, data_keys)),
|
55
|
+
}
|
56
|
+
)
|
57
|
+
db.executemany(query, query_params)
|
58
|
+
|
59
|
+
placeholders = ", ".join(["?"] * len(artifact_groups))
|
60
|
+
query = f"""
|
61
|
+
DELETE FROM ArtifactGroup
|
62
|
+
WHERE idid IN ({placeholders})
|
63
|
+
"""
|
64
|
+
query_params = list(artifact_groups.keys())
|
65
|
+
db.execute(query, query_params)
|
66
|
+
|
67
|
+
query = """
|
68
|
+
INSERT INTO ArtifactGroup (idid, artifactId, data, "order")
|
69
|
+
VALUES (:idid, :artifactId, :data, :order)
|
70
|
+
"""
|
71
|
+
|
72
|
+
query_params = []
|
73
|
+
for id, group in artifact_groups.items():
|
74
|
+
for order, artifactTransform in enumerate(group["artifactTransforms"]):
|
75
|
+
data_keys = artifactTransform.keys() - {"artifactId"}
|
76
|
+
query_params.append(
|
77
|
+
{
|
78
|
+
"idid": id,
|
79
|
+
"artifactId": artifactTransform["artifactId"],
|
80
|
+
"data": json.dumps(filter_dict(artifactTransform, data_keys)),
|
81
|
+
"order": order,
|
82
|
+
}
|
83
|
+
)
|
84
|
+
|
85
|
+
db.executemany(query, query_params)
|
@@ -0,0 +1,68 @@
|
|
1
|
+
import json
|
2
|
+
|
3
|
+
from setta.database.utils import create_new_id
|
4
|
+
|
5
|
+
|
6
|
+
def get_artifact_value_for_db(artifact, saveTo):
|
7
|
+
if saveTo == "disk":
|
8
|
+
return None
|
9
|
+
return json.dumps(artifact["value"])
|
10
|
+
|
11
|
+
|
12
|
+
def save_or_create_artifacts(db, artifacts, saveTo):
|
13
|
+
# Convert to parameters, using new IDs for anything without an ID
|
14
|
+
params = [
|
15
|
+
(
|
16
|
+
art.get("id") or create_new_id(),
|
17
|
+
art["name"],
|
18
|
+
art["path"],
|
19
|
+
get_artifact_value_for_db(art, saveTo),
|
20
|
+
art["type"],
|
21
|
+
)
|
22
|
+
for art in artifacts
|
23
|
+
]
|
24
|
+
|
25
|
+
# Do the upsert
|
26
|
+
db.executemany(
|
27
|
+
"""
|
28
|
+
INSERT INTO Artifact (id, name, path, value, type)
|
29
|
+
VALUES (?, ?, ?, ?, ?)
|
30
|
+
ON CONFLICT (id) DO UPDATE
|
31
|
+
SET name=excluded.name,
|
32
|
+
path=excluded.path,
|
33
|
+
value=excluded.value,
|
34
|
+
type=excluded.type
|
35
|
+
ON CONFLICT (name, path, type) DO UPDATE
|
36
|
+
SET value=excluded.value
|
37
|
+
""",
|
38
|
+
params,
|
39
|
+
)
|
40
|
+
|
41
|
+
# Get all the actual IDs
|
42
|
+
id_map = lookup_artifacts(db, artifacts)
|
43
|
+
return [id_map[(art["name"], art["path"], art["type"])] for art in artifacts]
|
44
|
+
|
45
|
+
|
46
|
+
def lookup_artifacts(db, artifacts):
|
47
|
+
"""
|
48
|
+
Look up existing artifacts by name/path/type.
|
49
|
+
Returns a map of (name, path, type) -> id for found artifacts.
|
50
|
+
"""
|
51
|
+
if not artifacts:
|
52
|
+
return {}
|
53
|
+
|
54
|
+
lookup_params = [(art["name"], art["path"], art["type"]) for art in artifacts]
|
55
|
+
placeholders = " OR ".join("(name=? AND path=? AND type=?)" for _ in artifacts)
|
56
|
+
|
57
|
+
db.execute(
|
58
|
+
f"SELECT name, path, type, id FROM Artifact WHERE {placeholders}",
|
59
|
+
[param for params in lookup_params for param in params],
|
60
|
+
)
|
61
|
+
rows = db.fetchall()
|
62
|
+
|
63
|
+
return {(row["name"], row["path"], row["type"]): row["id"] for row in rows}
|
64
|
+
|
65
|
+
|
66
|
+
def get_artifact_ids(db, artifacts):
|
67
|
+
id_map = lookup_artifacts(db, artifacts)
|
68
|
+
return [id_map.get((art["name"], art["path"], art["type"])) for art in artifacts]
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import copy
|
2
|
+
|
3
|
+
from setta.utils.constants import DEFAULT_VALUES
|
4
|
+
from setta.utils.utils import recursive_dict_merge
|
5
|
+
|
6
|
+
|
7
|
+
def with_artifact_defaults(**kwargs):
|
8
|
+
return recursive_dict_merge(copy.deepcopy(DEFAULT_VALUES["artifact"]), kwargs)
|
9
|
+
|
10
|
+
|
11
|
+
def add_defaults_to_artifacts(artifacts):
|
12
|
+
for k, v in artifacts.items():
|
13
|
+
artifacts[k] = with_artifact_defaults(**v)
|
File without changes
|
@@ -0,0 +1,26 @@
|
|
1
|
+
from setta.database.utils import remap_ids, rename_keys
|
2
|
+
from setta.utils.constants import is_from_json_source
|
3
|
+
|
4
|
+
|
5
|
+
def copy_code_info(code_info):
|
6
|
+
ids_to_rename = [k for k in code_info.keys() if not is_from_json_source(k)]
|
7
|
+
new_code_info, code_info_id_map = remap_ids(code_info, ids_to_rename)
|
8
|
+
code_info_id_map.update({k: k for k in code_info.keys() if is_from_json_source(k)})
|
9
|
+
|
10
|
+
for c in new_code_info.values():
|
11
|
+
c["id"] = code_info_id_map[c["id"]]
|
12
|
+
|
13
|
+
return new_code_info, code_info_id_map
|
14
|
+
|
15
|
+
|
16
|
+
def copy_code_info_col(code_info_cols, code_info_id_map):
|
17
|
+
new_code_info_cols, code_info_col_id_map = remap_ids(code_info_cols)
|
18
|
+
|
19
|
+
for col in new_code_info_cols.values():
|
20
|
+
col["children"] = rename_keys(col["children"], code_info_id_map)
|
21
|
+
for parentId in col["children"].keys():
|
22
|
+
col["children"][parentId] = [
|
23
|
+
code_info_id_map[x] for x in col["children"][parentId]
|
24
|
+
]
|
25
|
+
|
26
|
+
return new_code_info_cols, code_info_col_id_map
|
@@ -0,0 +1,65 @@
|
|
1
|
+
import json
|
2
|
+
|
3
|
+
from setta.database.db.codeInfo.utils import (
|
4
|
+
with_code_info_col_defaults,
|
5
|
+
with_code_info_defaults,
|
6
|
+
)
|
7
|
+
|
8
|
+
|
9
|
+
def load_code_info(db, codeInfoColIds):
|
10
|
+
placeholders = ", ".join(["?"] * len(codeInfoColIds))
|
11
|
+
query = f"""
|
12
|
+
WITH RECURSIVE DESCENDANTS AS (
|
13
|
+
SELECT c.idid, c.parentId, c.childId, c."order"
|
14
|
+
FROM CodeInfoCol c
|
15
|
+
WHERE c.idid IN ({placeholders})
|
16
|
+
|
17
|
+
UNION
|
18
|
+
|
19
|
+
SELECT X.idid, X.parentId, X.childId, X."order"
|
20
|
+
FROM CodeInfoCol X
|
21
|
+
JOIN DESCENDANTS d ON X.parentId = d.childId AND X.idid = d.idid
|
22
|
+
)
|
23
|
+
SELECT * FROM DESCENDANTS
|
24
|
+
ORDER BY idid, "order";
|
25
|
+
"""
|
26
|
+
db.execute(query, tuple(codeInfoColIds))
|
27
|
+
results = db.fetchall()
|
28
|
+
all_ids = set()
|
29
|
+
code_info_cols = {}
|
30
|
+
for k in codeInfoColIds:
|
31
|
+
code_info_cols[k] = with_code_info_col_defaults()
|
32
|
+
for row in results:
|
33
|
+
(codeInfoColId, parentId, childId, _) = row
|
34
|
+
if parentId:
|
35
|
+
all_ids.add(parentId)
|
36
|
+
all_ids.add(childId)
|
37
|
+
children_dict = code_info_cols[codeInfoColId]["children"]
|
38
|
+
if parentId not in children_dict:
|
39
|
+
children_dict[parentId] = []
|
40
|
+
children_dict[parentId].append(childId)
|
41
|
+
if childId not in children_dict:
|
42
|
+
children_dict[childId] = []
|
43
|
+
|
44
|
+
all_ids = list(all_ids)
|
45
|
+
|
46
|
+
placeholders = ", ".join(["?"] * len(all_ids))
|
47
|
+
query = f"""
|
48
|
+
SELECT * FROM CodeInfo
|
49
|
+
WHERE id IN ({placeholders})
|
50
|
+
"""
|
51
|
+
db.execute(query, all_ids)
|
52
|
+
code_info = {}
|
53
|
+
for row in db.fetchall():
|
54
|
+
code_info[row["id"]] = with_code_info_defaults(
|
55
|
+
id=row["id"], name=row["name"], **json.loads(row["data"])
|
56
|
+
)
|
57
|
+
|
58
|
+
return code_info, code_info_cols
|
59
|
+
|
60
|
+
|
61
|
+
def load_code_info_cols(db, sectionVariants):
|
62
|
+
collection_ids = [
|
63
|
+
v["codeInfoColId"] for v in sectionVariants.values() if v["codeInfoColId"]
|
64
|
+
]
|
65
|
+
return load_code_info(db, collection_ids)
|
@@ -0,0 +1,75 @@
|
|
1
|
+
import json
|
2
|
+
|
3
|
+
from setta.utils.constants import CODE_INFO_TABLE_DATA_JSON_FIELDS, DEFAULT_VALUES
|
4
|
+
from setta.utils.utils import filter_dict, replace_null_keys_with_none
|
5
|
+
|
6
|
+
|
7
|
+
def save_code_info(db, codeInfo):
|
8
|
+
query = """
|
9
|
+
INSERT INTO CodeInfo (id, name, data)
|
10
|
+
VALUES (:id, :name, :data)
|
11
|
+
ON CONFLICT (id)
|
12
|
+
DO UPDATE SET
|
13
|
+
name = :name,
|
14
|
+
data = :data
|
15
|
+
"""
|
16
|
+
|
17
|
+
# insert into codeinfo table
|
18
|
+
query_params = []
|
19
|
+
for codeInfoId, c in codeInfo.items():
|
20
|
+
query_params.append(
|
21
|
+
{
|
22
|
+
"id": codeInfoId,
|
23
|
+
"name": c["name"],
|
24
|
+
"data": json.dumps(
|
25
|
+
filter_dict(
|
26
|
+
c, CODE_INFO_TABLE_DATA_JSON_FIELDS, DEFAULT_VALUES["codeInfo"]
|
27
|
+
)
|
28
|
+
),
|
29
|
+
}
|
30
|
+
)
|
31
|
+
|
32
|
+
db.executemany(query, query_params)
|
33
|
+
|
34
|
+
|
35
|
+
def save_code_info_col(db, codeInfoCols):
|
36
|
+
codeInfoCols = replace_null_keys_with_none(codeInfoCols)
|
37
|
+
|
38
|
+
query = """
|
39
|
+
INSERT INTO CodeInfoColId (id)
|
40
|
+
VALUES (:id)
|
41
|
+
ON CONFLICT (id)
|
42
|
+
DO NOTHING
|
43
|
+
"""
|
44
|
+
|
45
|
+
query_params = [{"id": k} for k in codeInfoCols.keys()]
|
46
|
+
db.executemany(query, query_params)
|
47
|
+
|
48
|
+
placeholders = ", ".join(["?"] * len(codeInfoCols))
|
49
|
+
query = f"""
|
50
|
+
DELETE FROM CodeInfoCol
|
51
|
+
WHERE idid IN ({placeholders})
|
52
|
+
"""
|
53
|
+
query_params = list(codeInfoCols.keys())
|
54
|
+
db.execute(query, query_params)
|
55
|
+
|
56
|
+
# add children
|
57
|
+
query = """
|
58
|
+
INSERT INTO CodeInfoCol (idid, parentId, childId, "order")
|
59
|
+
VALUES (:idid, :parentId, :childId, :order)
|
60
|
+
"""
|
61
|
+
query_params = []
|
62
|
+
for idid, c in codeInfoCols.items():
|
63
|
+
for parentId, children in c["children"].items():
|
64
|
+
order = 0
|
65
|
+
for childId in children:
|
66
|
+
query_params.append(
|
67
|
+
{
|
68
|
+
"idid": idid,
|
69
|
+
"parentId": parentId,
|
70
|
+
"childId": childId,
|
71
|
+
"order": order,
|
72
|
+
}
|
73
|
+
)
|
74
|
+
order += 1
|
75
|
+
db.executemany(query, query_params)
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import copy
|
2
|
+
|
3
|
+
from setta.database.db.sectionVariants.utils import with_ev_ref_entry_defaults
|
4
|
+
from setta.utils.constants import DEFAULT_VALUES
|
5
|
+
from setta.utils.utils import recursive_dict_merge, replace_null_keys_with_none
|
6
|
+
|
7
|
+
|
8
|
+
def with_code_info_defaults(**kwargs):
|
9
|
+
return recursive_dict_merge(copy.deepcopy(DEFAULT_VALUES["codeInfo"]), kwargs)
|
10
|
+
|
11
|
+
|
12
|
+
def add_defaults_to_code_info(code_info):
|
13
|
+
for k, v in code_info.items():
|
14
|
+
code_info[k] = with_code_info_defaults(**v)
|
15
|
+
evRefs = code_info[k]["evRefs"]
|
16
|
+
for idx in range(len(evRefs)):
|
17
|
+
evRefs[idx] = with_ev_ref_entry_defaults(**evRefs[idx])
|
18
|
+
|
19
|
+
|
20
|
+
def with_code_info_col_defaults(**kwargs):
|
21
|
+
return recursive_dict_merge(
|
22
|
+
replace_null_keys_with_none(copy.deepcopy(DEFAULT_VALUES["codeInfoCol"])),
|
23
|
+
replace_null_keys_with_none(kwargs),
|
24
|
+
)
|
25
|
+
|
26
|
+
|
27
|
+
def add_defaults_to_code_info_cols(code_info_cols):
|
28
|
+
for k, v in code_info_cols.items():
|
29
|
+
code_info_cols[k] = with_code_info_col_defaults(**v)
|
30
|
+
|
31
|
+
|
32
|
+
def new_code_info_col():
|
33
|
+
return copy.deepcopy(DEFAULT_VALUES["codeInfoCol"])
|
File without changes
|
@@ -0,0 +1,45 @@
|
|
1
|
+
def load_ev_refs_into_data_structures(db, section_variants, code_info):
|
2
|
+
variant_placeholders = ", ".join(["?"] * len(section_variants))
|
3
|
+
codeinfo_placeholders = ", ".join(["?"] * len(code_info))
|
4
|
+
|
5
|
+
query = f"""
|
6
|
+
SELECT *
|
7
|
+
FROM EVRefs
|
8
|
+
WHERE variantId IN ({variant_placeholders})
|
9
|
+
OR codeInfoId IN ({codeinfo_placeholders})
|
10
|
+
"""
|
11
|
+
|
12
|
+
parameters = list(section_variants.keys()) + list(code_info.keys())
|
13
|
+
db.execute(query, parameters)
|
14
|
+
|
15
|
+
for row in db.fetchall():
|
16
|
+
row = dict(row)
|
17
|
+
row["isArgsObj"] = bool(row["isArgsObj"])
|
18
|
+
variantId = row.pop("variantId")
|
19
|
+
codeInfoId = row.pop("codeInfoId")
|
20
|
+
referringParamInfoId = row.pop("referringParamInfoId")
|
21
|
+
if codeInfoId:
|
22
|
+
code_info[codeInfoId]["evRefs"].append(row)
|
23
|
+
elif referringParamInfoId:
|
24
|
+
section_variants[variantId]["values"][referringParamInfoId][
|
25
|
+
"evRefs"
|
26
|
+
].append(row)
|
27
|
+
else:
|
28
|
+
section_variants[variantId]["evRefs"].append(row)
|
29
|
+
|
30
|
+
|
31
|
+
def load_template_vars_into_data_structures(db, section_variants):
|
32
|
+
variant_placeholders = ", ".join(["?"] * len(section_variants))
|
33
|
+
|
34
|
+
query = f"""
|
35
|
+
SELECT *
|
36
|
+
FROM TemplateVars
|
37
|
+
WHERE variantId IN ({variant_placeholders})
|
38
|
+
"""
|
39
|
+
|
40
|
+
db.execute(query, list(section_variants.keys()))
|
41
|
+
|
42
|
+
for row in db.fetchall():
|
43
|
+
row = dict(row)
|
44
|
+
variantId = row.pop("variantId")
|
45
|
+
section_variants[variantId]["templateVars"].append(row)
|
@@ -0,0 +1,95 @@
|
|
1
|
+
def save_ev_refs(db, section_variants, code_info):
|
2
|
+
placeholders = ", ".join(["?"] * len(section_variants))
|
3
|
+
query = f"""
|
4
|
+
DELETE FROM EVRefs
|
5
|
+
WHERE variantId IN ({placeholders})
|
6
|
+
"""
|
7
|
+
query_params = list(section_variants.keys())
|
8
|
+
db.execute(query, query_params)
|
9
|
+
|
10
|
+
placeholders = ", ".join(["?"] * len(code_info))
|
11
|
+
query = f"""
|
12
|
+
DELETE FROM EVRefs
|
13
|
+
WHERE codeInfoId IN ({placeholders})
|
14
|
+
"""
|
15
|
+
query_params = list(code_info.keys())
|
16
|
+
db.execute(query, query_params)
|
17
|
+
|
18
|
+
query = """
|
19
|
+
INSERT INTO EVRefs (variantId, codeInfoId, referringParamInfoId, sectionId, paramInfoId, isArgsObj, startPos, keyword)
|
20
|
+
VALUES (:variantId, :codeInfoId, :referringParamInfoId, :sectionId, :paramInfoId, :isArgsObj, :startPos, :keyword)
|
21
|
+
"""
|
22
|
+
|
23
|
+
query_params = []
|
24
|
+
for variantId, variant in section_variants.items():
|
25
|
+
evRefs = variant["evRefs"]
|
26
|
+
query_params.extend(
|
27
|
+
[
|
28
|
+
{
|
29
|
+
"variantId": variantId,
|
30
|
+
"codeInfoId": None,
|
31
|
+
"referringParamInfoId": None,
|
32
|
+
**x,
|
33
|
+
}
|
34
|
+
for x in evRefs
|
35
|
+
]
|
36
|
+
)
|
37
|
+
|
38
|
+
for referringParamInfoId, details in variant["values"].items():
|
39
|
+
evRefs = details["evRefs"]
|
40
|
+
query_params.extend(
|
41
|
+
[
|
42
|
+
{
|
43
|
+
"variantId": variantId,
|
44
|
+
"codeInfoId": None,
|
45
|
+
"referringParamInfoId": referringParamInfoId,
|
46
|
+
**x,
|
47
|
+
}
|
48
|
+
for x in evRefs
|
49
|
+
]
|
50
|
+
)
|
51
|
+
|
52
|
+
for codeInfoId, codeInfo in code_info.items():
|
53
|
+
evRefs = codeInfo["evRefs"]
|
54
|
+
query_params.extend(
|
55
|
+
[
|
56
|
+
{
|
57
|
+
"variantId": None,
|
58
|
+
"codeInfoId": codeInfoId,
|
59
|
+
"referringParamInfoId": None,
|
60
|
+
**x,
|
61
|
+
}
|
62
|
+
for x in evRefs
|
63
|
+
]
|
64
|
+
)
|
65
|
+
|
66
|
+
db.executemany(query, query_params)
|
67
|
+
|
68
|
+
|
69
|
+
def save_template_vars(db, section_variants):
|
70
|
+
placeholders = ", ".join(["?"] * len(section_variants))
|
71
|
+
query = f"""
|
72
|
+
DELETE FROM TemplateVars
|
73
|
+
WHERE variantId IN ({placeholders})
|
74
|
+
"""
|
75
|
+
query_params = list(section_variants.keys())
|
76
|
+
db.execute(query, query_params)
|
77
|
+
|
78
|
+
query = """
|
79
|
+
INSERT INTO TemplateVars (variantId, sectionId, startPos, keyword)
|
80
|
+
VALUES (:variantId, :sectionId, :startPos, :keyword)
|
81
|
+
"""
|
82
|
+
|
83
|
+
query_params = []
|
84
|
+
for variantId, variant in section_variants.items():
|
85
|
+
query_params.extend(
|
86
|
+
[
|
87
|
+
{
|
88
|
+
"variantId": variantId,
|
89
|
+
**x,
|
90
|
+
}
|
91
|
+
for x in variant["templateVars"]
|
92
|
+
]
|
93
|
+
)
|
94
|
+
|
95
|
+
db.executemany(query, query_params)
|
File without changes
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import copy
|
2
|
+
|
3
|
+
from setta.database.utils import create_new_id, rename_keys
|
4
|
+
|
5
|
+
from ..sections.copy import copy_sections_and_other_info
|
6
|
+
|
7
|
+
|
8
|
+
def copy_project_details(project, new_config_name=None, do_create_new_id=False):
|
9
|
+
new_info = copy_sections_and_other_info(project)
|
10
|
+
new_project_config = copy_project_config(
|
11
|
+
project["projectConfig"],
|
12
|
+
new_config_name,
|
13
|
+
do_create_new_id,
|
14
|
+
new_info["section_id_map"],
|
15
|
+
)
|
16
|
+
|
17
|
+
return {
|
18
|
+
**project,
|
19
|
+
**new_info,
|
20
|
+
"projectConfig": new_project_config,
|
21
|
+
}
|
22
|
+
|
23
|
+
|
24
|
+
def copy_project_config(
|
25
|
+
project_config, new_config_name=None, do_create_new_id=False, section_id_map=None
|
26
|
+
):
|
27
|
+
new_project_config = copy.deepcopy(project_config)
|
28
|
+
if new_config_name:
|
29
|
+
new_project_config["name"] = new_config_name
|
30
|
+
if do_create_new_id:
|
31
|
+
new_project_config["id"] = create_new_id()
|
32
|
+
if section_id_map:
|
33
|
+
new_project_config["children"] = rename_keys(
|
34
|
+
new_project_config["children"], section_id_map
|
35
|
+
)
|
36
|
+
return new_project_config
|