- class Selection(database, persistent=None)¶
Database backed file selection (base class for
A selection in this context represents the list of files available to the application. Instead of using
Selectiondirectly, user applications should usually use its subclass
Squirrelwhich adds content indices to the selection and provides high level data querying.
By default, a temporary table in the database is created to hold the names of the files in the selection. This table is only visible inside the application which created it. If a name is given to
persistent, a named selection is created, which is visible also in other applications using the same database.
Besides the filename references, desired content kind masks and file format indications are stored in the selection’s database table to make the user choice regarding these options persistent on a per-file basis. Book-keeping on whether files are unknown, known or if modification checks are forced is handled in the selection’s file-state table.
Is this a new selection?
Truefor non-persistent selections. Only
Falsefor a persistent selection which already existed in the database when the it was initialized.
- add(paths, kind_mask=255, format='detect', show_progress=True)¶
Add files to the selection.
paths (iterator yielding
strobjects) – Paths to files to be added to the selection.
int(bit mask)) – Content kinds to be added to the selection.
format (str) – File format identifier or
'detect'to enable auto-detection (available:
Remove files from the selection.
Iterate over all file paths currently belonging to the selection.
raw (bool) – By default absolute paths are yielded. Set to
Trueto yield the path as it is stored in the database, which can be relative or absolute, depending on whether the file is within a Squirrel environment or outside.
Get all file paths currently belonging to the selection.
raw (bool) – By default absolute paths are returned. Set to
Trueto return the path as it is stored in the database, which can be relative or absolute, depending on whether the file is within a Squirrel environment or outside.
List of file paths.
Get inventory of cached content for all files in the selection.
This generator yields tuples
((format, path), nuts)where
pathis the path to the file,
formatis the format assignation or
nutsis a list of
Nutobjects representing the contents of the file.
Mark files which have been modified.
check (bool) – If
Truequery modification times of known files on disk. If
False, only flag unknown files.
Assumes file state is 0 for newly added files, 1 for files added again to the selection (forces check), or 2 for all others (no checking is done for those).
Sets file state to 0 for unknown or modified files, 2 for known and not modified files.