Coverage for util/terminal_output.py: 65%
31 statements
« prev ^ index » next coverage.py v7.8.0, created at 2025-04-12 17:57 +0000
« prev ^ index » next coverage.py v7.8.0, created at 2025-04-12 17:57 +0000
1"""
2Contains functions and constants for printing to terminal.
3"""
5import os
8class Color:
9 """
10 Some pretty colors.
11 """
12 if os.name == 'nt': # windows
13 PURPLE = ''
14 CYAN = ''
15 BOLD = ''
16 BLUE = ''
17 GREEN = ''
18 YELLOW = ''
19 RED = ''
20 BLACK = ''
21 UNDERLINE = ''
22 END = ''
23 else:
24 PURPLE = '\033[1;35;48m'
25 CYAN = '\033[1;36;48m'
26 BOLD = '\033[1m'
27 BLUE = '\033[1;34;48m'
28 GREEN = '\033[1;32;48m'
29 YELLOW = '\033[1;33;48m'
30 RED = '\033[1;31;48m'
31 BLACK = '\033[1;30;48m'
32 UNDERLINE = '\033[4;37;48m'
33 END = '\033[1;37;0m'
36class Messages:
37 """
38 Messages to print to the terminal.
39 """
41 LOAD_CONCEPTS_PROMPT = '\nShould the program load previously encountered concept names '\
42 'from saved file for a faster runtime?\n\n'\
43 f'{Color.GREEN}Y: Use the file {Color.END}(takes < 30 seconds)\n'\
44 f'{Color.RED}N: Use WoRMS and overwrite the file {Color.END}(takes 15-20 minutes)\n\n'\
45 '>> '
47 DIVE_HEADER = f"\n{Color.BOLD}%-35s%-30s%-30s%-s" % ('Dive Name', 'Annotations Found', 'Duplicates Removed', 'Status') + \
48 f'\n========================================================================================================={Color.END}'
50 WORMS_HEADER = f'\n\n{Color.BOLD}WoRMS check:\n\n%-40s %-35s%-15s%-15s%-15s%-15s' % \
51 ('VARS Concept Name', 'WoRMS Query', 'Taxon Record', 'Taxon Tree', 'Vernaculars', 'Synonyms (VARS)') + \
52 '\n============================================================================================' + \
53 f'============================================{Color.END}'
55 WARNINGS_HEADER = f"\n{Color.BOLD}%-37s%-25s%-40s%-s" % ('Sample ID', 'Concept Name', 'UUID', 'Message') + \
56 '\n============================================================================================' + \
57 f'=========================================================================================={Color.END}'
59 @staticmethod
60 def dive_not_found(dive_name: str) -> str:
61 """
62 Returns an error message about missing dive information.
64 :param str dive_name: Name of the dive.
65 :return str: Error message.
66 """
67 return(
68 f'\n{Color.RED}###################################################################' +
69 f'\nERROR: Dive "{dive_name}" not found in Dives.csv file.' +
70 '\nThis dive must be added to Dives.csv to continue processing.' +
71 f'\n###################################################################\n{Color.END}'
72 )