qmm.bucket module¶
Buckets of dicts with a set of helpers function.
This module serves has a stand-in database, any function or method it contain would be facilitator to either access or transform the data. This module is necessary in order to keep track of the state of the different files and make that specific state available globally within the other modules.
- class qmm.bucket.FileMetadata(crc, path: Union[str, pathlib.Path], attributes, modified, isfrom)[source]¶
Bases:
object
Representation of a file.
Can handle game files, mod files or file information comming from an archive.
- Parameters
crc (int) – CRC32 of the represented file, 0 or empty if file is a folder.
path (str or os.PathLike) – relative path to the represented file.
attributes (str or None) – ‘D’ for folder, ‘F’ otherwise. If the value passed is None, the attributes will be deduced from path
modified (str or None) – timestamp of the last modification of the file.
isfrom (int or str) – Will be the name of the archive the file originates from. Otherwise either
TYPE_GAMEFILE
orTYPE_LOOSEFILE
.
- property attributes¶
- property crc¶
- property modified¶
- property origin¶
- property path¶
- path_as_posix() str [source]¶
Return a posixified path for the current file.
The software expect folder separator to be POSIX compatible, which means we need to convert windows backslash to regular slash.
If the path is a folder, append a terminating slash (/) to it.
- pathobj: pathlib.Path¶
- qmm.bucket.TYPE_GAMEFILE = 2¶
File present in an archive
- qmm.bucket.TYPE_LOOSEFILE = 1¶
File present on the disk
- qmm.bucket.as_gamefile(crc: qmm.bucket.Crc32, value: Union[pathlib.Path, pathlib.PurePath])[source]¶
Add to the gamefiles a path indexed to its target CRC32.
- qmm.bucket.as_loosefile(crc: qmm.bucket.Crc32, filepath: pathlib.Path)[source]¶
Adds filepath to the loosefiles bucket, indexed on given CRC.
- qmm.bucket.file_crc_in_loosefiles(filemd: qmm.bucket.FileMetadata) bool [source]¶
Check if a file’s crc exists in loosefile’s index.
- qmm.bucket.file_path_in_loosefiles(filemd: qmm.bucket.FileMetadata) bool [source]¶
Check if a file’s path exists within the different loosefile lists.
- qmm.bucket.remove_item_from_loosefiles(file: qmm.bucket.FileMetadata)[source]¶
Removes the reference to file if it is found in loosefiles.
- qmm.bucket.with_conflict(path: str) bool [source]¶
Check if path exists in conflicts’s keys.
The conflicts bucket purpose is to list issues in-between archives only.
- qmm.bucket.with_gamefiles(crc: Optional[qmm.bucket.Crc32] = None, path: Optional[str] = None)[source]¶
Determine if a file exists within the cached list of game files.
First check if a CRC32 exist within the gamefiles bucket, if no CRC is given or the check fails, will then check if a path is present in the gamefiles’s bucket values.