create_full_molecule
- specatalog.helpers.full_entry.create_full_molecule(data, molecular_formula_path, fmt, progress=None)[source]
Create a complete molecule entry with atomic database and file operations.
Performs all molecule creation steps in a transaction-safe manner:
Creates the database entry.
Sets up a temporary directory.
Creates the temporary molecule directory.
Determines the structural formula files to copy.
Copies the molecular structure files into the temporary archive.
Copies the completed molecule to the final archive location.
Commits the database transaction.
- Parameters:
data (cr.molecule_model_pyd) – Molecule metadata used to create the database entry.
molecular_formula_path (list[str]) –
List of paths to structural formula files.
If
fmtis a specific format, the corresponding suffix is applied to each path. Iffmtis"all", all supported formats are searched for and copied if they exist.fmt (str) – File format suffix, for example
".pdf", or"all"to process all supported formats.progress (ProgressCallback, optional) –
Optional callback used to report the progress of the operation. The callback is called with two arguments:
fractionfloatProgress value between
0.0and1.0.
messagestrHuman-readable description of the current processing step.
The callback is independent of the GUI and may, for example, be connected to a graphical progress bar by the caller.
- Returns:
Result object containing the status of the operation.
If the operation succeeds,
successisTrueandmolecular_idcontains the ID of the created molecule.If the operation fails,
successisFalseanderrorcontains the exception that caused the failure.- Return type:
CreateMoleculeResult
Notes
A temporary directory is used to ensure that incomplete files are not written directly to the final archive location.
If
fmtis"all", the following file formats are searched for:.pdf.cdxml.png.jpeg.jpg.svg
If an error occurs, database and file operations are rolled back where possible, and partially created archive data is removed.
The
progresscallback is optional. If it isNone, no progress information is reported.The function does not depend on Qt or any other GUI framework.