47 lines
1.5 KiB
Python
Executable file
47 lines
1.5 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
"""
|
|
+---------------------------------+
|
|
| CRC32 sum generator CLI utility |
|
|
+---------------------------------+
|
|
"""
|
|
|
|
import argparse
|
|
from multiprocessing import Pool
|
|
from fck import checker, fileutils
|
|
|
|
|
|
def main() -> None:
|
|
"""
|
|
Main function, should only run when programm gets directly invoked.
|
|
"""
|
|
parser = argparse.ArgumentParser(description="Calculate CRC32 of files")
|
|
parser.add_argument("-b", "--bigfiles",
|
|
help="parse files that exceed your memory limit",
|
|
action="store_true")
|
|
parser.add_argument("-p", "--processes",
|
|
help="",
|
|
default=2,
|
|
type=int)
|
|
parser.add_argument("-c", "--checksfv",
|
|
help="",
|
|
default="",
|
|
type=str)
|
|
parser.add_argument("files",
|
|
help="files and folders to process",
|
|
nargs='*',
|
|
default=[])
|
|
args = parser.parse_args()
|
|
|
|
file_list = fileutils.search(args.files)
|
|
ppool = Pool(processes=args.processes)
|
|
file_list_checked = ppool.starmap(checker.check, [(x, args.bigfiles)
|
|
for x in list(file_list)])
|
|
ppool.close()
|
|
print(f"[{len([x for x in file_list_checked if x])}/{len(file_list_checked)}] Files passed")
|
|
|
|
|
|
if __name__ == '__main__':
|
|
try:
|
|
main()
|
|
except KeyboardInterrupt:
|
|
print("Exception: KeyboardInterrupt")
|