checkmate5 4.1.0.dev40__py3-none-any.whl → 4.1.0.dev41__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.
@@ -106,14 +106,30 @@ def get_project(project_path, project_config, settings, backend):
106
106
  project_class = project_config.get('project_class', 'Project')
107
107
  ProjectClass = settings.models[project_class]
108
108
 
109
- # Attempt to find the project by project_id
110
- project = backend.get(ProjectClass, {'pk': project_config['project_id']})
109
+ try:
110
+ # Try to get the project using its primary key
111
+ project = backend.get(ProjectClass, {'pk': project_config['project_id']})
112
+
113
+
114
+ except ProjectClass.DoesNotExist:
115
+ # If the project doesn't exist, create a new one
116
+ # Create a new instance of ProjectClass.
117
+ # It's good practice to set the 'pk' explicitly if it's derived from your config,
118
+ # otherwise BlitzDB will generate one. Here, we're using project_id as pk.
119
+ project = ProjectClass(project_config)
120
+ project.pk = project_config['project_id'] # Ensure the PK is set to your project_id
121
+
122
+ # Save the newly created project
123
+ backend.save(project)
111
124
 
112
- # If the project doesn't exist, create a new one
113
- if project is None:
114
- project = ProjectClass(pk=project_config['project_id'])
115
- backend.add(project)
116
125
  # If needed, ensure that the project is persisted
117
- backend.commit() # If your backend requires an explicit commit
126
+ # (Crucial for FileBackend, optional/less critical for MongoBackend as it auto-persists)
127
+ backend.commit()
128
+
129
+ except ProjectClass.MultipleDocumentsReturned:
130
+ # This case should ideally not happen if 'pk' is truly unique.
131
+ # It means you have multiple documents with the same generated PK (a severe data integrity issue)
132
+ # or you're querying on non-unique fields with get().
133
+ raise # Re-raise the exception or handle appropriately
118
134
 
119
135
  return project
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: checkmate5
3
- Version: 4.1.0.dev40
3
+ Version: 4.1.0.dev41
4
4
  Summary: A meta-code checker written in Python.
5
5
  Author: Andreas Dewes
6
6
  License: AGPL-3.0
@@ -83,7 +83,7 @@ checkmate/lib/stats/helpers.py,sha256=X21Pb7dz3PWubDRoqUjbxwonl43TRxqKEcwyM80tS6
83
83
  checkmate/lib/stats/mapreduce.py,sha256=rGdA_HninEZSeowtBn5R02c6wyT5dxcu-0T2ftlMnY0,782
84
84
  checkmate/management/__init__.py,sha256=iwhKnzeBJLKxpRVjvzwiRE63_zNpIBfaKLITauVph-0,24
85
85
  checkmate/management/decorators.py,sha256=iwhKnzeBJLKxpRVjvzwiRE63_zNpIBfaKLITauVph-0,24
86
- checkmate/management/helpers.py,sha256=hMAdTC3JAALvzNWl_cFjwlQ-09cjg12wNT29vbddIfU,4621
86
+ checkmate/management/helpers.py,sha256=Yy99f_IpHdpd08XFZ17ydzcAToutUh-WJKpQwo5ar0k,5413
87
87
  checkmate/management/commands/__init__.py,sha256=XAi0y8z1NviyGvLB68Oxnzr6Nw5AP8xgbcSSnc1Zcvw,766
88
88
  checkmate/management/commands/alembic.py,sha256=DTWH8hcY6UmWDo0wMwcID_wQIa-es7nyJHV6p1_T4FQ,718
89
89
  checkmate/management/commands/analyze.py,sha256=J1rawVEGjbrXT9ArfUVpfoLNs2JaFkV4mCrBnEIrXaw,1159
@@ -111,9 +111,9 @@ checkmate/scripts/manage.py,sha256=mpioBaxzirAKXZtbxO-y4dbOcc6UoP0MaAMsNuKHbz0,4
111
111
  checkmate/settings/__init__.py,sha256=z32hPz-kGS-tTGa6dWCFjrrrbS_eagLd-YrqBP3gjWI,33
112
112
  checkmate/settings/base.py,sha256=3WBXZITqoWepIja96bo5JTi-TDpQALPTCugL0E8z-yE,4551
113
113
  checkmate/settings/defaults.py,sha256=JaR9H5fciWy4PMX3oqIeaui7HDzjWSIhsXZD3tj4mSc,2736
114
- checkmate5-4.1.0.dev40.dist-info/licenses/LICENSE.txt,sha256=SGQTFjJQjkYGoK1PCFfMKpfgRLm3yL0h9Mq2o26sm2E,151451
115
- checkmate5-4.1.0.dev40.dist-info/METADATA,sha256=R1Qoj7bziHazH38CC5ARQ_XJgfMwpy0kxALFM0Ls3HQ,1262
116
- checkmate5-4.1.0.dev40.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
117
- checkmate5-4.1.0.dev40.dist-info/entry_points.txt,sha256=FbGnau5C4z98WmBYpMJqUzobQEr1AIi9aZApSavNojQ,60
118
- checkmate5-4.1.0.dev40.dist-info/top_level.txt,sha256=tl6eIJXedpLZbcbmYEwlhEzuTaSt0TvIRUesOb8gtng,10
119
- checkmate5-4.1.0.dev40.dist-info/RECORD,,
114
+ checkmate5-4.1.0.dev41.dist-info/licenses/LICENSE.txt,sha256=SGQTFjJQjkYGoK1PCFfMKpfgRLm3yL0h9Mq2o26sm2E,151451
115
+ checkmate5-4.1.0.dev41.dist-info/METADATA,sha256=hUzaNtT0z8rGoujkWY-ko63THIlv8LELQ2zhHxRafJw,1262
116
+ checkmate5-4.1.0.dev41.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
117
+ checkmate5-4.1.0.dev41.dist-info/entry_points.txt,sha256=FbGnau5C4z98WmBYpMJqUzobQEr1AIi9aZApSavNojQ,60
118
+ checkmate5-4.1.0.dev41.dist-info/top_level.txt,sha256=tl6eIJXedpLZbcbmYEwlhEzuTaSt0TvIRUesOb8gtng,10
119
+ checkmate5-4.1.0.dev41.dist-info/RECORD,,