diff --git a/DataPuller.py b/DataPuller.py index 4ec1fa8..2deae1c 100755 --- a/DataPuller.py +++ b/DataPuller.py @@ -1,22 +1,34 @@ #! /usr/bin/python3 -import argparse -import filecmp import os +import argparse import shutil +import filecmp # Argument Parsing parser = argparse.ArgumentParser( - prog="DataPuller", - description="Check differences between folders and update files if needed", -) + prog='DataPuller', + description='Check differences between folders and update files if needed') -parser.add_argument("-i", "--input") -parser.add_argument("-o", "--output") -parser.add_argument("-q", "--quiet", action="store_true") -parser.add_argument("-y", "--confirm", action="store_true") -parser.add_argument("-d", "--delete", action="store_true") -parser.add_argument("--dry-run", action="store_true") +parser.add_argument("-i", "--input", help="Path to input folder") +parser.add_argument("-o", "--output", help="Path to output folder") +parser.add_argument( + "-q", + "--quiet", + action="store_true", + help="Suppress non-essential commandline output", +) +parser.add_argument( + "-y", "--confirm", action="store_true", help="Auto-confirm user queries" +) +parser.add_argument( + "-d", "--delete", action="store_true", help="Auto-confirm file deletion" +) +parser.add_argument( + "--dry-run", + action="store_true", + help="List affected files without copying or deleting", +) args = parser.parse_args() @@ -30,7 +42,6 @@ if not args.output: else: outpath = args.output - def get_files(path): file_info = [] if not os.path.exists(path): @@ -43,7 +54,6 @@ def get_files(path): file_info.append(rel_path) return file_info - def main(): startstring = " FOLDER-SYNC 1.0 " if not args.quiet: @@ -103,12 +113,10 @@ def main(): print("Changed:") for i in changed: print(f" ~ {i}") - print() if deleted: print("Deleted:") for i in deleted: print(f" - {i}") - print() # Copy and update files if not args.dry_run: @@ -182,9 +190,13 @@ def main(): print("\nSkipping deletion...") if not args.quiet: - print("\nFolder sync finished!") + if not args.dry_run: + print("\nFolder sync finished!") + else: + print("\nDry run complete!") input("\nPress ENTER to exit...") + if __name__ == "__main__": main()