Helpers
Compare by Similarity
The similarity calculation is customizable; visit the metrics section for more information.
JCompare.print_similar_files
print_similar_files(folder1: Folder, folder2: Folder, threshold: float, same_parent_only: bool = False, comparer: Similarity = CompressionSimilarity('lzma2'), mode: int = ASYNC_AND_MULTIPROCESS) -> None
Prints the similar files between two folders based on a similarity threshold.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
folder1 |
Folder
|
The first folder object, which contains the files to be compared. |
required |
folder2 |
Folder
|
The second folder object, which contains the files to be compared. |
required |
threshold |
float
|
The similarity threshold. Only files with a similarity score above this threshold will be considered similar. |
required |
same_parent_only |
bool
|
If set to True, only files with the same parent folder will be compared. Defaults to False. |
False
|
comparer |
Similarity
|
The similarity comparer to use. Defaults to CompressionSimilarity("lzma2"). |
CompressionSimilarity('lzma2')
|
mode |
int
|
The mode to use for comparison. Defaults to ASYNC_AND_MULTIPROCESS. |
ASYNC_AND_MULTIPROCESS
|
Source code in JCompare/compare.py
JCompare.print_dissimilar_files
print_dissimilar_files(folder1: Folder, folder2: Folder, threshold: float, same_parent_only: bool = False, comparer: Similarity = CompressionSimilarity('lzma2'), mode: int = ASYNC_AND_MULTIPROCESS) -> None
Prints the dissimilar files between two folders based on a similarity threshold.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
folder1 |
Folder
|
The first folder object, which contains the files to be compared. |
required |
folder2 |
Folder
|
The second folder object, which contains the files to be compared. |
required |
threshold |
float
|
The similarity threshold. Only files with a similarity score below this threshold will be considered dissimilar. |
required |
same_parent_only |
bool
|
If set to True, only files with the same parent folder will be compared. Defaults to False. |
False
|
comparer |
Similarity
|
The similarity comparer to use. Defaults to CompressionSimilarity("lzma2"). |
CompressionSimilarity('lzma2')
|
mode |
int
|
The mode to use for comparison. Defaults to ASYNC_AND_MULTIPROCESS. |
ASYNC_AND_MULTIPROCESS
|
Source code in JCompare/compare.py
Compare by Hash
JCompare.print_identical_files
print_identical_files(folder1: Folder, folder2: Folder, same_parent_only: bool = False, hash_algorithm: tuple[str] = ('sha256')) -> None
Prints the identical files between two folders based on their hash values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
folder1 |
Folder
|
The first folder object, which contains the files to be compared. |
required |
folder2 |
Folder
|
The second folder object, which contains the files to be compared. |
required |
same_parent_only |
bool
|
If set to True, only files with the same parent folder will be compared. Defaults to False. |
False
|
hash_algorithm |
tuple[str]
|
A tuple of strings specifying the names of the hash algorithms to use. Defaults to ("sha256",). |
('sha256')
|
Source code in JCompare/compare.py
JCompare.print_different_files
print_different_files(folder1: Folder, folder2: Folder, same_parent_only: bool = False, hash_algorithm: tuple[str] = ('sha256')) -> None
Prints the different files between two folders based on their hash values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
folder1 |
Folder
|
The first folder object, which contains the files to be compared. |
required |
folder2 |
Folder
|
The second folder object, which contains the files to be compared. |
required |
same_parent_only |
bool
|
If set to True, only files with the same parent folder will be compared. Defaults to False. |
False
|
hash_algorithm |
tuple[str]
|
A tuple of strings specifying the names of the hash algorithms to use. Defaults to ("sha256",). |
('sha256')
|
Source code in JCompare/compare.py
Compare by Directory Structure
JCompare.print_identical_files_by_mcs
print_identical_files_by_mcs(folder1: Folder, folder2: Folder, ignore_directory_names: bool = False, path: None | tuple[tuple[str], tuple[str]] = None) -> None
Prints the identical files between two folders based on the maximum common subtree (MCS).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
folder1 |
Folder
|
The first folder object, which contains the files to be compared. |
required |
folder2 |
Folder
|
The second folder object, which contains the files to be compared. |
required |
ignore_directory_names |
bool
|
If set to True, directory names will be ignored when comparing the folder structures. Defaults to False. |
False
|
path |
None | tuple[tuple[str], tuple[str]]
|
A tuple of two tuples, each containing the path to a subtree in the corresponding folder. If provided, only the specified subtrees will be compared. Defaults to None. |
None
|
Source code in JCompare/compare.py
JCompare.print_different_files_by_mcs
print_different_files_by_mcs(folder1: Folder, folder2: Folder, ignore_directory_names: bool = False, path: None | tuple[tuple[str], tuple[str]] = None) -> None
Prints the different files between two folders based on the maximum common subtree (MCS).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
folder1 |
Folder
|
The first folder object, which contains the files to be compared. |
required |
folder2 |
Folder
|
The second folder object, which contains the files to be compared. |
required |
ignore_directory_names |
bool
|
If set to True, directory names will be ignored when comparing the folder structures. Defaults to False. |
False
|
path |
None | tuple[tuple[str], tuple[str]]
|
A tuple of two tuples, each containing the path to a subtree in the corresponding folder. If provided, only the specified subtrees will be compared. Defaults to None. |
None
|