Refactor color temrinal escaping into a common module

I have no idea which one of the existing pypi modules is best for these,
and given that we're using just two escape codes, I think it makes sense
not to bother with a more capable third-party module just for two magic
strings.
This commit is contained in:
Jan Kundrát
2019-05-30 12:25:53 +02:00
parent b2e12cd3e0
commit f09789f5ef
3 changed files with 16 additions and 2 deletions

View File

@@ -27,6 +27,7 @@ from gnpy.core.elements import Transceiver, Fiber, Edfa, Roadm
from gnpy.core.info import create_input_spectral_information, SpectralInformation, Channel, Power, Pref
from gnpy.core.request import Path_request, RequestParams, compute_constrained_path, propagate2
from gnpy.core.exceptions import ConfigurationError
import gnpy.core.ansi_escapes as ansi_escapes
logger = getLogger(__name__)
@@ -201,7 +202,7 @@ if __name__ == '__main__':
equipment = load_equipment(args.equipment)
network = load_network(args.filename, equipment, args.names_matching)
except ConfigurationError as e:
print('\x1b[1;31;40m' + 'Configuration error:' + '\x1b[0m' + f' {e}')
print(f'{ansi_escapes.red}Configuration error:{ansi_escapes.reset} {e}')
exit(1)
if args.plot: