qmm.filehandler module

exception qmm.filehandler.ArchiveException[source]

Bases: qmm.filehandler.FileHandlerException

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)
refresh() → Iterable[Tuple[int, str]][source]

Scan the local repository to add or remove archives as needed.

This is a companion method to use with WatchDog whenever something changes on the filesystem.

Yields:event_type, name of archive, List[Filemetadata]
rename_archive(src_path, dest_path)[source]

Rename the key pointing to an archive

Whenever an archive on the drive gets renamed, we need to do the same with the key under which the parsed data is stored.

exception qmm.filehandler.FileHandlerException[source]

Bases: Exception

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.delete_archive(filepath)[source]

Delete an archive from the filesystem.

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.

qmm.filehandler.sha256hash(filename: Union[IO, str]) → Optional[str][source]

Returns the 256 hash of the managed archive.

Parameters:filename – path to the file to hash
Returns:if successful None: if not successful
Return type:string
qmm.filehandler.uninstall_files(file_list: list)[source]

Removes a list of files and directory from the filesystem.