setta 0.0.7__py3-none-any.whl → 0.0.8.dev1__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.
setta/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.0.7"
1
+ __version__ = "0.0.8.dev1"
@@ -113,7 +113,7 @@ def load_project_config_metadata(db, config_name):
113
113
  return list(output.values())[0]
114
114
 
115
115
 
116
- def load_project_config(db, project_config_name):
116
+ def load_project_config(db, project_config_name, do_load_json_sources=True):
117
117
  projectConfig = load_project_config_metadata(db, project_config_name)
118
118
  sections_data = load_sections(db, list(projectConfig["children"].keys()))
119
119
  sectionConfigs = load_section_configs(db, projectConfig["id"])
@@ -127,9 +127,10 @@ def load_project_config(db, project_config_name):
127
127
  codeInfo, codeInfoCols = load_code_info_cols(db, sectionVariants)
128
128
  load_ev_refs_into_data_structures(db, sectionVariants, codeInfo)
129
129
  load_template_vars_into_data_structures(db, sectionVariants)
130
- load_json_sources_into_data_structures(
131
- sections, codeInfo, codeInfoCols, sectionVariants
132
- )
130
+ if do_load_json_sources:
131
+ load_json_sources_into_data_structures(
132
+ sections, codeInfo, codeInfoCols, sectionVariants
133
+ )
133
134
 
134
135
  return {
135
136
  "projectConfig": projectConfig,
@@ -159,11 +160,11 @@ def load_project_config_names(db, excludeProjectConfigName=None):
159
160
  return [r[0] for r in db.fetchall()]
160
161
 
161
162
 
162
- def load_full_project(db, excludeProjectConfigName=None):
163
+ def load_full_project(db, excludeProjectConfigName=None, do_load_json_sources=True):
163
164
  config_names = load_project_config_names(db, excludeProjectConfigName)
164
165
  configs = []
165
166
  for c in config_names:
166
- p = load_project_config(db, c)
167
+ p = load_project_config(db, c, do_load_json_sources)
167
168
  configs.append(p)
168
169
 
169
170
  return configs
@@ -5,6 +5,7 @@ from setta.database.db.codeInfo.utils import (
5
5
  add_defaults_to_code_info,
6
6
  add_defaults_to_code_info_cols,
7
7
  )
8
+ from setta.database.db.sections.jsonSource import remove_json_source_data
8
9
  from setta.database.db.sections.load import load_json_sources_into_data_structures
9
10
  from setta.database.db.sections.utils import add_defaults_to_sections
10
11
  from setta.database.db.sectionVariants.utils import add_defaults_to_section_variants
@@ -42,7 +43,9 @@ def remove_empty(x):
42
43
  return {k: v for k, v in x.items() if len(v) > 0}
43
44
 
44
45
 
45
- def filter_data_for_json_export(p):
46
+ def filter_data_for_json_export(p, keepCodeInfoThatHaveUITypes):
47
+ remove_json_source_data(p, keepCodeInfoThatHaveUITypes)
48
+
46
49
  p["projectConfig"] = filter_dict(
47
50
  p["projectConfig"],
48
51
  DEFAULT_VALUES["projectConfig"].keys(),
@@ -21,13 +21,13 @@ def _export_database(
21
21
  export_readable(db, filename, with_variants=True)
22
22
 
23
23
 
24
- def export_database(path):
24
+ def export_database(path, raw, readable, readable_with_variants):
25
25
  # Connect to the SQLite database
26
26
  dbq = DBQueue(path)
27
27
  dbq.connect()
28
28
  with dbq as db:
29
29
  # Export the database, including schema and data, to JSON and YAML
30
- _export_database(db, path, True, True, True)
30
+ _export_database(db, path, raw, readable, readable_with_variants)
31
31
  dbq.disconnect()
32
32
 
33
33
 
@@ -10,6 +10,6 @@ from setta.utils.constants import SETTA_FILES_FOLDER
10
10
  def get_configs_and_root_folder(db, filename):
11
11
  # export defaultdict the same way as dict
12
12
  yaml.add_representer(defaultdict, Representer.represent_dict)
13
- configs = load_full_project(db)
13
+ configs = load_full_project(db, do_load_json_sources=False)
14
14
  root_folder = SETTA_FILES_FOLDER / f"{filename}_export"
15
15
  return configs, root_folder
@@ -7,10 +7,7 @@ from setta.database.db.projects.utils import (
7
7
  add_defaults_to_project_and_load_json_sources,
8
8
  filter_data_for_json_export,
9
9
  )
10
- from setta.database.db.sections.jsonSource import (
11
- remove_json_source_data,
12
- save_json_source_data,
13
- )
10
+ from setta.database.db.sections.jsonSource import save_json_source_data
14
11
  from setta.utils.constants import CONSTANTS_FOLDER, SETTA_FILES_FOLDER, USER_SETTINGS
15
12
  from setta.utils.utils import get_absolute_path, save_json_to_file
16
13
 
@@ -113,6 +110,5 @@ class MetaSettingsFile:
113
110
 
114
111
  def save_settings_project(self, p):
115
112
  save_json_source_data(p)
116
- remove_json_source_data(p, keepCodeInfoThatHaveUITypes=False)
117
- filter_data_for_json_export(p)
113
+ filter_data_for_json_export(p, keepCodeInfoThatHaveUITypes=False)
118
114
  save_json_to_file(self.path_meta_settings, p)
setta/routers/projects.py CHANGED
@@ -178,7 +178,7 @@ def router_set_as_default_project(x: SetAsDefaultProjectRequest, dbq=Depends(get
178
178
 
179
179
  @router.post(C.ROUTE_FILTER_DATA_FOR_JSON_EXPORT)
180
180
  def router_filter_data_for_json_export(x: FilterDataForJSONExportRequest):
181
- filter_data_for_json_export(x.project)
181
+ filter_data_for_json_export(x.project, keepCodeInfoThatHaveUITypes=True)
182
182
  return x.project
183
183
 
184
184
 
setta/start.py CHANGED
@@ -43,8 +43,19 @@ def init_db(path, with_examples):
43
43
 
44
44
  @click.command()
45
45
  @click.argument("path", default=get_default_db_path(), required=False)
46
- def export_db(path):
47
- export_database(path)
46
+ @click.option("--raw", is_flag=True, help="Export raw database format")
47
+ @click.option("--readable", is_flag=True, help="Export in human-readable format")
48
+ @click.option(
49
+ "--readable-with-variants",
50
+ is_flag=True,
51
+ help="Export in readable format with variants",
52
+ )
53
+ def export_db(path, raw, readable, readable_with_variants):
54
+ # If no export options are specified, default to raw format
55
+ if not any([raw, readable, readable_with_variants]):
56
+ readable_with_variants = True
57
+
58
+ export_database(path, raw, readable, readable_with_variants)
48
59
 
49
60
 
50
61
  @click.command()