3 from logging
import getLogger; log =
getLogger(
"DQDefects.folders")
5 from DQUtils
import Databases
7 from DQDefects
import (DEFECTS_FOLDER, DEFECT_FOLDER_DESC, DEFECT_LOGIC_FOLDER,
8 DEFECT_LOGIC_FOLDER_DESC, PARENT_FOLDERSET)
10 from PyCool
import cool
12 from typing
import Tuple
15 FV = cool.FolderVersioning
19 This mixin contains code for managing the defect folders
27 super(DefectsDBFoldersMixin, self).
__init__()
30 log.debug(
"DefectsDB connections cleared")
32 connection.closeDatabase()
38 Lazy-loads parent folderset (useful for heirarchical tag manipulation)
41 db = Databases.get_instance(self.connection_string,
42 read_only=self._read_only)
46 def _load_folder(self, folder, create_function) -> Tuple[cool.IFolder, cool.Record]:
48 Internal function used to load a COOL folder
50 db_folder_string =
"%s::%s" % (self.connection_string, folder)
53 create_function =
None
55 db, folder = Databases.get_folder(db_folder_string,
56 read_only=self._read_only,
57 create_function=create_function,
62 payload = cool.Record(folder.payloadSpecification())
64 return folder, payload
69 Returns the folder containing the defects, loading it if necessary
76 Internal function for populating the self._defects_folder variable
78 log.debug(
"Loading defects folder")
84 Creates the COOL database/folder for defects, if they don't exist.
85 Internal - use create=True in the constructor to create the COOL folder.
87 log.info(
"Creating defects folder")
89 record_spec = cool.RecordSpecification()
90 record_spec.extend(
"present", ST.Bool)
91 record_spec.extend(
"recoverable", ST.Bool)
92 record_spec.extend(
"user", ST.String255)
93 record_spec.extend(
"comment", ST.String255)
95 folder_spec = cool.FolderSpecification(FV.MULTI_VERSION, record_spec)
96 return db.createFolder(DEFECTS_FOLDER, folder_spec,
97 DEFECT_FOLDER_DESC,
True)
102 Returns the folder containing the virtual defect logic, loading it if necessary
109 Internal function for populating the self._defect_logic_folder variable
117 Creates the COOL database/folder for virtual defect logic, if they don't exist.
118 Internal - use create=True in the constructor to create the COOL folder.
120 log.info(
"Creating defect logic folder")
122 record_spec = cool.RecordSpecification()
123 record_spec.extend(
"clauses", ST.String4k)
125 folder_spec = cool.FolderSpecification(FV.MULTI_VERSION, record_spec)
126 return db.createFolder(DEFECT_LOGIC_FOLDER, folder_spec,
127 DEFECT_LOGIC_FOLDER_DESC,
True)