some fixes regarding massages

This commit is contained in:
MLH
2024-12-10 01:17:19 +01:00
parent 23e3863643
commit ceeeacb032

View File

@ -51,18 +51,21 @@ def copySources(config, destinationDirectory):
# Distinguish between sources with explicit target and without
if isinstance(source, dict):
sourcePath = source['source']
#targetPath = os.path.join(destinationDirectory, source['target'])
checkTargetPath = source['target']
# Check for absolute paths in target and correct them if necessary
if os.path.isabs(checkTargetPath):
targetPath = os.path.normpath(os.path.join(destinationDirectory, checkTargetPath.lstrip('./')))
raise ValueError(f"Absolute path incorrect: Corrected {checkTargetPath} to {targetPath}.")
else:
#targetPath = os.path.join(destinationDirectory, source['target']) # old code
targetPath = os.path.normpath(os.path.join(destinationDirectory, checkTargetPath))
else:
sourcePath = source
#targetPath = os.path.join(destinationDirectory, os.path.basename(sourcePath))
#targetPath = os.path.join(destinationDirectory, os.path.basename(sourcePath)) # old code
targetPath = os.path.normpath(os.path.join(destinationDirectory, os.path.basename(sourcePath)))
# Check if source exists
@ -90,7 +93,7 @@ def copySources(config, destinationDirectory):
if srcMtime <= destMtime:
print(f"Skipping {sourcePath}: Destination is up to date")
break # Skip this source file/folder
else:
elif rule.get('mode') != 'update' and not os.path.exists(sourcePath):
print(f"Should update {sourcePath} to {targetPath}, but {sourcePath} is not (yet) existing.")
# Copy files or directories
@ -122,7 +125,7 @@ def copySources(config, destinationDirectory):
errorList["copies"] += 1
continue
print("\nSource file & folder copy/replace process completed.\n")
print(f"\nSource file & folder copy/replace process completed with {errorList['copies']} errors.\n")
def modifyFiles(config, destinationDirectory):
@ -182,7 +185,7 @@ def modifyFiles(config, destinationDirectory):
errorList["modifications"] += 1
continue
print("\nFile modification process completed.\n")
print(f"\nFile modification process completed with {errorList['modifications']} errors.\n")
def main():