add colored output
This commit is contained in:
@ -4,6 +4,13 @@ import yaml
|
|||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
# ANSI escape sequences for colors
|
||||||
|
class Colors:
|
||||||
|
CYAN = '\033[96m'
|
||||||
|
GREEN = '\033[92m'
|
||||||
|
YELLOW = '\033[93m'
|
||||||
|
RED = '\033[91m'
|
||||||
|
RESET = '\033[0m'
|
||||||
|
|
||||||
# Global variable to track errors
|
# Global variable to track errors
|
||||||
errorList = {"copies": 0, "modifications": 0, "copyWarnings": 0, "modWarnings": 0}
|
errorList = {"copies": 0, "modifications": 0, "copyWarnings": 0, "modWarnings": 0}
|
||||||
@ -134,7 +141,7 @@ def copySources(config, destinationDirectory):
|
|||||||
errorList["copies"] += 1
|
errorList["copies"] += 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
print(f"\nSource file & folder copy/replace process completed with {errorList['copies']} errors and {errorList['copyWarnings']} warnings.\n")
|
print(f"\nSource file & folder copy/replace process completed with {Colors.RED}{errorList['copies']} errors{Colors.RESET} and {Colors.YELLOW}{errorList['copyWarnings']} warnings{Colors.RESET}.\n")
|
||||||
|
|
||||||
|
|
||||||
def modifyFiles(config, destinationDirectory):
|
def modifyFiles(config, destinationDirectory):
|
||||||
@ -218,7 +225,7 @@ def modifyFiles(config, destinationDirectory):
|
|||||||
errorList["modifications"] += 1
|
errorList["modifications"] += 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
print(f"\nFile modification process completed with {errorList['modifications']} errors and {errorList['modWarnings']} warnings.\n")
|
print(f"\nFile modification process completed with {Colors.RED}{errorList['modifications']} errors{Colors.RESET} and {Colors.YELLOW}{errorList['modWarnings']} warnings{Colors.RESET}.\n")
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@ -244,17 +251,17 @@ def main():
|
|||||||
modifyFiles(config, destinationDirectory)
|
modifyFiles(config, destinationDirectory)
|
||||||
|
|
||||||
# Print results
|
# Print results
|
||||||
print(f'\nTotal successful copies: {results["copies"]}')
|
print(f'\n{Colors.GREEN}Total successful copies: {results["copies"]}')
|
||||||
print(f'Total file modifications: {results["modifications"]}')
|
print(f'Total file modifications: {results["modifications"]}{Colors.RESET}')
|
||||||
|
|
||||||
if errorList["copies"] > 0 or errorList["modifications"] > 0:
|
if errorList["copies"] > 0 or errorList["modifications"] > 0:
|
||||||
print("Errors occurred during the process. Check the output for details.")
|
print(f"{Colors.RED}Errors occurred during the process. Check the output for details.")
|
||||||
print(f"Total copy errors: {errorList['copies']}")
|
print(f"Total copy errors: {errorList['copies']}")
|
||||||
print(f"Total modification errors: {errorList['modifications']}")
|
print(f"Total modification errors: {errorList['modifications']}{Colors.RESET}")
|
||||||
elif errorList["copyWarnings"] > 0 or errorList["modWarnings"] > 0:
|
elif errorList["copyWarnings"] > 0 or errorList["modWarnings"] > 0:
|
||||||
print(f"All operations in {destinationDirectory} from {configPath} completed successfully! But there were {errorList['modWarnings'] + errorList['copyWarnings']} warnings. Mybe you should check them.")
|
print(f"{Colors.YELLOW}All operations in {destinationDirectory} from {configPath} completed successfully! But there were {errorList['modWarnings'] + errorList['copyWarnings']} warnings. Maybe you should check them.{Colors.RESET}")
|
||||||
else:
|
else:
|
||||||
print(f"All operations in {destinationDirectory} from {configPath} completed successfully!")
|
print(f"{Colors.GREEN}All operations in {destinationDirectory} from {configPath} completed successfully!{Colors.RESET}")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Reference in New Issue
Block a user