58
58
"""
59
59
60
60
61
+ def UpgradeSymbologyOfUnits (unit : str ) -> str :
62
+ """
63
+ UpgradeSymbologyOfUnits is a function that takes a string that represents a unit and replaces the **2 and **3
64
+ with the appropriate unicode characters for superscript 2 and 3, and replaces "deg" with the unicode character
65
+ for degrees.
66
+ :param unit: a string that represents a unit
67
+ :return: a string that represents a unit with the appropriate unicode characters for superscript 2 and 3, and
68
+ replaces "deg" with the unicode character for degrees.
69
+ """
70
+ unit = unit .replace ('**2' , '\u00b2 ' ).replace ('**3' , '\u00b3 ' ).replace ('deg' , '\u00b0 ' )
71
+ return unit
72
+
73
+
61
74
class HIP_RA_X :
62
75
"""
63
76
HIP_RA_X is the container class of the HIP-RA-X application, giving access to everything else, including the logger
@@ -892,28 +905,22 @@ def render_scientific(p: floatParameter | OutputParameter) -> str:
892
905
f .write (f' { k } :{ kv_spaces } { v } { nl } ' )
893
906
894
907
except FileNotFoundError as ex :
895
- print (str (ex ))
896
908
traceback_str = traceback .format_exc ()
897
909
msg = f'Error: HIP_RA_X Failed to write the output file. Exiting....\n { traceback_str } '
898
- print (msg )
899
910
self .logger .critical (str (ex ))
900
911
self .logger .critical (msg )
901
912
raise
902
913
903
914
except PermissionError as ex :
904
- print (str (ex ))
905
915
traceback_str = traceback .format_exc ()
906
916
msg = f'Error: HIP_RA_X Failed to write the output file. Exiting....\n { traceback_str } '
907
- print (msg )
908
917
self .logger .critical (str (ex ))
909
918
self .logger .critical (msg )
910
919
raise
911
920
912
921
except Exception as ex :
913
- print (str (ex ))
914
922
traceback_str = traceback .format_exc ()
915
923
msg = f'Error: HIP_RA_X Failed to write the output file. Exiting....\n { traceback_str } '
916
- print (msg )
917
924
self .logger .critical (str (ex ))
918
925
self .logger .critical (msg )
919
926
raise
@@ -958,13 +965,7 @@ def PrintOutputsHTML(self, inputs, outputs, output_filename: str = 'HIP.html'):
958
965
val = val1 [0 ]
959
966
unit = ''
960
967
if len (val1 ) > 1 :
961
- unit : str = str (val1 [1 ])
962
- if '**2' in unit :
963
- unit = unit .replace ('**2' , '\u00b2 ' )
964
- if '**3' in unit :
965
- unit = unit .replace ('**3' , '\u00b3 ' )
966
- if 'deg' in unit :
967
- unit = unit .replace ('deg' , '\u00b0 ' )
968
+ unit : str = UpgradeSymbologyOfUnits (str (val1 [1 ]))
968
969
inputs_table .add_row (name , val , unit )
969
970
970
971
for key , value in outputs ['SUMMARY OF RESULTS' ].items ():
@@ -973,13 +974,8 @@ def PrintOutputsHTML(self, inputs, outputs, output_filename: str = 'HIP.html'):
973
974
val = val1 [0 ]
974
975
unit = ''
975
976
if len (val1 ) > 1 :
976
- unit : str = str (val1 [1 ])
977
- if '**2' in unit :
978
- unit = unit .replace ('**2' , '\u00b2 ' )
979
- if '**3' in unit :
980
- unit = unit .replace ('**3' , '\u00b3 ' )
981
- if 'deg' in unit :
982
- unit = unit .replace ('deg' , '\u00b0 ' )
977
+ unit : str = UpgradeSymbologyOfUnits (str (val1 [1 ]))
978
+
983
979
outputs_table .add_row (name , val , unit )
984
980
985
981
console = Console (style = 'bold white on blue' , force_terminal = True , record = True )
@@ -993,28 +989,22 @@ def PrintOutputsHTML(self, inputs, outputs, output_filename: str = 'HIP.html'):
993
989
console .save_html ('d:\\ temp\\ test_table.html' )
994
990
995
991
except FileNotFoundError as ex :
996
- print (str (ex ))
997
992
traceback_str = traceback .format_exc ()
998
993
msg = f'Error: HIP_RA_X Failed to write the output file. Exiting....\n { traceback_str } '
999
- print (msg )
1000
994
self .logger .critical (str (ex ))
1001
995
self .logger .critical (msg )
1002
996
raise
1003
997
1004
998
except PermissionError as ex :
1005
- print (str (ex ))
1006
999
traceback_str = traceback .format_exc ()
1007
1000
msg = f'Error: HIP_RA_X Failed to write the output file. Exiting....\n { traceback_str } '
1008
- print (msg )
1009
1001
self .logger .critical (str (ex ))
1010
1002
self .logger .critical (msg )
1011
1003
raise
1012
1004
1013
1005
except Exception as ex :
1014
- print (str (ex ))
1015
1006
traceback_str = traceback .format_exc ()
1016
1007
msg = f'Error: HIP_RA_X Failed to write the output file. Exiting....\n { traceback_str } '
1017
- print (msg )
1018
1008
self .logger .critical (str (ex ))
1019
1009
self .logger .critical (msg )
1020
1010
raise
0 commit comments