MCPcopy Index your code
hub / github.com/StackStorm/st2 / _diff

Function _diff

tools/diff-db-disk.py:165–234  ·  view source on GitHub ↗
(
    persistence_model, artifact_type, pack_dir=None, verbose=True, content_diff=True
)

Source from the content-addressed store, hash-verified

163
164
165def _diff(
166 persistence_model, artifact_type, pack_dir=None, verbose=True, content_diff=True
167):
168 artifacts_in_db_dict = _get_api_models_from_db(persistence_model, pack_dir=pack_dir)
169 artifacts_in_disk_dict = _get_api_models_from_disk(artifact_type, pack_dir=pack_dir)
170
171 # print(artifacts_in_disk_dict)
172 all_artifacts = set(
173 list(artifacts_in_db_dict.keys()) + list(artifacts_in_disk_dict.keys())
174 )
175
176 for artifact in all_artifacts:
177 artifact_in_db = artifacts_in_db_dict.get(artifact, None)
178 artifact_in_disk = artifacts_in_disk_dict.get(artifact, None)
179 artifact_in_disk_pretty_json = None
180 artifact_in_db_pretty_json = None
181
182 if verbose:
183 print(
184 "******************************************************************************"
185 )
186 print("Checking if artifact %s is present in both disk and db." % artifact)
187 if not artifact_in_db:
188 print(
189 "##############################################################################"
190 )
191 print(
192 "%s %s in disk not available in db." % (artifact_type.upper(), artifact)
193 )
194 artifact_in_disk_pretty_json = json.dumps(
195 artifact_in_disk.__json__(),
196 sort_keys=True,
197 indent=4,
198 separators=(",", ": "),
199 )
200 if verbose:
201 print("File contents: \n")
202 print(artifact_in_disk_pretty_json)
203 continue
204
205 if not artifact_in_disk:
206 print(
207 "##############################################################################"
208 )
209 print(
210 "%s %s in db not available in disk." % (artifact_type.upper(), artifact)
211 )
212 artifact_in_db_pretty_json = json.dumps(
213 artifact_in_db.__json__(),
214 sort_keys=True,
215 indent=4,
216 separators=(",", ": "),
217 )
218 if verbose:
219 print("DB contents: \n")
220 print(artifact_in_db_pretty_json)
221 continue
222 if verbose:

Callers 3

_diff_actionsFunction · 0.85
_diff_sensorsFunction · 0.85
_diff_rulesFunction · 0.85

Calls 6

_get_api_models_from_dbFunction · 0.85
_content_diffFunction · 0.85
keysMethod · 0.80
getMethod · 0.45
__json__Method · 0.45

Tested by

no test coverage detected