qmm.filehandler module¶
-
class
qmm.filehandler.ArchivesCollection[source]¶ Bases:
collections.abc.MutableMapping,typing.Generic-
add_archive(path, hashsum: str = None, progress=None)[source]¶ Add an archive to the list of managed archives.
This method should be used over __setitem__ as it setup the different metadata required by the UI.
-
find(archive_name: str = None, hashsum: str = None)[source]¶ Find a member based on the name or hashsum of the archive.
If archiveName is not None, will check if archiveName exists in the keys of the collection. If hashsum is not None, will check if the value exists in the self._hashsums dict. If all checks fails, returns False.
Parameters: - archive_name – filename of the archive, suffix included (default None)
- hashsum – sha256sum of the file (default None)
-
-
qmm.filehandler.archive_analysis(file_list: List[qmm.bucket.FileMetadata]) → List[Tuple[qmm.bucket.FileMetadata, int]][source]¶ Return a list of tuples representing the archive.
The tuples contains the item of an archive alongside it’s status. The status can be either FILE_MATCHED, FILE_MISMATCHED, FILE_IGNORED or FILE_MISSING.
Parameters: file_list – a list containing every items of an archive, must be bucket.FileMetadata Returns: A list of tuples, each tuple being (FileMetadata, int)
-
qmm.filehandler.build_game_files_crc32(progress=None)[source]¶ Compute the CRC32 value of all the game files then add them to a bucket.
The paths returned by this function are non-existent due to a difference between the mods and the game folder structure. It is needed to be that way in order to compare the mod files with the existing game files.
Parameters: progress (dialogs.qProgress.progress) – Callback to a method accepting strings as argument.
-
qmm.filehandler.build_loose_files_crc32(progress=None)[source]¶ Build the CRC32 value of all loose files.
Parameters: progress (dialogs.qProgress.progress) – Callback to a method accepting strings as argument. Returns: None
-
qmm.filehandler.conflicts_process_files(files, archives_list, current_archive, processed)[source]¶ Process an archive, verify that each of its files are unique.
-
qmm.filehandler.copy_archive_to_repository(filename)[source]¶ Copy an archive to the manager’s repository
-
qmm.filehandler.file_in_other_archives(file: qmm.bucket.FileMetadata, archives: qmm.filehandler.ArchivesCollection, ignore: List[T]) → List[T][source]¶ Search for existence of file in other archives.
Parameters: - file (FileMetadata) – file to be found
- archives (ArchivesCollection) – instance of ArchivesCollection
- ignore (list) – list of archives to ignore, for example already parsed archives
Returns: List of archives containing the same file.
Return type: List
-
qmm.filehandler.get_mod_folder(with_file: str = None, prepend_modpath=False) → pathlib.Path[source]¶ Return the path to the game folder.
Parameters: - with_file – append ‘with_file’ to the path
- prepend_modpath – if True, adds the module path before ‘with_file’
Returns: PathLike structure representing the game folder.
-
qmm.filehandler.ignore_patterns(seven_flag=False)[source]¶ Output a tuple of patterns to ignore.
Parameters: seven_flag (bool) – Patterns format following 7z exclude switch.
-
qmm.filehandler.install_archive(file_to_extract: str, file_context: Dict[str, List[qmm.bucket.FileMetadata]]) → Union[bool, List[qmm.bucket.FileMetadata]][source]¶ Install the content of an archive into the game mod folder.
Parameters: - file_to_extract – path to the archive to extract.
- file_context – A dict containing the keys matched, mismatched, ignored. Each of these entries point to a list containing FileMetadata objects.
Returns: Output of function extract7z() or False
-
qmm.filehandler.reErrorMatch()¶ Matches zero or more characters at the beginning of the string.
-
qmm.filehandler.reExtractMatch()¶ Matches zero or more characters at the beginning of the string.
-
qmm.filehandler.reListMatch()¶ Matches zero or more characters at the beginning of the string.