setta 0.0.1__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.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.dist-info/METADATA +0 -18
- setta-0.0.1.dist-info/RECORD +0 -5
- {setta-0.0.1.dist-info → setta-0.0.2.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,350 @@
|
|
1
|
+
import copy
|
2
|
+
import glob
|
3
|
+
import itertools
|
4
|
+
import json
|
5
|
+
import logging
|
6
|
+
from collections import defaultdict
|
7
|
+
|
8
|
+
from setta.database.db.artifacts.load import load_artifact_groups
|
9
|
+
from setta.database.db.codeInfo.utils import new_code_info_col, with_code_info_defaults
|
10
|
+
from setta.database.db.sections.utils import with_section_defaults
|
11
|
+
from setta.database.db.sectionVariants.utils import new_ev_entry, new_section_variant
|
12
|
+
from setta.database.utils import create_new_id
|
13
|
+
from setta.utils.constants import C
|
14
|
+
|
15
|
+
from ..sectionVariants.load import load_section_variants
|
16
|
+
from ..uiTypes.load import load_uitypecols, load_uitypes
|
17
|
+
|
18
|
+
logger = logging.getLogger(__name__)
|
19
|
+
|
20
|
+
|
21
|
+
def load_sections(db, ids):
|
22
|
+
all_ids, child_to_parent_id = get_section_ids(db, ids)
|
23
|
+
|
24
|
+
section_id_to_config_count = num_projects_each_section_exists_in(db, all_ids)
|
25
|
+
|
26
|
+
placeholders = ", ".join(["?"] * len(all_ids))
|
27
|
+
query = f"""
|
28
|
+
SELECT
|
29
|
+
S.*,
|
30
|
+
U.nonPresetUITypeIds,
|
31
|
+
E.variantIds,
|
32
|
+
A.artifactGroupIds
|
33
|
+
FROM
|
34
|
+
Section S
|
35
|
+
LEFT JOIN
|
36
|
+
(
|
37
|
+
SELECT
|
38
|
+
asNonPresetForSectionId,
|
39
|
+
GROUP_CONCAT(id) AS nonPresetUITypeIds
|
40
|
+
FROM
|
41
|
+
UIType
|
42
|
+
GROUP BY
|
43
|
+
asNonPresetForSectionId
|
44
|
+
) AS U ON S.id = U.asNonPresetForSectionId
|
45
|
+
LEFT JOIN
|
46
|
+
(
|
47
|
+
SELECT
|
48
|
+
originSectionId,
|
49
|
+
GROUP_CONCAT(id) AS variantIds
|
50
|
+
FROM
|
51
|
+
SectionVariantId
|
52
|
+
GROUP BY
|
53
|
+
originSectionId
|
54
|
+
) AS E ON S.id = E.originSectionId
|
55
|
+
LEFT JOIN
|
56
|
+
(
|
57
|
+
SELECT
|
58
|
+
originSectionId,
|
59
|
+
GROUP_CONCAT(id) AS artifactGroupIds
|
60
|
+
FROM
|
61
|
+
ArtifactGroupId
|
62
|
+
GROUP BY
|
63
|
+
originSectionId
|
64
|
+
) AS A ON S.id = A.originSectionId
|
65
|
+
WHERE
|
66
|
+
S.id IN ({placeholders})
|
67
|
+
GROUP BY
|
68
|
+
S.id;
|
69
|
+
"""
|
70
|
+
db.execute(query, all_ids)
|
71
|
+
|
72
|
+
sections = {}
|
73
|
+
for v in db.fetchall():
|
74
|
+
v = dict(v)
|
75
|
+
data = v.pop("data")
|
76
|
+
v["isInOtherProjectConfigs"] = section_id_to_config_count[v["id"]] > 1
|
77
|
+
v["parentId"] = child_to_parent_id.get(v["id"], None)
|
78
|
+
v["variantIds"] = v["variantIds"].split(",") if v["variantIds"] else []
|
79
|
+
v["artifactGroupIds"] = (
|
80
|
+
v["artifactGroupIds"].split(",") if v["artifactGroupIds"] else []
|
81
|
+
)
|
82
|
+
v["nonPresetUITypeIds"] = (
|
83
|
+
v["nonPresetUITypeIds"].split(",") if v["nonPresetUITypeIds"] else []
|
84
|
+
)
|
85
|
+
sections[v["id"]] = with_section_defaults(
|
86
|
+
**v,
|
87
|
+
**json.loads(data),
|
88
|
+
)
|
89
|
+
|
90
|
+
variantIds = list(
|
91
|
+
itertools.chain.from_iterable([s["variantIds"] for s in sections.values()])
|
92
|
+
)
|
93
|
+
sectionVariants = load_section_variants(db, variantIds)
|
94
|
+
|
95
|
+
artifactGroupIds = list(
|
96
|
+
itertools.chain.from_iterable(
|
97
|
+
[s["artifactGroupIds"] for s in sections.values()]
|
98
|
+
)
|
99
|
+
)
|
100
|
+
artifactGroups = load_artifact_groups(db, artifactGroupIds)
|
101
|
+
|
102
|
+
uiTypeCols = load_uitypecols(db, [s["uiTypeColId"] for s in sections.values()])
|
103
|
+
|
104
|
+
nonPresetUITypeIds = []
|
105
|
+
for s in sections.values():
|
106
|
+
nonPresetUITypeIds.extend(s["nonPresetUITypeIds"])
|
107
|
+
for u in uiTypeCols.values():
|
108
|
+
for c in u.values():
|
109
|
+
nonPresetUITypeIds.extend(c["nonPresetUITypeIds"])
|
110
|
+
|
111
|
+
nonPresetUITypes = load_uitypes(db, nonPresetUITypeIds)
|
112
|
+
|
113
|
+
return {
|
114
|
+
"sections": sections,
|
115
|
+
"sectionVariants": sectionVariants,
|
116
|
+
"artifactGroups": artifactGroups,
|
117
|
+
"uiTypeCols": uiTypeCols,
|
118
|
+
"nonPresetUITypes": nonPresetUITypes,
|
119
|
+
}
|
120
|
+
|
121
|
+
|
122
|
+
# TODO: try using a recursive sql query for this
|
123
|
+
def get_section_ids(db, top_level_ids):
|
124
|
+
section_id_to_variants = defaultdict(list)
|
125
|
+
variant_id_to_children = defaultdict(list)
|
126
|
+
|
127
|
+
db.execute("SELECT id, originSectionId FROM SectionVariantId")
|
128
|
+
for row in db.fetchall():
|
129
|
+
section_id_to_variants[row["originSectionId"]].append(row["id"])
|
130
|
+
|
131
|
+
db.execute("SELECT idid, childId FROM SectionVariantChildren")
|
132
|
+
for row in db.fetchall():
|
133
|
+
variant_id_to_children[row["idid"]].append(row["childId"])
|
134
|
+
|
135
|
+
ids = copy.deepcopy(top_level_ids)
|
136
|
+
output = copy.deepcopy(top_level_ids)
|
137
|
+
child_to_parent_id = {}
|
138
|
+
visited = set()
|
139
|
+
|
140
|
+
while len(ids) > 0:
|
141
|
+
id = ids.pop()
|
142
|
+
if id in visited:
|
143
|
+
continue
|
144
|
+
variantIds = section_id_to_variants[id]
|
145
|
+
for vid in variantIds:
|
146
|
+
for c in variant_id_to_children[vid]:
|
147
|
+
if c not in visited:
|
148
|
+
ids.append(c)
|
149
|
+
output.append(c)
|
150
|
+
child_to_parent_id[c] = id
|
151
|
+
visited.add(id)
|
152
|
+
|
153
|
+
return output, child_to_parent_id
|
154
|
+
|
155
|
+
|
156
|
+
def load_section_configs(db, project_config_id):
|
157
|
+
query = """
|
158
|
+
SELECT s.sectionId, s.variantId, s.data, v.variantId as selectedVariantId
|
159
|
+
FROM SectionConfig s
|
160
|
+
LEFT JOIN SectionConfigSelectedVariants v
|
161
|
+
ON s.sectionId = v.sectionId
|
162
|
+
AND s.projectConfigId = v.projectConfigId
|
163
|
+
WHERE s.projectConfigId = :projectConfigId
|
164
|
+
"""
|
165
|
+
|
166
|
+
db.execute(query, {"projectConfigId": project_config_id})
|
167
|
+
output = {}
|
168
|
+
for row in db.fetchall():
|
169
|
+
section_id = row["sectionId"]
|
170
|
+
if section_id not in output:
|
171
|
+
output[section_id] = {
|
172
|
+
"id": section_id,
|
173
|
+
"variantId": row["variantId"],
|
174
|
+
"selectedVariantIds": {},
|
175
|
+
**json.loads(row["data"]),
|
176
|
+
}
|
177
|
+
if row["selectedVariantId"]:
|
178
|
+
output[section_id]["selectedVariantIds"][row["selectedVariantId"]] = True
|
179
|
+
|
180
|
+
return output
|
181
|
+
|
182
|
+
|
183
|
+
def num_projects_each_section_exists_in(db, section_ids):
|
184
|
+
placeholders = ", ".join(["?"] * len(section_ids))
|
185
|
+
query = f"""
|
186
|
+
SELECT sectionId, COUNT(DISTINCT projectConfigId) as projectConfigCount
|
187
|
+
FROM SectionConfig
|
188
|
+
WHERE sectionId IN ({placeholders})
|
189
|
+
GROUP BY sectionId
|
190
|
+
"""
|
191
|
+
|
192
|
+
db.execute(query, section_ids)
|
193
|
+
output = {}
|
194
|
+
for row in db.fetchall():
|
195
|
+
output[row[0]] = row[1]
|
196
|
+
|
197
|
+
return output
|
198
|
+
|
199
|
+
|
200
|
+
def load_json_sources_into_data_structures(
|
201
|
+
sections, codeInfo, codeInfoCols, sectionVariants, section_ids=None
|
202
|
+
):
|
203
|
+
filenames_loaded = set()
|
204
|
+
sections = {
|
205
|
+
k: v
|
206
|
+
for k, v in sections.items()
|
207
|
+
if v["jsonSource"] and ((not section_ids) or k in section_ids)
|
208
|
+
}
|
209
|
+
for s in sections.values():
|
210
|
+
new_data = load_json_source(s["jsonSource"], s["jsonSourceKeys"])
|
211
|
+
for filename, data in new_data.items():
|
212
|
+
codeInfo.update(data["codeInfo"])
|
213
|
+
variantId = None
|
214
|
+
for vid in s["variantIds"]:
|
215
|
+
if sectionVariants[vid]["name"] == filename:
|
216
|
+
variantId = vid
|
217
|
+
break
|
218
|
+
if not variantId:
|
219
|
+
variantId, section_variant = new_section_variant(
|
220
|
+
name=filename,
|
221
|
+
)
|
222
|
+
s["variantIds"].append(variantId)
|
223
|
+
sectionVariants[variantId] = section_variant
|
224
|
+
|
225
|
+
curr_section_variant = sectionVariants[variantId]
|
226
|
+
curr_section_variant["values"] = data["sectionVariantValues"]
|
227
|
+
codeInfoColId = curr_section_variant["codeInfoColId"]
|
228
|
+
|
229
|
+
if not codeInfoColId:
|
230
|
+
codeInfoColId = create_new_id()
|
231
|
+
curr_section_variant["codeInfoColId"] = codeInfoColId
|
232
|
+
codeInfoCols[codeInfoColId] = new_code_info_col()
|
233
|
+
|
234
|
+
codeInfoCols[codeInfoColId]["children"] = data["codeInfoColChildren"]
|
235
|
+
|
236
|
+
s["configLanguage"] = "json"
|
237
|
+
filenames_loaded.add(filename)
|
238
|
+
|
239
|
+
# delete variants that aren't associated with a loaded file
|
240
|
+
to_delete = []
|
241
|
+
for s in sections.values():
|
242
|
+
for vid in s["variantIds"]:
|
243
|
+
if sectionVariants[vid]["name"] not in filenames_loaded:
|
244
|
+
to_delete.append(vid)
|
245
|
+
|
246
|
+
for vid in to_delete:
|
247
|
+
if sectionVariants[vid]["codeInfoColId"]:
|
248
|
+
del codeInfoCols[sectionVariants[vid]["codeInfoColId"]]
|
249
|
+
del sectionVariants[vid]
|
250
|
+
|
251
|
+
for s in sections.values():
|
252
|
+
s["jsonSourceMissing"] = False
|
253
|
+
s["variantIds"] = [v for v in s["variantIds"] if v in sectionVariants]
|
254
|
+
if len(s["variantIds"]) == 0:
|
255
|
+
variantId, variant = new_section_variant()
|
256
|
+
s["variantIds"].append(variantId)
|
257
|
+
sectionVariants[variantId] = variant
|
258
|
+
s["jsonSourceMissing"] = True
|
259
|
+
elif s["variantId"] not in s["variantIds"]:
|
260
|
+
s["variantId"] = s["variantIds"][0]
|
261
|
+
|
262
|
+
|
263
|
+
def load_json_source(filename_glob, jsonSourceKeys):
|
264
|
+
new_data = {}
|
265
|
+
|
266
|
+
filenames = glob.glob(filename_glob)
|
267
|
+
for filename in filenames:
|
268
|
+
try:
|
269
|
+
with open(filename, "r") as f:
|
270
|
+
jsonSourceData = json.load(f)
|
271
|
+
except:
|
272
|
+
logger.debug(f"couldn't find: {filename}")
|
273
|
+
continue
|
274
|
+
|
275
|
+
new_data[filename] = {
|
276
|
+
"codeInfo": {},
|
277
|
+
"codeInfoColChildren": {},
|
278
|
+
"sectionVariantValues": {},
|
279
|
+
}
|
280
|
+
|
281
|
+
try:
|
282
|
+
for k in jsonSourceKeys:
|
283
|
+
jsonSourceData = jsonSourceData[k]
|
284
|
+
except:
|
285
|
+
# TODO print warning or something
|
286
|
+
pass
|
287
|
+
|
288
|
+
process_json_object(
|
289
|
+
new_data, jsonSourceData, filename, filename_glob, jsonSourceKeys
|
290
|
+
)
|
291
|
+
|
292
|
+
if len(jsonSourceKeys) > 0:
|
293
|
+
# point directly from None (the root) to the children
|
294
|
+
highest_key = create_json_code_info_key(filename_glob, jsonSourceKeys)
|
295
|
+
codeInfoChildren = new_data[filename]["codeInfoColChildren"]
|
296
|
+
codeInfoChildren[None] = codeInfoChildren[highest_key]
|
297
|
+
del codeInfoChildren[highest_key]
|
298
|
+
|
299
|
+
return new_data
|
300
|
+
|
301
|
+
|
302
|
+
def process_json_object(output, obj, filename, filename_glob, current_path):
|
303
|
+
if not isinstance(obj, dict):
|
304
|
+
return
|
305
|
+
|
306
|
+
children_keys = []
|
307
|
+
for k, v in obj.items():
|
308
|
+
path = current_path + [k]
|
309
|
+
full_key, is_dict = create_json_code_info(
|
310
|
+
filename, filename_glob, path, k, v, output
|
311
|
+
)
|
312
|
+
children_keys.append(full_key)
|
313
|
+
if is_dict:
|
314
|
+
process_json_object(output, v, filename, filename_glob, path)
|
315
|
+
|
316
|
+
parent_id = None
|
317
|
+
if len(current_path) > 0:
|
318
|
+
parent_id = create_json_code_info_key(filename_glob, current_path)
|
319
|
+
|
320
|
+
output[filename]["codeInfoColChildren"][parent_id] = children_keys
|
321
|
+
|
322
|
+
|
323
|
+
def create_json_code_info(filename, filename_glob, path, key, value, output):
|
324
|
+
full_key = create_json_code_info_key(filename_glob, path)
|
325
|
+
# Create code info entry
|
326
|
+
output[filename]["codeInfo"][full_key] = with_code_info_defaults(
|
327
|
+
id=full_key, name=key
|
328
|
+
)
|
329
|
+
output[filename]["codeInfoColChildren"][full_key] = []
|
330
|
+
|
331
|
+
is_dict = isinstance(value, dict)
|
332
|
+
# Create variant value entry
|
333
|
+
if is_dict:
|
334
|
+
# For objects, store empty value and process children
|
335
|
+
output[filename]["sectionVariantValues"][full_key] = new_ev_entry()
|
336
|
+
else:
|
337
|
+
# For non-objects, store the value directly
|
338
|
+
output[filename]["sectionVariantValues"][full_key] = new_ev_entry(
|
339
|
+
value=json.dumps(value)
|
340
|
+
)
|
341
|
+
|
342
|
+
return full_key, is_dict
|
343
|
+
|
344
|
+
|
345
|
+
def create_json_code_info_key(filename_glob, path):
|
346
|
+
# specify separators to make json.dumps equivalent to JSON.stringify
|
347
|
+
key = json.dumps(
|
348
|
+
{"filenameGlob": filename_glob, "key": path}, separators=(",", ":")
|
349
|
+
)
|
350
|
+
return f"{C.JSON_SOURCE_PREFIX}{key}"
|
@@ -0,0 +1,204 @@
|
|
1
|
+
import json
|
2
|
+
|
3
|
+
from setta.utils.constants import DEFAULT_VALUES, SECTION_TABLE_DATA_JSON_FIELDS
|
4
|
+
from setta.utils.utils import filter_dict, replace_null_keys_with_none
|
5
|
+
|
6
|
+
|
7
|
+
def save_sections(db, sections, section_variants):
|
8
|
+
query = """
|
9
|
+
INSERT INTO Section (
|
10
|
+
id,
|
11
|
+
name,
|
12
|
+
data,
|
13
|
+
uiTypeId,
|
14
|
+
uiTypeColId,
|
15
|
+
defaultVariantId
|
16
|
+
)
|
17
|
+
VALUES (
|
18
|
+
:id,
|
19
|
+
:name,
|
20
|
+
:data,
|
21
|
+
:uiTypeId,
|
22
|
+
:uiTypeColId,
|
23
|
+
:defaultVariantId
|
24
|
+
)
|
25
|
+
ON CONFLICT (id)
|
26
|
+
DO UPDATE SET
|
27
|
+
name = :name,
|
28
|
+
data = :data,
|
29
|
+
uiTypeId = :uiTypeId,
|
30
|
+
uiTypeColId = :uiTypeColId,
|
31
|
+
defaultVariantId = :defaultVariantId
|
32
|
+
"""
|
33
|
+
|
34
|
+
query_params = [
|
35
|
+
{
|
36
|
+
"id": s["id"],
|
37
|
+
"name": s["name"],
|
38
|
+
"data": json.dumps(
|
39
|
+
filter_dict(
|
40
|
+
s, SECTION_TABLE_DATA_JSON_FIELDS, DEFAULT_VALUES["section"]
|
41
|
+
)
|
42
|
+
),
|
43
|
+
"uiTypeId": s["uiTypeId"],
|
44
|
+
"uiTypeColId": s["uiTypeColId"],
|
45
|
+
"defaultVariantId": s["defaultVariantId"],
|
46
|
+
}
|
47
|
+
for s in sections.values()
|
48
|
+
]
|
49
|
+
|
50
|
+
db.executemany(query, query_params)
|
51
|
+
|
52
|
+
ids = [s["id"] for s in sections.values()]
|
53
|
+
placeholders = ", ".join(["?"] * len(ids))
|
54
|
+
query = f"""
|
55
|
+
UPDATE SectionVariantId
|
56
|
+
SET originSectionId = null
|
57
|
+
WHERE originSectionId IN ({placeholders})
|
58
|
+
"""
|
59
|
+
db.execute(query, ids)
|
60
|
+
|
61
|
+
query = """
|
62
|
+
UPDATE SectionVariantId
|
63
|
+
SET originSectionId = :sectionId
|
64
|
+
WHERE id = :variantId
|
65
|
+
"""
|
66
|
+
query_params = []
|
67
|
+
for s in sections.values():
|
68
|
+
for variantId in s["variantIds"]:
|
69
|
+
query_params.append({"variantId": variantId, "sectionId": s["id"]})
|
70
|
+
db.executemany(query, query_params)
|
71
|
+
|
72
|
+
query = f"""
|
73
|
+
UPDATE UIType
|
74
|
+
SET asNonPresetForSectionId = null
|
75
|
+
WHERE asNonPresetForSectionId IN ({placeholders})
|
76
|
+
"""
|
77
|
+
db.execute(query, ids)
|
78
|
+
|
79
|
+
query = """
|
80
|
+
UPDATE UIType
|
81
|
+
SET asNonPresetForSectionId = :sectionId
|
82
|
+
WHERE id = :uiTypeId
|
83
|
+
"""
|
84
|
+
query_params = []
|
85
|
+
for s in sections.values():
|
86
|
+
for uiTypeId in s["nonPresetUITypeIds"]:
|
87
|
+
query_params.append({"uiTypeId": uiTypeId, "sectionId": s["id"]})
|
88
|
+
db.executemany(query, query_params)
|
89
|
+
|
90
|
+
query = """
|
91
|
+
UPDATE Section
|
92
|
+
SET paramSweepSectionId = :paramSweepSectionId
|
93
|
+
WHERE id = :id
|
94
|
+
"""
|
95
|
+
db.executemany(
|
96
|
+
query,
|
97
|
+
[
|
98
|
+
{"id": s["id"], "paramSweepSectionId": s["paramSweepSectionId"]}
|
99
|
+
for s in sections.values()
|
100
|
+
],
|
101
|
+
)
|
102
|
+
|
103
|
+
query = f"""
|
104
|
+
UPDATE ArtifactGroupId
|
105
|
+
SET originSectionId = null
|
106
|
+
WHERE originSectionId IN ({placeholders})
|
107
|
+
"""
|
108
|
+
db.execute(query, ids)
|
109
|
+
|
110
|
+
query = """
|
111
|
+
UPDATE ArtifactGroupId
|
112
|
+
SET originSectionId = :sectionId
|
113
|
+
WHERE id = :artifactId
|
114
|
+
"""
|
115
|
+
for s in sections.values():
|
116
|
+
for a in s["artifactGroupIds"]:
|
117
|
+
query_params.append(
|
118
|
+
{
|
119
|
+
"sectionId": s["id"],
|
120
|
+
"artifactId": a,
|
121
|
+
}
|
122
|
+
)
|
123
|
+
db.executemany(query, query_params)
|
124
|
+
|
125
|
+
# delete children
|
126
|
+
placeholders = ", ".join(["?"] * len(section_variants))
|
127
|
+
query = f"""
|
128
|
+
DELETE FROM SectionVariantChildren
|
129
|
+
WHERE idid IN ({placeholders});
|
130
|
+
"""
|
131
|
+
query_params = list(section_variants.keys())
|
132
|
+
db.execute(query, query_params)
|
133
|
+
|
134
|
+
# add children
|
135
|
+
query = """
|
136
|
+
INSERT INTO SectionVariantChildren (idid, childId, "order")
|
137
|
+
VALUES (:idid, :childId, :order)
|
138
|
+
"""
|
139
|
+
query_params = []
|
140
|
+
for idid, variant in section_variants.items():
|
141
|
+
query_params.extend(
|
142
|
+
[
|
143
|
+
{"idid": idid, "childId": x, "order": i}
|
144
|
+
for i, x in enumerate(variant["children"])
|
145
|
+
]
|
146
|
+
)
|
147
|
+
db.executemany(query, query_params)
|
148
|
+
|
149
|
+
placeholders = ", ".join(["?"] * len(section_variants))
|
150
|
+
query = f"""
|
151
|
+
DELETE FROM SectionVariantRunGroup
|
152
|
+
WHERE idid IN ({placeholders})
|
153
|
+
"""
|
154
|
+
query_params = list(section_variants.keys())
|
155
|
+
db.execute(query, query_params)
|
156
|
+
|
157
|
+
run_group_query_params = []
|
158
|
+
run_group_versions_query_params = []
|
159
|
+
run_group_param_sweeps_query_params = []
|
160
|
+
for idid, variant in section_variants.items():
|
161
|
+
variant = replace_null_keys_with_none(variant)
|
162
|
+
for sectionId, detailsForSection in variant["runGroup"].items():
|
163
|
+
for parentVariantId, detailsForParentVariant in detailsForSection.items():
|
164
|
+
base_query_params = {
|
165
|
+
"idid": idid,
|
166
|
+
"sectionId": sectionId,
|
167
|
+
"parentVariantId": parentVariantId,
|
168
|
+
}
|
169
|
+
run_group_query_params.append(
|
170
|
+
{
|
171
|
+
**base_query_params,
|
172
|
+
"selected": detailsForParentVariant["selected"],
|
173
|
+
}
|
174
|
+
)
|
175
|
+
for versionId, selected in detailsForParentVariant["versions"].items():
|
176
|
+
run_group_versions_query_params.append(
|
177
|
+
{
|
178
|
+
**base_query_params,
|
179
|
+
"versionId": versionId,
|
180
|
+
"selected": selected,
|
181
|
+
}
|
182
|
+
)
|
183
|
+
for sweepId, selected in detailsForParentVariant["paramSweeps"].items():
|
184
|
+
run_group_param_sweeps_query_params.append(
|
185
|
+
{**base_query_params, "sweepId": sweepId, "selected": selected}
|
186
|
+
)
|
187
|
+
|
188
|
+
query = """
|
189
|
+
INSERT INTO SectionVariantRunGroup (idid, sectionId, parentVariantId, selected)
|
190
|
+
VALUES (:idid, :sectionId, :parentVariantId, :selected)
|
191
|
+
"""
|
192
|
+
db.executemany(query, run_group_query_params)
|
193
|
+
|
194
|
+
query = """
|
195
|
+
INSERT INTO SectionVariantRunGroupVersions (idid, sectionId, parentVariantId, versionId, selected)
|
196
|
+
VALUES (:idid, :sectionId, :parentVariantId, :versionId, :selected)
|
197
|
+
"""
|
198
|
+
db.executemany(query, run_group_versions_query_params)
|
199
|
+
|
200
|
+
query = """
|
201
|
+
INSERT INTO SectionVariantRunGroupParamSweeps (idid, sectionId, parentVariantId, sweepId, selected)
|
202
|
+
VALUES (:idid, :sectionId, :parentVariantId, :sweepId, :selected)
|
203
|
+
"""
|
204
|
+
db.executemany(query, run_group_param_sweeps_query_params)
|
@@ -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_section_defaults(**kwargs):
|
8
|
+
return recursive_dict_merge(copy.deepcopy(DEFAULT_VALUES["section"]), kwargs)
|
9
|
+
|
10
|
+
|
11
|
+
def add_defaults_to_sections(sections):
|
12
|
+
for k, v in sections.items():
|
13
|
+
sections[k] = with_section_defaults(**v)
|
File without changes
|
@@ -0,0 +1,33 @@
|
|
1
|
+
from setta.database.utils import remap_ids, rename_keys
|
2
|
+
from setta.utils.constants import BASE_UI_TYPES
|
3
|
+
|
4
|
+
|
5
|
+
def copy_ui_types(ui_types):
|
6
|
+
non_preset_ui_types = {k: v for k, v in ui_types.items() if not v["presetType"]}
|
7
|
+
new_ui_types, ui_type_id_map = remap_ids(non_preset_ui_types)
|
8
|
+
|
9
|
+
for u in new_ui_types.values():
|
10
|
+
u["id"] = ui_type_id_map[u["id"]]
|
11
|
+
|
12
|
+
preset_ui_types = {k: v for k, v in ui_types.items() if v["presetType"]}
|
13
|
+
preset_ui_types.update(BASE_UI_TYPES)
|
14
|
+
# preset ids shouldn't change
|
15
|
+
for k in preset_ui_types.keys():
|
16
|
+
ui_type_id_map[k] = k
|
17
|
+
|
18
|
+
return {**new_ui_types, **preset_ui_types}, ui_type_id_map
|
19
|
+
|
20
|
+
|
21
|
+
def copy_ui_type_cols(ui_type_cols, ui_type_id_map, code_info_id_map):
|
22
|
+
new_ui_type_cols, ui_type_col_id_map = remap_ids(ui_type_cols)
|
23
|
+
|
24
|
+
for id in new_ui_type_cols.keys():
|
25
|
+
new_ui_type_cols[id] = rename_keys(new_ui_type_cols[id], code_info_id_map)
|
26
|
+
col = new_ui_type_cols[id]
|
27
|
+
for code_info_id, u in col.items():
|
28
|
+
col[code_info_id]["uiTypeId"] = ui_type_id_map[u["uiTypeId"]]
|
29
|
+
col[code_info_id]["nonPresetUITypeIds"] = [
|
30
|
+
ui_type_id_map[x] for x in col[code_info_id]["nonPresetUITypeIds"]
|
31
|
+
]
|
32
|
+
|
33
|
+
return new_ui_type_cols, ui_type_col_id_map
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import json
|
2
|
+
|
3
|
+
|
4
|
+
def load_uitypes(db, ids):
|
5
|
+
placeholders = ", ".join(["?"] * len(ids))
|
6
|
+
query = f"""
|
7
|
+
SELECT id, type, data
|
8
|
+
FROM UIType
|
9
|
+
WHERE UIType.id in ({placeholders})
|
10
|
+
"""
|
11
|
+
|
12
|
+
db.execute(query, ids)
|
13
|
+
output = {}
|
14
|
+
for row in db.fetchall():
|
15
|
+
output[row["id"]] = {
|
16
|
+
"id": row["id"],
|
17
|
+
"type": row["type"],
|
18
|
+
**json.loads(row["data"]),
|
19
|
+
}
|
20
|
+
return output
|
21
|
+
|
22
|
+
|
23
|
+
def load_uitypecols(db, ids):
|
24
|
+
placeholders = ", ".join(["?"] * len(ids))
|
25
|
+
query = f"""
|
26
|
+
SELECT UITypeColId.id, UITypeCol.codeInfoId, UITypeCol.uiTypeId, GROUP_CONCAT(UIType.id) as nonPresetUITypeIds
|
27
|
+
FROM UITypeColId
|
28
|
+
LEFT JOIN UITypeCol
|
29
|
+
ON UITypeColId.id = UITypeCol.idid
|
30
|
+
LEFT JOIN UIType
|
31
|
+
ON
|
32
|
+
UITypeColId.id = UIType.asNonPresetForUITypeColId
|
33
|
+
AND
|
34
|
+
UITypeCol.codeInfoId = UIType.asNonPresetForCodeInfoId
|
35
|
+
WHERE UITypeColId.id in ({placeholders})
|
36
|
+
GROUP BY UITypeColId.id, UITypeCol.codeInfoId
|
37
|
+
"""
|
38
|
+
db.execute(query, ids)
|
39
|
+
output = {}
|
40
|
+
for row in db.fetchall():
|
41
|
+
if row["id"] not in output:
|
42
|
+
output[row["id"]] = {}
|
43
|
+
output[row["id"]][row["codeInfoId"]] = {
|
44
|
+
"uiTypeId": row["uiTypeId"],
|
45
|
+
"nonPresetUITypeIds": row["nonPresetUITypeIds"].split(",")
|
46
|
+
if row["nonPresetUITypeIds"]
|
47
|
+
else [],
|
48
|
+
}
|
49
|
+
for v in output.values():
|
50
|
+
v.pop(None, None)
|
51
|
+
return output
|