Removed unused logic in get_files()
This commit is contained in:
parent
348f71ba69
commit
9e362e730c
2 changed files with 12 additions and 16 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -241,3 +241,4 @@ cython_debug/
|
|||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
.idea/
|
||||
|
||||
.test/
|
||||
|
|
|
|||
27
DataPuller.py
Normal file → Executable file
27
DataPuller.py
Normal file → Executable file
|
|
@ -1,9 +1,9 @@
|
|||
#! /usr/bin/python3
|
||||
|
||||
import os
|
||||
import argparse
|
||||
import shutil
|
||||
import filecmp
|
||||
import os
|
||||
import shutil
|
||||
|
||||
# Argument Parsing
|
||||
parser = argparse.ArgumentParser(
|
||||
|
|
@ -16,7 +16,7 @@ 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("--dryrun", action="store_true")
|
||||
parser.add_argument("--dry-run", action="store_true")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ else:
|
|||
|
||||
|
||||
def get_files(path):
|
||||
file_info = {}
|
||||
file_info = []
|
||||
if not os.path.exists(path):
|
||||
return file_info
|
||||
|
||||
|
|
@ -40,14 +40,7 @@ def get_files(path):
|
|||
for file in files:
|
||||
full_path = os.path.join(folder, file)
|
||||
rel_path = os.path.relpath(full_path, path)
|
||||
try:
|
||||
stat = os.stat(full_path)
|
||||
file_info[rel_path] = {
|
||||
"size": stat.st_size,
|
||||
"modified": stat.st_mtime,
|
||||
}
|
||||
except Exception:
|
||||
pass
|
||||
file_info.append(rel_path)
|
||||
return file_info
|
||||
|
||||
|
||||
|
|
@ -59,7 +52,7 @@ def main():
|
|||
)
|
||||
|
||||
# Test Folder availability
|
||||
if not os.path.exists((inpath)):
|
||||
if not os.path.exists(inpath):
|
||||
print(f"ERROR: The input folder ({inpath}) is unavailable or non-existant.")
|
||||
if not args.quiet:
|
||||
input("\nPress ENTER to exit...")
|
||||
|
|
@ -81,7 +74,7 @@ def main():
|
|||
deleted = []
|
||||
|
||||
# Check for file additions and changes
|
||||
for path, info in source.items():
|
||||
for path in source:
|
||||
if path not in target:
|
||||
new.append(path)
|
||||
elif not filecmp.cmp(os.path.join(inpath, path), os.path.join(outpath, path)):
|
||||
|
|
@ -110,13 +103,15 @@ 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.dryrun:
|
||||
if not args.dry_run:
|
||||
if new or changed:
|
||||
if args.confirm:
|
||||
copy_confirm = "y"
|
||||
|
|
@ -153,7 +148,7 @@ def main():
|
|||
print("\nSkipping changes...")
|
||||
|
||||
# Delete files
|
||||
if not args.dryrun:
|
||||
if not args.dry_run:
|
||||
if deleted:
|
||||
alert = " ALERT: Some files only exist at the destination. "
|
||||
if not args.quiet:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue